Skip to content

fix: use package-lock/shrinkwrap when calling homebrew/npm MONGOSH-2485#2694

Open
tculig wants to merge 14 commits intomongodb-js:mainfrom
tculig:tiho/mongosh-2485-add-shrinkwrap
Open

fix: use package-lock/shrinkwrap when calling homebrew/npm MONGOSH-2485#2694
tculig wants to merge 14 commits intomongodb-js:mainfrom
tculig:tiho/mongosh-2485-add-shrinkwrap

Conversation

@tculig
Copy link

@tculig tculig commented Mar 18, 2026

Copilot AI review requested due to automatic review settings March 18, 2026 13:04
@tculig tculig requested a review from a team as a code owner March 18, 2026 13:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the build/release publishing pipeline to generate and use npm-shrinkwrap.json (lockfile) during npm/Homebrew publishing so downstream consumers install locked dependency versions (per MONGOSH-2485).

Changes:

  • Make npm publishing paths properly await the publish step to avoid racing subsequent steps.
  • Add shrinkwrap generation for the release packages as part of PackagePublisher.publishToNpm().
  • Ignore npm-shrinkwrap.json in git to keep the repo clean during release automation.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/build/src/release.ts Await auxiliary publish so the release command doesn’t continue early.
packages/build/src/publish-mongosh.ts Await npm publish before proceeding to Homebrew publish.
packages/build/src/publish-auxiliary.ts Make auxiliary publish async and await npm publish.
packages/build/src/npm-packages/publish.ts Inject shrinkwrap generation into the npm publish flow and make it async.
packages/build/src/npm-packages/publish.spec.ts Update publish test to await async publish; add shrinkwrap stub wiring.
packages/build/src/npm-packages/index.ts Re-export shrinkwrap helpers from the npm-packages module.
packages/build/src/npm-packages/generate-shrinkwrap.ts New helper to generate npm-shrinkwrap.json via temp dir + npm commands.
.gitignore Ignore npm-shrinkwrap.json artifacts created during publish.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

The approach to generating the shrinkwrap file looks good 👍

I do want to mention – it would probably be a bit nicer to have this as part of the "Update automatically generated files" GHA workflow, since that would mean having an up-to-date version of the file checked into the repo.

Doing this during the publishing phase also works, but we try to avoid adding new steps there unless necessary, since that means that the only way through which we can properly test the feature is through actually publishing.

@tculig tculig requested a review from gagik March 20, 2026 15:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds automation to generate npm-shrinkwrap.json for the release packages from the monorepo root package-lock.json, and wires it into the scheduled “auto-generated files” workflow so shrinkwraps stay up to date.

Changes:

  • Introduces a shrinkwrap generator that prunes the root lockfile down to production deps for packages/mongosh and packages/cli-repl.
  • Adds a runnable script (npm run update-shrinkwrap) to generate shrinkwraps from the repo root.
  • Updates the cron workflow to run the generator and commit the resulting shrinkwrap files.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
scripts/update-shrinkwrap.ts New entrypoint script to generate shrinkwraps for release packages.
packages/build/src/npm-packages/index.ts Re-exports shrinkwrap generator APIs from the npm-packages module.
packages/build/src/npm-packages/generate-shrinkwrap.ts Implements shrinkwrap generation by pruning the root lockfile and post-processing workspace entries.
package.json Adds update-shrinkwrap npm script using ts-node.
.github/workflows/cron-tasks.yml Runs update-shrinkwrap during scheduled auto-update workflow and stages generated files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

spawnSyncStub = sinon.stub(spawnSyncModule, 'spawnSync');
fsReadFile.onFirstCall().resolves(JSON.stringify(mockRootLockfile));
fsReadFile.onSecondCall().resolves(JSON.stringify(mockPackageJson));
fsReadFile.onThirdCall().resolves(JSON.stringify(mockPrunedLockfile));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit lost here, if reading the file is mocked, what is this checking?

Copy link
Author

Choose a reason for hiding this comment

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

Claude says: "The tests are verifying the post-processing logic — dev entry removal, workspace link conversion, workspace path filtering — not the file I/O itself. By mocking the inputs we can test that transformation logic in isolation without touching the filesystem or running npm."
But I agree with you that these are not super useful.
I'll attempt to replace this with an integration test that actually calls npm...

Copy link
Contributor

Choose a reason for hiding this comment

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

feel free to give it a go but if it ends up complex, it's fine to leave it as is

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

4 participants