Skip to content

chore: generate and publish npm-shrinkwrap.json to lock full dependency tree#563

Open
jonathannorris wants to merge 3 commits intomainfrom
chore-npm-shrinkwrap
Open

chore: generate and publish npm-shrinkwrap.json to lock full dependency tree#563
jonathannorris wants to merge 3 commits intomainfrom
chore-npm-shrinkwrap

Conversation

@jonathannorris
Copy link
Copy Markdown
Member

@jonathannorris jonathannorris commented Apr 3, 2026

Summary

  • Adds npm-shrinkwrap.json generation to the publish pipeline via a new prepack step, locking the full transitive dependency tree to the exact versions resolved at build time
  • Pins all 27 production dependencies to exact versions (removing ^ and ~ ranges) as defense-in-depth
  • scripts/generate-shrinkwrap.js handles the full flow: generates the lockfile via npm install --package-lock-only, converts it to shrinkwrap, strips workspace entries (mcp-worker), and protects yarn.lock from npm's Berry-incompatible rewrite via a save/restore in a finally block

Motivation

package.json already listed /npm-shrinkwrap.json in the files array but the file was never generated, so consumers running npm install -g @devcycle/cli resolved all caret-ranged transitive deps to whatever was latest at install time. This is the same class of exposure that let the malicious axios@1.14.1 reach users on March 31. Pinning axios directly in 6.3.0 only covers one package; the shrinkwrap covers the full tree.

@jonathannorris jonathannorris requested a review from a team as a code owner April 3, 2026 21:09
Copilot AI review requested due to automatic review settings April 3, 2026 21:09
@jonathannorris jonathannorris requested a review from JamieSinn April 3, 2026 21:11
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 3, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
devcycle-mcp-server ec29121 Apr 10 2026, 01:53 PM

Copy link
Copy Markdown

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 automated npm-shrinkwrap.json generation during publish to fully lock the transitive dependency tree shipped to npm consumers, and pins direct production dependencies to exact versions.

Changes:

  • Add a prepack step to generate npm-shrinkwrap.json (and adjust postpack cleanup).
  • Pin production dependencies in package.json (and update yarn.lock accordingly).
  • Add helper scripts for shrinkwrap generation and (future) verification; ignore generated artifacts in .gitignore.

Reviewed changes

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

Show a summary per file
File Description
yarn.lock Updates lock entries to reflect newly pinned dependency versions/ranges.
scripts/verify-shrinkwrap.js New verifier/cleaner for shrinkwrap contents vs installed node_modules (not wired yet).
scripts/generate-shrinkwrap.js New generator invoked from prepack to create shrinkwrap while protecting yarn.lock.
package.json Adds shrinkwrap generation to prepack, expands postpack cleanup, pins dependencies, adds shrinkwrap script.
.gitignore Ignores generated shrinkwrap/lock artifacts and yarn.lock backup file.

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

Copilot AI review requested due to automatic review settings April 10, 2026 13:30
Copy link
Copy Markdown

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 2 out of 5 changed files in this pull request and generated 2 comments.


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

Copilot AI review requested due to automatic review settings April 10, 2026 13:49
Copy link
Copy Markdown

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 2 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

package.json:169

  • The newly added resolutions entries don’t match what’s currently in yarn.lock (e.g. vite resolves to 7.1.11, lodash resolves to 4.17.23, and lodash.template resolves to 4.5.0). With Yarn Berry, this kind of mismatch typically breaks CI installs; either regenerate yarn.lock so it satisfies these resolutions or adjust/remove the resolutions to match the actually resolved versions (and prefer exact versions if the intent is to pin).
    "resolutions": {
        "axios@npm:^1.13.6": "1.13.6",
        "axios@npm:^1.6.0": "1.13.6",
        "nanoid@3.3.1": "3.3.8",

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

Copy link
Copy Markdown

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 2 out of 5 changed files in this pull request and generated 1 comment.


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

Comment on lines +28 to +33
if (!fs.existsSync(YARN_LOCK)) {
console.error(
'Error: yarn.lock not found. Cannot protect it from npm overwrite.',
)
process.exit(1)
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

console is used throughout this script, but ESLint’s JS globals configuration doesn’t declare console (see eslint.config.mjs JS languageOptions.globals). This will trigger no-undef lint errors (note scripts/fetch-install-prompts.js works around this via /* global console */). Add the same global directive here or update the ESLint globals to include console for JS files.

Copilot uses AI. Check for mistakes.
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.

3 participants