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

feat: you must now opt in to bumping minor pre-major #10

Merged
merged 1 commit into from
May 2, 2019
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
5 changes: 5 additions & 0 deletions src/bin/release-please.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ yargs
options: ['node'],
default: 'node'
})
.option('bump-minor-pre-major', {
describe: 'should we bump the semver minor prior to the first major release',
default: false,
type: 'boolean'
})
.option('label', {
default: 'autorelease: pending',
describe: 'label to add to generated PR'
Expand Down
5 changes: 4 additions & 1 deletion src/conventional-commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface ConventionalCommitsOptions {
commits: string[];
githubRepoUrl: string;
host?: string;
bumpMinorPreMajor?: boolean;
}

interface ChangelogEntryOptions {
Expand Down Expand Up @@ -65,18 +66,20 @@ export class ConventionalCommits {
host: string;
owner: string;
repository: string;
bumpMinorPreMajor?: boolean;

constructor(options: ConventionalCommitsOptions) {
const parsedGithubRepoUrl = parseGithubRepoUrl(options.githubRepoUrl);
if (!parsedGithubRepoUrl) throw Error('could not parse githubRepoUrl');
const [owner, repository] = parsedGithubRepoUrl;
this.commits = options.commits;
this.bumpMinorPreMajor = options.bumpMinorPreMajor || false;
this.host = options.host || 'https://www.github.com';
this.owner = owner;
this.repository = repository;
}
async suggestBump(version: string): Promise<BumpSuggestion> {
const preMajor = semver.lt(version, 'v1.0.0');
const preMajor = this.bumpMinorPreMajor ? semver.lt(version, 'v1.0.0') : false;
const bump: BumpSuggestion = await this.guessReleaseType(preMajor);
checkpoint(
`release as ${chalk.green(bump.releaseType)}: ${
Expand Down
9 changes: 8 additions & 1 deletion src/mint-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum ReleaseType {
}

export interface MintReleaseOptions {
bumpMinorPreMajor?: boolean;
label: string;
token?: string;
repoUrl: string;
Expand All @@ -41,12 +42,14 @@ export interface MintReleaseOptions {
export class MintRelease {
label: string;
gh: GitHub;
bumpMinorPreMajor?: boolean;
repoUrl: string;
token: string|undefined;
packageName: string;
releaseType: ReleaseType;

constructor(options: MintReleaseOptions) {
this.bumpMinorPreMajor = options.bumpMinorPreMajor || false;
this.label = options.label;
this.repoUrl = options.repoUrl;
this.token = options.token;
Expand All @@ -68,7 +71,11 @@ export class MintRelease {
const latestTag: GitHubTag = await this.gh.latestTag();
const commits: string[] = await this.commits(latestTag);

const cc = new ConventionalCommits({commits, githubRepoUrl: this.repoUrl});
const cc = new ConventionalCommits({
commits,
githubRepoUrl: this.repoUrl,
bumpMinorPreMajor: this.bumpMinorPreMajor
});
const bump = await cc.suggestBump(latestTag.version);
const version = semver.inc(latestTag.version, bump.releaseType);

Expand Down
3 changes: 2 additions & 1 deletion test/conventional-commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('ConventionalCommits', () => {
'chore: upgrade to Node 7\n\nBREAKING CHANGE: we were on Node 6',
'feat: awesome feature'
],
githubRepoUrl: 'https://github.com/bcoe/release-please.git'
githubRepoUrl: 'https://github.com/bcoe/release-please.git',
bumpMinorPreMajor: true
});
const bump = await cc.suggestBump('0.3.0');
expect(bump.releaseType).to.equal('minor');
Expand Down