-
Notifications
You must be signed in to change notification settings - Fork 5
Add alternative command to run npm ci
with cache
#96
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
base: trunk
Are you sure you want to change the base?
Conversation
LOCAL_NPM_CACHE=./vendor/npm | ||
mkdir -p $LOCAL_NPM_CACHE | ||
echo "--- :npm: Set npm to use $LOCAL_NPM_CACHE for cache" | ||
npm set cache $LOCAL_NPM_CACHE | ||
echo "npm cache set to $(npm get cache)" |
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.
Might be worth making this configurable?
# Default value from npm. | ||
# TODO: Link to source | ||
MAX_SOCKETS=15 |
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 code this script was extracted from had the comment about 15 being the default. I had a quick look and couldn't find a reference. Need to look more and document.
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.
Found the source of that default in the npm/make-fetch-happen
library, which is used by npm/cli
# Default value from npm. | |
# TODO: Link to source | |
MAX_SOCKETS=15 | |
# Default value from npm. (See https://github.com/npm/make-fetch-happen/blob/main/README.md#opts-max-sockets) | |
MAX_SOCKETS=15 |
See #96 (comment) Co-authored-by: Olivier Halligon <[email protected]>
Mmmm.... 🤔
|
If a project uses `yarn` it should not use the `npm ci` command in CI!
See #96 (comment) Co-authored-by: Olivier Halligon <[email protected]>
Note: I moved the Windows stuff to #100 because there's additional work to be done on that front and I wanted to keep the two streams separated. Sorry for the noise that the rebase created. |
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.
Nitpick / Question: is the goal to keep this new script being called install_npm_packages_clean
? Or is this just for ease of testing the new setup using a temp separate name, but once the PR is ready for review you'll end up removing install_npm_packages
and renaming install_npm_packages_clean
to install_npm_packages
, or alternatively (in case we want to keep the old implementation around for some time, consolidate the two scripts in one and add a --clean
flag or something to allow to switch between the two behaviors?
Asking mostly because I'm not sure I like the naming of …_clean
in that new command… especially since one of its role is to use npm ci
+ save_cache
so us still using the cache doesn't feel like the term "clean" (as in "clean install") is appropriate? Or is it because, while we do use some caching, we only cache the root npm folder with the package downloads… but not the node_modules
, which in a way are clean-installed? Though even if that's the case, it's not completely a clean install since if the cached downloads gets corrupted for some reason that cache will still poison the installed modules and in such case the naming of the helper might be misleadingly make us believe that it couldn't possibly be a case of cache poisoning because the command is named …_clean
…
That being said, I'm not sure I have a suggestion for a better naming that would indicate "clean install of the modules, but still using cache for the downloaded packages"… yet, idk why but even if we keep the "clean" wording, it feels it'd be more logical to have it as a --clean
flag than as a separate command? 🤷
At the moment, I wrote this as a dedicated script to avoid breaking the But like you noticed, it's highly likely the only difference between the two will be whether we call
I wonder if this applies more broadly to our existing naming convention.
|
See #96 (comment) Co-authored-by: Olivier Halligon <[email protected]>
If/when we'll go for this consolidate implementation, we might also want to allow passing additional flags down to the |
RTO: @mokagio I am seeing this PR being included on the |
It was not intentional. I must have forgot to set a status when adding this PR to the Apps Infra Roadmap project. |
@mokagio How do you feel about undrafting this PR and pushing it to the finish line? IMHO:
I think the passing of unfiltered |
WIP
CHANGELOG.md
if necessary.