fxpio / foxy

A fast, reliable, and secure NPM/Yarn/pnpm bridge for Composer
https://foxypkg.com
MIT License
173 stars 21 forks source link

Yarn update should use install instead of upgrade #26

Closed krissss closed 5 years ago

krissss commented 5 years ago

Upgrade will update all packages to lastest version.

Install not.

If I create a project, then I need add a package after few days. upgrade will update all packages, install will only install that package I need. I think install is correct.

francoispluchino commented 5 years ago

The Yarn install command is used with the Composer install command. Otherwise, with the Composer update command, install command or the upgrade command of Yarn can be used, it depends if the node_modules folder is present (because the upgrade command of Yarn can not update the dependencies if they are not already installed, which is not the case of Composer for example).

You can see the code for:

However, it is possible to replace the commands of Yarn and NPM, so check if this is not the case in your configuration.

krissss commented 5 years ago

I known that. But, composer require xx will trigger yarn update --non-interactive if the node_modules folder is present. Is this right? If right, when I composer require one package (project already installed, and node_modules already exist), yarn will failed use yarn update --non-interactive

francoispluchino commented 5 years ago

Yes, the Foxy update command is used for the require command of Composer, if the asset dependencies are already installed.

And indeed, the case of Yarn is that if there is a change of the dependencies, we must use the command install and not upgrade, which is not the case for NPM, which still accepts the update command.

francoispluchino commented 5 years ago

Small precision, the error Outdated lockfile. Please run 'yarn install' and try again. thrown when the version of a package changes, but not for adding or removing a package, the upgrade command works correctly.

It would be good to check if the folder is synchronized or not, to return the good command. To could help to do this detection, run the yarn check command before and check the command return an error.

francoispluchino commented 5 years ago

Can you check if this commit fix your bug?

krissss commented 5 years ago

Fixed.