Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

balm-git-flow

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balm-git-flow - npm Package Compare versions

Comparing version 0.9.1-legacy to 0.9.1

11

bin/balm-dev.js
#!/usr/bin/env node
const { Command } = require('commander');
const chalk = require('chalk');
const { setEnvironment } = require('../lib/env.js');
const { createDevBranch } = require('../lib/branch.js');
import { argv } from 'node:process';
import { Command } from 'commander';
import chalk from 'chalk';
import setEnvironment from '../lib/env.js';
import { createDevBranch } from '../lib/branch.js';

@@ -31,3 +32,3 @@ const program = new Command();

function help() {
program.parse(process.argv);
program.parse(argv);
if (program.args.length < 1) return program.help();

@@ -34,0 +35,0 @@ }

#!/usr/bin/env node
const { setEnvironment } = require('../lib/env.js');
import setEnvironment from '../lib/env.js';

@@ -4,0 +4,0 @@ function doctor() {

#!/usr/bin/env node
const { Command } = require('commander');
const pkg = require('../package.json');
import { createRequire } from 'node:module';
import { argv } from 'node:process';
import { Command } from 'commander';
const requireModule = createRequire(import.meta.url);
const pkg = requireModule('../package.json');
const program = new Command();

@@ -15,2 +18,2 @@ const version = `balm-git-flow: ${pkg.version}`;

program.parse(process.argv);
program.parse(argv);
#!/usr/bin/env node
const inquirer = require('inquirer');
const { setEnvironment } = require('../lib/env.js');
const { getConfig } = require('../lib/config.js');
const { getCurrentBranch, getDevelopmentBranches } = require('../lib/cmd.js');
const { deployProject } = require('../lib/deploy.js');
const logger = require('../lib/logger.js');
import inquirer from 'inquirer';
import setEnvironment from '../lib/env.js';
import { getConfig } from '../lib/config.js';
import { getCurrentBranch, getDevelopmentBranches } from '../lib/cmd.js';
import deployProject from '../lib/deploy.js';
import logger from '../lib/logger.js';

@@ -12,3 +12,4 @@ async function production() {

const { main, release, releases, scripts } = getConfig();
const { main, release, releases, scripts, releaseScripts, useCustomMessage } =
getConfig();

@@ -37,5 +38,8 @@ const prompt = inquirer.createPromptModule();

name: 'devBranch',
message: 'Please select the branch of development:',
message: 'Please select the development branch to be merged:',
choices: devBranches,
when: release.includes(releaseBranch) && currentBranch === main
when:
release.includes(releaseBranch) &&
currentBranch === main &&
devBranches.length > 1
},

@@ -46,33 +50,42 @@ {

message: 'Please select the command of npm-run-script:',
default: () => {
const index = releases.indexOf(releaseBranch);
return scripts[index];
},
choices: scripts
choices: scripts,
when:
!releaseScripts &&
scripts.length > 1 &&
scripts.length !== releases.length
},
{
type: 'confirm',
name: 'ok',
message: ({ releaseScript }) => {
let msg = `Determine the release '${releaseBranch}' branch`;
if (releaseScript) {
msg += ` using the '${releaseScript}' command`;
}
return `${msg}?`;
}
},
{
type: 'input',
name: 'logMessage',
message: 'Please input the release log message:'
message: '(Optional) Please input the release log message:',
when: useCustomMessage
}
]).then(
(answers) =>
answers.ok &&
deployProject({
currentBranch,
releaseBranch,
...answers
})
);
]).then((answers) => {
switch (scripts.length) {
case 1:
answers.releaseScript = scripts[0];
break;
case releases.length:
const index = releases.indexOf(releaseBranch);
answers.releaseScript = scripts[index];
break;
default:
for (let i = 0, len = scripts.length; i < len; i++) {
const script = scripts[i];
if (
Array.isArray(releaseScripts[script]) &&
releaseScripts[script].includes(releaseBranch)
) {
answers.releaseScript = script;
break;
}
}
}
deployProject({
currentBranch,
releaseBranch,
...answers
});
});
} else {

@@ -79,0 +92,0 @@ logger.fatal(

@@ -1,156 +0,47 @@

"use strict";
import { getConfig } from './config.js';
import {
execCommand,
runCommands,
getCurrentBranch,
getRemoteBranches
} from './cmd.js';
import logger from './logger.js';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createDevBranch = createDevBranch;
exports.init = init;
var _config = require("./config.js");
var _cmd = require("./cmd.js");
var _logger = _interopRequireDefault(require("./logger.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(value) { var ret = this.s["return"]; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, "throw": function _throw(value) { var thr = this.s["return"]; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
function createEmptyBranch(_x, _x2) {
return _createEmptyBranch.apply(this, arguments);
async function createEmptyBranch(newBranch, currentBranch) {
const createCommands = [
`git checkout --orphan ${newBranch}`,
'git rm -rf .',
`git commit --allow-empty -m "Initial commit for ${newBranch}"`,
`git push origin ${newBranch}`,
`git checkout ${currentBranch}`,
`git branch -D ${newBranch}`
];
await runCommands(createCommands);
}
function _createEmptyBranch() {
_createEmptyBranch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(newBranch, currentBranch) {
var createCommands;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
createCommands = ["git checkout --orphan ".concat(newBranch), 'git rm -rf .', "git commit --allow-empty -m \"Initial commit for ".concat(newBranch, "\""), "git push origin ".concat(newBranch), "git checkout ".concat(currentBranch), "git branch -D ".concat(newBranch)];
_context.next = 3;
return (0, _cmd.runCommands)(createCommands);
case 3:
case "end":
return _context.stop();
export async function init() {
const remoteBranches = await getRemoteBranches();
if (remoteBranches) {
const currentBranch = await getCurrentBranch();
const releases = getConfig('releases');
let isOK = true;
for await (const releaseBranch of releases) {
if (!remoteBranches.includes(releaseBranch)) {
isOK = false;
logger.log(`Missing branch: '${releaseBranch}'`);
await createEmptyBranch(releaseBranch, currentBranch);
}
}, _callee);
}));
return _createEmptyBranch.apply(this, arguments);
}
const message = isOK ? 'Everything is OK' : 'New branch has been created';
logger.success(message);
}
}
function init() {
return _init.apply(this, arguments);
export async function createDevBranch(newBranch, startPoint) {
const main = getConfig('main');
startPoint = startPoint || `origin/${main}`;
await execCommand(`git checkout -b ${newBranch} ${startPoint}`);
}
function _init() {
_init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
var remoteBranches, currentBranch, releases, isOK, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, releaseBranch, message;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
_context2.next = 3;
return (0, _cmd.getRemoteBranches)('grep -v HEAD');
case 3:
remoteBranches = _context2.sent;
_context2.next = 11;
break;
case 6:
_context2.prev = 6;
_context2.t0 = _context2["catch"](0);
_context2.next = 10;
return (0, _cmd.getRemoteBranches)('find /v "HEAD"');
case 10:
remoteBranches = _context2.sent;
case 11:
if (!remoteBranches) {
_context2.next = 51;
break;
}
_context2.next = 14;
return (0, _cmd.getCurrentBranch)();
case 14:
currentBranch = _context2.sent;
releases = (0, _config.getConfig)('releases');
isOK = true;
_iteratorAbruptCompletion = false;
_didIteratorError = false;
_context2.prev = 19;
_iterator = _asyncIterator(releases);
case 21:
_context2.next = 23;
return _iterator.next();
case 23:
if (!(_iteratorAbruptCompletion = !(_step = _context2.sent).done)) {
_context2.next = 33;
break;
}
releaseBranch = _step.value;
if (remoteBranches.includes(releaseBranch)) {
_context2.next = 30;
break;
}
isOK = false;
_logger["default"].log("Missing branch: '".concat(releaseBranch, "'"));
_context2.next = 30;
return createEmptyBranch(releaseBranch, currentBranch);
case 30:
_iteratorAbruptCompletion = false;
_context2.next = 21;
break;
case 33:
_context2.next = 39;
break;
case 35:
_context2.prev = 35;
_context2.t1 = _context2["catch"](19);
_didIteratorError = true;
_iteratorError = _context2.t1;
case 39:
_context2.prev = 39;
_context2.prev = 40;
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
_context2.next = 44;
break;
}
_context2.next = 44;
return _iterator["return"]();
case 44:
_context2.prev = 44;
if (!_didIteratorError) {
_context2.next = 47;
break;
}
throw _iteratorError;
case 47:
return _context2.finish(44);
case 48:
return _context2.finish(39);
case 49:
message = isOK ? 'Everything is OK' : 'New branch has been created';
_logger["default"].success(message);
case 51:
case "end":
return _context2.stop();
}
}, _callee2, null, [[0, 6], [19, 35, 39, 49], [40,, 44, 48]]);
}));
return _init.apply(this, arguments);
}
function createDevBranch(_x3, _x4) {
return _createDevBranch.apply(this, arguments);
}
function _createDevBranch() {
_createDevBranch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(newBranch, startPoint) {
var main;
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
main = (0, _config.getConfig)('main');
startPoint = startPoint || "origin/".concat(main);
_context3.next = 4;
return (0, _cmd.execCommand)("git checkout -b ".concat(newBranch, " ").concat(startPoint));
case 4:
case "end":
return _context3.stop();
}
}, _callee3);
}));
return _createDevBranch.apply(this, arguments);
}

@@ -1,353 +0,87 @@

"use strict";
import util from 'node:util';
import { exec } from 'node:child_process';
import logger from './logger.js';
import { releaseDir, getConfig, NO_NEED_TO_MERGE } from './config.js';
import { parseBranchLines } from './utils.js';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.checkStatus = checkStatus;
exports.clean = clean;
exports.execCommand = execCommand;
exports.getCurrentBranch = getCurrentBranch;
exports.getCurrentCommitId = getCurrentCommitId;
exports.getDevelopmentBranches = getDevelopmentBranches;
exports.getRemoteBranches = getRemoteBranches;
exports.runCommands = runCommands;
var _nodeUtil = _interopRequireDefault(require("node:util"));
var _nodeChild_process = require("node:child_process");
var _logger = _interopRequireDefault(require("./logger.js"));
var _config = require("./config.js");
var _utils = require("./utils.js");
var _excluded = ["debug", "justRun", "useClean", "releaseBranch"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(value) { var ret = this.s["return"]; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, "throw": function _throw(value) { var thr = this.s["return"]; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
var asyncExec = _nodeUtil["default"].promisify(_nodeChild_process.exec);
function execCommand(_x) {
return _execCommand.apply(this, arguments);
const asyncExec = util.promisify(exec);
export async function execCommand(command, options = {}) {
let result;
try {
const { stdout } = await asyncExec(command, options);
result = stdout.trim();
} catch (error) {
logger.fatal(error);
}
return result;
}
function _execCommand() {
_execCommand = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(command) {
var options,
result,
_yield$asyncExec,
stdout,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
_context.prev = 1;
_context.next = 4;
return asyncExec(command, options);
case 4:
_yield$asyncExec = _context.sent;
stdout = _yield$asyncExec.stdout;
result = stdout.trim();
_context.next = 12;
break;
case 9:
_context.prev = 9;
_context.t0 = _context["catch"](1);
_logger["default"].fatal(_context.t0);
case 12:
return _context.abrupt("return", result);
case 13:
case "end":
return _context.stop();
}
}, _callee, null, [[1, 9]]);
}));
return _execCommand.apply(this, arguments);
async function runCommand(command, cmdOptions) {
const { debug, justRun, useClean, releaseBranch, ...options } = cmdOptions;
debug && console.log(command);
if (justRun) {
const { stdout } = await asyncExec(command, options || {});
console.log(stdout);
} else {
try {
const { stdout } = await asyncExec(command, options || {});
console.log(stdout);
} catch (error) {
useClean && (await clean(releaseBranch));
logger.fatal(error);
}
}
}
function runCommand(_x2, _x3) {
return _runCommand.apply(this, arguments);
export async function runCommands(awesomeCommand, cmdOptions = {}) {
if (Array.isArray(awesomeCommand)) {
for await (const command of awesomeCommand) {
await runCommand(command, cmdOptions);
}
} else {
await runCommand(awesomeCommand, cmdOptions);
}
}
function _runCommand() {
_runCommand = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(command, cmdOptions) {
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, releaseBranch = cmdOptions.releaseBranch, options = _objectWithoutProperties(cmdOptions, _excluded);
debug && console.log(command);
if (!justRun) {
_context2.next = 10;
break;
}
_context2.next = 5;
return asyncExec(command, options || {});
case 5:
_yield$asyncExec2 = _context2.sent;
stdout = _yield$asyncExec2.stdout;
console.log(stdout);
_context2.next = 25;
break;
case 10:
_context2.prev = 10;
_context2.next = 13;
return asyncExec(command, options || {});
case 13:
_yield$asyncExec3 = _context2.sent;
_stdout = _yield$asyncExec3.stdout;
console.log(_stdout);
_context2.next = 25;
break;
case 18:
_context2.prev = 18;
_context2.t0 = _context2["catch"](10);
_context2.t1 = useClean;
if (!_context2.t1) {
_context2.next = 24;
break;
}
_context2.next = 24;
return clean(releaseBranch);
case 24:
_logger["default"].fatal(_context2.t0);
case 25:
case "end":
return _context2.stop();
}
}, _callee2, null, [[10, 18]]);
}));
return _runCommand.apply(this, arguments);
export async function clean(releaseBranch, message = '') {
const cleanCommands = [`rm -rf ${releaseDir}`, 'git worktree prune'];
await runCommands(cleanCommands);
message && logger.log(message);
releaseBranch && (await asyncExec(`git branch -D ${releaseBranch}`));
}
function runCommands(_x4) {
return _runCommands.apply(this, arguments);
export async function checkStatus(options = {}) {
const result = await execCommand('git status -s', options);
return !!result.length;
}
function _runCommands() {
_runCommands = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(awesomeCommand) {
var cmdOptions,
_iteratorAbruptCompletion,
_didIteratorError,
_iteratorError,
_iterator,
_step,
command,
_args3 = arguments;
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
cmdOptions = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
if (!Array.isArray(awesomeCommand)) {
_context3.next = 33;
break;
}
_iteratorAbruptCompletion = false;
_didIteratorError = false;
_context3.prev = 4;
_iterator = _asyncIterator(awesomeCommand);
case 6:
_context3.next = 8;
return _iterator.next();
case 8:
if (!(_iteratorAbruptCompletion = !(_step = _context3.sent).done)) {
_context3.next = 15;
break;
}
command = _step.value;
_context3.next = 12;
return runCommand(command, cmdOptions);
case 12:
_iteratorAbruptCompletion = false;
_context3.next = 6;
break;
case 15:
_context3.next = 21;
break;
case 17:
_context3.prev = 17;
_context3.t0 = _context3["catch"](4);
_didIteratorError = true;
_iteratorError = _context3.t0;
case 21:
_context3.prev = 21;
_context3.prev = 22;
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
_context3.next = 26;
break;
}
_context3.next = 26;
return _iterator["return"]();
case 26:
_context3.prev = 26;
if (!_didIteratorError) {
_context3.next = 29;
break;
}
throw _iteratorError;
case 29:
return _context3.finish(26);
case 30:
return _context3.finish(21);
case 31:
_context3.next = 35;
break;
case 33:
_context3.next = 35;
return runCommand(awesomeCommand, cmdOptions);
case 35:
case "end":
return _context3.stop();
}
}, _callee3, null, [[4, 17, 21, 31], [22,, 26, 30]]);
}));
return _runCommands.apply(this, arguments);
export async function getCurrentCommitId() {
return await execCommand('git log -1 --pretty=format:%h');
}
function clean(_x5) {
return _clean.apply(this, arguments);
export async function getCurrentBranch() {
return await execCommand('git symbolic-ref --short -q HEAD');
}
function _clean() {
_clean = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(releaseBranch) {
var message,
_args4 = arguments;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
message = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : '';
_context4.next = 3;
return (0, _utils.rm)(_config.RELEASE_DIR);
case 3:
_context4.next = 5;
return runCommands('git worktree prune');
case 5:
message && _logger["default"].log(message);
_context4.t0 = releaseBranch;
if (!_context4.t0) {
_context4.next = 10;
break;
}
_context4.next = 10;
return asyncExec("git branch -D ".concat(releaseBranch));
case 10:
case "end":
return _context4.stop();
}
}, _callee4);
}));
return _clean.apply(this, arguments);
export async function getRemoteBranches() {
const remoteBranches = await execCommand('git branch -r | grep -v HEAD');
return remoteBranches ? parseBranchLines(remoteBranches) : false;
}
function checkStatus() {
return _checkStatus.apply(this, arguments);
export async function getDevelopmentBranches() {
const { main, releases } = getConfig();
const localBranches = await execCommand('git branch');
let devBranches = parseBranchLines(localBranches).filter(
(branch) => !(branch === main || releases.includes(branch))
);
devBranches.unshift(NO_NEED_TO_MERGE);
return devBranches;
}
function _checkStatus() {
_checkStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
var options,
result,
_args5 = arguments;
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
while (1) switch (_context5.prev = _context5.next) {
case 0:
options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
_context5.next = 3;
return execCommand('git status -s', options);
case 3:
result = _context5.sent;
return _context5.abrupt("return", !!result.length);
case 5:
case "end":
return _context5.stop();
}
}, _callee5);
}));
return _checkStatus.apply(this, arguments);
}
function getCurrentBranch() {
return _getCurrentBranch.apply(this, arguments);
}
function _getCurrentBranch() {
_getCurrentBranch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
while (1) switch (_context6.prev = _context6.next) {
case 0:
_context6.next = 2;
return execCommand('git symbolic-ref --short -q HEAD');
case 2:
return _context6.abrupt("return", _context6.sent);
case 3:
case "end":
return _context6.stop();
}
}, _callee6);
}));
return _getCurrentBranch.apply(this, arguments);
}
function getCurrentCommitId(_x6) {
return _getCurrentCommitId.apply(this, arguments);
}
function _getCurrentCommitId() {
_getCurrentCommitId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(currentBranch) {
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
while (1) switch (_context7.prev = _context7.next) {
case 0:
_context7.next = 2;
return execCommand("git log -1 --pretty=format:%h ".concat(currentBranch));
case 2:
return _context7.abrupt("return", _context7.sent);
case 3:
case "end":
return _context7.stop();
}
}, _callee7);
}));
return _getCurrentCommitId.apply(this, arguments);
}
function getRemoteBranches(_x7) {
return _getRemoteBranches.apply(this, arguments);
}
function _getRemoteBranches() {
_getRemoteBranches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(filterHeadCommand) {
var _yield$asyncExec4, error, stdout;
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
while (1) switch (_context8.prev = _context8.next) {
case 0:
_context8.next = 2;
return asyncExec("git branch -r | ".concat(filterHeadCommand));
case 2:
_yield$asyncExec4 = _context8.sent;
error = _yield$asyncExec4.error;
stdout = _yield$asyncExec4.stdout;
if (error) {
_logger["default"].fatal(error);
}
return _context8.abrupt("return", stdout ? (0, _utils.parseBranchLines)(stdout) : false);
case 7:
case "end":
return _context8.stop();
}
}, _callee8);
}));
return _getRemoteBranches.apply(this, arguments);
}
function getDevelopmentBranches() {
return _getDevelopmentBranches.apply(this, arguments);
}
function _getDevelopmentBranches() {
_getDevelopmentBranches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
var _getConfig, main, releases, localBranches, devBranches;
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
while (1) switch (_context9.prev = _context9.next) {
case 0:
_getConfig = (0, _config.getConfig)(), main = _getConfig.main, releases = _getConfig.releases;
_context9.next = 3;
return execCommand('git branch');
case 3:
localBranches = _context9.sent;
devBranches = (0, _utils.parseBranchLines)(localBranches).filter(function (branch) {
return !(branch === main || releases.includes(branch));
});
devBranches.unshift(_config.NO_NEED_TO_MERGE);
return _context9.abrupt("return", devBranches);
case 7:
case "end":
return _context9.stop();
}
}, _callee9);
}));
return _getDevelopmentBranches.apply(this, arguments);
}

@@ -1,18 +0,9 @@

"use strict";
import path from 'node:path';
import { cwd, env } from 'node:process';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.defaultContents = exports.RELEASE_DIR = exports.NO_NEED_TO_MERGE = void 0;
exports.getConfig = getConfig;
exports.releaseDir = void 0;
exports.setConfig = setConfig;
var _nodePath = _interopRequireDefault(require("node:path"));
var _nodeProcess = require("node:process");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var RELEASE_DIR = '.balm-git-flow';
exports.RELEASE_DIR = RELEASE_DIR;
var releaseDir = _nodePath["default"].join((0, _nodeProcess.cwd)(), RELEASE_DIR);
exports.releaseDir = releaseDir;
var defaultOptions = {
const RELEASE_DIR = '.balm-git-flow';
export const releaseDir = path.join(cwd(), RELEASE_DIR);
const defaultOptions = {
main: 'main',

@@ -22,25 +13,60 @@ release: 'release',

scripts: ['build'],
releaseScripts: false,
buildDir: 'dist',
ignoreUncommitted: false,
useCustomMessage: false,
repositories: [],
site: ''
};
var defaultContents = ["process.env.BALM_GIT_FLOW_MAIN = 'main';", "process.env.BALM_GIT_FLOW_RELEASE = 'release';", "process.env.BALM_GIT_FLOW_RELEASES = ['release'];", "process.env.BALM_GIT_FLOW_SCRIPTS = ['build'];", "process.env.BALM_GIT_FLOW_BUILD_DIR = 'dist';", "// process.env.BALM_GIT_FLOW_REPOSITORIES = [];", "// process.env.BALM_GIT_FLOW_SITE = '';"];
exports.defaultContents = defaultContents;
var options = {};
function setConfig() {
export const defaultContents = [
`process.env.BALM_GIT_FLOW_MAIN = 'main';`,
`process.env.BALM_GIT_FLOW_RELEASE = 'release';`,
`process.env.BALM_GIT_FLOW_RELEASES = ['release'];`,
`process.env.BALM_GIT_FLOW_SCRIPTS = ['build'];`,
`process.env.BALM_GIT_FLOW_BUILD_DIR = 'dist';`
];
let options = {};
export function setConfig() {
const boolRegex = /^true$/i;
const releaseScripts = env.BALM_GIT_FLOW_RELEASE_SCRIPTS
? JSON.parse(env.BALM_GIT_FLOW_RELEASE_SCRIPTS)
: {};
const releases = Object.values(releaseScripts).flat();
const scripts = Object.keys(releaseScripts);
options = {
debug: _nodeProcess.env.BALM_GIT_FLOW_DEBUG || false,
main: _nodeProcess.env.BALM_GIT_FLOW_MAIN || defaultOptions.main,
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,
scripts: _nodeProcess.env.BALM_GIT_FLOW_SCRIPTS ? _nodeProcess.env.BALM_GIT_FLOW_SCRIPTS.split(',') : defaultOptions.scripts,
buildDir: _nodeProcess.env.BALM_GIT_FLOW_BUILD_DIR || defaultOptions.buildDir,
repositories: _nodeProcess.env.BALM_GIT_FLOW_REPOSITORIES ? _nodeProcess.env.BALM_GIT_FLOW_REPOSITORIES.split(',') : defaultOptions.repositories,
site: _nodeProcess.env.BALM_GIT_FLOW_SITE || defaultOptions.site
debug: env.BALM_GIT_FLOW_DEBUG || false,
main: env.BALM_GIT_FLOW_MAIN || defaultOptions.main,
release: env.BALM_GIT_FLOW_RELEASE
? env.BALM_GIT_FLOW_RELEASE.split(',')
: [defaultOptions.release],
releases: env.BALM_GIT_FLOW_RELEASES
? env.BALM_GIT_FLOW_RELEASES.split(',')
: releases || defaultOptions.releases,
scripts: env.BALM_GIT_FLOW_SCRIPTS
? env.BALM_GIT_FLOW_SCRIPTS.split(',')
: scripts || defaultOptions.scripts,
releaseScripts,
buildDir: env.BALM_GIT_FLOW_BUILD_DIR || defaultOptions.buildDir,
ignoreUncommitted:
boolRegex.test(env.BALM_GIT_FLOW_IGNORE_UNCOMMITTED) ||
defaultOptions.ignoreUncommitted,
useCustomMessage:
boolRegex.test(env.BALM_GIT_FLOW_USE_CUSTOM_MESSAGE) ||
defaultOptions.useCustomMessage,
repositories: env.BALM_GIT_FLOW_REPOSITORIES
? env.BALM_GIT_FLOW_REPOSITORIES.split(',')
: defaultOptions.repositories,
site: env.BALM_GIT_FLOW_SITE || defaultOptions.site
};
}
function getConfig(key) {
export function getConfig(key) {
return options[key] || options;
}
var NO_NEED_TO_MERGE = '[No need to merge]';
exports.NO_NEED_TO_MERGE = NO_NEED_TO_MERGE;
export const NO_NEED_TO_MERGE = '[No need to merge]';

@@ -1,218 +0,138 @@

"use strict";
import chalk from 'chalk';
import { releaseDir, getConfig, NO_NEED_TO_MERGE } from './config.js';
import { runCommands, clean, checkStatus, getCurrentCommitId } from './cmd.js';
import logger from './logger.js';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.deployProject = deployProject;
var _chalk = _interopRequireDefault(require("chalk"));
var _config = require("./config.js");
var _cmd = require("./cmd.js");
var _logger = _interopRequireDefault(require("./logger.js"));
var _utils = require("./utils.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function checkReleaseBranch(_x, _x2, _x3) {
return _checkReleaseBranch.apply(this, arguments);
}
function _checkReleaseBranch() {
_checkReleaseBranch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(currentBranch, releaseBranch, devBranch) {
var _getConfig, debug, main, release, hasUncommitted;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_getConfig = (0, _config.getConfig)(), debug = _getConfig.debug, main = _getConfig.main, release = _getConfig.release;
_context.next = 3;
return (0, _cmd.checkStatus)();
case 3:
hasUncommitted = _context.sent;
if (!hasUncommitted) {
_context.next = 8;
break;
}
_context.next = 7;
return (0, _cmd.runCommands)('git stash');
case 7:
_logger["default"].log("You can use ".concat(_chalk["default"].yellow('git stash pop'), " to restore the latest status after release completed"));
case 8:
if (!(release.includes(releaseBranch) && currentBranch === main)) {
_context.next = 24;
break;
}
devBranch = devBranch === _config.NO_NEED_TO_MERGE ? '' : devBranch;
if (!devBranch) {
_context.next = 24;
break;
}
_context.prev = 11;
_context.next = 14;
return (0, _cmd.runCommands)("git merge --no-ff origin/".concat(devBranch), {
debug: debug,
justRun: true
});
case 14:
_context.next = 20;
break;
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 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:
case "end":
return _context.stop();
async function checkReleaseBranch(currentBranch, releaseBranch, devBranch) {
const { debug, main, release, ignoreUncommitted } = getConfig();
const hasUncommitted = await checkStatus();
if (hasUncommitted) {
if (ignoreUncommitted) {
await runCommands('git stash');
logger.log(
`You can use ${chalk.yellow(
'git stash pop'
)} to restore the latest status after release completed`
);
} else {
logger.log(chalk.yellow('Local changes were not restored'));
return false;
}
}
if (release.includes(releaseBranch) && currentBranch === main) {
devBranch = devBranch === NO_NEED_TO_MERGE ? '' : devBranch;
if (devBranch) {
try {
await runCommands(`git merge --no-ff origin/${devBranch}`, {
debug,
justRun: true
});
} catch (e) {
await runCommands(`git merge --no-ff ${devBranch}`, { debug });
} finally {
await runCommands(`git push origin ${main}`, { debug });
}
}, _callee, null, [[11, 16, 20, 24]]);
}));
return _checkReleaseBranch.apply(this, arguments);
}
}
return true;
}
function publishingFromSource(_x4) {
return _publishingFromSource.apply(this, arguments);
async function publishingFromSource(releaseBranch) {
const { debug, releases, repositories, site } = getConfig();
if (repositories.length) {
const releaseIndex = releases.indexOf(releaseBranch);
const repository = repositories[releaseIndex] || repositories[0];
if (repository) {
const branch = `${releaseBranch}:${site || releaseBranch}`;
const publishingCommands = `git push -f ${repository} ${branch}`;
await runCommands(publishingCommands, {
cwd: releaseDir,
useClean: true,
releaseBranch,
debug
});
}
}
}
function _publishingFromSource() {
_publishingFromSource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(releaseBranch) {
var _getConfig2, debug, releases, repositories, site, releaseIndex, repository, branch, publishingCommands;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_getConfig2 = (0, _config.getConfig)(), debug = _getConfig2.debug, releases = _getConfig2.releases, repositories = _getConfig2.repositories, site = _getConfig2.site;
if (!repositories.length) {
_context2.next = 9;
break;
}
releaseIndex = releases.indexOf(releaseBranch);
repository = repositories[releaseIndex] || repositories[0];
if (!repository) {
_context2.next = 9;
break;
}
branch = "".concat(releaseBranch, ":").concat(site || releaseBranch);
publishingCommands = "git push -f ".concat(repository, " ").concat(branch);
_context2.next = 9;
return (0, _cmd.runCommands)(publishingCommands, {
cwd: _config.releaseDir,
useClean: true,
releaseBranch: releaseBranch,
debug: debug
});
case 9:
case "end":
return _context2.stop();
}
}, _callee2);
}));
return _publishingFromSource.apply(this, arguments);
async function buildReleaseBranch(
currentBranch,
releaseBranch,
releaseScript,
logMessage
) {
const { debug, buildDir } = getConfig();
// Clean up
await clean(false, 'Start building');
// New worktree
const createCommands = [
'git remote prune origin',
'git pull --ff-only',
`git worktree add -B ${releaseBranch} ${releaseDir} origin/${releaseBranch}`,
`rm -rf ${releaseDir}/*`
];
await runCommands(createCommands, { useClean: true, releaseBranch, debug });
// Build
const buildCommands = [
`npm run ${releaseScript}`,
`cp -rf ${buildDir}/* ${releaseDir}`
];
await runCommands(buildCommands, { useClean: true, releaseBranch, debug });
// Release
const hasUncommitted = await checkStatus({
cwd: releaseDir
});
if (hasUncommitted) {
const commitId = await getCurrentCommitId();
const LOG_MESSAGE =
logMessage || `${releaseBranch} from ${currentBranch} as of ${commitId}`;
const releaseCommands = [
'git status',
'git add -A',
`git commit -m "build: ${LOG_MESSAGE}"`,
`git push -f origin ${releaseBranch}`
];
await runCommands(releaseCommands, {
cwd: releaseDir,
useClean: true,
releaseBranch,
debug
});
await publishingFromSource(releaseBranch);
// Clean up
await clean(releaseBranch, 'Release completed');
} else {
await clean(releaseBranch, 'Release unchanged');
}
}
function buildReleaseBranch(_x5, _x6, _x7, _x8) {
return _buildReleaseBranch.apply(this, arguments);
async function deployProject({
currentBranch,
releaseBranch,
releaseScript,
devBranch,
logMessage
}) {
if (await checkReleaseBranch(currentBranch, releaseBranch, devBranch)) {
await buildReleaseBranch(
currentBranch,
releaseBranch,
releaseScript,
logMessage
);
}
}
function _buildReleaseBranch() {
_buildReleaseBranch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(currentBranch, releaseBranch, releaseScript, logMessage) {
var _getConfig3, debug, buildDir, createCommands, hasUncommitted, commitId, LOG_MESSAGE, releaseCommand;
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_getConfig3 = (0, _config.getConfig)(), debug = _getConfig3.debug, buildDir = _getConfig3.buildDir; // Clean up
_context3.next = 3;
return (0, _cmd.clean)(false, 'Start building');
case 3:
// New worktree
createCommands = ['git remote prune origin', 'git pull --ff-only', "git worktree add -B ".concat(releaseBranch, " ").concat(_config.releaseDir, " origin/").concat(releaseBranch)];
_context3.next = 6;
return (0, _cmd.runCommands)(createCommands, {
useClean: true,
releaseBranch: releaseBranch,
debug: debug
});
case 6:
_context3.next = 8;
return (0, _utils.rm)(["".concat(_config.RELEASE_DIR, "/**"), "!".concat(_config.RELEASE_DIR)]);
case 8:
_context3.next = 10;
return (0, _cmd.runCommands)("npm run ".concat(releaseScript), {
useClean: true,
releaseBranch: releaseBranch,
debug: debug
});
case 10:
_context3.next = 12;
return (0, _utils.cp)(buildDir, _config.releaseDir);
case 12:
_context3.next = 14;
return (0, _cmd.checkStatus)({
cwd: _config.releaseDir
});
case 14:
hasUncommitted = _context3.sent;
if (!hasUncommitted) {
_context3.next = 29;
break;
}
_context3.next = 18;
return (0, _cmd.getCurrentCommitId)(currentBranch);
case 18:
commitId = _context3.sent;
LOG_MESSAGE = logMessage || "build: ".concat(releaseBranch, " from ").concat(currentBranch, " as of ").concat(commitId);
releaseCommand = ['git status', 'git add -A', "git commit -m \"".concat(LOG_MESSAGE, "\""), "git push -f origin ".concat(releaseBranch)];
_context3.next = 23;
return (0, _cmd.runCommands)(releaseCommand, {
cwd: _config.releaseDir,
useClean: true,
releaseBranch: releaseBranch,
debug: debug
});
case 23:
_context3.next = 25;
return publishingFromSource(releaseBranch);
case 25:
_context3.next = 27;
return (0, _cmd.clean)(releaseBranch, 'Release completed');
case 27:
_context3.next = 31;
break;
case 29:
_context3.next = 31;
return (0, _cmd.clean)(releaseBranch, 'Release unchanged');
case 31:
case "end":
return _context3.stop();
}
}, _callee3);
}));
return _buildReleaseBranch.apply(this, arguments);
}
function deployProject(_x9) {
return _deployProject.apply(this, arguments);
}
function _deployProject() {
_deployProject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref) {
var currentBranch, releaseBranch, releaseScript, devBranch, logMessage;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
currentBranch = _ref.currentBranch, releaseBranch = _ref.releaseBranch, releaseScript = _ref.releaseScript, devBranch = _ref.devBranch, logMessage = _ref.logMessage;
_context4.next = 3;
return checkReleaseBranch(currentBranch, releaseBranch, devBranch);
case 3:
_context4.next = 5;
return buildReleaseBranch(currentBranch, releaseBranch, releaseScript, logMessage);
case 5:
case "end":
return _context4.stop();
}
}, _callee4);
}));
return _deployProject.apply(this, arguments);
}
export default deployProject;

@@ -1,70 +0,32 @@

"use strict";
import path from 'node:path';
import { cwd } from 'node:process';
import fs from 'node:fs';
import { defaultContents, setConfig } from './config.js';
import logger from './logger.js';
import { writeIterableToFile } from './utils.js';
import { init } from './branch.js';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setEnvironment = setEnvironment;
var _nodePath = _interopRequireDefault(require("node:path"));
var _nodeProcess = require("node:process");
var _nodeFs = _interopRequireDefault(require("node:fs"));
var _config = require("./config.js");
var _logger = _interopRequireDefault(require("./logger.js"));
var _utils = require("./utils.js");
var _branch = require("./branch.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
var balmEnvFile = _nodePath["default"].join((0, _nodeProcess.cwd)(), 'balm.env.js');
function setEnvironment() {
return _setEnvironment.apply(this, arguments);
const balmEnvFile = path.join(cwd(), 'balm.env.js');
async function setEnvironment(needInit = false) {
if (fs.existsSync(balmEnvFile)) {
await import(balmEnvFile);
setConfig();
needInit && init();
} else {
if (needInit) {
await writeIterableToFile(defaultContents, balmEnvFile);
logger.success(
`'balm.env.js' has been created. After configuration, please re-run 'doctor' command`
);
} else {
logger.fatal(
`Missing 'balm.env.js' in the project root directory. Please run 'doctor' command first`
);
}
}
}
function _setEnvironment() {
_setEnvironment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var needInit,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
needInit = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
if (!_nodeFs["default"].existsSync(balmEnvFile)) {
_context.next = 8;
break;
}
_context.next = 4;
return function (specifier) {
return new Promise(function (r) {
return r("".concat(specifier));
}).then(function (s) {
return _interopRequireWildcard(require(s));
});
}(balmEnvFile);
case 4:
(0, _config.setConfig)();
needInit && (0, _branch.init)();
_context.next = 15;
break;
case 8:
if (!needInit) {
_context.next = 14;
break;
}
_context.next = 11;
return (0, _utils.writeIterableToFile)(_config.defaultContents, balmEnvFile);
case 11:
_logger["default"].success("'balm.env.js' has been created. After configuration, please re-run 'doctor' command");
_context.next = 15;
break;
case 14:
_logger["default"].fatal("Missing 'balm.env.js' in the project root directory. Please run 'doctor' command first");
case 15:
case "end":
return _context.stop();
}
}, _callee);
}));
return _setEnvironment.apply(this, arguments);
}
export default setEnvironment;

@@ -1,11 +0,5 @@

"use strict";
import { format } from 'node:util';
import { exit } from 'node:process';
import chalk from 'chalk';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _nodeUtil = require("node:util");
var _nodeProcess = require("node:process");
var _chalk = _interopRequireDefault(require("chalk"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/**

@@ -15,4 +9,4 @@ * Prefix.

var prefix = '[Balm Git Flow]';
var sep = _chalk["default"].gray('·');
const prefix = '[Balm Git Flow]';
const sep = chalk.gray('·');

@@ -25,8 +19,5 @@ /**

function log() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var msg = _nodeUtil.format.apply(_nodeUtil.format, args);
console.log(_chalk["default"].white(prefix), sep, msg);
function log(...args) {
const msg = format.apply(format, args);
console.log(chalk.white(prefix), sep, msg);
}

@@ -40,10 +31,7 @@

function fatal() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
function fatal(...args) {
if (args[0] instanceof Error) args[0] = args[0].message.trim();
var msg = _nodeUtil.format.apply(_nodeUtil.format, args);
console.log(_chalk["default"].red(prefix), sep, msg);
(0, _nodeProcess.exit)(1);
const msg = format.apply(format, args);
console.log(chalk.red(prefix), sep, msg);
exit(1);
}

@@ -57,14 +45,7 @@

function success() {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
var msg = _nodeUtil.format.apply(_nodeUtil.format, args);
console.log(_chalk["default"].green(prefix), sep, msg);
function success(...args) {
const msg = format.apply(format, args);
console.log(chalk.green(prefix), sep, msg);
}
var _default = {
log: log,
fatal: fatal,
success: success
};
exports["default"] = _default;
export default { log, fatal, success };

@@ -1,172 +0,39 @@

"use strict";
import { EOL } from 'node:os';
import util from 'node:util';
import stream from 'node:stream';
import fs from 'node:fs';
import { once } from 'node:events';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cp = cp;
exports.parseBranchLines = exports.isObject = void 0;
exports.rm = rm;
exports.writeIterableToFile = writeIterableToFile;
var _nodeOs = require("node:os");
var _nodeUtil = _interopRequireDefault(require("node:util"));
var _nodeStream = _interopRequireDefault(require("node:stream"));
var _nodeFs = _interopRequireDefault(require("node:fs"));
var _nodeEvents = require("node:events");
var _nodePath = _interopRequireDefault(require("node:path"));
var _del = _interopRequireDefault(require("del"));
var _fsExtra = require("fs-extra");
var _logger = _interopRequireDefault(require("./logger.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(value) { var ret = this.s["return"]; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, "throw": function _throw(value) { var thr = this.s["return"]; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
// Define regular expression
var reTypeOf = /(?:^\[object\s(.*?)\]$)/;
var REGEX_STAR = /^(\*)?\s*(origin\/)?/g;
var ENTER = '\n';
var getType = function getType(any) {
return Object.prototype.toString.call(any).replace(reTypeOf, '$1').toLowerCase();
const reTypeOf = /(?:^\[object\s(.*?)\]$)/;
const REGEX_STAR = /^(\*|\+)?\s*(origin\/)?/g;
const getType = (any) => {
return Object.prototype.toString
.call(any)
.replace(reTypeOf, '$1')
.toLowerCase();
};
var isObject = function isObject(obj) {
return getType(obj) === 'object';
};
exports.isObject = isObject;
var parseBranchLines = function parseBranchLines(str) {
var branches = str.trim().split(_nodeOs.EOL);
// FIX: for windows terminal bug
if (branches[0].includes(ENTER)) {
branches = str.trim().split(ENTER);
export const isObject = (obj) => getType(obj) === 'object';
export const parseBranchLines = (str) =>
str
.trim()
.split(EOL)
.map((line) => line.trim().replace(REGEX_STAR, ''));
const finished = util.promisify(stream.finished);
export async function writeIterableToFile(iterable, filePath) {
const writable = fs.createWriteStream(filePath, { encoding: 'utf8' });
for await (const chunk of iterable) {
if (!writable.write(`${chunk}\n`)) {
// Handle backpressure
await once(writable, 'drain');
}
}
return branches.map(function (line) {
return line.trim().replace(REGEX_STAR, '');
});
};
exports.parseBranchLines = parseBranchLines;
var finished = _nodeUtil["default"].promisify(_nodeStream["default"].finished);
function writeIterableToFile(_x, _x2) {
return _writeIterableToFile.apply(this, arguments);
writable.end();
// Wait until done. Throws if there are errors.
await finished(writable);
}
function _writeIterableToFile() {
_writeIterableToFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(iterable, filePath) {
var writable, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
writable = _nodeFs["default"].createWriteStream(filePath, {
encoding: 'utf8'
});
_iteratorAbruptCompletion = false;
_didIteratorError = false;
_context.prev = 3;
_iterator = _asyncIterator(iterable);
case 5:
_context.next = 7;
return _iterator.next();
case 7:
if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
_context.next = 15;
break;
}
chunk = _step.value;
if (writable.write("".concat(chunk, "\n"))) {
_context.next = 12;
break;
}
_context.next = 12;
return (0, _nodeEvents.once)(writable, 'drain');
case 12:
_iteratorAbruptCompletion = false;
_context.next = 5;
break;
case 15:
_context.next = 21;
break;
case 17:
_context.prev = 17;
_context.t0 = _context["catch"](3);
_didIteratorError = true;
_iteratorError = _context.t0;
case 21:
_context.prev = 21;
_context.prev = 22;
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
_context.next = 26;
break;
}
_context.next = 26;
return _iterator["return"]();
case 26:
_context.prev = 26;
if (!_didIteratorError) {
_context.next = 29;
break;
}
throw _iteratorError;
case 29:
return _context.finish(26);
case 30:
return _context.finish(21);
case 31:
writable.end();
// Wait until done. Throws if there are errors.
_context.next = 34;
return finished(writable);
case 34:
case "end":
return _context.stop();
}
}, _callee, null, [[3, 17, 21, 31], [22,, 26, 30]]);
}));
return _writeIterableToFile.apply(this, arguments);
}
function rm(_x3) {
return _rm.apply(this, arguments);
}
function _rm() {
_rm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(dir) {
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return (0, _del["default"])(dir, {
force: true
});
case 2:
case "end":
return _context2.stop();
}
}, _callee2);
}));
return _rm.apply(this, arguments);
}
function cp(_x4, _x5) {
return _cp.apply(this, arguments);
}
function _cp() {
_cp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(src, dest) {
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_context3.prev = 0;
_context3.next = 3;
return (0, _fsExtra.copy)(src, dest);
case 3:
_logger["default"].log('Build contents copied successfully');
_context3.next = 9;
break;
case 6:
_context3.prev = 6;
_context3.t0 = _context3["catch"](0);
_logger["default"].fatal(_context3.t0);
case 9:
case "end":
return _context3.stop();
}
}, _callee3, null, [[0, 6]]);
}));
return _cp.apply(this, arguments);
}
{
"name": "balm-git-flow",
"version": "0.9.1-legacy",
"version": "0.9.1",
"description": "The best practices for front-end git flow",

@@ -20,2 +20,3 @@ "keywords": [

},
"type": "module",
"files": [

@@ -31,5 +32,2 @@ "bin",

},
"scripts": {
"build": "gulp prepublish"
},
"repository": {

@@ -43,17 +41,9 @@ "type": "git",

"dependencies": {
"chalk": "4",
"chalk": "^5.2.0",
"commander": "^10.0.0",
"del": "6",
"fs-extra": "^11.0.0",
"inquirer": "8"
"inquirer": "^9.2.0"
},
"devDependencies": {
"@babel/core": "^7.21.0",
"@babel/preset-env": "^7.20.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0"
},
"engines": {
"node": ">=14.18.0"
"node": ">=12.20.0"
}
}

@@ -34,12 +34,33 @@ # Balm Git Flow

| 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 |
| Variable Name | Type | Default | Description |
| -------------------------------- | ----------------- | -------------------- | -------------------------------------------------------------------------------------------------- |
| BALM_GIT_FLOW_MAIN | `string` | `'main'` | main branch (source code) |
| BALM_GIT_FLOW_RELEASE | `string`, `array` | `'release'` | production release branch(es) |
| BALM_GIT_FLOW_RELEASES | `array` | `['release']` | all release branches |
| BALM_GIT_FLOW_SCRIPTS | `array` | `['build']` | all build scripts corresponding to the release branches ( the keys of `scripts` in `package.json`) |
| BALM_GIT_FLOW_RELEASE_SCRIPTS | `string` | `JSON.stringify({})` | associated scripts and release branches (`{ [script: string]: [releases: string[]] }`) |
| BALM_GIT_FLOW_BUILD_DIR | `string` | `'dist'` | build out dir (by `npm-run-script`) |
| BALM_GIT_FLOW_IGNORE_UNCOMMITTED | `boolean` | `false` | ignore uncommitted for workflow |
| BALM_GIT_FLOW_USE_CUSTOM_MESSAGE | `boolean` | `false` | use custom log message |
| BALM_GIT_FLOW_REPOSITORIES | `array` | | independent repositories |
| BALM_GIT_FLOW_SITE | `string` | | production release branch for independent repositories |
- release scripts settings
- Method 1:
```ini
BALM_GIT_FLOW_RELEASES = ['test', 'release'];
BALM_GIT_FLOW_SCRIPTS = ['build:test', 'build:release'];
```
- Method 2:
```js
BALM_GIT_FLOW_RELEASE_SCRIPTS = JSON.stringify({
'build:test': ['test-a', 'test-b'],
'build:release': ['release']
});
```
## Usage

@@ -46,0 +67,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc