Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flags to support automation in edge cases #707

Merged
merged 2 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ module.exports = function (argv: string[]): void {
.option('--no-gitLabIssueLinking', 'Disable automatic expansion of GitLab-style issue syntax into links')
.option('--no-dependencies', 'Disable dependency detection via npm or yarn')
.option('--pre-release', 'Mark this package as a pre-release')
.option('--allow-star-activation', 'Allow using * in activation events')
.option('--allow-missing-repository', 'Allow missing a repository URL in package.json')
.action(
(
version,
Expand All @@ -123,6 +125,8 @@ module.exports = function (argv: string[]): void {
gitLabIssueLinking,
dependencies,
preRelease,
allowStarActivation,
allowMissingRepository,
}
) =>
main(
Expand All @@ -144,6 +148,8 @@ module.exports = function (argv: string[]): void {
gitLabIssueLinking,
dependencies,
preRelease,
allowStarActivation,
allowMissingRepository,
})
)
);
Expand Down Expand Up @@ -180,6 +186,8 @@ module.exports = function (argv: string[]): void {
.option('--ignoreFile <path>', 'Indicate alternative .vscodeignore')
.option('--no-dependencies', 'Disable dependency detection via npm or yarn')
.option('--pre-release', 'Mark this package as a pre-release')
.option('--allow-star-activation', 'Allow using * in activation events')
.option('--allow-missing-repository', 'Allow missing a repository URL in package.json')
.action(
(
version,
Expand All @@ -199,6 +207,8 @@ module.exports = function (argv: string[]): void {
ignoreFile,
dependencies,
preRelease,
allowStarActivation,
allowMissingRepository,
}
) =>
main(
Expand All @@ -219,6 +229,8 @@ module.exports = function (argv: string[]): void {
ignoreFile,
dependencies,
preRelease,
allowStarActivation,
allowMissingRepository,
})
)
);
Expand Down
6 changes: 4 additions & 2 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export interface IPackageOptions {
readonly gitLabIssueLinking?: boolean;
readonly dependencies?: boolean;
readonly preRelease?: boolean;
readonly allowStarActivation?: boolean;
readonly allowMissingRepository?: boolean;
}

export interface IProcessor {
Expand Down Expand Up @@ -490,15 +492,15 @@ export class ManifestProcessor extends BaseProcessor {
);
}

if (!this.manifest.repository) {
if (!this.options.allowMissingRepository && !this.manifest.repository) {
util.log.warn(`A 'repository' field is missing from the 'package.json' manifest file.`);

if (!/^y$/i.test(await util.read('Do you want to continue? [y/N] '))) {
throw new Error('Aborted');
}
}

if (this.manifest.activationEvents?.some(e => e === '*')) {
if (!this.options.allowStarActivation && this.manifest.activationEvents?.some(e => e === '*')) {
util.log.warn(
`Using '*' activation is usually a bad idea as it impacts performance.\nMore info: https://code.visualstudio.com/api/references/activation-events#Start-up`
);
Expand Down
2 changes: 2 additions & 0 deletions src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface IPublishOptions {
readonly noVerify?: boolean;
readonly dependencies?: boolean;
readonly preRelease?: boolean;
readonly allowStarActivation?: boolean;
readonly allowMissingRepository?: boolean;
}

export async function publish(options: IPublishOptions = {}): Promise<any> {
Expand Down