@teams-max/mwsp 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/mwsp.js +0 -29
- package/es/cli/build.d.ts +0 -1
- package/es/cli/build.js +69 -61
- package/es/cli/cli.js +4 -12
- package/es/cli/start.d.ts +0 -1
- package/es/cli/start.js +48 -26
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/es/utils/chalk/LICENSE +9 -0
- package/es/utils/chalk/index.d.ts +416 -0
- package/es/utils/chalk/index.js +1719 -0
- package/es/utils/chalk/package.json +1 -0
- package/es/{cli/update.js → utils/changelog.js} +41 -34
- package/es/{internal → utils}/datetimeFormat.js +1 -3
- package/es/utils/defineConfig.js +20 -0
- package/es/{internal → utils}/exec.js +3 -2
- package/es/utils/getPackages.js +9 -0
- package/es/{cli/dev.js → utils/git.js} +88 -36
- package/es/{internal/buildNotify.js → utils/index.js} +220 -97
- package/es/utils/isNextVersion.js +3 -0
- package/es/utils/parseDoc.js +33 -0
- package/es/utils/yargs-parser/index.d.ts +112 -0
- package/es/utils/yargs-parser/index.js +919 -0
- package/es/utils/yargs-parser/package.json +1 -0
- package/lib/cli/build.d.ts +0 -1
- package/lib/cli/build.js +54 -50
- package/lib/cli/cli.js +0 -8
- package/lib/cli/start.d.ts +0 -1
- package/lib/cli/start.js +25 -30
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/utils/chalk/LICENSE +9 -0
- package/lib/utils/chalk/index.d.ts +416 -0
- package/lib/utils/chalk/index.js +1495 -0
- package/lib/utils/chalk/package.json +1 -0
- package/lib/utils/changelog.js +21 -0
- package/lib/{internal → utils}/cross-spawn/index.js +1 -1
- package/lib/{internal → utils}/datetimeFormat.js +10 -29
- package/lib/utils/defineConfig.js +19 -0
- package/lib/utils/exec.js +23 -0
- package/lib/{internal → utils}/execa/index.js +1 -1
- package/lib/utils/getPackages.js +6 -0
- package/lib/utils/git.js +23 -0
- package/lib/utils/index.js +159 -0
- package/lib/utils/isNextVersion.js +4 -0
- package/lib/{internal → utils}/merge-stream/index.js +1 -1
- package/lib/utils/parseDoc.js +30 -0
- package/lib/utils/yargs-parser/index.d.ts +112 -0
- package/lib/utils/yargs-parser/index.js +905 -0
- package/lib/utils/yargs-parser/package.json +1 -0
- package/package.json +4 -11
- package/es/cli/dev.d.ts +0 -1
- package/es/cli/update.d.ts +0 -2
- package/es/internal/buildNotify.d.ts +0 -10
- package/es/internal/datetimeFormat.d.ts +0 -9
- package/es/internal/exec.d.ts +0 -1
- package/es/internal/utils.d.ts +0 -14
- package/es/internal/utils.js +0 -90
- package/lib/cli/dev.d.ts +0 -1
- package/lib/cli/dev.js +0 -62
- package/lib/cli/update.d.ts +0 -2
- package/lib/cli/update.js +0 -50
- package/lib/internal/buildNotify.d.ts +0 -10
- package/lib/internal/buildNotify.js +0 -112
- package/lib/internal/datetimeFormat.d.ts +0 -9
- package/lib/internal/exec.d.ts +0 -1
- package/lib/internal/exec.js +0 -60
- package/lib/internal/utils.d.ts +0 -14
- package/lib/internal/utils.js +0 -100
- /package/es/{internal → utils}/cross-spawn/LICENSE +0 -0
- /package/es/{internal → utils}/cross-spawn/index.d.ts +0 -0
- /package/es/{internal → utils}/cross-spawn/index.js +0 -0
- /package/es/{internal → utils}/cross-spawn/package.json +0 -0
- /package/es/{internal → utils}/execa/LICENSE +0 -0
- /package/es/{internal → utils}/execa/index.d.ts +0 -0
- /package/es/{internal → utils}/execa/index.js +0 -0
- /package/es/{internal → utils}/execa/package.json +0 -0
- /package/es/{internal → utils}/merge-stream/LICENSE +0 -0
- /package/es/{internal → utils}/merge-stream/index.d.ts +0 -0
- /package/es/{internal → utils}/merge-stream/index.js +0 -0
- /package/es/{internal → utils}/merge-stream/package.json +0 -0
- /package/lib/{internal → utils}/cross-spawn/LICENSE +0 -0
- /package/lib/{internal → utils}/cross-spawn/index.d.ts +0 -0
- /package/lib/{internal → utils}/cross-spawn/package.json +0 -0
- /package/lib/{internal → utils}/execa/LICENSE +0 -0
- /package/lib/{internal → utils}/execa/index.d.ts +0 -0
- /package/lib/{internal → utils}/execa/package.json +0 -0
- /package/lib/{internal → utils}/merge-stream/LICENSE +0 -0
- /package/lib/{internal → utils}/merge-stream/index.d.ts +0 -0
- /package/lib/{internal → utils}/merge-stream/package.json +0 -0
|
@@ -1,123 +1,246 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
var _templateObject;
|
|
3
2
|
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; }
|
|
4
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
5
3
|
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); } }
|
|
6
4
|
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); }); }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var _require = require('path'),
|
|
7
|
+
join = _require.join;
|
|
8
|
+
var inquirer = require('inquirer');
|
|
9
|
+
var yParser = require("./yargs-parser");
|
|
10
|
+
var execa = require("./execa");
|
|
11
|
+
var exec = require("./exec");
|
|
12
|
+
var chalk = require("./chalk");
|
|
13
|
+
var cwd = process.cwd() || process.env.INIT_CWD || process.env.PWD;
|
|
14
|
+
var asgDir = join(cwd, '.asg');
|
|
15
|
+
function logStep() {
|
|
16
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17
|
+
args[_key] = arguments[_key];
|
|
18
|
+
}
|
|
19
|
+
var name = "".concat(chalk.magenta.bold(args === null || args === void 0 ? void 0 : args[0]));
|
|
20
|
+
var desc = args !== null && args !== void 0 && args[1] ? "".concat(chalk.greenBright(args.slice(1).join(' '))) : '';
|
|
21
|
+
console.log("".concat(chalk.gray('[MWSP] '), " ").concat(name, " ").concat(desc));
|
|
22
|
+
}
|
|
23
|
+
function printError() {
|
|
24
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
25
|
+
args[_key2] = arguments[_key2];
|
|
26
|
+
}
|
|
27
|
+
var name = "".concat(chalk.red.bold(args === null || args === void 0 ? void 0 : args[0]));
|
|
28
|
+
var desc = args !== null && args !== void 0 && args[1] ? "".concat(chalk.greenBright(args.slice(1).join(' '))) : '';
|
|
29
|
+
console.error("".concat(chalk.gray(' >> Error: [MWSP] '), " ").concat(name, " ").concat(desc));
|
|
16
30
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
id: commit.slice(splitIndex + 1)
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
return commits.map(function (commit) {
|
|
27
|
-
return "- ".concat(commit.message, " ").concat(commit.id);
|
|
28
|
-
}).join('\n');
|
|
31
|
+
function printErrorAndExit() {
|
|
32
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
33
|
+
args[_key3] = arguments[_key3];
|
|
34
|
+
}
|
|
35
|
+
printError(args);
|
|
36
|
+
process.exit(1);
|
|
29
37
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
function getCfg() {
|
|
39
|
+
var pkgs = require(join(cwd, 'package.json'));
|
|
40
|
+
var _pkgs$infra = pkgs.infra,
|
|
41
|
+
infra = _pkgs$infra === void 0 ? {} : _pkgs$infra,
|
|
42
|
+
appKey = pkgs.appKey;
|
|
43
|
+
if (!(infra !== null && infra !== void 0 && infra.url) || !appKey) {
|
|
44
|
+
printErrorAndExit('Please check the infra and appKey in package.json.');
|
|
45
|
+
}
|
|
46
|
+
var args = yParser(process.argv.slice(2));
|
|
47
|
+
var JENKINS_BUILD = args.jenkinsBuild || args.JENKINSBUILD || args.jenkins_build || args.JENKINS_BUILD;
|
|
48
|
+
var APP_ENV = args.env || args.ENV || '';
|
|
49
|
+
var ASG_BRAHCH = args.asg_branch || args.ASG_BRAHCH || '';
|
|
50
|
+
var RESOURCE_URL = '';
|
|
51
|
+
var SUB_APP = '';
|
|
52
|
+
var archStr = 'unknown';
|
|
53
|
+
if (infra.url.includes('teams-pro')) {
|
|
54
|
+
archStr = 'PRO';
|
|
55
|
+
} else if (infra.url.includes('teams-max')) {
|
|
56
|
+
archStr = 'MAX';
|
|
57
|
+
RESOURCE_URL = args.versionUrl || args.RESOURCE_URL || '';
|
|
58
|
+
SUB_APP = args.subApp || args.SUB_APP || '';
|
|
38
59
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
return {
|
|
61
|
+
appKey: appKey,
|
|
62
|
+
infra: {
|
|
63
|
+
url: infra.url,
|
|
64
|
+
arch: archStr
|
|
65
|
+
},
|
|
66
|
+
ASG_DIR: asgDir,
|
|
67
|
+
JENKINS_BUILD: JENKINS_BUILD,
|
|
68
|
+
ASG_BRAHCH: ASG_BRAHCH,
|
|
69
|
+
APP_ENV: APP_ENV,
|
|
70
|
+
RESOURCE_URL: RESOURCE_URL,
|
|
71
|
+
SUB_APP: SUB_APP
|
|
72
|
+
};
|
|
50
73
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
74
|
+
|
|
75
|
+
// 判断目录是否存在
|
|
76
|
+
function checkDirectoryExistsSync(dirPath) {
|
|
77
|
+
try {
|
|
78
|
+
var stats = fs.statSync(dirPath);
|
|
79
|
+
return stats.isDirectory();
|
|
80
|
+
} catch (err) {
|
|
81
|
+
if (err.code === 'ENOENT') {
|
|
82
|
+
return false;
|
|
83
|
+
} else {
|
|
84
|
+
printErrorAndExit(err); // 其他错误,抛出异常
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 获取远程仓库信息
|
|
90
|
+
function fetchRemoteRepository() {
|
|
91
|
+
return _fetchRemoteRepository.apply(this, arguments);
|
|
92
|
+
}
|
|
93
|
+
function _fetchRemoteRepository() {
|
|
94
|
+
_fetchRemoteRepository = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
95
|
+
var cfg, infra, directory, ASG_BRAHCH, JENKINS_BUILD, remoteUrl, doesExist, _yield$inquirer$promp, syncUp, infraBranchsOutput, infraBranchArray, filteredBranches, defaultBrancheIdx, questions;
|
|
54
96
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
55
97
|
while (1) switch (_context.prev = _context.next) {
|
|
56
98
|
case 0:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
branch = args.branch || args.BRANCH || '';
|
|
64
|
-
serverEnv = args.opsEnv || args.OPSENV || args.ops_env || args.OPS_ENV || '';
|
|
65
|
-
if (omitDevEnv.length) {
|
|
66
|
-
_context.next = 8;
|
|
99
|
+
cfg = getCfg();
|
|
100
|
+
infra = cfg.infra, directory = cfg.ASG_DIR, ASG_BRAHCH = cfg.ASG_BRAHCH, JENKINS_BUILD = cfg.JENKINS_BUILD;
|
|
101
|
+
remoteUrl = infra.url;
|
|
102
|
+
doesExist = checkDirectoryExistsSync(directory);
|
|
103
|
+
if (doesExist) {
|
|
104
|
+
_context.next = 24;
|
|
67
105
|
break;
|
|
68
106
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_context.t0 = args.buildUser || args.build_user || args.BUILD_USER;
|
|
76
|
-
if (_context.t0) {
|
|
77
|
-
_context.next = 17;
|
|
107
|
+
logStep('Cloning the repository from GitHub...');
|
|
108
|
+
execa.sync('git', ['clone', '-b', 'feature-asg', remoteUrl, directory]);
|
|
109
|
+
logStep('Cloning completed.');
|
|
110
|
+
logStep('Installing dependencies...');
|
|
111
|
+
if (!((infra === null || infra === void 0 ? void 0 : infra.arch) === 'PRO')) {
|
|
112
|
+
_context.next = 16;
|
|
78
113
|
break;
|
|
79
114
|
}
|
|
80
|
-
_context.next =
|
|
81
|
-
return
|
|
115
|
+
_context.next = 12;
|
|
116
|
+
return exec('yarn', ['add', 'snb-mock-middleware', 'lodash-webpack-plugin', '-D']);
|
|
117
|
+
case 12:
|
|
118
|
+
_context.next = 14;
|
|
119
|
+
return exec('yarn', ['add', '@teams-max/skynet', 'history']);
|
|
120
|
+
case 14:
|
|
121
|
+
_context.next = 21;
|
|
122
|
+
break;
|
|
82
123
|
case 16:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
changeLogText = formatChangeLog(changeLog);
|
|
87
|
-
content = "".concat(BUILD_USER, " ").concat(statusTextMap[buildStatus], ":\n");
|
|
88
|
-
content += "APP: [".concat(appList.join(', '), "] \n");
|
|
89
|
-
if (branch) {
|
|
90
|
-
content += "BRANCH: ".concat(branch, " \n");
|
|
124
|
+
if (!((infra === null || infra === void 0 ? void 0 : infra.arch) === 'MAX')) {
|
|
125
|
+
_context.next = 21;
|
|
126
|
+
break;
|
|
91
127
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
128
|
+
_context.next = 19;
|
|
129
|
+
return exec('pnpm', ['add', 'axios', '-D']);
|
|
130
|
+
case 19:
|
|
131
|
+
_context.next = 21;
|
|
132
|
+
return exec('pnpm', ['add', '@teams-max/skynet', 'classnames', 'qs', 'uuid', 'react-draggable']);
|
|
133
|
+
case 21:
|
|
134
|
+
logStep('Installation completed.');
|
|
135
|
+
_context.next = 35;
|
|
136
|
+
break;
|
|
137
|
+
case 24:
|
|
138
|
+
if (!(JENKINS_BUILD && !ASG_BRAHCH)) {
|
|
139
|
+
_context.next = 29;
|
|
140
|
+
break;
|
|
95
141
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
142
|
+
logStep('Jenkins build detected. Skipping sync up.');
|
|
143
|
+
return _context.abrupt("return");
|
|
144
|
+
case 29:
|
|
145
|
+
_context.next = 31;
|
|
146
|
+
return inquirer.prompt([{
|
|
147
|
+
type: 'confirm',
|
|
148
|
+
name: 'syncUp',
|
|
149
|
+
message: '同步远端仓库',
|
|
150
|
+
default: 'Y'
|
|
151
|
+
}]);
|
|
152
|
+
case 31:
|
|
153
|
+
_yield$inquirer$promp = _context.sent;
|
|
154
|
+
syncUp = _yield$inquirer$promp.syncUp;
|
|
155
|
+
if (syncUp) {
|
|
156
|
+
_context.next = 35;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
return _context.abrupt("return");
|
|
160
|
+
case 35:
|
|
161
|
+
if (!(!doesExist && JENKINS_BUILD && !ASG_BRAHCH)) {
|
|
162
|
+
_context.next = 38;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
printErrorAndExit('Jenkins build detected. The branch parameter is missing!');
|
|
166
|
+
return _context.abrupt("return");
|
|
167
|
+
case 38:
|
|
168
|
+
logStep('Synchronizing with the remote repository...');
|
|
169
|
+
process.chdir(directory);
|
|
170
|
+
_context.prev = 40;
|
|
171
|
+
execa.sync('git', ['pull', 'origin', 'master']);
|
|
172
|
+
if (!(JENKINS_BUILD && ASG_BRAHCH)) {
|
|
173
|
+
_context.next = 47;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
execa.sync('git', ['checkout', ASG_BRAHCH]);
|
|
177
|
+
logStep("Anto switched to branch:", ASG_BRAHCH);
|
|
178
|
+
_context.next = 57;
|
|
179
|
+
break;
|
|
180
|
+
case 47:
|
|
181
|
+
// 获取远程分支列表
|
|
182
|
+
infraBranchsOutput = execa.sync('git', ['branch', '-r']).stdout; // 处理分支列表
|
|
183
|
+
infraBranchArray = infraBranchsOutput.trim().split('\n');
|
|
184
|
+
filteredBranches = infraBranchArray.map(function (b) {
|
|
185
|
+
return b.trim();
|
|
186
|
+
}).filter(function (b) {
|
|
187
|
+
return !(b.startsWith('origin/HEA') || b.startsWith('origin/app-') || b.startsWith('app-'));
|
|
188
|
+
});
|
|
189
|
+
defaultBrancheIdx = filteredBranches.indexOf('origin/feature-asg');
|
|
190
|
+
if (defaultBrancheIdx !== -1) {
|
|
191
|
+
filteredBranches.splice(defaultBrancheIdx, 1);
|
|
192
|
+
filteredBranches.unshift('origin/feature-asg');
|
|
193
|
+
}
|
|
194
|
+
// 若过滤后分支列表为空,则给出提示并退出
|
|
195
|
+
if (filteredBranches.length === 0) {
|
|
196
|
+
printErrorAndExit('No branches available for selection.');
|
|
100
197
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
198
|
+
|
|
199
|
+
// 提示用户选择分支
|
|
200
|
+
_context.next = 55;
|
|
201
|
+
return inquirer.prompt([{
|
|
202
|
+
type: 'list',
|
|
203
|
+
name: 'branch',
|
|
204
|
+
message: 'Please select the branch first: ',
|
|
205
|
+
choices: filteredBranches,
|
|
206
|
+
validate: function validate(val) {
|
|
207
|
+
if (!val || !val.length) {
|
|
208
|
+
return 'Please select a branch!';
|
|
111
209
|
}
|
|
210
|
+
return true;
|
|
112
211
|
}
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
|
|
212
|
+
}]);
|
|
213
|
+
case 55:
|
|
214
|
+
questions = _context.sent;
|
|
215
|
+
// 切换分支,增加错误处理
|
|
216
|
+
try {
|
|
217
|
+
execa.sync('git', ['checkout', '-q', questions.branch]);
|
|
218
|
+
logStep("Switched to branch:", questions.branch);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
printErrorAndExit("Failed to switch to branch '".concat(questions.branch, "'. Reason: ").concat(error.message));
|
|
221
|
+
}
|
|
222
|
+
case 57:
|
|
223
|
+
_context.next = 62;
|
|
224
|
+
break;
|
|
225
|
+
case 59:
|
|
226
|
+
_context.prev = 59;
|
|
227
|
+
_context.t0 = _context["catch"](40);
|
|
228
|
+
// 获取分支列表时的错误处理
|
|
229
|
+
printErrorAndExit("An error occurred while fetching remote branches: ".concat(_context.t0.message));
|
|
230
|
+
case 62:
|
|
231
|
+
process.chdir(cwd);
|
|
232
|
+
case 63:
|
|
116
233
|
case "end":
|
|
117
234
|
return _context.stop();
|
|
118
235
|
}
|
|
119
|
-
}, _callee);
|
|
236
|
+
}, _callee, null, [[40, 59]]);
|
|
120
237
|
}));
|
|
121
|
-
return
|
|
238
|
+
return _fetchRemoteRepository.apply(this, arguments);
|
|
122
239
|
}
|
|
123
|
-
;
|
|
240
|
+
module.exports.yParser = yParser;
|
|
241
|
+
module.exports.execa = execa;
|
|
242
|
+
module.exports.chalk = chalk;
|
|
243
|
+
module.exports.logStep = logStep;
|
|
244
|
+
module.exports.printErrorAndExit = printErrorAndExit;
|
|
245
|
+
module.exports.getCfg = getCfg;
|
|
246
|
+
module.exports.fetchRemoteRepository = fetchRemoteRepository;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = function (docStr) {
|
|
2
|
+
docStr = docStr.trim();
|
|
3
|
+
var hasYamlConfig = docStr.startsWith('---');
|
|
4
|
+
var docArr = docStr.split('\n');
|
|
5
|
+
var title = null;
|
|
6
|
+
var titleIndex = null;
|
|
7
|
+
var yamlEndIndex = null;
|
|
8
|
+
var i = hasYamlConfig ? 1 : 0;
|
|
9
|
+
while (i < docArr.length) {
|
|
10
|
+
var line = docArr[i];
|
|
11
|
+
|
|
12
|
+
// yaml end
|
|
13
|
+
if (line.startsWith('---')) {
|
|
14
|
+
yamlEndIndex = i;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// title
|
|
18
|
+
if (line.startsWith('# ') && titleIndex === null) {
|
|
19
|
+
title = line.replace('# ', '');
|
|
20
|
+
titleIndex = i;
|
|
21
|
+
}
|
|
22
|
+
i += 1;
|
|
23
|
+
}
|
|
24
|
+
if (titleIndex === null && yamlEndIndex !== null) {
|
|
25
|
+
titleIndex = yamlEndIndex;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
hasYamlConfig: hasYamlConfig,
|
|
29
|
+
title: title,
|
|
30
|
+
yamlConfig: hasYamlConfig ? docArr.slice(1, yamlEndIndex) : [],
|
|
31
|
+
body: docArr.slice(titleIndex === null ? titleIndex : titleIndex + 1)
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Type definitions for yargs-parser 20.2
|
|
2
|
+
// Project: https://github.com/yargs/yargs-parser#readme
|
|
3
|
+
// Definitions by: Miles Johnson <https://github.com/milesj>
|
|
4
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
// TypeScript Version: 2.2
|
|
6
|
+
|
|
7
|
+
declare namespace yargsParser {
|
|
8
|
+
interface Arguments {
|
|
9
|
+
/** Non-option arguments */
|
|
10
|
+
_: string[];
|
|
11
|
+
/** The script name or node command */
|
|
12
|
+
$0: string;
|
|
13
|
+
/** All remaining options */
|
|
14
|
+
[argName: string]: any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface DetailedArguments {
|
|
18
|
+
/** An object representing the parsed value of `args` */
|
|
19
|
+
argv: Arguments;
|
|
20
|
+
/** Populated with an error object if an exception occurred during parsing. */
|
|
21
|
+
error: Error | null;
|
|
22
|
+
/** The inferred list of aliases built by combining lists in opts.alias. */
|
|
23
|
+
aliases: { [alias: string]: string[] };
|
|
24
|
+
/** Any new aliases added via camel-case expansion. */
|
|
25
|
+
newAliases: { [alias: string]: boolean };
|
|
26
|
+
/** The configuration loaded from the yargs stanza in package.json. */
|
|
27
|
+
configuration: Configuration;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Configuration {
|
|
31
|
+
/** Should variables prefixed with --no be treated as negations? Default is `true` */
|
|
32
|
+
'boolean-negation': boolean;
|
|
33
|
+
/** Should hyphenated arguments be expanded into camel-case aliases? Default is `true` */
|
|
34
|
+
'camel-case-expansion': boolean;
|
|
35
|
+
/** Should arrays be combined when provided by both command line arguments and a configuration file. Default is `false` */
|
|
36
|
+
'combine-arrays': boolean;
|
|
37
|
+
/** Should keys that contain . be treated as objects? Default is `true` */
|
|
38
|
+
'dot-notation': boolean;
|
|
39
|
+
/** Should arguments be coerced into an array when duplicated. Default is `true` */
|
|
40
|
+
'duplicate-arguments-array': boolean;
|
|
41
|
+
/** Should array arguments be coerced into a single array when duplicated. Default is `true` */
|
|
42
|
+
'flatten-duplicate-arrays': boolean;
|
|
43
|
+
/** Should arrays consume more than one positional argument following their flag. Default is `true` */
|
|
44
|
+
'greedy-arrays': boolean;
|
|
45
|
+
/** Should nargs consume dash options as well as positional arguments. Default is `false` */
|
|
46
|
+
'nargs-eats-options': boolean;
|
|
47
|
+
/** Should parsing stop at the first text argument? This is similar to how e.g. ssh parses its command line. Default is `false` */
|
|
48
|
+
'halt-at-non-option': boolean;
|
|
49
|
+
/** The prefix to use for negated boolean variables. Default is `'no-'` */
|
|
50
|
+
'negation-prefix': string;
|
|
51
|
+
/** Should keys that look like numbers be treated as such? Default is `true` */
|
|
52
|
+
'parse-numbers': boolean;
|
|
53
|
+
/** Should positional keys that look like numbers be treated as such? Default is `true` */
|
|
54
|
+
'parse-positional-numbers': boolean;
|
|
55
|
+
/** Should unparsed flags be stored in -- or _. Default is `false` */
|
|
56
|
+
'populate--': boolean;
|
|
57
|
+
/** Should a placeholder be added for keys not set via the corresponding CLI argument? Default is `false` */
|
|
58
|
+
'set-placeholder-key': boolean;
|
|
59
|
+
/** Should a group of short-options be treated as boolean flags? Default is `true` */
|
|
60
|
+
'short-option-groups': boolean;
|
|
61
|
+
/** Should aliases be removed before returning results? Default is `false` */
|
|
62
|
+
'strip-aliased': boolean;
|
|
63
|
+
/** Should dashed keys be removed before returning results? This option has no effect if camel-case-expansion is disabled. Default is `false` */
|
|
64
|
+
'strip-dashed': boolean;
|
|
65
|
+
/** Should unknown options be treated like regular arguments? An unknown option is one that is not configured in opts. Default is `false` */
|
|
66
|
+
'unknown-options-as-args': boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface Options {
|
|
70
|
+
/** An object representing the set of aliases for a key: `{ alias: { foo: ['f']} }`. */
|
|
71
|
+
alias?: { [key: string]: string | string[] };
|
|
72
|
+
/**
|
|
73
|
+
* Indicate that keys should be parsed as an array: `{ array: ['foo', 'bar'] }`.
|
|
74
|
+
* Indicate that keys should be parsed as an array and coerced to booleans / numbers:
|
|
75
|
+
* { array: [ { key: 'foo', boolean: true }, {key: 'bar', number: true} ] }`.
|
|
76
|
+
*/
|
|
77
|
+
array?: string[] | Array<{ key: string; boolean?: boolean; number?: boolean }>;
|
|
78
|
+
/** Arguments should be parsed as booleans: `{ boolean: ['x', 'y'] }`. */
|
|
79
|
+
boolean?: string[];
|
|
80
|
+
/** Indicate a key that represents a path to a configuration file (this file will be loaded and parsed). */
|
|
81
|
+
config?: string | string[] | { [key: string]: boolean };
|
|
82
|
+
/** Provide configuration options to the yargs-parser. */
|
|
83
|
+
configuration?: Partial<Configuration>;
|
|
84
|
+
/**
|
|
85
|
+
* Provide a custom synchronous function that returns a coerced value from the argument provided (or throws an error), e.g.
|
|
86
|
+
* `{ coerce: { foo: function (arg) { return modifiedArg } } }`.
|
|
87
|
+
*/
|
|
88
|
+
coerce?: { [key: string]: (arg: any) => any };
|
|
89
|
+
/** Indicate a key that should be used as a counter, e.g., `-vvv = {v: 3}`. */
|
|
90
|
+
count?: string[];
|
|
91
|
+
/** Provide default values for keys: `{ default: { x: 33, y: 'hello world!' } }`. */
|
|
92
|
+
default?: { [key: string]: any };
|
|
93
|
+
/** Environment variables (`process.env`) with the prefix provided should be parsed. */
|
|
94
|
+
envPrefix?: string;
|
|
95
|
+
/** Specify that a key requires n arguments: `{ narg: {x: 2} }`. */
|
|
96
|
+
narg?: { [key: string]: number };
|
|
97
|
+
/** `path.normalize()` will be applied to values set to this key. */
|
|
98
|
+
normalize?: string[];
|
|
99
|
+
/** Keys should be treated as strings (even if they resemble a number `-x 33`). */
|
|
100
|
+
string?: string[];
|
|
101
|
+
/** Keys should be treated as numbers. */
|
|
102
|
+
number?: string[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface Parser {
|
|
106
|
+
(argv: string | string[], opts?: Options): Arguments;
|
|
107
|
+
detailed(argv: string | string[], opts?: Options): DetailedArguments;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
declare var yargsParser: yargsParser.Parser;
|
|
112
|
+
export = yargsParser;
|