diff --git a/README.md b/README.md index e62632d..ac6c254 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,27 @@ With this configuration, the `package.json` files in your workspaces would be updated with the new version information but the packages would not be published. +### publishCommand + +`@release-it-plugins/workspaces` uses `npm publish` by default. +Some repository configurations may wish to use a different publish command. +Using `publishCommand`, this can be changed: + +```json +{ + "release-it": { + "plugins": { + "@release-it-plugins/workspaces": { + "publishCommand": "pnpm publish" + } + } + } +} +``` + +With this configuration, `pnpm publish` will be used for each workspace instead of `npm publish` + + ### distTag `@release-it-plugins/workspaces` uses the `latest` dist-tag when the diff --git a/index.js b/index.js index e6bbba3..6c9ce0b 100644 --- a/index.js +++ b/index.js @@ -428,9 +428,11 @@ export default class WorkspacesPlugin extends Plugin { return; } + const publishCommand = this.getContext().publishCommand ?? 'npm publish'; + try { await this.exec( - `npm publish ./${workspaceInfo.relativeRoot} --tag ${tag}${accessArg}${otpArg}${dryRunArg}`, + `${publishCommand} ./${workspaceInfo.relativeRoot} --tag ${tag}${accessArg}${otpArg}${dryRunArg}`, { options, } diff --git a/tests/plugin-test.js b/tests/plugin-test.js index 51f9d29..4f5c438 100644 --- a/tests/plugin-test.js +++ b/tests/plugin-test.js @@ -611,6 +611,57 @@ describe('@release-it-plugins/workspaces', () => { `); }); + it('uses custom publish command', async () => { + setupProject(['packages/*']); + let plugin = buildPlugin({ + publishCommand: 'pnpm publish' + }); + + await runTasks(plugin); + + expect(plugin.operations).toMatchInlineSnapshot(` + [ + { + "command": "npm ping --registry https://registry.npmjs.org", + "operationType": "command", + "options": undefined, + }, + { + "command": "npm whoami --registry https://registry.npmjs.org", + "operationType": "command", + "options": undefined, + }, + { + "command": "pnpm publish ./packages/bar --tag latest", + "operationType": "command", + "options": { + "write": false, + }, + }, + { + "command": "pnpm publish ./packages/foo --tag latest", + "operationType": "command", + "options": { + "write": false, + }, + }, + { + "messages": [ + "🔗 https://www.npmjs.com/package/bar", + ], + "operationType": "log", + }, + { + "messages": [ + "🔗 https://www.npmjs.com/package/foo", + ], + "operationType": "log", + }, + ] + `); + }); + + it('uses custom registry', async () => { setupProject(['packages/*'], { publishConfig: { registry: 'http://my-custom-registry' } }); let plugin = buildPlugin();