Code Monkey home page Code Monkey logo

Comments (5)

francoispluchino avatar francoispluchino commented on June 19, 2024

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.

from foxy.

rdss-sknott avatar rdss-sknott commented on June 19, 2024

Thank you for your quick reply.

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.

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 (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.

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

from foxy.

rdss-hmorsi avatar rdss-hmorsi commented on June 19, 2024

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!

from foxy.

francoispluchino avatar francoispluchino commented on June 19, 2024

Hello @rdss-hmorsi, thank you for your help, and in this case, I await your Pull Request :-).

from foxy.

francoispluchino avatar francoispluchino commented on June 19, 2024

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.

from foxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.