Skip to content

Commit

Permalink
fix(publish): deprecate publish --require-scripts (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Jan 27, 2023
1 parent 5cc0920 commit e8ef54e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/cli/schemas/lerna-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@
},
"requireScripts": {
"type": "boolean",
"description": "During `lerna publish`, when true, execute ./scripts/prepublish.js and ./scripts/postpublish.js, relative to package root."
"description": "@deprecated During `lerna publish`, when true, execute ./scripts/prepublish.js and ./scripts/postpublish.js, relative to package root."
},
"noGitReset": {
"type": "boolean",
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/cli-commands/cli-publish-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ export default {
delete argv['npm-tag'];
log.warn('deprecated', '--npm-tag has been renamed --dist-tag');
}

if (argv.requireScripts) {
log.warn('deprecated', '--require-scripts has been deprecated and will be removed in next major');
}
/* eslint-enable no-param-reassign */

return argv;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/models/command-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export interface PublishCommandOption extends VersionCommandOption {
/** Remove fields from each package.json before publishing them to the registry, removing fields from a complex object is also supported via the dot notation (ie "scripts.build") */
removePackageFields?: string[];

/** Execute ./scripts/prepublish.js and ./scripts/postpublish.js, relative to package root. */
/** @deprecated Execute ./scripts/prepublish.js and ./scripts/postpublish.js, relative to package root. */
requireScripts?: boolean;

/** Do not reset changes to working tree after publishing is complete. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ describe('lifecycle scripts', () => {
});
});

// @deprecated, execScript should be removed since requireScripts is deprecated
describe('execScript', () => {
it('execute --require-scripts but fails since scripts folder does not exist and log error with script not found message is shown', async () => {
const cwd = await initFixture('lifecycle');
Expand Down
2 changes: 2 additions & 0 deletions packages/publish/src/publish-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export class PublishCommand extends Command<PublishCommandOption> {
this.logger.info('canary', 'enabled');
}

// @deprecated, to be removed in next major
if (this.options.requireScripts) {
this.logger.info('require-scripts', 'enabled');
}
Expand Down Expand Up @@ -725,6 +726,7 @@ export class PublishCommand extends Command<PublishCommandOption> {
});
}

// @deprecated, see Lerna PR https://github.com/lerna/lerna/pull/1862/files
execScript(pkg: Package, script: string) {
const scriptLocation = path.join(pkg.location, 'scripts', script);

Expand Down

0 comments on commit e8ef54e

Please sign in to comment.