From 5a20769b5a39c83063d40b8ec964f8d3f3ae4453 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Sat, 4 Apr 2020 19:14:18 -0700 Subject: [PATCH 1/6] add name+email flags to shipit and latest commands --- packages/cli/src/parse-args.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/parse-args.ts b/packages/cli/src/parse-args.ts index 4c81df9ec..42c1ee1aa 100644 --- a/packages/cli/src/parse-args.ts +++ b/packages/cli/src/parse-args.ts @@ -465,6 +465,8 @@ export const commands: AutoCommand[] = [ 'Make auto publish prerelease versions when merging to master. Only PRs merged with "release" label will generate a "latest" release. Only use this flag if you do not want to maintain a prerelease branch, and instead only want to use master.', config: true, }, + name, + email, ], }, { @@ -474,7 +476,7 @@ export const commands: AutoCommand[] = [ Run the full \`auto\` release pipeline. Force a release to latest and bypass \`shipit\` safeguards. `, examples: ["{green $} auto latest"], - options: [baseBranch, dryRun], + options: [name, email, baseBranch, dryRun], }, { name: "canary", From 82a5c4618cf4abd072258e09fdc4c9e68b036378 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Sat, 4 Apr 2020 19:14:47 -0700 Subject: [PATCH 2/6] add onlyPublishWithReleaseLabel to latest command --- packages/cli/src/parse-args.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/parse-args.ts b/packages/cli/src/parse-args.ts index 42c1ee1aa..a65f3cfe6 100644 --- a/packages/cli/src/parse-args.ts +++ b/packages/cli/src/parse-args.ts @@ -476,7 +476,7 @@ export const commands: AutoCommand[] = [ Run the full \`auto\` release pipeline. Force a release to latest and bypass \`shipit\` safeguards. `, examples: ["{green $} auto latest"], - options: [name, email, baseBranch, dryRun], + options: [name, email, onlyPublishWithReleaseLabel, baseBranch, dryRun], }, { name: "canary", From f25e41cb0247742fb4e3a9cff64bd8a90ae5c1fb Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Sat, 4 Apr 2020 19:15:44 -0700 Subject: [PATCH 3/6] add noVersionPrefix flag to shipit and latest commands --- packages/cli/src/parse-args.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/parse-args.ts b/packages/cli/src/parse-args.ts index a65f3cfe6..788b5f552 100644 --- a/packages/cli/src/parse-args.ts +++ b/packages/cli/src/parse-args.ts @@ -467,6 +467,7 @@ export const commands: AutoCommand[] = [ }, name, email, + noVersionPrefix, ], }, { @@ -476,7 +477,14 @@ export const commands: AutoCommand[] = [ Run the full \`auto\` release pipeline. Force a release to latest and bypass \`shipit\` safeguards. `, examples: ["{green $} auto latest"], - options: [name, email, onlyPublishWithReleaseLabel, baseBranch, dryRun], + options: [ + name, + email, + onlyPublishWithReleaseLabel, + baseBranch, + dryRun, + noVersionPrefix, + ], }, { name: "canary", From 2e8219e64b0cc34e481eb5ace859f2ebfa951e7a Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Sat, 4 Apr 2020 19:17:15 -0700 Subject: [PATCH 4/6] add prerelease flag to shipit and latest commands --- packages/cli/src/parse-args.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/parse-args.ts b/packages/cli/src/parse-args.ts index 788b5f552..1606bf732 100644 --- a/packages/cli/src/parse-args.ts +++ b/packages/cli/src/parse-args.ts @@ -65,6 +65,14 @@ const version: AutoOption = { group: "global", }; +const prerelease: AutoOption = { + name: "prerelease", + type: Boolean, + group: "main", + description: "Publish a prerelease on GitHub.", + config: true, +}; + const onlyPublishWithReleaseLabel: AutoOption = { name: "only-publish-with-release-label", type: Boolean, @@ -427,13 +435,7 @@ export const commands: AutoCommand[] = [ "Version number to publish as. Defaults to reading from the package definition for the platform.", }, baseBranch, - { - name: "prerelease", - type: Boolean, - group: "main", - description: "Publish a prerelease.", - config: true, - }, + prerelease, ], examples: [ "{green $} auto release", @@ -468,6 +470,7 @@ export const commands: AutoCommand[] = [ name, email, noVersionPrefix, + prerelease, ], }, { @@ -484,6 +487,7 @@ export const commands: AutoCommand[] = [ baseBranch, dryRun, noVersionPrefix, + prerelease, ], }, { From 482feb61a42e7e03dc3694bcf43389eeb85d1a2d Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Sat, 4 Apr 2020 19:22:39 -0700 Subject: [PATCH 5/6] add changelogTitle and changelogCommitMessage flag to shipit and latest commands --- packages/cli/src/parse-args.ts | 59 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/packages/cli/src/parse-args.ts b/packages/cli/src/parse-args.ts index 1606bf732..23e6705ad 100644 --- a/packages/cli/src/parse-args.ts +++ b/packages/cli/src/parse-args.ts @@ -186,11 +186,37 @@ const message: AutoOption = { alias: "m", }; +const changelogTitle: AutoOption = { + name: "title", + type: String, + group: "main", + description: "Override the title used in the addition to the CHANGELOG.md.", +}; + +const changelogCommitMessage: AutoOption = { + ...message, + description: + "Message to commit the changelog with. Defaults to 'Update CHANGELOG.md [skip ci]'", + config: true, +}; + interface AutoCommand extends Command { /** Options for the command */ options?: AutoOption[]; } +const latestCommandArgs: AutoOption[] = [ + name, + email, + onlyPublishWithReleaseLabel, + baseBranch, + dryRun, + noVersionPrefix, + prerelease, + changelogTitle, + changelogCommitMessage, +]; + export const commands: AutoCommand[] = [ { name: "init", @@ -385,19 +411,8 @@ export const commands: AutoCommand[] = [ group: "main", description: "Tag to end changelog generation on. Defaults to HEAD.", }, - { - name: "title", - type: String, - group: "main", - description: - "Override the title used in the addition to the CHANGELOG.md.", - }, - { - ...message, - description: - "Message to commit the changelog with. Defaults to 'Update CHANGELOG.md [skip ci]'", - config: true, - }, + changelogTitle, + changelogCommitMessage, baseBranch, ], examples: [ @@ -455,9 +470,7 @@ export const commands: AutoCommand[] = [ `, examples: ["{green $} auto shipit"], options: [ - baseBranch, - dryRun, - onlyPublishWithReleaseLabel, + ...latestCommandArgs, { name: "only-graduate-with-release-label", type: Boolean, @@ -467,10 +480,6 @@ export const commands: AutoCommand[] = [ 'Make auto publish prerelease versions when merging to master. Only PRs merged with "release" label will generate a "latest" release. Only use this flag if you do not want to maintain a prerelease branch, and instead only want to use master.', config: true, }, - name, - email, - noVersionPrefix, - prerelease, ], }, { @@ -480,15 +489,7 @@ export const commands: AutoCommand[] = [ Run the full \`auto\` release pipeline. Force a release to latest and bypass \`shipit\` safeguards. `, examples: ["{green $} auto latest"], - options: [ - name, - email, - onlyPublishWithReleaseLabel, - baseBranch, - dryRun, - noVersionPrefix, - prerelease, - ], + options: latestCommandArgs, }, { name: "canary", From 77bb5d167a4265f8677b7c8bea10ae3ded8725be Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Sat, 4 Apr 2020 19:37:57 -0700 Subject: [PATCH 6/6] update types to match new flags --- packages/core/src/auto-args.ts | 88 +++++++++++++++++++++++----------- packages/core/src/auto.ts | 4 +- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/packages/core/src/auto-args.ts b/packages/core/src/auto-args.ts index 3fe6169c4..72235ec7e 100644 --- a/packages/core/src/auto-args.ts +++ b/packages/core/src/auto-args.ts @@ -49,62 +49,92 @@ export type IVersionOptions = ReleaseCalculationOptions & { from?: string; }; -export interface IChangelogOptions extends Partial { +interface NoVersionPrefix { /** Whether to prefix the version with a "v" */ noVersionPrefix?: boolean; +} + +interface DryRun { /** Do not actually do anything */ dryRun?: boolean; - /** Commit to start calculating the changelog from */ - from?: string; - /** Commit to start calculating the changelog to */ - to?: string; +} + +interface ChangelogMessage { /** The commit message to commit the changelog changes with */ message?: string; +} + +interface ChangelogTitle { /** Override the title use in the addition to the CHANGELOG.md. */ title?: string; } -export interface IReleaseOptions extends Partial { - /** Whether to prefix the version with a "v" */ - noVersionPrefix?: boolean; - /** Do not actually do anything */ - dryRun?: boolean; - /** Commit to start calculating the release from */ - from?: string; - /** Override the version to release */ - useVersion?: string; +interface Prerelease { /** Create a prerelease */ prerelease?: boolean; } -export interface ICommentOptions { +interface BaseBranch { + /** The branch to treat as the base. Default is master */ + baseBranch?: string; +} + +export type IChangelogOptions = BaseBranch & + ChangelogTitle & + ChangelogMessage & + DryRun & + NoVersionPrefix & + Partial & { + /** Commit to start calculating the changelog from */ + from?: string; + /** Commit to start calculating the changelog to */ + to?: string; + }; + +export type IReleaseOptions = BaseBranch & + Prerelease & + DryRun & + NoVersionPrefix & + Partial & + Partial & { + /** Commit to start calculating the release from */ + from?: string; + /** Override the version to release */ + useVersion?: string; + }; + +export type ICommentOptions = DryRun & { /** The message to use when commenting */ message?: string; /** THe PR to comment on */ pr?: number; /** The context the message should be attached to. Use to post multiple comments to a PR */ context?: string; - /** Do not actually do anything */ - dryRun?: boolean; /** Delete the previous comment */ delete?: boolean; /** Instead of deleting/adding a new comment. Just edit the old one */ edit?: boolean; -} +}; export type IPRBodyOptions = Omit; -export interface IShipItOptions { - /** Do not actually do anything */ - dryRun?: boolean; - /** - * Make auto publish prerelease versions when merging to master. - * Only PRs merged with "release" label will generate a "latest" release. - * Only use this flag if you do not want to maintain a prerelease branch, - * and instead only want to use master. - */ - onlyGraduateWithReleaseLabel?: boolean; -} +export type IShipItOptions = BaseBranch & + Prerelease & + NoVersionPrefix & + ChangelogMessage & + ChangelogTitle & + DryRun & + Partial & + Partial & + ReleaseCalculationOptions & { + /** + * Make auto publish prerelease versions when merging to master. + * Only PRs merged with "release" label will generate a "latest" release. + * Only use this flag if you do not want to maintain a prerelease branch, + * and instead only want to use master. + */ + onlyGraduateWithReleaseLabel?: boolean; + }; export interface ICanaryOptions { /** Do not actually do anything */ diff --git a/packages/core/src/auto.ts b/packages/core/src/auto.ts index 571e7b6da..6affbbab5 100644 --- a/packages/core/src/auto.ts +++ b/packages/core/src/auto.ts @@ -1269,8 +1269,8 @@ export default class Auto { * 4. Create a release */ async shipit(args: IShipItOptions = {}) { - const options: IShipItOptions = { - ...this.getCommandDefault("shipit"), + const options = { + ...(this.getCommandDefault("shipit") as IShipItOptions), ...args, };