balm-git-flow
Advanced tools
Comparing version 0.8.1-legacy to 0.9.0-legacy
@@ -7,2 +7,3 @@ #!/usr/bin/env node | ||
const { deployProject } = require('../lib/deploy.js'); | ||
const logger = require('../lib/logger.js'); | ||
@@ -13,20 +14,28 @@ async function production() { | ||
const { main, release, releases, scripts } = getConfig(); | ||
const prompt = inquirer.createPromptModule(); | ||
const { releaseBranch } = await prompt([ | ||
{ | ||
type: 'list', | ||
name: 'releaseBranch', | ||
message: 'Please select the production branch:', | ||
choices: releases | ||
} | ||
]); | ||
const currentBranch = await getCurrentBranch(); | ||
const devBranches = await getDevelopmentBranches(); | ||
const canRelease = release.includes(releaseBranch) | ||
? currentBranch === main | ||
: true; | ||
inquirer | ||
.prompt([ | ||
if (canRelease) { | ||
const devBranches = await getDevelopmentBranches(); | ||
prompt([ | ||
{ | ||
type: 'list', | ||
name: 'releaseBranch', | ||
message: 'Please select the branch of production:', | ||
choices: releases | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'devBranch', | ||
message: 'Please select the branch of development:', | ||
choices: devBranches, | ||
when: ({ releaseBranch }) => | ||
currentBranch === main && releaseBranch === release | ||
when: release.includes(releaseBranch) && currentBranch === main | ||
}, | ||
@@ -37,3 +46,3 @@ { | ||
message: 'Please select the command of npm-run-script:', | ||
default: ({ releaseBranch }) => { | ||
default: () => { | ||
const index = releases.indexOf(releaseBranch); | ||
@@ -47,3 +56,3 @@ return scripts[index]; | ||
name: 'ok', | ||
message: ({ releaseBranch, releaseScript }) => { | ||
message: ({ releaseScript }) => { | ||
let msg = `Determine the release '${releaseBranch}' branch`; | ||
@@ -61,4 +70,3 @@ if (releaseScript) { | ||
} | ||
]) | ||
.then( | ||
]).then( | ||
(answers) => | ||
@@ -68,7 +76,13 @@ answers.ok && | ||
currentBranch, | ||
releaseBranch, | ||
...answers | ||
}) | ||
); | ||
} else { | ||
logger.fatal( | ||
`If you want to release '${releaseBranch}', switch to the '${main}' branch first!` | ||
); | ||
} | ||
} | ||
production(); |
@@ -19,3 +19,3 @@ "use strict"; | ||
var _utils = require("./utils.js"); | ||
var _excluded = ["debug", "justRun", "useClean"]; | ||
var _excluded = ["debug", "justRun", "useClean", "releaseBranch"]; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -73,7 +73,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
_runCommand = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(command, cmdOptions) { | ||
var debug, justRun, useClean, options, _yield$asyncExec2, stdout, _yield$asyncExec3, _stdout; | ||
var debug, justRun, useClean, releaseBranch, options, _yield$asyncExec2, stdout, _yield$asyncExec3, _stdout; | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
debug = cmdOptions.debug, justRun = cmdOptions.justRun, useClean = cmdOptions.useClean, options = _objectWithoutProperties(cmdOptions, _excluded); | ||
debug = cmdOptions.debug, justRun = cmdOptions.justRun, useClean = cmdOptions.useClean, releaseBranch = cmdOptions.releaseBranch, options = _objectWithoutProperties(cmdOptions, _excluded); | ||
debug && console.log(command); | ||
@@ -111,3 +111,3 @@ if (!justRun) { | ||
_context2.next = 24; | ||
return clean(); | ||
return clean(releaseBranch); | ||
case 24: | ||
@@ -205,7 +205,7 @@ _logger["default"].fatal(_context2.t0); | ||
} | ||
function clean() { | ||
function clean(_x5) { | ||
return _clean.apply(this, arguments); | ||
} | ||
function _clean() { | ||
_clean = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() { | ||
_clean = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(releaseBranch) { | ||
var message, | ||
@@ -216,3 +216,3 @@ _args4 = arguments; | ||
case 0: | ||
message = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : ''; | ||
message = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : ''; | ||
_context4.next = 3; | ||
@@ -225,3 +225,10 @@ return (0, _utils.rm)(_config.RELEASE_DIR); | ||
message && _logger["default"].log(message); | ||
case 6: | ||
_context4.t0 = releaseBranch; | ||
if (!_context4.t0) { | ||
_context4.next = 10; | ||
break; | ||
} | ||
_context4.next = 10; | ||
return asyncExec("git branch -D ".concat(releaseBranch)); | ||
case 10: | ||
case "end": | ||
@@ -279,3 +286,3 @@ return _context4.stop(); | ||
} | ||
function getCurrentCommitId(_x5) { | ||
function getCurrentCommitId(_x6) { | ||
return _getCurrentCommitId.apply(this, arguments); | ||
@@ -300,3 +307,3 @@ } | ||
} | ||
function getRemoteBranches(_x6) { | ||
function getRemoteBranches(_x7) { | ||
return _getRemoteBranches.apply(this, arguments); | ||
@@ -303,0 +310,0 @@ } |
@@ -33,3 +33,3 @@ "use strict"; | ||
main: _nodeProcess.env.BALM_GIT_FLOW_MAIN || defaultOptions.main, | ||
release: _nodeProcess.env.BALM_GIT_FLOW_RELEASE || defaultOptions.release, | ||
release: _nodeProcess.env.BALM_GIT_FLOW_RELEASE ? _nodeProcess.env.BALM_GIT_FLOW_RELEASE.split(',') : [defaultOptions.release], | ||
releases: _nodeProcess.env.BALM_GIT_FLOW_RELEASES ? _nodeProcess.env.BALM_GIT_FLOW_RELEASES.split(',') : defaultOptions.releases, | ||
@@ -36,0 +36,0 @@ scripts: _nodeProcess.env.BALM_GIT_FLOW_SCRIPTS ? _nodeProcess.env.BALM_GIT_FLOW_SCRIPTS.split(',') : defaultOptions.scripts, |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.deployProject = deployProject; | ||
var _chalk = _interopRequireDefault(require("chalk")); | ||
var _config = require("./config.js"); | ||
@@ -38,19 +39,15 @@ var _cmd = require("./cmd.js"); | ||
case 7: | ||
_logger["default"].log("You can use 'git stash pop' to restore the latest status after release completed"); | ||
_logger["default"].log("You can use ".concat(_chalk["default"].yellow('git stash pop'), " to restore the latest status after release completed")); | ||
case 8: | ||
if (!(releaseBranch === release)) { | ||
_context.next = 28; | ||
if (!(release.includes(releaseBranch) && currentBranch === main)) { | ||
_context.next = 24; | ||
break; | ||
} | ||
if (!(currentBranch === main)) { | ||
_context.next = 27; | ||
break; | ||
} | ||
devBranch = devBranch === _config.NO_NEED_TO_MERGE ? '' : devBranch; | ||
if (!devBranch) { | ||
_context.next = 25; | ||
_context.next = 24; | ||
break; | ||
} | ||
_context.prev = 12; | ||
_context.next = 15; | ||
_context.prev = 11; | ||
_context.next = 14; | ||
return (0, _cmd.runCommands)("git merge --no-ff origin/".concat(devBranch), { | ||
@@ -60,30 +57,25 @@ debug: debug, | ||
}); | ||
case 15: | ||
_context.next = 21; | ||
case 14: | ||
_context.next = 20; | ||
break; | ||
case 17: | ||
_context.prev = 17; | ||
_context.t0 = _context["catch"](12); | ||
_context.next = 21; | ||
case 16: | ||
_context.prev = 16; | ||
_context.t0 = _context["catch"](11); | ||
_context.next = 20; | ||
return (0, _cmd.runCommands)("git merge --no-ff ".concat(devBranch), { | ||
debug: debug | ||
}); | ||
case 21: | ||
_context.prev = 21; | ||
_context.next = 24; | ||
case 20: | ||
_context.prev = 20; | ||
_context.next = 23; | ||
return (0, _cmd.runCommands)("git push origin ".concat(main), { | ||
debug: debug | ||
}); | ||
case 23: | ||
return _context.finish(20); | ||
case 24: | ||
return _context.finish(21); | ||
case 25: | ||
_context.next = 28; | ||
break; | ||
case 27: | ||
_logger["default"].fatal("If you want to release '".concat(release, "', switch to the '").concat(main, "' branch first!")); | ||
case 28: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, null, [[12, 17, 21, 25]]); | ||
}, _callee, null, [[11, 16, 20, 24]]); | ||
})); | ||
@@ -118,2 +110,3 @@ return _checkReleaseBranch.apply(this, arguments); | ||
useClean: true, | ||
releaseBranch: releaseBranch, | ||
debug: debug | ||
@@ -140,3 +133,3 @@ }); | ||
_context3.next = 3; | ||
return (0, _cmd.clean)('Start building'); | ||
return (0, _cmd.clean)(false, 'Start building'); | ||
case 3: | ||
@@ -148,2 +141,3 @@ // New worktree | ||
useClean: true, | ||
releaseBranch: releaseBranch, | ||
debug: debug | ||
@@ -158,2 +152,3 @@ }); | ||
useClean: true, | ||
releaseBranch: releaseBranch, | ||
debug: debug | ||
@@ -185,2 +180,3 @@ }); | ||
useClean: true, | ||
releaseBranch: releaseBranch, | ||
debug: debug | ||
@@ -193,3 +189,3 @@ }); | ||
_context3.next = 27; | ||
return (0, _cmd.clean)('Release completed'); | ||
return (0, _cmd.clean)(releaseBranch, 'Release completed'); | ||
case 27: | ||
@@ -200,3 +196,3 @@ _context3.next = 31; | ||
_context3.next = 31; | ||
return (0, _cmd.clean)('Release unchanged'); | ||
return (0, _cmd.clean)(releaseBranch, 'Release unchanged'); | ||
case 31: | ||
@@ -203,0 +199,0 @@ case "end": |
{ | ||
"name": "balm-git-flow", | ||
"version": "0.8.1-legacy", | ||
"version": "0.9.0-legacy", | ||
"description": "The best practices for front-end git flow", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
"del": "6", | ||
"fs-extra": "^11.1.0", | ||
"fs-extra": "^11.0.0", | ||
"inquirer": "8" | ||
@@ -47,0 +47,0 @@ }, |
@@ -5,2 +5,9 @@ # Balm Git Flow | ||
## Features | ||
- One install, unified development process for all git projects | ||
- Relatively simple release initialization | ||
- Easy to configure and publish multiple environment branches | ||
- Support for publishing independent repositories | ||
## Workflow | ||
@@ -28,11 +35,11 @@ | ||
| Variable Name | Type | Description | | ||
| -------------------------- | -------- | -------------------------------------------------------------------------------------------------- | | ||
| BALM_GIT_FLOW_MAIN | `string` | main branch (source code) | | ||
| BALM_GIT_FLOW_RELEASE | `string` | production release branch | | ||
| BALM_GIT_FLOW_RELEASES | `array` | all release branches | | ||
| BALM_GIT_FLOW_SCRIPTS | `array` | all build scripts corresponding to the release branches ( the keys of `scripts` in `package.json`) | | ||
| BALM_GIT_FLOW_BUILD_DIR | `string` | build out dir (by `npm-run-script`) | | ||
| BALM_GIT_FLOW_REPOSITORIES | `array` | remote repositories | | ||
| BALM_GIT_FLOW_SITE | `string` | production release branch (remote) for project site | | ||
| Variable Name | Type | Description | | ||
| -------------------------- | ----------------- | -------------------------------------------------------------------------------------------------- | | ||
| BALM_GIT_FLOW_MAIN | `string` | main branch (source code) | | ||
| BALM_GIT_FLOW_RELEASE | `string`, `array` | production release branch(es) | | ||
| BALM_GIT_FLOW_RELEASES | `array` | all release branches | | ||
| BALM_GIT_FLOW_SCRIPTS | `array` | all build scripts corresponding to the release branches ( the keys of `scripts` in `package.json`) | | ||
| BALM_GIT_FLOW_BUILD_DIR | `string` | build out dir (by `npm-run-script`) | | ||
| BALM_GIT_FLOW_REPOSITORIES | `array` | independent repositories | | ||
| BALM_GIT_FLOW_SITE | `string` | production release branch (remote) for project site | | ||
@@ -39,0 +46,0 @@ ## Usage |
118109
1421
51
Updatedfs-extra@^11.0.0