Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkmg committed May 3, 2018
2 parents b916eea + 79c35ac commit 1c5abd8
Show file tree
Hide file tree
Showing 35 changed files with 1,023 additions and 778 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@ Generate a release for a project following semver using nodejs and gitflow
[![Generate Release on NPM](https://img.shields.io/npm/v/generate-release.svg?style=flat-square)](https://www.npmjs.com/package/generate-release)
[![Generate Release uses the MIT](https://img.shields.io/npm/l/generate-release.svg?style=flat-square)](https://opensource.org/licenses/MIT)

Current Version: 1.0.0
Current Version: 1.0.1

Requires NodeJS v4.0.0 or greater

Expand Down
515 changes: 277 additions & 238 deletions main/index.js

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions main/lib/GitCommands.js
Expand Up @@ -14,32 +14,32 @@ env.GIT_MERGE_AUTOEDIT = "no";
var AVH_EDITION_REGEX = /AVH Edition/;
var GitCommands = /** @class */ (function () {
function GitCommands(opts) {
this.masterBranch = "master";
this.developBranch = "develop";
this.skipGitFlowFinish = false;
this.isAvh = false;
this.masterBranch = "master";
this.skipGitFlowFinish = false;
this.releaseMessage = "release/" + this.nextVersion;
if (opts.masterBranch) {
this.masterBranch = opts.masterBranch;
if (opts.currentVersion) {
this.currentVersion = opts.currentVersion;
}
if (opts.developBranch) {
this.developBranch = opts.developBranch;
}
if (opts.currentVersion) {
this.currentVersion = opts.currentVersion;
if (opts.masterBranch) {
this.masterBranch = opts.masterBranch;
}
if (opts.nextVersion) {
this.nextVersion = opts.nextVersion;
}
if (opts.releaseMessage) {
this.releaseMessage = opts.releaseMessage;
}
if (opts.skipGitFlowFinish) {
this.skipGitFlowFinish = opts.skipGitFlowFinish;
}
if (opts.remote) {
this.remote = opts.remote;
}
if (opts.skipGitFlowFinish) {
this.skipGitFlowFinish = opts.skipGitFlowFinish;
}
this.isAvh = GitCommands.isAvhEdition();
if (!opts.currentVersion) {
throw new Error("Current Version is not set.");
Expand Down Expand Up @@ -100,7 +100,12 @@ var GitCommands = /** @class */ (function () {
GitCommands.prototype.reset = function () {
GitCommands.git("checkout", this.developBranch);
GitCommands.git("reset", "--hard", "HEAD");
GitCommands.git("branch", "-D", "release/" + this.nextVersion);
try {
GitCommands.git("branch", "-D", "release/" + this.nextVersion);
}
catch (e) {
// It is safe to throw this away in case the next release branch was not yet made
}
};
GitCommands.prototype.start = function () {
GitCommands.git("checkout", this.developBranch);
Expand Down
159 changes: 80 additions & 79 deletions main/lib/Options.js
Expand Up @@ -5,88 +5,81 @@
* MIT License 2018
*/
Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = require("fs");
var Minimist = require("minimist");
var path_1 = require("path");
var extend = require("xtend");
var fs_1 = require("fs");
var options = {
showHelp: {
default: false,
switches: ["h", "help"],
file_key: false,
validate: function (input) { return typeof input === "boolean"; },
},
quiet: {
default: false,
switches: ["q", "quiet"],
currentVersion: {
default: null,
file_key: false,
validate: function (input) { return typeof input === "boolean"; },
},
packageFileLocation: {
default: "./package.json",
switches: ["p", "package"],
file_key: "package_file_location",
filter: function (input) { return path_1.resolve(input); },
validate: function (input) { return typeof input === "string" && fs_1.existsSync(input); },
switches: ["c", "current-version"],
validate: function (input) { return input === null || typeof input === "string"; },
},
dotReleaseFileLocation: {
default: "./.release.json",
switches: ["d", "release-file"],
file_key: false,
filter: function (input) { return path_1.resolve(input); },
switches: ["d", "release-file"],
validate: function (input) { return typeof input === "string"; },
},
noConfirm: {
default: false,
switches: ["n", "no-confirm"],
file_key: "no_confirm",
validate: function (input) { return typeof input === "boolean"; },
},
releaseType: {
default: null,
switches: ["t", "release-type"],
file_key: "release_type",
validate: function (input) { return input === null || (typeof input === "string" && (input === "patch" || input === "minor" || input === "major")); },
filesToCommit: {
default: [],
file_key: "files_to_commit",
switches: false,
validate: function (input) { return Array.isArray(input); },
},
currentVersion: {
default: null,
switches: ["c", "current-version"],
file_key: false,
validate: function (input) { return input === null || typeof input === "string"; },
filesToVersion: {
default: ["README.md"],
file_key: "files_to_version",
switches: false,
validate: function (input) { return Array.isArray(input); },
},
nextVersion: {
default: null,
switches: ["v", "next-version"],
file_key: false,
switches: ["v", "next-version"],
validate: function (input) { return input === null || typeof input === "string"; },
},
remote: {
default: "origin",
switches: ["o", "remote"],
file_key: "remote",
validate: function (input) { return typeof input === "string"; },
},
skipGitPull: {
noConfirm: {
default: false,
switches: ["l", "skip-git-pull"],
file_key: "skip_git_pull",
file_key: "no_confirm",
switches: ["n", "no-confirm"],
validate: function (input) { return typeof input === "boolean"; },
},
skipGitPush: {
default: false,
switches: ["s", "skip-git-push"],
file_key: "skip_git_push",
validate: function (input) { return typeof input === "boolean"; },
packageFileLocation: {
default: "./package.json",
file_key: "package_file_location",
filter: function (input) { return path_1.resolve(input); },
switches: ["p", "package"],
validate: function (input) { return typeof input === "string" && fs_1.existsSync(input); },
},
skipGitFlowFinish: {
postCommitCommands: {
default: [],
file_key: "post_commit_commands",
switches: false,
validate: function (input) { return Array.isArray(input); },
},
postCompleteCommands: {
default: [],
file_key: "post_complete_commands",
switches: false,
validate: function (input) { return Array.isArray(input); },
},
preCommitCommands: {
default: [],
file_key: "pre_commit_commands",
switches: false,
validate: function (input) { return Array.isArray(input); },
},
quiet: {
default: false,
switches: ["f", "skip-git-flow-finish"],
file_key: "skip_git_flow_finish",
file_key: false,
switches: ["q", "quiet"],
validate: function (input) { return typeof input === "boolean"; },
},
releaseMessage: {
default: "Release {version}",
switches: ["m", "set-release-message"],
file_key: "release_message",
filter: function (input) {
if (input === false) {
Expand All @@ -96,37 +89,45 @@ var options = {
return input;
}
},
switches: ["m", "set-release-message"],
validate: function (input) { return input === true || typeof input === "string"; },
},
preCommitCommands: {
default: [],
switches: false,
file_key: "pre_commit_commands",
validate: function (input) { return Array.isArray(input); },
releaseType: {
default: null,
file_key: "release_type",
switches: ["t", "release-type"],
validate: function (input) { return input === null ||
(typeof input === "string" && (input === "patch" || input === "minor" || input === "major")); },
},
postCommitCommands: {
default: [],
switches: false,
file_key: "post_commit_commands",
validate: function (input) { return Array.isArray(input); },
remote: {
default: "origin",
file_key: "remote",
switches: ["o", "remote"],
validate: function (input) { return typeof input === "string"; },
},
postCompleteCommands: {
default: [],
switches: false,
file_key: "post_complete_commands",
validate: function (input) { return Array.isArray(input); },
showHelp: {
default: false,
file_key: false,
switches: ["h", "help"],
validate: function (input) { return typeof input === "boolean"; },
},
filesToVersion: {
default: ["README.md"],
switches: false,
file_key: "files_to_version",
validate: function (input) { return Array.isArray(input); },
skipGitFlowFinish: {
default: false,
file_key: "skip_git_flow_finish",
switches: ["f", "skip-git-flow-finish"],
validate: function (input) { return typeof input === "boolean"; },
},
filesToCommit: {
default: [],
switches: false,
file_key: "files_to_commit",
validate: function (input) { return Array.isArray(input); },
skipGitPull: {
default: false,
file_key: "skip_git_pull",
switches: ["l", "skip-git-pull"],
validate: function (input) { return typeof input === "boolean"; },
},
skipGitPush: {
default: false,
file_key: "skip_git_push",
switches: ["s", "skip-git-push"],
validate: function (input) { return typeof input === "boolean"; },
},
};
var Options = /** @class */ (function () {
Expand Down
12 changes: 7 additions & 5 deletions main/lib/error/GitResetError.js
Expand Up @@ -17,15 +17,17 @@ var __extends = (this && this.__extends) || (function () {
Object.defineProperty(exports, "__esModule", { value: true });
var GitResetError = /** @class */ (function (_super) {
__extends(GitResetError, _super);
function GitResetError(original_error) {
function GitResetError(originalError) {
var _newTarget = this.constructor;
var _this = _super.call(this, original_error ? original_error.message : "Unknown Error, Resetting.") || this;
_this.original_error = original_error;
var _this = _super.call(this, originalError ? originalError.message : "Unknown Error, Resetting.") || this;
_this.originalError = originalError;
var proto = _newTarget.prototype;
if (Object.setPrototypeOf)
if (Object.setPrototypeOf) {
Object.setPrototypeOf(_this, proto);
else
}
else {
_this.__proto__ = _newTarget.prototype;
}
return _this;
}
return GitResetError;
Expand Down
8 changes: 5 additions & 3 deletions main/lib/error/HelpError.js
Expand Up @@ -19,12 +19,14 @@ var HelpError = /** @class */ (function (_super) {
__extends(HelpError, _super);
function HelpError(post) {
var _newTarget = this.constructor;
var _this = _super.call(this, "generate-release\n\n-p, --package FILE Path to package.json file. Default: ./package.json\n-c, --current-version VERSION Current Version. Default: read from package.json\n-v, --next-version VERSION Next Version. Default: automatically bumps\n-t, --release-type TYPE Release Type: patch, minor, major. Ignored when next-version is given. Default: prompt, if next-version is undefined\n-n, --no-confirm Do not ask for confirmation. Default: prompt for confirmation\n-l, --skip-git-pull Do not pull from origin and rebase master and dev. Default: Do pull\n-s, --skip-git-push Do not push to origin when complete. Default: Do push\n-f, --skip-git-flow-finish Do not finish git-flow release. Default: Do finish\n-d, --release-file FILE Path to your .release.json file. Default: ./.release.json\n-o, --remote REMOTE Change the remote. Default: origin\n-q, --quiet Less output. Default: Do show output\n-m, release-message [MESSAGE] Set a release message. If no message given, prompt for one. Will replace\n \"{version}\" with the next version. Default: Release {version}\n\n" + (post ? post : "") + "\n") || this;
var _this = _super.call(this, "generate-release\n\n-p, --package FILE Path to package.json file. Default: ./package.json\n-c, --current-version VERSION Current Version. Default: read from package.json\n-v, --next-version VERSION Next Version. Default: automatically bumps\n-t, --release-type TYPE Release Type: patch, minor, major. Ignored when next-version is given.\n Default: prompt, if next-version is undefined\n-n, --no-confirm Do not ask for confirmation. Default: prompt for confirmation\n-l, --skip-git-pull Do not pull from origin and rebase master and dev. Default: Do pull\n-s, --skip-git-push Do not push to origin when complete. Default: Do push\n-f, --skip-git-flow-finish Do not finish git-flow release. Default: Do finish\n-d, --release-file FILE Path to your .release.json file. Default: ./.release.json\n-o, --remote REMOTE Change the remote. Default: origin\n-q, --quiet Less output. Default: Do show output\n-m, release-message [MESSAGE] Set a release message. If no message given, prompt for one. Will replace\n \"{version}\" with the next version. Default: Release {version}\n\n" + (post ? post : "") + "\n") || this;
var proto = _newTarget.prototype;
if (Object.setPrototypeOf)
if (Object.setPrototypeOf) {
Object.setPrototypeOf(_this, proto);
else
}
else {
_this.__proto__ = _newTarget.prototype;
}
return _this;
}
return HelpError;
Expand Down
34 changes: 34 additions & 0 deletions main/lib/error/ReleaseCanceledError.js
@@ -0,0 +1,34 @@
"use strict";
/**
* Generate Release
* Written by Kevin Gravier <kevin@mrkmg.com>
* MIT License 2018
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var ReleaseCanceledError = /** @class */ (function (_super) {
__extends(ReleaseCanceledError, _super);
function ReleaseCanceledError() {
var _newTarget = this.constructor;
var _this = _super.call(this, "Release Was Canceled.") || this;
var proto = _newTarget.prototype;
if (Object.setPrototypeOf) {
Object.setPrototypeOf(_this, proto);
}
else {
_this.__proto__ = _newTarget.prototype;
}
return _this;
}
return ReleaseCanceledError;
}(Error));
exports.ReleaseCanceledError = ReleaseCanceledError;
6 changes: 4 additions & 2 deletions main/lib/error/UncleanWorkingDirectoryError.js
Expand Up @@ -21,10 +21,12 @@ var UncleanWorkingDirectoryError = /** @class */ (function (_super) {
var _newTarget = this.constructor;
var _this = _super.call(this, "The working directory is not clean.") || this;
var proto = _newTarget.prototype;
if (Object.setPrototypeOf)
if (Object.setPrototypeOf) {
Object.setPrototypeOf(_this, proto);
else
}
else {
_this.__proto__ = _newTarget.prototype;
}
return _this;
}
return UncleanWorkingDirectoryError;
Expand Down
6 changes: 3 additions & 3 deletions main/lib/helper/gitFlowSettings.js
Expand Up @@ -9,8 +9,8 @@ var fs_1 = require("fs");
var iniparser_1 = require("iniparser");
var BRANCH_CONFIG = 'gitflow "branch"';
var PREFIX_CONFIG = 'gitflow "prefix"';
function gitFlowSettings(project_path) {
var file = project_path + "/.git/config";
function gitFlowSettings(projectPath) {
var file = projectPath + "/.git/config";
if (!fs_1.existsSync(file)) {
throw new Error("Git Config File is missing: " + file);
}
Expand All @@ -25,8 +25,8 @@ function gitFlowSettings(project_path) {
throw new Error("Git config missing git-flow prefix configuration");
}
return {
master: iniData[BRANCH_CONFIG].master,
develop: iniData[BRANCH_CONFIG].develop,
master: iniData[BRANCH_CONFIG].master,
};
}
exports.gitFlowSettings = gitFlowSettings;
2 changes: 1 addition & 1 deletion main/lib/helper/incrementVersion.js
Expand Up @@ -10,7 +10,7 @@ function incrementVersion(version, type) {
if (!VERSION_REGEX.test(version)) {
throw new Error("Version does not match semver " + version);
}
var versionSplit = version.match(VERSION_REGEX)[0].split(".").map(function (t) { return parseInt(t); });
var versionSplit = version.match(VERSION_REGEX)[0].split(".").map(function (t) { return +t; });
switch (type) {
case "patch":
versionSplit[2]++;
Expand Down

0 comments on commit 1c5abd8

Please sign in to comment.