smooth-release
Version:
Smart CLI tool to safely and automatically do every step to release a new version of a library hosted on GitHub and published on npm
101 lines (73 loc) • 3.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _utils = require('./utils');
var _config = require('./config');
var _config2 = _interopRequireDefault(_config);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var stdio = [process.stdin, null, process.stderr];
exports.default = function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref) {
var hasIncreasedVersion = _ref.hasIncreasedVersion,
hasUpdatedChangelog = _ref.hasUpdatedChangelog;
var changelogPath, packageJsonPath, packageJsonVersion, commitMessage;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(!hasIncreasedVersion && !hasUpdatedChangelog)) {
_context.next = 2;
break;
}
return _context.abrupt('return');
case 2:
(0, _utils.title)('Commit and push changes');
_utils.status.addSteps(['Create commit', hasIncreasedVersion && 'Add tag', 'Push changes to GitHub', hasIncreasedVersion && 'Push tags to GitHub']);
changelogPath = (0, _utils.getRootFolderPath)() + '/' + _config2.default.github.changelog.outputPath;
packageJsonPath = (0, _utils.getRootFolderPath)() + '/package.json';
_context.next = 8;
return (0, _utils.exec)('git add ' + changelogPath + ' ' + packageJsonPath, { stdio: stdio });
case 8:
packageJsonVersion = (0, _utils.getPackageJsonVersion)();
commitMessage = hasIncreasedVersion ? packageJsonVersion : 'Update CHANGELOG.md';
_context.next = 12;
return (0, _utils.exec)('git commit -m "' + commitMessage + '"', { stdio: stdio });
case 12:
_utils.status.doneStep(true);
if (!hasIncreasedVersion) {
_context.next = 17;
break;
}
_context.next = 16;
return (0, _utils.exec)('git tag v' + packageJsonVersion, { stdio: stdio });
case 16:
_utils.status.doneStep(true);
case 17:
_context.next = 19;
return (0, _utils.exec)('git push', { stdio: stdio });
case 19:
_utils.status.doneStep(true);
if (!hasIncreasedVersion) {
_context.next = 24;
break;
}
_context.next = 23;
return (0, _utils.exec)('git push --tags', { stdio: stdio });
case 23:
_utils.status.doneStep(true);
case 24:
case 'end':
return _context.stop();
}
}
}, _callee, undefined);
}));
return function (_x) {
return _ref2.apply(this, arguments);
};
}();