-
Notifications
You must be signed in to change notification settings - Fork 363
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
feat(node): do NOT run "yarn/npm install" if package.json did not change #1435
Conversation
Run `yarn/npm install` in post-synthesis only if `package.json` had actually changed (or if `node_modules` doesn’t exist). Otherwise, there is no need.
Codecov Report
@@ Coverage Diff @@
## main #1435 +/- ##
==========================================
- Coverage 88.06% 87.76% -0.30%
==========================================
Files 132 134 +2
Lines 5109 5165 +56
Branches 1207 1198 -9
==========================================
+ Hits 4499 4533 +34
- Misses 610 632 +22
Continue to review full report at Codecov.
|
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.
Woah very cool!
One thought I had was whether there should be some kind of "--force" flag to override this behavior. But this might first require formalizing this post-installation behavior as an API.
I also wonder if it makes sense to also extend this behavior to the projenrc file? But for this to be reliable we would also probably have to check that tasks.json did not change and the projen dependency defined in package.json
did not change.
I guess one can just run |
#1435 introduced an optimization to only run `yarn/npm install` if package.json has changed. This uncovered a latent issue which already existed. When a dependency version is not specified, projen initially synthesizes a `package.json` file with a `*` dependency. Then invokes `yarn install`, resolves the actual version from the installed module and updates `package.json` with a caret version requirement. This mimicks the same behavior as `yarn add` or `npm install`. But now we need to re-execute "install" in order to update the package lock file. Fixes #1443
#1435 introduced an optimization to only run `yarn/npm install` if package.json has changed. This uncovered a latent issue which already existed. When a dependency version is not specified, projen initially synthesizes a `package.json` file with a `*` dependency. Then invokes `yarn install`, resolves the actual version from the installed module and updates `package.json` with a caret version requirement. This mimicks the same behavior as `yarn add` or `npm install`. But now we need to re-execute "install" in order to update the package lock file. Fixes #1443 --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Run
yarn/npm install
in post-synthesis only ifpackage.json
had actually changed. Otherwise, there is no need.If
node_modules
doesn't exist in the project root, we also install to allow users to simply runnpx projen
from freshly cloned repositories.conditional-install.mov
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.