Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to exclude files and entire folders from built application #165

Merged
merged 5 commits into from
Oct 18, 2023

Conversation

nexxai
Copy link
Contributor

@nexxai nexxai commented Aug 9, 2023

As it stands right now, the native:build command takes your entire project folder and builds the application with it.

This may not be desirable as certain files may be unnecessary for the app to run, or may unintentionally leak sensitive information by being included.

This PR allows for the blocking of individual files, folders, glob patterns, or wildcards (a user can mix and match) that they do not want being packaged.

I realize the tests are probably overly verbose but I couldn't think of a better way to generalize them. Happy to refactor them if anyone can give me any pointers on a good way to do that.

@osc2nuke
Copy link

I understand why you want this, and i understand the complexity of what you want to achieve.
I found the following repository what might can bring you to what you want to accomplish.
https://github.com/composer-unused/composer-unused

@nexxai
Copy link
Contributor Author

nexxai commented Aug 11, 2023

I understand why you want this, and i understand the complexity of what you want to achieve. I found the following repository what might can bring you to what you want to accomplish. https://github.com/composer-unused/composer-unused

I'm not clear how a package that removes unnecessary composer dependencies would be useful to exclude specific, unrelated files and folders in a PHP project. Can you explain your thought process?

@osc2nuke
Copy link

I was thinking you wanted to reduce (as for nativephp exclusiv) the generated build file size.
But beside that, not just for nativephp or vendor packages, i see for example many shared repositories that includes a complete Laravel framework but only added a few files.

For example when they build it in laravel 5X but i want to check it out on v10, and i only want "the stuff" that is used.
But perhaps i might go a little over the edge here in my thinking proccess.

@heikokrebs
Copy link

I was thinking you wanted to reduce (as for nativephp exclusiv) the generated build file size. But beside that, not just for nativephp or vendor packages, i see for example many shared repositories that includes a complete Laravel framework but only added a few files.

For example when they build it in laravel 5X but i want to check it out on v10, and i only want "the stuff" that is used. But perhaps i might go a little over the edge here in my thinking proccess.

No this PR is about removing files like file-caches or files where you store data and need them to be removed for a clean build of the app.


private function delete_directory_recursive($dir)
{
if (! file_exists($dir)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm clear on what you mean by "space". Can you please elaborate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that clean code is the goal but I don't agree that removing the space makes it easier to read. In fact, (and this is strictly my own personal opinion) I believe that the space makes it more readable as it's easy to see that there are two characters "(!" indicating something weird is about to happen, separated by a space, and then the variable name that the weirdness is about to apply to, making it easy for someone reading the code to quickly see that the expression is being negated.

If Marcel is against this, I'll revert it, but for now, I'm going to leave it.

Copy link
Contributor Author

@nexxai nexxai Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, it's being applied via the not_operator_with_successor_space PHP-CS-Fixer rule and also referenced in Spatie's Laravel code style guide

Copy link

@nilBora nilBora Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize! Thank you for your explain, It is my mistake!

@mpociot mpociot merged commit 7b837c7 into NativePHP:main Oct 18, 2023
@mpociot
Copy link
Member

mpociot commented Oct 18, 2023

Awesome, thank you for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants