@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.
Files changed (90) hide show
  1. package/bin/mwsp.js +0 -29
  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 +1 -0
  13. package/es/{cli/update.js → utils/changelog.js} +41 -34
  14. package/es/{internal → utils}/datetimeFormat.js +1 -3
  15. package/es/utils/defineConfig.js +20 -0
  16. package/es/{internal → utils}/exec.js +3 -2
  17. package/es/utils/getPackages.js +9 -0
  18. package/es/{cli/dev.js → utils/git.js} +88 -36
  19. package/es/{internal/buildNotify.js → utils/index.js} +220 -97
  20. package/es/utils/isNextVersion.js +3 -0
  21. package/es/utils/parseDoc.js +33 -0
  22. package/es/utils/yargs-parser/index.d.ts +112 -0
  23. package/es/utils/yargs-parser/index.js +919 -0
  24. package/es/utils/yargs-parser/package.json +1 -0
  25. package/lib/cli/build.d.ts +0 -1
  26. package/lib/cli/build.js +54 -50
  27. package/lib/cli/cli.js +0 -8
  28. package/lib/cli/start.d.ts +0 -1
  29. package/lib/cli/start.js +25 -30
  30. package/lib/index.d.ts +2 -0
  31. package/lib/index.js +3 -0
  32. package/lib/utils/chalk/LICENSE +9 -0
  33. package/lib/utils/chalk/index.d.ts +416 -0
  34. package/lib/utils/chalk/index.js +1495 -0
  35. package/lib/utils/chalk/package.json +1 -0
  36. package/lib/utils/changelog.js +21 -0
  37. package/lib/{internal → utils}/cross-spawn/index.js +1 -1
  38. package/lib/{internal → utils}/datetimeFormat.js +10 -29
  39. package/lib/utils/defineConfig.js +19 -0
  40. package/lib/utils/exec.js +23 -0
  41. package/lib/{internal → utils}/execa/index.js +1 -1
  42. package/lib/utils/getPackages.js +6 -0
  43. package/lib/utils/git.js +23 -0
  44. package/lib/utils/index.js +159 -0
  45. package/lib/utils/isNextVersion.js +4 -0
  46. package/lib/{internal → utils}/merge-stream/index.js +1 -1
  47. package/lib/utils/parseDoc.js +30 -0
  48. package/lib/utils/yargs-parser/index.d.ts +112 -0
  49. package/lib/utils/yargs-parser/index.js +905 -0
  50. package/lib/utils/yargs-parser/package.json +1 -0
  51. package/package.json +4 -11
  52. package/es/cli/dev.d.ts +0 -1
  53. package/es/cli/update.d.ts +0 -2
  54. package/es/internal/buildNotify.d.ts +0 -10
  55. package/es/internal/datetimeFormat.d.ts +0 -9
  56. package/es/internal/exec.d.ts +0 -1
  57. package/es/internal/utils.d.ts +0 -14
  58. package/es/internal/utils.js +0 -90
  59. package/lib/cli/dev.d.ts +0 -1
  60. package/lib/cli/dev.js +0 -62
  61. package/lib/cli/update.d.ts +0 -2
  62. package/lib/cli/update.js +0 -50
  63. package/lib/internal/buildNotify.d.ts +0 -10
  64. package/lib/internal/buildNotify.js +0 -112
  65. package/lib/internal/datetimeFormat.d.ts +0 -9
  66. package/lib/internal/exec.d.ts +0 -1
  67. package/lib/internal/exec.js +0 -60
  68. package/lib/internal/utils.d.ts +0 -14
  69. package/lib/internal/utils.js +0 -100
  70. /package/es/{internal → utils}/cross-spawn/LICENSE +0 -0
  71. /package/es/{internal → utils}/cross-spawn/index.d.ts +0 -0
  72. /package/es/{internal → utils}/cross-spawn/index.js +0 -0
  73. /package/es/{internal → utils}/cross-spawn/package.json +0 -0
  74. /package/es/{internal → utils}/execa/LICENSE +0 -0
  75. /package/es/{internal → utils}/execa/index.d.ts +0 -0
  76. /package/es/{internal → utils}/execa/index.js +0 -0
  77. /package/es/{internal → utils}/execa/package.json +0 -0
  78. /package/es/{internal → utils}/merge-stream/LICENSE +0 -0
  79. /package/es/{internal → utils}/merge-stream/index.d.ts +0 -0
  80. /package/es/{internal → utils}/merge-stream/index.js +0 -0
  81. /package/es/{internal → utils}/merge-stream/package.json +0 -0
  82. /package/lib/{internal → utils}/cross-spawn/LICENSE +0 -0
  83. /package/lib/{internal → utils}/cross-spawn/index.d.ts +0 -0
  84. /package/lib/{internal → utils}/cross-spawn/package.json +0 -0
  85. /package/lib/{internal → utils}/execa/LICENSE +0 -0
  86. /package/lib/{internal → utils}/execa/index.d.ts +0 -0
  87. /package/lib/{internal → utils}/execa/package.json +0 -0
  88. /package/lib/{internal → utils}/merge-stream/LICENSE +0 -0
  89. /package/lib/{internal → utils}/merge-stream/index.d.ts +0 -0
  90. /package/lib/{internal → utils}/merge-stream/package.json +0 -0
@@ -0,0 +1 @@
1
+ {"name":"chalk","main":"index.js","license":"MIT","types":"index.d.ts"}
@@ -1,38 +1,45 @@
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, _templateObject2;
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
- import * as logger from '@umijs/utils/dist/logger';
8
- import { assert } from "../internal/utils";
9
- import 'zx/globals';
10
- export default function update() {
11
- return _update.apply(this, arguments);
12
- }
13
- function _update() {
14
- _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
15
- var pnpmVersion;
16
- return _regeneratorRuntime().wrap(function _callee$(_context) {
17
- while (1) switch (_context.prev = _context.next) {
18
- case 0:
19
- // Check pnpm version
20
- logger.event('check pnpm version');
21
- _context.next = 3;
22
- return $(_templateObject || (_templateObject = _taggedTemplateLiteral(["pnpm --version"])));
23
- case 3:
24
- pnpmVersion = _context.sent.stdout.trim();
25
- assert(!pnpmVersion.includes('not found'), 'pnpm: command not found please use npm install -g pnpm');
26
- logger.event('update @teams-max/*');
27
- _context.next = 8;
28
- return $(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["pnpm up \"@teams-max/*\""])));
29
- case 8:
30
- logger.info("Success update @teams-max/*");
31
- case 9:
32
- case "end":
33
- return _context.stop();
34
- }
35
- }, _callee);
36
- }));
37
- return _update.apply(this, arguments);
38
- }
5
+ var _require = require('escape-goat'),
6
+ htmlEscape = _require.htmlEscape;
7
+ var git = require("./git");
8
+ exports.getChangelog = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
9
+ var repoUrl, latest, log, commits;
10
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
11
+ while (1) switch (_context.prev = _context.next) {
12
+ case 0:
13
+ repoUrl = 'https://v.src.corp.qihoo.net/it_informatization/pro-teams';
14
+ _context.next = 3;
15
+ return git.latestTagOrFirstCommit();
16
+ case 3:
17
+ latest = _context.sent;
18
+ _context.next = 6;
19
+ return git.commitLogFromRevision(latest);
20
+ case 6:
21
+ log = _context.sent;
22
+ if (log) {
23
+ _context.next = 9;
24
+ break;
25
+ }
26
+ throw new Error("get changelog failed, no new commits was found.");
27
+ case 9:
28
+ commits = log.split('\n').map(function (commit) {
29
+ var splitIndex = commit.lastIndexOf(' ');
30
+ return {
31
+ message: commit.slice(0, splitIndex),
32
+ id: commit.slice(splitIndex + 1)
33
+ };
34
+ });
35
+ return _context.abrupt("return", function (nextTag) {
36
+ return commits.map(function (commit) {
37
+ return "- ".concat(htmlEscape(commit.message), " ").concat(commit.id);
38
+ }).join('\n') + "\n\n".concat(repoUrl, "/compare/").concat(latest, "...").concat(nextTag);
39
+ });
40
+ case 11:
41
+ case "end":
42
+ return _context.stop();
43
+ }
44
+ }, _callee);
45
+ }));
@@ -82,15 +82,13 @@ function datetimeFormat(value, format, isCoerce) {
82
82
  6: '六'
83
83
  };
84
84
  if (/(E+)/.test(format)) {
85
- // @ts-ignore
86
85
  format = format.replace(RegExp.$1, (RegExp.$1.length > 1 ? RegExp.$1.length > 2 ? '星期' : '周' : '') + week[date.getDay() + '']);
87
86
  }
88
87
  for (var k in o) {
89
88
  if (new RegExp('(' + k + ')').test(format)) {
90
- // @ts-ignore
91
89
  format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
92
90
  }
93
91
  }
94
92
  return format;
95
93
  }
96
- export default datetimeFormat;
94
+ module.exports = datetimeFormat;
@@ -0,0 +1,20 @@
1
+ var path = require('path');
2
+ var _require = require("./index"),
3
+ logStep = _require.logStep,
4
+ printErrorAndExit = _require.printErrorAndExit;
5
+ function defineConfig(config) {
6
+ if (!process.env.ASG_DIR) {
7
+ logStep('The Asgard directory does not exist, using default config...');
8
+ return config;
9
+ }
10
+ var iConfigFromPlugins = null;
11
+ try {
12
+ iConfigFromPlugins = require(path.join(process.env.ASG_DIR, 'base', 'pluginConfig.js'));
13
+ } catch (error) {
14
+ printErrorAndExit('The Asgard directory does not exist.', "Reason: ".concat(error.message));
15
+ return;
16
+ }
17
+ logStep('The Asgard directory exists, using config from plugins...');
18
+ return iConfigFromPlugins(config);
19
+ }
20
+ module.exports = defineConfig;
@@ -4,8 +4,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  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; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  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); }
7
- import spawn from '@umijs/utils/compiled/cross-spawn';
8
- export var exec = function exec(command, args, opts) {
7
+ var _require = require('child_process'),
8
+ spawn = _require.spawn;
9
+ module.exports = function exec(command, args, opts) {
9
10
  return new Promise(function (resolve, reject) {
10
11
  var child = spawn(command, args, _objectSpread({
11
12
  shell: true,
@@ -0,0 +1,9 @@
1
+ var _require = require('fs'),
2
+ readdirSync = _require.readdirSync;
3
+ var _require2 = require('path'),
4
+ join = _require2.join;
5
+ module.exports = function getPackages() {
6
+ return readdirSync(join(__dirname, '../../packages')).filter(function (pkg) {
7
+ return pkg.charAt(0) !== '.';
8
+ });
9
+ };
@@ -2,43 +2,95 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2
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; }
3
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); } }
4
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); }); }; }
5
- import * as logger from '@umijs/utils/dist/logger';
6
- import { assert } from "../internal/utils";
7
- import { join } from 'path';
8
- import { exec } from "../internal/exec";
9
- var execa = require("../internal/execa");
10
- var cwd = process.cwd();
11
- export default function start() {
12
- return _start.apply(this, arguments);
13
- }
14
- function _start() {
15
- _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
16
- var pkg, env, pnpmVersion;
17
- return _regeneratorRuntime().wrap(function _callee$(_context) {
18
- while (1) switch (_context.prev = _context.next) {
5
+ var _require = require("./index"),
6
+ execa = _require.execa,
7
+ chalk = _require.chalk,
8
+ yParser = _require.yParser;
9
+ exports.latestTag = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
10
+ var _yield$execa, stdout;
11
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
12
+ while (1) switch (_context.prev = _context.next) {
13
+ case 0:
14
+ _context.next = 2;
15
+ return execa('git', ['describe', '--abbrev=0', '--tags']);
16
+ case 2:
17
+ _yield$execa = _context.sent;
18
+ stdout = _yield$execa.stdout;
19
+ return _context.abrupt("return", stdout);
20
+ case 5:
21
+ case "end":
22
+ return _context.stop();
23
+ }
24
+ }, _callee);
25
+ }));
26
+ var firstCommit = /*#__PURE__*/function () {
27
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
28
+ var _yield$execa2, stdout;
29
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
30
+ while (1) switch (_context2.prev = _context2.next) {
19
31
  case 0:
20
- pkg = require(join(cwd, 'package.json')); // Do this as the first thing so that any code reading it knows the right env.
21
- process.env.MAX_APP_ENV = 'development';
22
- process.env.BABEL_ENV = 'development';
23
- process.env.MAX_APP_TYPE = 'max';
24
- process.env.MAX_APP_KEY = pkg.appKey || "";
25
- env = Object.create(process.env); // Check pnpm version
26
- logger.event('check pnpm version');
27
- pnpmVersion = execa.sync('pnpm', ['--version']).stdout;
28
- assert(!pnpmVersion.includes('not found'), 'pnpm: command not found please use npm install -g pnpm');
29
- logger.info("MAX_APP_ENV: ".concat(env.MAX_APP_ENV, " MAX_APP_KEY: ").concat(env.MAX_APP_KEY, " MAX_APP_TYPE: ").concat(env.MAX_APP_TYPE));
30
- logger.event('max dev');
31
- _context.next = 13;
32
- return exec('max', ['dev'], {
33
- env: env
34
- });
35
- case 13:
36
- logger.info("Success MAX_APP_ENV: ".concat(env.MAX_APP_ENV, " MAX_APP_KEY: ").concat(env.MAX_APP_KEY, " MAX_APP_TYPE: ").concat(env.MAX_APP_TYPE));
37
- case 14:
32
+ _context2.next = 2;
33
+ return execa('git', ['rev-list', '--max-parents=0', 'HEAD']);
34
+ case 2:
35
+ _yield$execa2 = _context2.sent;
36
+ stdout = _yield$execa2.stdout;
37
+ return _context2.abrupt("return", stdout);
38
+ case 5:
38
39
  case "end":
39
- return _context.stop();
40
+ return _context2.stop();
40
41
  }
41
- }, _callee);
42
+ }, _callee2);
42
43
  }));
43
- return _start.apply(this, arguments);
44
- }
44
+ return function firstCommit() {
45
+ return _ref2.apply(this, arguments);
46
+ };
47
+ }();
48
+ exports.latestTagOrFirstCommit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
49
+ var latest;
50
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
51
+ while (1) switch (_context3.prev = _context3.next) {
52
+ case 0:
53
+ _context3.prev = 0;
54
+ _context3.next = 3;
55
+ return exports.latestTag();
56
+ case 3:
57
+ latest = _context3.sent;
58
+ _context3.next = 11;
59
+ break;
60
+ case 6:
61
+ _context3.prev = 6;
62
+ _context3.t0 = _context3["catch"](0);
63
+ _context3.next = 10;
64
+ return firstCommit();
65
+ case 10:
66
+ latest = _context3.sent;
67
+ case 11:
68
+ return _context3.abrupt("return", latest);
69
+ case 12:
70
+ case "end":
71
+ return _context3.stop();
72
+ }
73
+ }, _callee3, null, [[0, 6]]);
74
+ }));
75
+ exports.commitLogFromRevision = /*#__PURE__*/function () {
76
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(revision) {
77
+ var _yield$execa3, stdout;
78
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
79
+ while (1) switch (_context4.prev = _context4.next) {
80
+ case 0:
81
+ _context4.next = 2;
82
+ return execa('git', ['log', '--format=%s %h', "".concat(revision, "..HEAD")]);
83
+ case 2:
84
+ _yield$execa3 = _context4.sent;
85
+ stdout = _yield$execa3.stdout;
86
+ return _context4.abrupt("return", stdout);
87
+ case 5:
88
+ case "end":
89
+ return _context4.stop();
90
+ }
91
+ }, _callee4);
92
+ }));
93
+ return function (_x) {
94
+ return _ref4.apply(this, arguments);
95
+ };
96
+ }();