Skip to content
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

fix(ci): rm workspace node_modules #7490

Open
wants to merge 8 commits into
base: latest
Choose a base branch
from
Open

Conversation

reggi
Copy link
Contributor

@reggi reggi commented May 8, 2024

Fixes #7226, an issue where the npm ci needs to remove node_modules within workspace directories.

lib/base-cmd.js Outdated Show resolved Hide resolved
@npm-cli-bot
Copy link
Collaborator

npm-cli-bot commented May 13, 2024

no statistically significant performance changes detected

timing results
app-large clean lock-only cache-only modules-only no-lock no-cache no-modules no-clean show-version run-script cache-only
peer-deps
no-clean
audit
npm@latest 38.757 ±3.81 10.873 ±0.11 12.134 ±0.05 1.586 ±0.02 1.618 ±0.01 1.304 ±0.00 8.516 ±0.09 1.316 ±0.01 0.144 ±0.01 0.170 ±0.00 14.012 ±0.49 3.426 ±1.78
#7490 38.891 ±0.50 10.728 ±0.05 11.677 ±0.01 1.582 ±0.04 1.543 ±0.00 1.278 ±0.00 8.318 ±0.03 1.281 ±0.00 0.140 ±0.00 0.167 ±0.00 14.875 ±0.05 2.162 ±0.01
app-medium clean lock-only cache-only modules-only no-lock no-cache no-modules no-clean show-version run-script cache-only
peer-deps
no-clean
audit
npm@latest 31.022 ±1.69 7.987 ±0.02 8.945 ±0.05 1.518 ±0.01 1.500 ±0.01 1.445 ±0.01 5.809 ±0.00 1.323 ±0.02 0.139 ±0.00 0.168 ±0.00 9.453 ±0.04 3.541 ±2.22
#7490 29.324 ±0.04 8.025 ±0.03 8.831 ±0.05 1.543 ±0.00 1.554 ±0.02 1.428 ±0.00 5.879 ±0.03 1.314 ±0.03 0.140 ±0.00 0.165 ±0.00 9.759 ±0.01 1.990 ±0.05

lib/commands/ci.js Outdated Show resolved Hide resolved
lib/commands/ci.js Outdated Show resolved Hide resolved
lib/commands/ci.js Outdated Show resolved Hide resolved
lib/commands/ci.js Outdated Show resolved Hide resolved
@reggi reggi changed the title fix(ci): rm workspace node_modules fix(ci): rm workspace node_modules May 14, 2024
@reggi reggi marked this pull request as ready for review May 14, 2024 17:03
@reggi reggi requested a review from a team as a code owner May 14, 2024 17:03
Copy link
Contributor

@lukekarrys lukekarrys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI extends ArboristWorkspaceCmd which will call this.setWorkspaces() and then this.exec(). So we can check if this.workspacePaths is set and use that instead of calling getWorkspaces directly. Also ArboristWorkspaceCmd will always set includeWorkspaceRoot: false so we need to explicitly include where.

We need to do this because you can run npm ci -w workspace-a and have it only install the deps for workspace-a but you can't guarantee that the root node_modules won't end up populated. So in fixing this bug we want to make sure that we only rm -rf the node_modules specified by the workspace config, plus the root.

const entries = await fs.readdir(path, null).catch(() => [])
return Promise.all(entries.map(f => fs.rm(`${path}/${f}`,
{ force: true, recursive: true })))
return await Promise.all([...workspacePaths.values()].map(async modulePath => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return await Promise.all([...workspacePaths.values()].map(async modulePath => {
return await Promise.all([...(this.workspacePaths || []), where]).map(async modulePath => {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] npm ci does not remove/recreate existing node_modules inside workspaces
4 participants