@teams-max/mwsp 1.0.2 → 2.0.1

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.
Files changed (96) hide show
  1. package/bin/mwsp.js +2 -31
  2. package/es/cli/build.d.ts +0 -1
  3. package/es/cli/build.js +69 -61
  4. package/es/cli/cli.js +4 -12
  5. package/es/cli/start.d.ts +0 -1
  6. package/es/cli/start.js +48 -26
  7. package/es/index.d.ts +2 -0
  8. package/es/index.js +3 -1
  9. package/es/utils/chalk/LICENSE +9 -0
  10. package/es/utils/chalk/index.d.ts +416 -0
  11. package/es/utils/chalk/index.js +1719 -0
  12. package/es/utils/chalk/package.json +6 -0
  13. package/es/{cli/update.js → utils/changelog.js} +41 -34
  14. package/es/utils/cross-spawn/package.json +7 -0
  15. package/es/{internal → utils}/datetimeFormat.js +1 -3
  16. package/es/utils/defineConfig.js +20 -0
  17. package/es/{internal → utils}/exec.js +3 -2
  18. package/{lib/internal → es/utils}/execa/index.d.ts +41 -11
  19. package/es/utils/execa/package.json +11 -0
  20. package/es/utils/getPackages.js +9 -0
  21. package/es/{cli/dev.js → utils/git.js} +88 -36
  22. package/es/{internal/utils.js → utils/index.js} +270 -70
  23. package/es/utils/isNextVersion.js +3 -0
  24. package/{lib/internal → es/utils}/merge-stream/index.d.ts +3 -1
  25. package/es/utils/merge-stream/package.json +7 -0
  26. package/es/utils/parseDoc.js +33 -0
  27. package/es/utils/yargs-parser/index.d.ts +114 -0
  28. package/es/utils/yargs-parser/index.js +919 -0
  29. package/es/utils/yargs-parser/package.json +7 -0
  30. package/lib/cli/build.d.ts +0 -1
  31. package/lib/cli/build.js +54 -50
  32. package/lib/cli/cli.js +0 -8
  33. package/lib/cli/start.d.ts +0 -1
  34. package/lib/cli/start.js +25 -30
  35. package/lib/index.d.ts +2 -0
  36. package/lib/index.js +3 -0
  37. package/lib/utils/chalk/LICENSE +9 -0
  38. package/lib/utils/chalk/index.d.ts +416 -0
  39. package/lib/utils/chalk/index.js +1538 -0
  40. package/lib/utils/chalk/package.json +6 -0
  41. package/lib/utils/changelog.js +21 -0
  42. package/lib/{internal → utils}/cross-spawn/index.js +9 -3
  43. package/lib/utils/cross-spawn/package.json +7 -0
  44. package/lib/{internal → utils}/datetimeFormat.js +14 -30
  45. package/lib/utils/defineConfig.js +26 -0
  46. package/lib/utils/exec.js +23 -0
  47. package/{es/internal → lib/utils}/execa/index.d.ts +41 -11
  48. package/lib/{internal → utils}/execa/index.js +76 -18
  49. package/lib/utils/execa/package.json +11 -0
  50. package/lib/utils/getPackages.js +8 -0
  51. package/lib/utils/git.js +31 -0
  52. package/lib/utils/index.js +183 -0
  53. package/lib/utils/isNextVersion.js +4 -0
  54. package/{es/internal → lib/utils}/merge-stream/index.d.ts +3 -1
  55. package/lib/{internal → utils}/merge-stream/index.js +1 -1
  56. package/lib/utils/merge-stream/package.json +7 -0
  57. package/lib/utils/parseDoc.js +30 -0
  58. package/lib/utils/yargs-parser/index.d.ts +114 -0
  59. package/lib/utils/yargs-parser/index.js +919 -0
  60. package/lib/utils/yargs-parser/package.json +7 -0
  61. package/package.json +7 -14
  62. package/es/cli/dev.d.ts +0 -1
  63. package/es/cli/update.d.ts +0 -2
  64. package/es/internal/buildNotify.d.ts +0 -10
  65. package/es/internal/buildNotify.js +0 -123
  66. package/es/internal/cross-spawn/package.json +0 -1
  67. package/es/internal/datetimeFormat.d.ts +0 -9
  68. package/es/internal/exec.d.ts +0 -1
  69. package/es/internal/execa/package.json +0 -1
  70. package/es/internal/merge-stream/package.json +0 -1
  71. package/es/internal/utils.d.ts +0 -14
  72. package/lib/cli/dev.d.ts +0 -1
  73. package/lib/cli/dev.js +0 -62
  74. package/lib/cli/update.d.ts +0 -2
  75. package/lib/cli/update.js +0 -50
  76. package/lib/internal/buildNotify.d.ts +0 -10
  77. package/lib/internal/buildNotify.js +0 -112
  78. package/lib/internal/cross-spawn/package.json +0 -1
  79. package/lib/internal/datetimeFormat.d.ts +0 -9
  80. package/lib/internal/exec.d.ts +0 -1
  81. package/lib/internal/exec.js +0 -60
  82. package/lib/internal/execa/package.json +0 -1
  83. package/lib/internal/merge-stream/package.json +0 -1
  84. package/lib/internal/utils.d.ts +0 -14
  85. package/lib/internal/utils.js +0 -100
  86. /package/es/{internal → utils}/cross-spawn/LICENSE +0 -0
  87. /package/es/{internal → utils}/cross-spawn/index.d.ts +0 -0
  88. /package/es/{internal → utils}/cross-spawn/index.js +0 -0
  89. /package/es/{internal → utils}/execa/LICENSE +0 -0
  90. /package/es/{internal → utils}/execa/index.js +0 -0
  91. /package/es/{internal → utils}/merge-stream/LICENSE +0 -0
  92. /package/es/{internal → utils}/merge-stream/index.js +0 -0
  93. /package/lib/{internal → utils}/cross-spawn/LICENSE +0 -0
  94. /package/lib/{internal → utils}/cross-spawn/index.d.ts +0 -0
  95. /package/lib/{internal → utils}/execa/LICENSE +0 -0
  96. /package/lib/{internal → utils}/merge-stream/LICENSE +0 -0
@@ -1,90 +1,290 @@
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
- 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
- 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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
5
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
- import spawn from '@umijs/utils/compiled/cross-spawn';
16
- import * as logger from '@umijs/utils/dist/logger';
17
- import { existsSync, readFileSync, writeFileSync } from 'fs';
18
- import { join } from 'path';
19
- import 'zx/globals';
20
- export function assert(v, message) {
21
- if (!v) {
22
- logger.error(message);
23
- process.exit(1);
9
+ 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); } }
10
+ 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); }); }; }
11
+ var fs = require('fs');
12
+ var _require = require('path'),
13
+ join = _require.join;
14
+ var inquirer = require('inquirer');
15
+ var yParser = require("./yargs-parser");
16
+ var execa = require("./execa");
17
+ var exec = require("./exec");
18
+ var chalk = require("./chalk");
19
+ var cwd = process.cwd() || process.env.INIT_CWD || process.env.PWD;
20
+ var asgDir = join(cwd, '.asg');
21
+ function logStep() {
22
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
23
+ args[_key] = arguments[_key];
24
24
  }
25
+ var name = "".concat(chalk.magenta.bold(args === null || args === void 0 ? void 0 : args[0]));
26
+ var desc = args !== null && args !== void 0 && args[1] ? "".concat(chalk.greenBright(args.slice(1).join(' '))) : '';
27
+ console.log("".concat(chalk.gray('[MWSP] '), " ").concat(name, " ").concat(desc));
25
28
  }
26
- export function setExcludeFolder(opts) {
27
- var dirName = opts.dirName || 'packages';
28
- var folders = opts.folders || ['dist', 'compiled'];
29
- if (!existsSync(join(opts.cwd, '.idea'))) return;
30
- var configPath = join(opts.cwd, '.idea', 'umi-next.iml');
31
- var content = readFileSync(configPath, 'utf-8');
32
- var _iterator = _createForOfIteratorHelper(folders),
33
- _step;
34
- try {
35
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
36
- var folder = _step.value;
37
- var excludeContent = "<excludeFolder url='file://$MODULE_DIR$/".concat(dirName, "/").concat(opts.pkg, "/").concat(folder, "' />");
38
- var replaceMatcher = "<content url=\"file://$MODULE_DIR$\">";
39
- if (!content.includes(excludeContent)) {
40
- content = content.replace(replaceMatcher, "".concat(replaceMatcher, "\n ").concat(excludeContent));
41
- }
42
- }
43
- } catch (err) {
44
- _iterator.e(err);
45
- } finally {
46
- _iterator.f();
29
+ function printError() {
30
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
31
+ args[_key2] = arguments[_key2];
47
32
  }
48
- writeFileSync(configPath, content, 'utf-8');
33
+ var name = "".concat(chalk.red.bold(args === null || args === void 0 ? void 0 : args[0]));
34
+ var desc = args !== null && args !== void 0 && args[1] ? "".concat(chalk.greenBright(args.slice(1).join(' '))) : '';
35
+ console.error("".concat(chalk.gray(' >> Error: [MWSP] '), " ").concat(name, " ").concat(desc));
49
36
  }
50
- export function spawnSync(cmd, opts, status) {
51
- var result = spawn.sync(cmd, _objectSpread({
52
- shell: true,
53
- stdio: 'inherit'
54
- }, opts));
55
- if (result.status !== 0 && status !== 'continue') {
56
- logger.error("Execute command error (".concat(cmd, ")"));
57
- process.exit(1);
37
+ function printErrorAndExit() {
38
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
39
+ args[_key3] = arguments[_key3];
58
40
  }
59
- return result;
41
+ printError(args);
42
+ process.exit(1);
60
43
  }
61
- export function toArray(v) {
62
- if (Array.isArray(v)) {
63
- return v;
44
+ function pickDependencies(dependencies, isDev) {
45
+ var pkgs = require(join(cwd, 'package.json'));
46
+ return dependencies.filter(function (p) {
47
+ if (isDev) {
48
+ return !pkgs.devDependencies[p];
49
+ } else {
50
+ return !pkgs.dependencies[p];
51
+ }
52
+ });
53
+ }
54
+ function getCfg() {
55
+ var pkgs = require(join(cwd, 'package.json'));
56
+ var _pkgs$infra = pkgs.infra,
57
+ infra = _pkgs$infra === void 0 ? {} : _pkgs$infra,
58
+ appKey = pkgs.appKey;
59
+ if (!(infra !== null && infra !== void 0 && infra.url) || !appKey) {
60
+ printErrorAndExit('Please check the infra and appKey in package.json.');
61
+ }
62
+ var args = yParser(process.argv.slice(2));
63
+ var JENKINS_BUILD = args.jenkinsBuild || args.JENKINSBUILD || args.jenkins_build || args.JENKINS_BUILD;
64
+ var APP_ENV = args.env || args.ENV || '';
65
+ var ASG_BRAHCH = args.asg_branch || args.ASG_BRAHCH || '';
66
+ var RESOURCE_URL = '';
67
+ var SUB_APP = '';
68
+ var archStr = 'unknown';
69
+ if (infra.url.includes('teams-pro')) {
70
+ archStr = 'PRO';
71
+ } else if (infra.url.includes('teams-max')) {
72
+ archStr = 'MAX';
73
+ RESOURCE_URL = args.versionUrl || args.RESOURCE_URL || '';
74
+ SUB_APP = args.subApp || args.SUB_APP || '';
75
+ }
76
+ return {
77
+ appKey: appKey,
78
+ infra: {
79
+ url: infra.url,
80
+ arch: archStr
81
+ },
82
+ ASG_DIR: asgDir,
83
+ JENKINS_BUILD: JENKINS_BUILD,
84
+ ASG_BRAHCH: ASG_BRAHCH,
85
+ APP_ENV: APP_ENV,
86
+ RESOURCE_URL: RESOURCE_URL,
87
+ SUB_APP: SUB_APP
88
+ };
89
+ }
90
+
91
+ // 判断目录是否存在
92
+ function checkDirectoryExistsSync(dirPath) {
93
+ try {
94
+ var stats = fs.statSync(dirPath);
95
+ return stats.isDirectory();
96
+ } catch (err) {
97
+ if (err.code === 'ENOENT') {
98
+ return false;
99
+ } else {
100
+ printErrorAndExit(err); // 其他错误,抛出异常
101
+ }
64
102
  }
65
- return [v];
66
103
  }
67
- export function gitHeadReset() {
68
- return _gitHeadReset.apply(this, arguments);
104
+
105
+ // 获取远程仓库信息
106
+ function fetchRemoteRepository() {
107
+ return _fetchRemoteRepository.apply(this, arguments);
69
108
  }
70
- function _gitHeadReset() {
71
- _gitHeadReset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
109
+ function _fetchRemoteRepository() {
110
+ _fetchRemoteRepository = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
111
+ var cfg, infra, directory, ASG_BRAHCH, JENKINS_BUILD, remoteUrl, doesExist, proDevDeps, proDeps, maxDevDeps, maxDeps, _yield$inquirer$promp, syncUp, infraBranchsOutput, infraBranchArray, filteredBranches, defaultBrancheIdx, questions;
72
112
  return _regeneratorRuntime().wrap(function _callee$(_context) {
73
113
  while (1) switch (_context.prev = _context.next) {
74
114
  case 0:
75
- $.verbose = false;
76
- _context.next = 3;
77
- return $(_templateObject || (_templateObject = _taggedTemplateLiteral(["git reset HEAD -- packages/app-* .gitmodules"])));
78
- case 3:
79
- $.verbose = true;
80
- // spawnSync(`git reset HEAD -- packages/app-* .gitmodules`, {
81
- // cwd: PATHS.ROOT,
82
- // });
83
- case 4:
115
+ cfg = getCfg();
116
+ infra = cfg.infra, directory = cfg.ASG_DIR, ASG_BRAHCH = cfg.ASG_BRAHCH, JENKINS_BUILD = cfg.JENKINS_BUILD;
117
+ remoteUrl = infra.url;
118
+ doesExist = checkDirectoryExistsSync(directory);
119
+ if (doesExist) {
120
+ _context.next = 36;
121
+ break;
122
+ }
123
+ logStep('Cloning the repository from GitHub...');
124
+ execa.sync('git', ['clone', '-b', 'feature-asg', remoteUrl, directory]);
125
+ logStep('Cloning completed.');
126
+ logStep('Installing dependencies...');
127
+ if (!((infra === null || infra === void 0 ? void 0 : infra.arch) === 'PRO')) {
128
+ _context.next = 22;
129
+ break;
130
+ }
131
+ proDevDeps = pickDependencies(['snb-mock-middleware', 'lodash-webpack-plugin'], true);
132
+ _context.t0 = !!proDevDeps.length;
133
+ if (!_context.t0) {
134
+ _context.next = 15;
135
+ break;
136
+ }
137
+ _context.next = 15;
138
+ return exec('yarn', ['add'].concat(_toConsumableArray(proDevDeps), ['-D']));
139
+ case 15:
140
+ proDeps = pickDependencies(['@teams-max/skynet', 'history']);
141
+ _context.t1 = !!proDeps.length;
142
+ if (!_context.t1) {
143
+ _context.next = 20;
144
+ break;
145
+ }
146
+ _context.next = 20;
147
+ return exec('yarn', ['add'].concat(_toConsumableArray(proDeps)));
148
+ case 20:
149
+ _context.next = 33;
150
+ break;
151
+ case 22:
152
+ if (!((infra === null || infra === void 0 ? void 0 : infra.arch) === 'MAX')) {
153
+ _context.next = 33;
154
+ break;
155
+ }
156
+ maxDevDeps = pickDependencies(['axios'], true);
157
+ _context.t2 = !!maxDevDeps.length;
158
+ if (!_context.t2) {
159
+ _context.next = 28;
160
+ break;
161
+ }
162
+ _context.next = 28;
163
+ return exec('pnpm', ['add'].concat(_toConsumableArray(maxDevDeps), ['-D']));
164
+ case 28:
165
+ maxDeps = pickDependencies(['@teams-max/skynet', 'classnames', 'qs', 'uuid', 'react-draggable', 'lodash', 'moment', 'dayjs']);
166
+ _context.t3 = !!maxDeps.length;
167
+ if (!_context.t3) {
168
+ _context.next = 33;
169
+ break;
170
+ }
171
+ _context.next = 33;
172
+ return exec('pnpm', ['add'].concat(_toConsumableArray(maxDeps)));
173
+ case 33:
174
+ logStep('Installation completed.');
175
+ _context.next = 48;
176
+ break;
177
+ case 36:
178
+ if (!(JENKINS_BUILD && !ASG_BRAHCH)) {
179
+ _context.next = 41;
180
+ break;
181
+ }
182
+ logStep('Jenkins build detected. Skipping sync up.');
183
+ return _context.abrupt("return");
184
+ case 41:
185
+ if (JENKINS_BUILD) {
186
+ _context.next = 48;
187
+ break;
188
+ }
189
+ _context.next = 44;
190
+ return inquirer.prompt([{
191
+ type: 'confirm',
192
+ name: 'syncUp',
193
+ message: '同步远端仓库',
194
+ default: 'Y'
195
+ }]);
196
+ case 44:
197
+ _yield$inquirer$promp = _context.sent;
198
+ syncUp = _yield$inquirer$promp.syncUp;
199
+ if (syncUp) {
200
+ _context.next = 48;
201
+ break;
202
+ }
203
+ return _context.abrupt("return");
204
+ case 48:
205
+ if (!(!doesExist && JENKINS_BUILD && !ASG_BRAHCH)) {
206
+ _context.next = 51;
207
+ break;
208
+ }
209
+ printErrorAndExit('Jenkins build detected. The branch parameter is missing!');
210
+ return _context.abrupt("return");
211
+ case 51:
212
+ logStep('Synchronizing with the remote repository...');
213
+ process.chdir(directory);
214
+ _context.prev = 53;
215
+ execa.sync('git', ['fetch', 'origin', '--prune']);
216
+ if (!(JENKINS_BUILD && ASG_BRAHCH)) {
217
+ _context.next = 60;
218
+ break;
219
+ }
220
+ execa.sync('git', ['checkout', ASG_BRAHCH]);
221
+ logStep("Anto switched to branch:", ASG_BRAHCH);
222
+ _context.next = 70;
223
+ break;
224
+ case 60:
225
+ // 获取远程分支列表
226
+ infraBranchsOutput = execa.sync('git', ['branch', '-r']).stdout; // 处理分支列表
227
+ infraBranchArray = infraBranchsOutput.trim().split('\n');
228
+ filteredBranches = infraBranchArray.map(function (b) {
229
+ return b.trim();
230
+ }).filter(function (b) {
231
+ return !(b.startsWith('origin/HEA') || b.startsWith('origin/app-') || b.startsWith('app-'));
232
+ });
233
+ defaultBrancheIdx = filteredBranches.indexOf('origin/feature-asg');
234
+ if (defaultBrancheIdx !== -1) {
235
+ filteredBranches.splice(defaultBrancheIdx, 1);
236
+ filteredBranches.unshift('origin/feature-asg');
237
+ }
238
+ // 若过滤后分支列表为空,则给出提示并退出
239
+ if (filteredBranches.length === 0) {
240
+ printErrorAndExit('No branches available for selection.');
241
+ }
242
+
243
+ // 提示用户选择分支
244
+ _context.next = 68;
245
+ return inquirer.prompt([{
246
+ type: 'list',
247
+ name: 'branch',
248
+ message: 'Please select the branch first: ',
249
+ choices: filteredBranches,
250
+ validate: function validate(val) {
251
+ if (!val || !val.length) {
252
+ return 'Please select a branch!';
253
+ }
254
+ return true;
255
+ }
256
+ }]);
257
+ case 68:
258
+ questions = _context.sent;
259
+ // 切换分支,增加错误处理
260
+ try {
261
+ execa.sync('git', ['checkout', '-q', questions.branch]);
262
+ logStep("Switched to branch:", questions.branch);
263
+ } catch (error) {
264
+ printErrorAndExit("Failed to switch to branch '".concat(questions.branch, "'. Reason: ").concat(error.message));
265
+ }
266
+ case 70:
267
+ _context.next = 75;
268
+ break;
269
+ case 72:
270
+ _context.prev = 72;
271
+ _context.t4 = _context["catch"](53);
272
+ // 获取分支列表时的错误处理
273
+ printErrorAndExit("An error occurred while fetching remote branches: ".concat(_context.t4.message));
274
+ case 75:
275
+ process.chdir(cwd);
276
+ case 76:
84
277
  case "end":
85
278
  return _context.stop();
86
279
  }
87
- }, _callee);
280
+ }, _callee, null, [[53, 72]]);
88
281
  }));
89
- return _gitHeadReset.apply(this, arguments);
90
- }
282
+ return _fetchRemoteRepository.apply(this, arguments);
283
+ }
284
+ module.exports.yParser = yParser;
285
+ module.exports.execa = execa;
286
+ module.exports.chalk = chalk;
287
+ module.exports.logStep = logStep;
288
+ module.exports.printErrorAndExit = printErrorAndExit;
289
+ module.exports.getCfg = getCfg;
290
+ module.exports.fetchRemoteRepository = fetchRemoteRepository;
@@ -0,0 +1,3 @@
1
+ module.exports = function (version) {
2
+ return version.includes('-rc.') || version.includes('-beta.') || version.includes('-alpha.');
3
+ };
@@ -9,7 +9,9 @@
9
9
  /// <reference types="node"/>
10
10
 
11
11
  interface MergedStream extends NodeJS.ReadWriteStream {
12
- add(source: NodeJS.ReadableStream | ReadonlyArray<NodeJS.ReadableStream>): MergedStream;
12
+ add(
13
+ source: NodeJS.ReadableStream | ReadonlyArray<NodeJS.ReadableStream>,
14
+ ): MergedStream;
13
15
  isEmpty(): boolean;
14
16
  }
15
17
 
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "merge-stream",
3
+ "license": "MIT",
4
+ "author": "Stephen Sugden <me@stephensugden.com>",
5
+ "main": "index.js",
6
+ "types": "index.d.ts"
7
+ }
@@ -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,114 @@
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?:
78
+ | string[]
79
+ | Array<{ key: string; boolean?: boolean; number?: boolean }>;
80
+ /** Arguments should be parsed as booleans: `{ boolean: ['x', 'y'] }`. */
81
+ boolean?: string[];
82
+ /** Indicate a key that represents a path to a configuration file (this file will be loaded and parsed). */
83
+ config?: string | string[] | { [key: string]: boolean };
84
+ /** Provide configuration options to the yargs-parser. */
85
+ configuration?: Partial<Configuration>;
86
+ /**
87
+ * Provide a custom synchronous function that returns a coerced value from the argument provided (or throws an error), e.g.
88
+ * `{ coerce: { foo: function (arg) { return modifiedArg } } }`.
89
+ */
90
+ coerce?: { [key: string]: (arg: any) => any };
91
+ /** Indicate a key that should be used as a counter, e.g., `-vvv = {v: 3}`. */
92
+ count?: string[];
93
+ /** Provide default values for keys: `{ default: { x: 33, y: 'hello world!' } }`. */
94
+ default?: { [key: string]: any };
95
+ /** Environment variables (`process.env`) with the prefix provided should be parsed. */
96
+ envPrefix?: string;
97
+ /** Specify that a key requires n arguments: `{ narg: {x: 2} }`. */
98
+ narg?: { [key: string]: number };
99
+ /** `path.normalize()` will be applied to values set to this key. */
100
+ normalize?: string[];
101
+ /** Keys should be treated as strings (even if they resemble a number `-x 33`). */
102
+ string?: string[];
103
+ /** Keys should be treated as numbers. */
104
+ number?: string[];
105
+ }
106
+
107
+ interface Parser {
108
+ (argv: string | string[], opts?: Options): Arguments;
109
+ detailed(argv: string | string[], opts?: Options): DetailedArguments;
110
+ }
111
+ }
112
+
113
+ declare var yargsParser: yargsParser.Parser;
114
+ export = yargsParser;