auto-release-cli
Advanced tools
Comparing version 0.21.0 to 0.22.0
@@ -0,1 +1,11 @@ | ||
# 0.22.0 (Fri Dec 07 2018) | ||
#### 🚀 Enhancement | ||
- Add git user options [#37](https://github.com/intuit/auto-release/pull/37) ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
#### Authors: 1 | ||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
--- | ||
# 0.21.0 (Fri Dec 07 2018) | ||
@@ -2,0 +12,0 @@ |
@@ -20,2 +20,6 @@ import { ArgumentParser } from 'argparse'; | ||
} | ||
export interface IOwnerArgs { | ||
name?: string; | ||
email?: string; | ||
} | ||
export interface IRepoArgs { | ||
@@ -54,3 +58,3 @@ owner?: string; | ||
command: string; | ||
} & ISemverArgs & IRepoArgs & IChangelogArgs & IReleaseArgs & ICommentArgs & IPRArgs & ILogArgs; | ||
} & ISemverArgs & IRepoArgs & IChangelogArgs & IReleaseArgs & ICommentArgs & IPRArgs & ILogArgs & IOwnerArgs; | ||
export default function parse(stuff?: string[]): ArgsType; |
@@ -110,2 +110,10 @@ "use strict"; | ||
} | ||
function addGitUser(parser) { | ||
parser.addArgument(['--name'], { | ||
help: 'Git name to commit and release with. Defaults to package.json' | ||
}); | ||
parser.addArgument(['--email'], { | ||
help: 'Git email to commit with. Defaults to package.json' | ||
}); | ||
} | ||
// All of the parsers for each command are setup in their own functions | ||
@@ -165,2 +173,3 @@ // This allows us to either use separate commands for each one (github-pr, github-label) | ||
addLoggingParser(parser); | ||
addGitUser(parser); | ||
} | ||
@@ -185,2 +194,3 @@ exports.addReleaseParser = addReleaseParser; | ||
addLoggingParser(parser); | ||
addGitUser(parser); | ||
} | ||
@@ -187,0 +197,0 @@ exports.addChangelogParser = addChangelogParser; |
@@ -31,2 +31,4 @@ import signale from 'signale'; | ||
githubApi?: string; | ||
name?: string; | ||
email?: string; | ||
changelogTitles?: { | ||
@@ -33,0 +35,0 @@ [label: string]: string; |
182
dist/main.js
@@ -138,2 +138,35 @@ #!/usr/bin/env node | ||
} | ||
function setGitUser(args) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var packageJson, _a, _b, name, email; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_b = (_a = JSON).parse; | ||
return [4 /*yield*/, readFile('package.json', 'utf-8')]; | ||
case 1: | ||
packageJson = _b.apply(_a, [_c.sent()]); | ||
name = args.name, email = args.email; | ||
if (!name) { | ||
(name = packageJson.author.name); | ||
} | ||
if (!email) { | ||
(email = packageJson.author.email); | ||
} | ||
if (!email) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, exec_promise_1.default("git config user.email \"" + email + "\"")]; | ||
case 2: | ||
_c.sent(); | ||
_c.label = 3; | ||
case 3: | ||
if (!name) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, exec_promise_1.default("git config user.name \"" + name + "\"")]; | ||
case 4: | ||
_c.sent(); | ||
_c.label = 5; | ||
case 5: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function getVersion(githubRelease, args) { | ||
@@ -265,2 +298,5 @@ return __awaiter(this, void 0, void 0, function () { | ||
config = __assign({}, rawConfig, args, { logger: logger }); | ||
return [4 /*yield*/, setGitUser(config)]; | ||
case 2: | ||
_c.sent(); | ||
semVerLabels = github_release_1.defaultLabels; | ||
@@ -277,14 +313,14 @@ if (config.labels) { | ||
switch (_a) { | ||
case 'shipit': return [3 /*break*/, 2]; | ||
case 'label': return [3 /*break*/, 12]; | ||
case 'pr-check': return [3 /*break*/, 14]; | ||
case 'pr': return [3 /*break*/, 23]; | ||
case 'comment': return [3 /*break*/, 31]; | ||
case 'version': return [3 /*break*/, 33]; | ||
case 'changelog': return [3 /*break*/, 35]; | ||
case 'release': return [3 /*break*/, 37]; | ||
case 'shipit': return [3 /*break*/, 3]; | ||
case 'label': return [3 /*break*/, 13]; | ||
case 'pr-check': return [3 /*break*/, 15]; | ||
case 'pr': return [3 /*break*/, 24]; | ||
case 'comment': return [3 /*break*/, 32]; | ||
case 'version': return [3 /*break*/, 34]; | ||
case 'changelog': return [3 /*break*/, 36]; | ||
case 'release': return [3 /*break*/, 38]; | ||
} | ||
return [3 /*break*/, 39]; | ||
case 2: return [4 /*yield*/, getVersion(githubRelease, args)]; | ||
case 3: | ||
return [3 /*break*/, 40]; | ||
case 3: return [4 /*yield*/, getVersion(githubRelease, args)]; | ||
case 4: | ||
version = _c.sent(); | ||
@@ -295,31 +331,31 @@ if (version === '') { | ||
return [4 /*yield*/, makeChangelog(args, githubRelease, log, prefixRelease, veryVerbose, verbose)]; | ||
case 4: | ||
case 5: | ||
_c.sent(); | ||
if (!isMonorepo()) return [3 /*break*/, 6]; | ||
if (!isMonorepo()) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, exec_promise_1.default("npx lerna publish --yes --force-publish=* " + version + " -m '%v [skip ci]'")]; | ||
case 5: | ||
case 6: | ||
_c.sent(); | ||
return [3 /*break*/, 10]; | ||
case 6: return [4 /*yield*/, exec_promise_1.default("npm version " + version + " -m \"Bump version to: %s [skip ci]\"")]; | ||
case 7: | ||
return [3 /*break*/, 11]; | ||
case 7: return [4 /*yield*/, exec_promise_1.default("npm version " + version + " -m \"Bump version to: %s [skip ci]\"")]; | ||
case 8: | ||
_c.sent(); | ||
return [4 /*yield*/, exec_promise_1.default('npm publish')]; | ||
case 8: | ||
case 9: | ||
_c.sent(); | ||
return [4 /*yield*/, exec_promise_1.default('git push --follow-tags --set-upstream origin $branch')]; | ||
case 9: | ||
case 10: | ||
_c.sent(); | ||
_c.label = 10; | ||
case 10: return [4 /*yield*/, makeRelease(args, githubRelease, log, prefixRelease, veryVerbose, verbose)]; | ||
case 11: | ||
_c.label = 11; | ||
case 11: return [4 /*yield*/, makeRelease(args, githubRelease, log, prefixRelease, veryVerbose, verbose)]; | ||
case 12: | ||
_c.sent(); | ||
return [3 /*break*/, 40]; | ||
case 12: | ||
return [3 /*break*/, 41]; | ||
case 13: | ||
verbose.info("Using command: 'label'"); | ||
return [4 /*yield*/, githubRelease.getLabels(args.pr)]; | ||
case 13: | ||
case 14: | ||
labels = _c.sent(); | ||
console.log(labels.join('\n')); | ||
return [3 /*break*/, 40]; | ||
case 14: | ||
return [3 /*break*/, 41]; | ||
case 15: | ||
verbose.info("Using command: 'pr-check' for '" + args.url + "'"); | ||
@@ -329,11 +365,11 @@ args.target_url = args.url; | ||
msg = void 0; | ||
_c.label = 15; | ||
case 15: | ||
_c.trys.push([15, 18, , 19]); | ||
_c.label = 16; | ||
case 16: | ||
_c.trys.push([16, 19, , 20]); | ||
return [4 /*yield*/, githubRelease.getPullRequest(args.pr)]; | ||
case 16: | ||
case 17: | ||
res = _c.sent(); | ||
args.sha = res.data.head.sha; | ||
return [4 /*yield*/, githubRelease.getLabels(args.pr)]; | ||
case 17: | ||
case 18: | ||
labels = _c.sent(); | ||
@@ -362,4 +398,4 @@ labelTexts_1 = Object.values(semVerLabels); | ||
}; | ||
return [3 /*break*/, 19]; | ||
case 18: | ||
return [3 /*break*/, 20]; | ||
case 19: | ||
error_1 = _c.sent(); | ||
@@ -370,77 +406,77 @@ msg = { | ||
}; | ||
return [3 /*break*/, 19]; | ||
case 19: | ||
return [3 /*break*/, 20]; | ||
case 20: | ||
verbose.info('Posting comment to Github\n', msg); | ||
if (!!args.dry_run) return [3 /*break*/, 21]; | ||
if (!!args.dry_run) return [3 /*break*/, 22]; | ||
return [4 /*yield*/, githubRelease.createStatus(__assign({}, args, msg))]; | ||
case 20: | ||
case 21: | ||
_c.sent(); | ||
log.success('Posted status to Pull Request.'); | ||
return [3 /*break*/, 22]; | ||
case 21: | ||
return [3 /*break*/, 23]; | ||
case 22: | ||
verbose.info('`pr-check` dry run complete.'); | ||
_c.label = 22; | ||
case 22: | ||
_c.label = 23; | ||
case 23: | ||
verbose.success('Finished `pr-check` command'); | ||
return [3 /*break*/, 40]; | ||
case 23: | ||
return [3 /*break*/, 41]; | ||
case 24: | ||
verbose.info("Using command: 'pr'"); | ||
if (!(!args.sha && args.pr)) return [3 /*break*/, 25]; | ||
if (!(!args.sha && args.pr)) return [3 /*break*/, 26]; | ||
verbose.info('Getting commit SHA from PR.'); | ||
return [4 /*yield*/, githubRelease.getPullRequest(args.pr)]; | ||
case 24: | ||
case 25: | ||
res = _c.sent(); | ||
args.sha = res.data.head.sha; | ||
return [3 /*break*/, 27]; | ||
case 25: | ||
if (!!args.sha) return [3 /*break*/, 27]; | ||
return [3 /*break*/, 28]; | ||
case 26: | ||
if (!!args.sha) return [3 /*break*/, 28]; | ||
verbose.info('No PR found, getting commit SHA from HEAD.'); | ||
_b = args; | ||
return [4 /*yield*/, githubRelease.getSha()]; | ||
case 26: | ||
case 27: | ||
_b.sha = _c.sent(); | ||
_c.label = 27; | ||
case 27: | ||
_c.label = 28; | ||
case 28: | ||
verbose.info('Found PR SHA:', args.sha); | ||
args.target_url = args.url; | ||
delete args.url; | ||
if (!!args.dry_run) return [3 /*break*/, 29]; | ||
if (!!args.dry_run) return [3 /*break*/, 30]; | ||
return [4 /*yield*/, githubRelease.createStatus(args)]; | ||
case 28: | ||
case 29: | ||
_c.sent(); | ||
return [3 /*break*/, 30]; | ||
case 29: | ||
return [3 /*break*/, 31]; | ||
case 30: | ||
verbose.info('`pr` dry run complete.'); | ||
_c.label = 30; | ||
case 30: | ||
_c.label = 31; | ||
case 31: | ||
verbose.success('Finished `pr` command'); | ||
return [3 /*break*/, 40]; | ||
case 31: | ||
return [3 /*break*/, 41]; | ||
case 32: | ||
verbose.info("Using command: 'comment'"); | ||
return [4 /*yield*/, githubRelease.createComment(args.message, args.pr, args.context || undefined)]; | ||
case 32: | ||
case 33: | ||
_c.sent(); | ||
log.success("Commented on PR #" + args.pr); | ||
return [3 /*break*/, 40]; | ||
case 33: | ||
return [3 /*break*/, 41]; | ||
case 34: | ||
verbose.info("Using command: 'version'"); | ||
return [4 /*yield*/, getVersion(githubRelease, args)]; | ||
case 34: | ||
case 35: | ||
bump = _c.sent(); | ||
console.log(bump); | ||
return [3 /*break*/, 40]; | ||
case 35: | ||
return [3 /*break*/, 41]; | ||
case 36: | ||
verbose.info("Using command: 'changelog'"); | ||
return [4 /*yield*/, makeChangelog(args, githubRelease, log, prefixRelease, veryVerbose, verbose)]; | ||
case 36: | ||
case 37: | ||
_c.sent(); | ||
return [3 /*break*/, 40]; | ||
case 37: | ||
return [3 /*break*/, 41]; | ||
case 38: | ||
verbose.info("Using command: 'release'"); | ||
return [4 /*yield*/, makeRelease(args, githubRelease, log, prefixRelease, veryVerbose, verbose)]; | ||
case 38: | ||
case 39: | ||
_c.sent(); | ||
return [3 /*break*/, 40]; | ||
case 39: throw new Error("idk what i'm doing."); | ||
case 40: return [2 /*return*/]; | ||
return [3 /*break*/, 41]; | ||
case 40: throw new Error("idk what i'm doing."); | ||
case 41: return [2 /*return*/]; | ||
} | ||
@@ -447,0 +483,0 @@ }); |
{ | ||
"name": "auto-release-cli", | ||
"description": "CLI tools to help facilitate semantic versioning based on Github PR labels.", | ||
"version": "0.21.0", | ||
"version": "0.22.0", | ||
"author": { | ||
@@ -30,3 +30,3 @@ "name": "Andrew Lisowski", | ||
"test": "jest", | ||
"release": "./scripts/release.sh", | ||
"release": "chmod +x ./dist/bin/auto.js && ./dist/bin/auto.js shipit", | ||
"contributors:add": "all-contributors", | ||
@@ -33,0 +33,0 @@ "contributors:generate": "all-contributors generate", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195950
2598