Skip to content

Commit

Permalink
Merge pull request #1117 from intuit/name-email
Browse files Browse the repository at this point in the history
Add most flags for version+changelog+release to shipit/latest
  • Loading branch information
hipstersmoothie authored Apr 5, 2020
2 parents 354a4c4 + 77bb5d1 commit 350cff9
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 55 deletions.
63 changes: 39 additions & 24 deletions packages/cli/src/parse-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -178,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",
Expand Down Expand Up @@ -377,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: [
Expand Down Expand Up @@ -427,13 +450,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",
Expand All @@ -453,9 +470,7 @@ export const commands: AutoCommand[] = [
`,
examples: ["{green $} auto shipit"],
options: [
baseBranch,
dryRun,
onlyPublishWithReleaseLabel,
...latestCommandArgs,
{
name: "only-graduate-with-release-label",
type: Boolean,
Expand All @@ -474,7 +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: [baseBranch, dryRun],
options: latestCommandArgs,
},
{
name: "canary",
Expand Down
88 changes: 59 additions & 29 deletions packages/core/src/auto-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,62 +49,92 @@ export type IVersionOptions = ReleaseCalculationOptions & {
from?: string;
};

export interface IChangelogOptions extends Partial<AuthorInformation> {
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<RepoInformation> {
/** 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<AuthorInformation> & {
/** 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<AuthorInformation> &
Partial<RepoInformation> & {
/** 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<ICommentOptions, "edit" | "delete">;

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<AuthorInformation> &
Partial<RepoInformation> &
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 */
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down

0 comments on commit 350cff9

Please sign in to comment.