Repository navigation
Conversation
📝 WalkthroughWalkthroughAdds a native ChangesSet-Script Command Release Note
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pkg/commands/src/setScript.ts (1)
21-27: ⚡ Quick winMove
help()belowhandler()to match the hoisting convention.
help()is currently declared before its call site; this file can follow the project’s “declare after use” pattern for consistency.As per coding guidelines: "Declare functions after they are used, relying on hoisting".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/commands/src/setScript.ts` around lines 21 - 27, The help() function is declared before its use; move its declaration below the handler() function to follow the project's "declare after use" hoisting convention—locate the help() export and cut/paste it so it appears after the handler() implementation (ensure any imports it depends on remain accessible) so handler() calls resolve correctly while preserving the same function body and export.pkg/commands/test/setScript.ts (1)
7-34: ⚡ Quick winAdd a small test asserting the
ssalias is exposed.Since alias support is part of this PR’s objective, a focused assertion (e.g.,
expect(setScript.commandNames).toContain('ss')) would guard against regressions in command registration.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/commands/test/setScript.ts` around lines 7 - 34, Add an assertion that the command alias `ss` is exposed by the setScript command: in the test file for setScript (pkg/commands/test/setScript.ts) add a test or extend an existing test to assert that setScript.commandNames includes 'ss' using expect(setScript.commandNames).toContain('ss'); ensure you reference the exported setScript symbol so the test fails if the alias is removed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/commands/src/setScript.ts`:
- Around line 21-27: The help() function is declared before its use; move its
declaration below the handler() function to follow the project's "declare after
use" hoisting convention—locate the help() export and cut/paste it so it appears
after the handler() implementation (ensure any imports it depends on remain
accessible) so handler() calls resolve correctly while preserving the same
function body and export.
In `@pkg/commands/test/setScript.ts`:
- Around line 7-34: Add an assertion that the command alias `ss` is exposed by
the setScript command: in the test file for setScript
(pkg/commands/test/setScript.ts) add a test or extend an existing test to assert
that setScript.commandNames includes 'ss' using
expect(setScript.commandNames).toContain('ss'); ensure you reference the
exported setScript symbol so the test fails if the alias is removed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 2690d8fe-470c-4fb2-8c35-d61513a330c4
📒 Files selected for processing (4)
pkg/commands/package.jsonpkg/commands/src/index.tspkg/commands/src/setScript.tspkg/commands/test/setScript.ts
There was a problem hiding this comment.
Pull request overview
Adds a new @pnpm/pkg.commands package that implements a native set-script command (with ss alias) intended to update the scripts field in a project manifest.
Changes:
- Introduces
set-scriptcommand implementation and help/options wiring inpkg/commands/src/setScript.ts. - Exports the new command from
pkg/commands/src/index.ts. - Adds Jest tests covering add/update and missing-args behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/commands/src/setScript.ts | Implements set-script/ss handler and help/options. |
| pkg/commands/src/index.ts | Exposes setScript from the package entrypoint. |
| pkg/commands/test/setScript.ts | Adds basic tests for adding/updating a script and missing args error. |
| pkg/commands/package.json | Defines the new @pnpm/pkg.commands package, scripts, and deps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@zkochan could you take a look at it? Thanks |
- Move set-script into @pnpm/pkg-manifest.commands (drops the orphan @pnpm/pkg.commands package; pkg/* is not in the workspace). - Use readProjectManifest from @pnpm/cli.utils so package.json5 and package.yaml are updated in place instead of growing a stray package.json. - Remove set-script from notImplemented and register the command in pnpm/src/cmd/index.ts. - Cover the ss alias and the multi-word command path in tests.
Replace direct manifest.scripts mutation with setObjectValueByPropertyPath - the same primitive pkg-set uses. Reuses the prototype-pollution rejection for free and keeps the two commands on the same write path. Avoids the pkg-set string-CLI's first-equals key/value split, so script names containing '=' work too.
Adds a native
pnpm set-script <name> <command>(aliasss) implemented in@pnpm/pkg-manifest.commands, alongside the existingpnpm pkgcommand.notImplemented.tsand registered inpnpm/src/cmd/index.ts.readProjectManifest, sopackage.json,package.json5, andpackage.yamlare all updated in place — no straypackage.jsonis created next to an existing alternate manifest.setObjectValueByPropertyPath) withpkg set, which inherits the prototype-pollution rejection for keys like__proto__..,-,", or=are all handled correctly.Summary by CodeRabbit