Skip to content

Commit

Permalink
refactor: MintRelease is better described as ReleasePR (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored May 13, 2019
1 parent 74dea84 commit 02bbbd9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
20 changes: 12 additions & 8 deletions src/bin/release-please.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,29 @@

'use strict';

import {MintRelease, MintReleaseOptions} from '../mint-release';
import {ReleasePR, ReleasePROptions} from '../release-pr';
import {CandidateIssue} from '../candidate-issue';

const yargs = require('yargs');

yargs
.command(
'mint-release', 'mint a new release for a repo', () => {},
async (argv: MintReleaseOptions) => {
const mr = new MintRelease(argv);
await mr.run();
})
.command(
'candidate-issue',
'create an issue that\'s an example of the next release', () => {},
async (argv: MintReleaseOptions) => {
async (argv: ReleasePROptions) => {
const ci = new CandidateIssue(argv);
await ci.run();
})
.command(
'release-pr', 'create a new release PR from a candidate issue',
() => {},
async (argv: ReleasePROptions) => {
const rp = new ReleasePR(argv);
await rp.run();
})
.command(
'github-release', 'create a GitHub release from am release PR',
() => {}, async (argv: ReleasePROptions) => {})
.option(
'token', {describe: 'GitHub repo token', default: process.env.GH_TOKEN})
.option('package-name', {
Expand Down
10 changes: 5 additions & 5 deletions src/candidate-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import * as semver from 'semver';
import {checkpoint, CheckpointType} from './checkpoint';
import {ConventionalCommits} from './conventional-commits';
import {GitHub, GitHubTag} from './github';
import {ReleaseCandidate, ReleaseType} from './mint-release';
import {MintRelease, MintReleaseOptions} from './mint-release';
import {ReleaseCandidate, ReleaseType} from './release-pr';
import {ReleasePR, ReleasePROptions} from './release-pr';

const parseGithubRepoUrl = require('parse-github-repo-url');

Expand All @@ -38,7 +38,7 @@ export class CandidateIssue {
packageName: string;
releaseType: ReleaseType;

constructor(options: MintReleaseOptions) {
constructor(options: ReleasePROptions) {
this.bumpMinorPreMajor = options.bumpMinorPreMajor || false;
this.label = options.label;
this.repoUrl = options.repoUrl;
Expand Down Expand Up @@ -88,15 +88,15 @@ export class CandidateIssue {
checkpoint(
`release checkbox was checked, creating release`,
CheckpointType.Success);
const mr = new MintRelease({
const rp = new ReleasePR({
bumpMinorPreMajor: this.bumpMinorPreMajor,
label: this.label,
token: this.token,
repoUrl: this.repoUrl,
packageName: this.packageName,
releaseType: this.releaseType
});
const prNumber = await mr.run();
const prNumber = await rp.run();
body = body.replace(CHECKBOX, `**release created at #${prNumber}**`);
} else if (issue.body === body) {
// don't update the issue if the content is the same for the release.
Expand Down
1 change: 1 addition & 0 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class GitHub {
})) {
for (let i = 0, commit; response.data[i] !== undefined; i++) {
commit = response.data[i];
console.info(JSON.stringify(commit, null, 2));
if (commit.sha === sha) {
return commits;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/mint-release.ts → src/release-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export enum ReleaseType {
Node = 'node'
}

export interface MintReleaseOptions {
export interface ReleasePROptions {
bumpMinorPreMajor?: boolean;
label: string;
token?: string;
Expand All @@ -45,7 +45,7 @@ export interface ReleaseCandidate {
previousTag?: string;
}

export class MintRelease {
export class ReleasePR {
label: string;
gh: GitHub;
bumpMinorPreMajor?: boolean;
Expand All @@ -55,7 +55,7 @@ export class MintRelease {
releaseAs?: string;
releaseType: ReleaseType;

constructor(options: MintReleaseOptions) {
constructor(options: ReleasePROptions) {
this.bumpMinorPreMajor = options.bumpMinorPreMajor || false;
this.label = options.label;
this.repoUrl = options.repoUrl;
Expand Down

0 comments on commit 02bbbd9

Please sign in to comment.