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
Fixed Plugin Task to deny option of ROOT/plugins and fixed Autoloading Generation #26
Conversation
I am unsure how to handle the test failures, could it be that the ROOT constant is not defined in the Tests which lead to the failure? Is the usage of the ROOT variable not fine or do I simply have to rename the paths in the testcases? |
I don't think it's a good idea to deny baking of plugins into I don't see what's wrong with baking plugins into |
@dakota Did you read the PR linked at top? |
I did, I still don't think it's a good idea blocking baking into |
A warning or maybe a option flag could be used, like --composer or something like that. |
@dakota IMHO you should maintain separate folders for developing / publishing and using in an app. |
@ADmad you're right, I'm just being lazy :) |
@dakota you can still be lazy, this PR won't stop you ;) And to suit your laziness, here's the new path ready for you to copy/paste:
|
I don't think preventing people from putting code where they want is a good idea. What if there was an output-dir option that defaulted to the new path? This would let people output plugin skeletons for standalone plugins as well. |
I like that idea @markstory |
Then we can just remove the filter again and the app.default.php has to be adapted, since this controls how the paths are ordered when multiple exist. Or did I misunderstood something? @lorenzo, any hints regarding the tests? |
@@ -235,7 +237,7 @@ protected function _modifyAutoloader($plugin, $path) | |||
$cwd = getcwd(); | |||
|
|||
// Windows makes running multiple commands at once hard. | |||
chdir(dirname($path)); | |||
chdir(ROOT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks to be logically correct to make this change; dirname($path)
means dirname('plugins/
)` - it's implicitly assuming the plugins dir is one level below the root.
However, I'd rather it was:
$file = $this->_rootComposerFilePath(); # <-
...
chdir(dirname($file));
There's no need to use a constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the changes was related to that issue. Regarding _rootComposerFilePath(), that would be an unnecessary function call since the function is also just:
"return ROOT . DS . 'composer.json';"
However, if requested I can ofc change it to use the function call. In your snippet, dirname($file) is sufficient, since we do not want to step out of the root, hu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider testing - you don't want to be modifying ROOT . DS . 'composer.json
when tests run and that's why it's in a separate function (and why generally I purged constants from the code recently).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's totally fine, I will update the code to use the function tomorrow. Thanks for your advice @AD7six
When using a different path than ROOT/plugins you would not switch back correct to the root folder. As example, ROOT/src/Plugin would switch back to ROOT/src, leading to a failure for the composer call. |
@lorenzo bump |
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"ComposerExample\\Test\\": "./plugins/ComposerExample/tests" | ||
"ComposerExample\\Test\\": "/tmp/tests/BakedPlugins/ComposerExample/tests" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paths should be relative as when you deploy the path will probably not be the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path used above is related to the fact that the plugin path in the Test Instance is set to /tmp/tests/BakedPlugins, on a productive environment it would look like:
'"Test6\Test": "./src/Plugin/Test6/tests"
Thanks a lot for the effort @DSchalla, the team decided to go another way with this. Instead of disallowing baked plugins in ROOT, we decided to put them only there and have composer install plugins in vendors. That way there will be a clear separation between both, all thrid-party libraries will be in the same place and no gitignore will be required for in-app plugins. I'm sorry you had to work on this and not get this merged, you win 100 internets from me 💪 |
Reopening as this PR was transformed to fix a couple limitations on how plugins are baked. The problem in tests still need to be solved |
The issues with the tests should be fixed after https://github.com/DSchalla/bake/commit/48a284bb4fe6211e0d0665b03a544f78844c9e63 and https://github.com/DSchalla/bake/commit/475d5f3c71c957474dd633e39da8397edc91f6c7. |
…neration Merge branch 'DSchalla/master' into master. Closes #26
Thanks 👍 |
Thanks @markstory for the merge! |
PR related to the change: cakephp/app#206
The first commit is filtering the ROOT/plugins path from the options and exits with an error if no other path is available, I am unsure if exit; was the correct choice in a Shell Task, I would like to get some feedback regarding that.
The second commit fixed the Autoloading Generation to allow other than the default path options to be used as plugin path, the chdir adaption was required since the old version could not deal with anything but the first child of ROOT.
Any comments are appreciated.