Closed rdss-sknott closed 3 years ago
When you add Foxy in the require
or require-dev
section (make optional Foxy), it's only to enable Foxy for the PHP library (see the doc Use the plugin in PHP library). In addition, when you install a NPM dependency, this one never installs dev dependencies (only the dependencies in the root package.json file), so, Foxy has the same behavior, which is why you do not have the desired behavior.
Given that the dev dependencies of the JS library are Given that the dev dependencies of a JS library are present only for its development, the dev dependencies are never installed by NPM/Yarn, and Foxy keeps this behavior.
On the other hand I understand your wait, and it would be interesting to add a new option to activate the possibility of injecting devDependencies
from the package.json file of the PHP library into the root package.json file (like extra.foxy.dev-dependencies = true
, disabled by default).
In this case, and regarding your example, you should use the dev-dependencies
section and not dependencies
in the package.json file of the PHP library.
Thank you for your quick reply.
When you add Foxy in the
require
orrequire-dev
section (make optional Foxy), it's only to enable Foxy for the PHP library (see the doc Use the plugin in PHP library). In addition, when you install a NPM dependency, this one never installs dev dependencies (only the dependencies in the root package.json file), so, Foxy has the same behavior, which is why you do not have the desired behavior.Given that the dev dependencies of the JS library are Given that the dev dependencies of a JS library are present only for its development, the dev dependencies are never installed by NPM/Yarn, and Foxy keeps this behavior.
Unfortunatly this is not possible for us as we want to install dev and no-dev dependencies with foxy.
On the other hand I understand your wait, and it would be interesting to add a new option to activate the possibility of injecting
devDependencies
from the package.json file of the PHP library into the root package.json file (likeextra.foxy.dev-dependencies = true
, disabled by default).In this case, and regarding your example, you should use the
dev-dependencies
section and notdependencies
in the package.json file of the PHP library.
I'm not completely sure if I understood you correctly. From our point of view it would be perfect if the deciding factor would be if the composer-package is added as dev or no dev. So composer require --dev libname
would result in all package.json packages (no matter if dev or no dev from npm point of view) be stored in the dev section of the resulting package.json of the main project.
As a cherry on top, it would be nice to have dependencies in the dev section of the package.json of the library always installed as dev dependency in the main package.json of the project but that would by far not be necessary for our use case.
As an practical example you may use our composer library zooroyal/coding-standard found on github and packagist.org. Obviously we only want to install this lib in our project as dev dependency. When we do it that way it results in a package.json in our main project which contains the npm dependencies. So far so good.
By the time we want to deploy the project we want to use composer install --no-dev
so dev dependencies are not installed. This results in npm throwing errors.
So executing:
composer require --dev zooroyal/coding-standard
composer install
composer install --no-dev
Results in:
npm WARN checkPermissions Missing write access to /project-path/node_modules/@composer-asset/zooroyal--coding-standard
npm ERR! path /project-path/node_modules/@composer-asset/zooroyal--coding-standard
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/project-path/node_modules/@composer-asset/zooroyal--coding-standard'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Hello, we will be working on a solution for that issue. Our approach will be an extension to the foxyscripts that rewrites the name before storing it in the "/node_modules/@composer-asset/"-folder. The idea is to identify if the current package is required as dev and if so the corrosponding section will be replaced in the "/vendor/foxy/composer/.../package.json".
We identified the "AssetUtil.php" with the "formatPackage" function to be our point of entry. We would like to inform you about our endeavour because we want to provide our solution as a pull request for you as soon as its finished.
If you have any suggestions that could help us please let us know. Thank you in advance!
Hello @rdss-hmorsi, thank you for your help, and in this case, I await your Pull Request :-).
If you wish, it is possible to add this improvement for version 1.2
. However, you have to rebase the Pull Request with the main branch 1.2
.
Situation is the following: package.json of library
composer.json of project
resulting package.json of project after installation with foxy
expected result in package.json
I'm not quite sure if I overlooked something in the documentation or if there is another way to get foxy to do what we like it to do. As it is right now we found no way to make foxy install dev dependencies as such. As they are absent when we do a
composer install --no-dev
we get npm errors.