@teams-max/mwsp 2.0.8 → 2.0.10

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/es/cli/build.js CHANGED
@@ -15,13 +15,13 @@ export default function build() {
15
15
  }
16
16
  function _build() {
17
17
  _build = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18
- var cfg, infra, ASG_DIR, appKey, APP_ENV, JENKINS_BUILD, MAX_SUB_APP, RESOURCE_URL, environment, questions, env;
18
+ var cfg, infra, ASG_DIR, appKey, subAppKey, APP_ENV, JENKINS_BUILD, MAX_SUB_APP, RESOURCE_URL, environment, questions, env;
19
19
  return _regeneratorRuntime().wrap(function _callee$(_context) {
20
20
  while (1) switch (_context.prev = _context.next) {
21
21
  case 0:
22
22
  // 配置检测 (package.json)
23
23
  cfg = getCfg();
24
- infra = cfg.infra, ASG_DIR = cfg.ASG_DIR, appKey = cfg.appKey, APP_ENV = cfg.APP_ENV, JENKINS_BUILD = cfg.JENKINS_BUILD, MAX_SUB_APP = cfg.MAX_SUB_APP, RESOURCE_URL = cfg.RESOURCE_URL;
24
+ infra = cfg.infra, ASG_DIR = cfg.ASG_DIR, appKey = cfg.appKey, subAppKey = cfg.subAppKey, APP_ENV = cfg.APP_ENV, JENKINS_BUILD = cfg.JENKINS_BUILD, MAX_SUB_APP = cfg.MAX_SUB_APP, RESOURCE_URL = cfg.RESOURCE_URL;
25
25
  _context.next = 4;
26
26
  return fetchRemoteRepository();
27
27
  case 4:
@@ -47,41 +47,43 @@ function _build() {
47
47
  env.ASG_DIR = ASG_DIR;
48
48
  logStep("Build ".concat(appKey), "ENV:".concat(environment));
49
49
  if (!((infra === null || infra === void 0 ? void 0 : infra.arch) === 'PRO')) {
50
- _context.next = 23;
50
+ _context.next = 24;
51
51
  break;
52
52
  }
53
53
  env.VUE_APP_ENV = environment;
54
54
  env.VUE_APP_TYPE = 'pro';
55
55
  env.VUE_JENKINS_BUILD = JENKINS_BUILD;
56
56
  env.VUE_APP_KEY = appKey;
57
- _context.next = 21;
57
+ env.VUE_SUB_APP_KEY = subAppKey;
58
+ _context.next = 22;
58
59
  return exec('vue-cli-service', ['build'], {
59
60
  env: env
60
61
  });
61
- case 21:
62
- _context.next = 32;
62
+ case 22:
63
+ _context.next = 34;
63
64
  break;
64
- case 23:
65
+ case 24:
65
66
  if (!((infra === null || infra === void 0 ? void 0 : infra.arch) === 'MAX')) {
66
- _context.next = 32;
67
+ _context.next = 34;
67
68
  break;
68
69
  }
69
70
  env.MAX_APP_ENV = environment;
70
71
  env.MAX_APP_TYPE = 'max';
71
72
  env.MAX_JENKINS_BUILD = JENKINS_BUILD;
72
73
  env.MAX_APP_KEY = appKey;
74
+ env.MAX_SUB_APP_KEY = subAppKey;
73
75
  env.MAX_SUB_APP = MAX_SUB_APP;
74
76
  env.RESOURCE_URL = RESOURCE_URL;
75
- _context.next = 32;
77
+ _context.next = 34;
76
78
  return exec('max', ['build'], {
77
79
  env: env
78
80
  });
79
- case 32:
80
- _context.next = 34;
81
+ case 34:
82
+ _context.next = 36;
81
83
  return exec('find', ['./dist', '-type', 'f', '-name', '*.map', '-exec', 'rm', '-f', '{}', '+'], {
82
84
  env: env
83
85
  });
84
- case 34:
86
+ case 36:
85
87
  case "end":
86
88
  return _context.stop();
87
89
  }
package/es/cli/start.js CHANGED
@@ -16,22 +16,24 @@ export default function start() {
16
16
  // });
17
17
  function _start() {
18
18
  _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
19
- var cfg, infra, appKey, ASG_DIR, env;
19
+ var cfg, infra, appKey, subAppKey, ASG_DIR, env;
20
20
  return _regeneratorRuntime().wrap(function _callee$(_context) {
21
21
  while (1) switch (_context.prev = _context.next) {
22
22
  case 0:
23
23
  // 配置检测 (package.json)
24
24
  cfg = getCfg();
25
- infra = cfg.infra, appKey = cfg.appKey, ASG_DIR = cfg.ASG_DIR;
25
+ infra = cfg.infra, appKey = cfg.appKey, subAppKey = cfg.subAppKey, ASG_DIR = cfg.ASG_DIR;
26
26
  env = Object.create(process.env); // Do this as the first thing so that any code reading it knows the right env.
27
27
  if ((infra === null || infra === void 0 ? void 0 : infra.arch) === 'PRO') {
28
28
  env.VUE_APP_TYPE = 'pro';
29
29
  env.VUE_APP_ENV = 'development';
30
30
  env.VUE_APP_KEY = appKey;
31
+ env.VUE_SUB_APP_KEY = subAppKey;
31
32
  } else if ((infra === null || infra === void 0 ? void 0 : infra.arch) === 'MAX') {
32
33
  env.MAX_APP_TYPE = 'max';
33
34
  env.MAX_APP_ENV = 'development';
34
35
  env.MAX_APP_KEY = appKey;
36
+ env.MAX_SUB_APP_KEY = subAppKey;
35
37
  }
36
38
  env.BABEL_ENV = 'development';
37
39
  env.ASG_DIR = ASG_DIR;
package/es/utils/index.js CHANGED
@@ -86,13 +86,12 @@ function _addIntegrateDeps() {
86
86
  _context.next = 6;
87
87
  break;
88
88
  }
89
- logStep("No integration packages are required.");
89
+ logStep('No integration packages are required.');
90
90
  return _context.abrupt("return");
91
91
  case 6:
92
- ;
93
92
  dependencies = {};
94
93
  devDependencies = {};
95
- _context.prev = 9;
94
+ _context.prev = 8;
96
95
  asgDependencies = require(join(ASG_DIR, 'base', 'integrationDeps.js')) || {};
97
96
  dependencies = integration.reduce(function (acc, item) {
98
97
  var _asgDependencies$item;
@@ -102,63 +101,63 @@ function _addIntegrateDeps() {
102
101
  var _asgDependencies$item2;
103
102
  return _objectSpread(_objectSpread({}, acc), ((_asgDependencies$item2 = asgDependencies[item]) === null || _asgDependencies$item2 === void 0 ? void 0 : _asgDependencies$item2.devDependencies) || {});
104
103
  }, {});
105
- _context.next = 19;
104
+ _context.next = 18;
106
105
  break;
107
- case 15:
108
- _context.prev = 15;
109
- _context.t0 = _context["catch"](9);
106
+ case 14:
107
+ _context.prev = 14;
108
+ _context.t0 = _context["catch"](8);
110
109
  printErrorAndExit('The Asgard directory does not exist.', "Reason: ".concat(_context.t0.message));
111
110
  return _context.abrupt("return");
112
- case 19:
111
+ case 18:
113
112
  asgDeps = pickDependencies(dependencies);
114
113
  asgDevDeps = pickDependencies(devDependencies, true);
115
- if (!((infra == null ? void 0 : infra.arch) === "PRO")) {
116
- _context.next = 32;
114
+ if (!((infra == null ? void 0 : infra.arch) === 'PRO')) {
115
+ _context.next = 31;
117
116
  break;
118
117
  }
119
118
  _context.t1 = !!asgDeps.length;
120
119
  if (!_context.t1) {
121
- _context.next = 26;
120
+ _context.next = 25;
122
121
  break;
123
122
  }
124
- _context.next = 26;
125
- return exec("yarn", ["add"].concat(_toConsumableArray(asgDeps)));
126
- case 26:
123
+ _context.next = 25;
124
+ return exec('yarn', ['add'].concat(_toConsumableArray(asgDeps)));
125
+ case 25:
127
126
  _context.t2 = !!asgDevDeps.length;
128
127
  if (!_context.t2) {
129
- _context.next = 30;
128
+ _context.next = 29;
130
129
  break;
131
130
  }
132
- _context.next = 30;
133
- return exec("yarn", ["add"].concat(_toConsumableArray(asgDevDeps), ["-D"]));
134
- case 30:
135
- _context.next = 41;
131
+ _context.next = 29;
132
+ return exec('yarn', ['add'].concat(_toConsumableArray(asgDevDeps), ['-D']));
133
+ case 29:
134
+ _context.next = 40;
136
135
  break;
137
- case 32:
138
- if (!((infra == null ? void 0 : infra.arch) === "MAX")) {
139
- _context.next = 41;
136
+ case 31:
137
+ if (!((infra == null ? void 0 : infra.arch) === 'MAX')) {
138
+ _context.next = 40;
140
139
  break;
141
140
  }
142
141
  _context.t3 = !!asgDeps.length;
143
142
  if (!_context.t3) {
144
- _context.next = 37;
143
+ _context.next = 36;
145
144
  break;
146
145
  }
147
- _context.next = 37;
148
- return exec("pnpm", ["add"].concat(_toConsumableArray(asgDeps)));
149
- case 37:
146
+ _context.next = 36;
147
+ return exec('pnpm', ['add'].concat(_toConsumableArray(asgDeps)));
148
+ case 36:
150
149
  _context.t4 = !!asgDevDeps.length;
151
150
  if (!_context.t4) {
152
- _context.next = 41;
151
+ _context.next = 40;
153
152
  break;
154
153
  }
155
- _context.next = 41;
156
- return exec("pnpm", ["add"].concat(_toConsumableArray(asgDevDeps), ["-D"]));
157
- case 41:
154
+ _context.next = 40;
155
+ return exec('pnpm', ['add'].concat(_toConsumableArray(asgDevDeps), ['-D']));
156
+ case 40:
158
157
  case "end":
159
158
  return _context.stop();
160
159
  }
161
- }, _callee, null, [[9, 15]]);
160
+ }, _callee, null, [[8, 14]]);
162
161
  }));
163
162
  return _addIntegrateDeps.apply(this, arguments);
164
163
  }
@@ -239,31 +238,39 @@ function _addAsgDependencies() {
239
238
  return _addAsgDependencies.apply(this, arguments);
240
239
  }
241
240
  function getCfg() {
241
+ var args = yParser(process.argv.slice(2));
242
+ var JENKINS_BUILD = args.jenkinsBuild || args.JENKINSBUILD || args.jenkins_build || args.JENKINS_BUILD;
242
243
  var pkgs = require(join(cwd, 'package.json'));
243
244
  var _pkgs$infra = pkgs.infra,
244
245
  infra = _pkgs$infra === void 0 ? {} : _pkgs$infra,
245
- appKey = pkgs.appKey;
246
- if (!(infra !== null && infra !== void 0 && infra.url) || !appKey) {
246
+ appKey = pkgs.appKey,
247
+ subAppKey = pkgs.subAppKey;
248
+ var projectUrl = '';
249
+ if (JENKINS_BUILD) {
250
+ projectUrl = infra.ssh || infra.url;
251
+ } else {
252
+ projectUrl = infra.http || infra.url;
253
+ }
254
+ if (!projectUrl || !appKey) {
247
255
  printErrorAndExit('Please check the infra and appKey in package.json.');
248
256
  }
249
- var args = yParser(process.argv.slice(2));
250
- var JENKINS_BUILD = args.jenkinsBuild || args.JENKINSBUILD || args.jenkins_build || args.JENKINS_BUILD;
251
257
  var APP_ENV = args.env || args.ENV || '';
252
258
  var ASG_BRANCH = args.asg_branch || args.ASG_BRANCH || '';
253
259
  var RESOURCE_URL = '';
254
260
  var SUB_APP = '';
255
261
  var archStr = 'unknown';
256
- if (infra.url.includes('teams-pro')) {
262
+ if (projectUrl.includes('teams-pro')) {
257
263
  archStr = 'PRO';
258
- } else if (infra.url.includes('teams-max')) {
264
+ } else if (projectUrl.includes('teams-max')) {
259
265
  archStr = 'MAX';
260
266
  RESOURCE_URL = args.versionUrl || args.RESOURCE_URL || '';
261
267
  SUB_APP = args.subApp || args.SUB_APP || '';
262
268
  }
263
269
  return {
264
270
  appKey: appKey,
271
+ subAppKey: subAppKey,
265
272
  infra: {
266
- url: infra.url,
273
+ url: projectUrl,
267
274
  arch: archStr
268
275
  },
269
276
  ASG_DIR: asgDir,
@@ -295,7 +302,7 @@ function fetchRemoteRepository() {
295
302
  }
296
303
  function _fetchRemoteRepository() {
297
304
  _fetchRemoteRepository = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
298
- var cfg, infra, directory, ASG_BRANCH, JENKINS_BUILD, remoteUrl, doesExist, _yield$inquirer$promp, syncUp, infraBranchsOutput, infraBranchArray, filteredBranches, defaultBrancheIdx, questions;
305
+ var cfg, infra, directory, ASG_BRANCH, JENKINS_BUILD, remoteUrl, doesExist, timer, _yield$Promise$race, syncUp, infraBranchsOutput, infraBranchArray, filteredBranches, defaultBrancheIdx, questions;
299
306
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
300
307
  while (1) switch (_context3.prev = _context3.next) {
301
308
  case 0:
@@ -330,15 +337,24 @@ function _fetchRemoteRepository() {
330
337
  break;
331
338
  }
332
339
  _context3.next = 22;
333
- return inquirer.prompt([{
340
+ return Promise.race([inquirer.prompt([{
334
341
  type: 'confirm',
335
342
  name: 'syncUp',
336
- message: '同步远端仓库',
343
+ message: '同步远端仓库(5s后跳过同步)',
337
344
  default: 'Y'
338
- }]);
345
+ }]).then(function (answer) {
346
+ timer && clearTimeout(timer);
347
+ return answer;
348
+ }), new Promise(function (resolve) {
349
+ timer = setTimeout(function () {
350
+ return resolve({
351
+ syncUp: false
352
+ });
353
+ }, 5e3);
354
+ })]);
339
355
  case 22:
340
- _yield$inquirer$promp = _context3.sent;
341
- syncUp = _yield$inquirer$promp.syncUp;
356
+ _yield$Promise$race = _context3.sent;
357
+ syncUp = _yield$Promise$race.syncUp;
342
358
  if (syncUp) {
343
359
  _context3.next = 26;
344
360
  break;
package/lib/cli/build.js CHANGED
@@ -33,6 +33,7 @@ async function build() {
33
33
  infra,
34
34
  ASG_DIR,
35
35
  appKey,
36
+ subAppKey,
36
37
  APP_ENV,
37
38
  JENKINS_BUILD,
38
39
  MAX_SUB_APP,
@@ -61,6 +62,7 @@ async function build() {
61
62
  env.VUE_APP_TYPE = "pro";
62
63
  env.VUE_JENKINS_BUILD = JENKINS_BUILD;
63
64
  env.VUE_APP_KEY = appKey;
65
+ env.VUE_SUB_APP_KEY = subAppKey;
64
66
  await exec("vue-cli-service", ["build"], {
65
67
  env
66
68
  });
@@ -69,6 +71,7 @@ async function build() {
69
71
  env.MAX_APP_TYPE = "max";
70
72
  env.MAX_JENKINS_BUILD = JENKINS_BUILD;
71
73
  env.MAX_APP_KEY = appKey;
74
+ env.MAX_SUB_APP_KEY = subAppKey;
72
75
  env.MAX_SUB_APP = MAX_SUB_APP;
73
76
  env.RESOURCE_URL = RESOURCE_URL;
74
77
  await exec("max", ["build"], {
package/lib/cli/start.js CHANGED
@@ -26,16 +26,18 @@ var exec = require("../utils/exec");
26
26
  var { getCfg, fetchRemoteRepository } = require("../utils");
27
27
  async function start() {
28
28
  const cfg = getCfg();
29
- const { infra, appKey, ASG_DIR } = cfg;
29
+ const { infra, appKey, subAppKey, ASG_DIR } = cfg;
30
30
  const env = Object.create(process.env);
31
31
  if ((infra == null ? void 0 : infra.arch) === "PRO") {
32
32
  env.VUE_APP_TYPE = "pro";
33
33
  env.VUE_APP_ENV = "development";
34
34
  env.VUE_APP_KEY = appKey;
35
+ env.VUE_SUB_APP_KEY = subAppKey;
35
36
  } else if ((infra == null ? void 0 : infra.arch) === "MAX") {
36
37
  env.MAX_APP_TYPE = "max";
37
38
  env.MAX_APP_ENV = "development";
38
39
  env.MAX_APP_KEY = appKey;
40
+ env.MAX_SUB_APP_KEY = subAppKey;
39
41
  }
40
42
  env.BABEL_ENV = "development";
41
43
  env.ASG_DIR = ASG_DIR;
@@ -43,25 +43,30 @@ async function addIntegrateDeps(cfg) {
43
43
  logStep("No integration packages are required.");
44
44
  return;
45
45
  }
46
- ;
47
46
  let dependencies = {};
48
47
  let devDependencies = {};
49
48
  try {
50
49
  const asgDependencies = require(join(ASG_DIR, "base", "integrationDeps.js")) || {};
51
- dependencies = integration.reduce((acc, item) => {
52
- var _a;
53
- return {
54
- ...acc,
55
- ...((_a = asgDependencies[item]) == null ? void 0 : _a.dependencies) || {}
56
- };
57
- }, {});
58
- devDependencies = integration.reduce((acc, item) => {
59
- var _a;
60
- return {
61
- ...acc,
62
- ...((_a = asgDependencies[item]) == null ? void 0 : _a.devDependencies) || {}
63
- };
64
- }, {});
50
+ dependencies = integration.reduce(
51
+ (acc, item) => {
52
+ var _a;
53
+ return {
54
+ ...acc,
55
+ ...((_a = asgDependencies[item]) == null ? void 0 : _a.dependencies) || {}
56
+ };
57
+ },
58
+ {}
59
+ );
60
+ devDependencies = integration.reduce(
61
+ (acc, item) => {
62
+ var _a;
63
+ return {
64
+ ...acc,
65
+ ...((_a = asgDependencies[item]) == null ? void 0 : _a.devDependencies) || {}
66
+ };
67
+ },
68
+ {}
69
+ );
65
70
  } catch (error) {
66
71
  printErrorAndExit(
67
72
  "The Asgard directory does not exist.",
@@ -105,29 +110,36 @@ async function addAsgDependencies(cfg) {
105
110
  }
106
111
  }
107
112
  function getCfg() {
113
+ const args = yParser(process.argv.slice(2));
114
+ const JENKINS_BUILD = args.jenkinsBuild || args.JENKINSBUILD || args.jenkins_build || args.JENKINS_BUILD;
108
115
  const pkgs = require(join(cwd, "package.json"));
109
- const { infra = {}, appKey } = pkgs;
110
- if (!(infra == null ? void 0 : infra.url) || !appKey) {
116
+ const { infra = {}, appKey, subAppKey } = pkgs;
117
+ let projectUrl = "";
118
+ if (JENKINS_BUILD) {
119
+ projectUrl = infra.ssh || infra.url;
120
+ } else {
121
+ projectUrl = infra.http || infra.url;
122
+ }
123
+ if (!projectUrl || !appKey) {
111
124
  printErrorAndExit("Please check the infra and appKey in package.json.");
112
125
  }
113
- const args = yParser(process.argv.slice(2));
114
- const JENKINS_BUILD = args.jenkinsBuild || args.JENKINSBUILD || args.jenkins_build || args.JENKINS_BUILD;
115
126
  const APP_ENV = args.env || args.ENV || "";
116
127
  const ASG_BRANCH = args.asg_branch || args.ASG_BRANCH || "";
117
128
  let RESOURCE_URL = "";
118
129
  let SUB_APP = "";
119
130
  let archStr = "unknown";
120
- if (infra.url.includes("teams-pro")) {
131
+ if (projectUrl.includes("teams-pro")) {
121
132
  archStr = "PRO";
122
- } else if (infra.url.includes("teams-max")) {
133
+ } else if (projectUrl.includes("teams-max")) {
123
134
  archStr = "MAX";
124
135
  RESOURCE_URL = args.versionUrl || args.RESOURCE_URL || "";
125
136
  SUB_APP = args.subApp || args.SUB_APP || "";
126
137
  }
127
138
  return {
128
139
  appKey,
140
+ subAppKey,
129
141
  infra: {
130
- url: infra.url,
142
+ url: projectUrl,
131
143
  arch: archStr
132
144
  },
133
145
  ASG_DIR: asgDir,
@@ -167,13 +179,22 @@ async function fetchRemoteRepository() {
167
179
  return;
168
180
  } else {
169
181
  if (!JENKINS_BUILD) {
170
- const { syncUp } = await inquirer.prompt([
171
- {
172
- type: "confirm",
173
- name: "syncUp",
174
- message: "\u540C\u6B65\u8FDC\u7AEF\u4ED3\u5E93",
175
- default: "Y"
176
- }
182
+ let timer;
183
+ const { syncUp } = await Promise.race([
184
+ inquirer.prompt([
185
+ {
186
+ type: "confirm",
187
+ name: "syncUp",
188
+ message: "\u540C\u6B65\u8FDC\u7AEF\u4ED3\u5E93(5s\u540E\u8DF3\u8FC7\u540C\u6B65)",
189
+ default: "Y"
190
+ }
191
+ ]).then((answer) => {
192
+ timer && clearTimeout(timer);
193
+ return answer;
194
+ }),
195
+ new Promise((resolve) => {
196
+ timer = setTimeout(() => resolve({ syncUp: false }), 5e3);
197
+ })
177
198
  ]);
178
199
  if (!syncUp)
179
200
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teams-max/mwsp",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "description": "@teams-max/mwsp",
5
5
  "homepage": "https://gitlab.daikuan.qihoo.net/efficacy-fe/teams-max/-/tree/master/packages/mwsp",
6
6
  "repository": {