@teams-max/mwsp 2.0.7 → 2.0.9
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/utils/index.js +200 -81
- package/lib/utils/index.js +81 -14
- package/package.json +1 -1
package/es/utils/index.js
CHANGED
|
@@ -4,6 +4,11 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
4
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."); }
|
|
5
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
6
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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); }
|
|
7
12
|
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); } }
|
|
8
13
|
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); }); }; }
|
|
9
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
@@ -63,101 +68,199 @@ function pickDependencies(dependencies, isDev) {
|
|
|
63
68
|
return "".concat(key, "@").concat(value);
|
|
64
69
|
});
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
|
|
72
|
+
//获取需要集成包的依赖
|
|
73
|
+
function addIntegrateDeps(_x2) {
|
|
74
|
+
return _addIntegrateDeps.apply(this, arguments);
|
|
75
|
+
} //安装Asgard的依赖
|
|
76
|
+
function _addIntegrateDeps() {
|
|
77
|
+
_addIntegrateDeps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cfg) {
|
|
78
|
+
var infra, ASG_DIR, pkgs, integration, dependencies, devDependencies, asgDependencies, asgDeps, asgDevDeps;
|
|
79
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
80
|
+
while (1) switch (_context.prev = _context.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
infra = cfg.infra, ASG_DIR = cfg.ASG_DIR;
|
|
83
|
+
pkgs = require(join(cwd, 'package.json'));
|
|
84
|
+
integration = pkgs.integration || [];
|
|
85
|
+
if (integration.length) {
|
|
86
|
+
_context.next = 6;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
logStep('No integration packages are required.');
|
|
90
|
+
return _context.abrupt("return");
|
|
91
|
+
case 6:
|
|
92
|
+
dependencies = {};
|
|
93
|
+
devDependencies = {};
|
|
94
|
+
_context.prev = 8;
|
|
95
|
+
asgDependencies = require(join(ASG_DIR, 'base', 'integrationDeps.js')) || {};
|
|
96
|
+
dependencies = integration.reduce(function (acc, item) {
|
|
97
|
+
var _asgDependencies$item;
|
|
98
|
+
return _objectSpread(_objectSpread({}, acc), ((_asgDependencies$item = asgDependencies[item]) === null || _asgDependencies$item === void 0 ? void 0 : _asgDependencies$item.dependencies) || {});
|
|
99
|
+
}, {});
|
|
100
|
+
devDependencies = integration.reduce(function (acc, item) {
|
|
101
|
+
var _asgDependencies$item2;
|
|
102
|
+
return _objectSpread(_objectSpread({}, acc), ((_asgDependencies$item2 = asgDependencies[item]) === null || _asgDependencies$item2 === void 0 ? void 0 : _asgDependencies$item2.devDependencies) || {});
|
|
103
|
+
}, {});
|
|
104
|
+
_context.next = 18;
|
|
105
|
+
break;
|
|
106
|
+
case 14:
|
|
107
|
+
_context.prev = 14;
|
|
108
|
+
_context.t0 = _context["catch"](8);
|
|
109
|
+
printErrorAndExit('The Asgard directory does not exist.', "Reason: ".concat(_context.t0.message));
|
|
110
|
+
return _context.abrupt("return");
|
|
111
|
+
case 18:
|
|
112
|
+
asgDeps = pickDependencies(dependencies);
|
|
113
|
+
asgDevDeps = pickDependencies(devDependencies, true);
|
|
114
|
+
if (!((infra == null ? void 0 : infra.arch) === 'PRO')) {
|
|
115
|
+
_context.next = 31;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
_context.t1 = !!asgDeps.length;
|
|
119
|
+
if (!_context.t1) {
|
|
120
|
+
_context.next = 25;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
_context.next = 25;
|
|
124
|
+
return exec('yarn', ['add'].concat(_toConsumableArray(asgDeps)));
|
|
125
|
+
case 25:
|
|
126
|
+
_context.t2 = !!asgDevDeps.length;
|
|
127
|
+
if (!_context.t2) {
|
|
128
|
+
_context.next = 29;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
_context.next = 29;
|
|
132
|
+
return exec('yarn', ['add'].concat(_toConsumableArray(asgDevDeps), ['-D']));
|
|
133
|
+
case 29:
|
|
134
|
+
_context.next = 40;
|
|
135
|
+
break;
|
|
136
|
+
case 31:
|
|
137
|
+
if (!((infra == null ? void 0 : infra.arch) === 'MAX')) {
|
|
138
|
+
_context.next = 40;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
_context.t3 = !!asgDeps.length;
|
|
142
|
+
if (!_context.t3) {
|
|
143
|
+
_context.next = 36;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
_context.next = 36;
|
|
147
|
+
return exec('pnpm', ['add'].concat(_toConsumableArray(asgDeps)));
|
|
148
|
+
case 36:
|
|
149
|
+
_context.t4 = !!asgDevDeps.length;
|
|
150
|
+
if (!_context.t4) {
|
|
151
|
+
_context.next = 40;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
_context.next = 40;
|
|
155
|
+
return exec('pnpm', ['add'].concat(_toConsumableArray(asgDevDeps), ['-D']));
|
|
156
|
+
case 40:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context.stop();
|
|
159
|
+
}
|
|
160
|
+
}, _callee, null, [[8, 14]]);
|
|
161
|
+
}));
|
|
162
|
+
return _addIntegrateDeps.apply(this, arguments);
|
|
163
|
+
}
|
|
164
|
+
function addAsgDependencies(_x3) {
|
|
68
165
|
return _addAsgDependencies.apply(this, arguments);
|
|
69
166
|
}
|
|
70
167
|
function _addAsgDependencies() {
|
|
71
|
-
_addAsgDependencies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
72
|
-
var infra, ASG_DIR, dependencies, devDependencies, asgDeps, asgDevDeps;
|
|
73
|
-
return _regeneratorRuntime().wrap(function
|
|
74
|
-
while (1) switch (
|
|
168
|
+
_addAsgDependencies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(cfg) {
|
|
169
|
+
var infra, ASG_DIR, dependencies, devDependencies, asgDependencies, asgDeps, asgDevDeps;
|
|
170
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
171
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
75
172
|
case 0:
|
|
76
173
|
infra = cfg.infra, ASG_DIR = cfg.ASG_DIR;
|
|
77
174
|
dependencies = {};
|
|
78
175
|
devDependencies = {};
|
|
79
|
-
|
|
176
|
+
_context2.prev = 3;
|
|
80
177
|
asgDependencies = require(join(ASG_DIR, 'base', 'dependencies.js')) || {};
|
|
81
178
|
dependencies = asgDependencies.dependencies || {};
|
|
82
179
|
devDependencies = asgDependencies.devDependencies || {};
|
|
83
|
-
|
|
180
|
+
_context2.next = 13;
|
|
84
181
|
break;
|
|
85
182
|
case 9:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
printErrorAndExit('The Asgard directory does not exist.', "Reason: ".concat(
|
|
89
|
-
return
|
|
183
|
+
_context2.prev = 9;
|
|
184
|
+
_context2.t0 = _context2["catch"](3);
|
|
185
|
+
printErrorAndExit('The Asgard directory does not exist.', "Reason: ".concat(_context2.t0.message));
|
|
186
|
+
return _context2.abrupt("return");
|
|
90
187
|
case 13:
|
|
91
188
|
asgDeps = pickDependencies(dependencies);
|
|
92
189
|
asgDevDeps = pickDependencies(devDependencies, true);
|
|
93
190
|
if (!((infra === null || infra === void 0 ? void 0 : infra.arch) === 'PRO')) {
|
|
94
|
-
|
|
191
|
+
_context2.next = 26;
|
|
95
192
|
break;
|
|
96
193
|
}
|
|
97
|
-
|
|
98
|
-
if (!
|
|
99
|
-
|
|
194
|
+
_context2.t1 = !!asgDeps.length;
|
|
195
|
+
if (!_context2.t1) {
|
|
196
|
+
_context2.next = 20;
|
|
100
197
|
break;
|
|
101
198
|
}
|
|
102
|
-
|
|
199
|
+
_context2.next = 20;
|
|
103
200
|
return exec('yarn', ['add'].concat(_toConsumableArray(asgDeps)));
|
|
104
201
|
case 20:
|
|
105
|
-
|
|
106
|
-
if (!
|
|
107
|
-
|
|
202
|
+
_context2.t2 = !!asgDevDeps.length;
|
|
203
|
+
if (!_context2.t2) {
|
|
204
|
+
_context2.next = 24;
|
|
108
205
|
break;
|
|
109
206
|
}
|
|
110
|
-
|
|
207
|
+
_context2.next = 24;
|
|
111
208
|
return exec('yarn', ['add'].concat(_toConsumableArray(asgDevDeps), ['-D']));
|
|
112
209
|
case 24:
|
|
113
|
-
|
|
210
|
+
_context2.next = 35;
|
|
114
211
|
break;
|
|
115
212
|
case 26:
|
|
116
213
|
if (!((infra === null || infra === void 0 ? void 0 : infra.arch) === 'MAX')) {
|
|
117
|
-
|
|
214
|
+
_context2.next = 35;
|
|
118
215
|
break;
|
|
119
216
|
}
|
|
120
|
-
|
|
121
|
-
if (!
|
|
122
|
-
|
|
217
|
+
_context2.t3 = !!asgDeps.length;
|
|
218
|
+
if (!_context2.t3) {
|
|
219
|
+
_context2.next = 31;
|
|
123
220
|
break;
|
|
124
221
|
}
|
|
125
|
-
|
|
222
|
+
_context2.next = 31;
|
|
126
223
|
return exec('pnpm', ['add'].concat(_toConsumableArray(asgDeps)));
|
|
127
224
|
case 31:
|
|
128
|
-
|
|
129
|
-
if (!
|
|
130
|
-
|
|
225
|
+
_context2.t4 = !!asgDevDeps.length;
|
|
226
|
+
if (!_context2.t4) {
|
|
227
|
+
_context2.next = 35;
|
|
131
228
|
break;
|
|
132
229
|
}
|
|
133
|
-
|
|
230
|
+
_context2.next = 35;
|
|
134
231
|
return exec('pnpm', ['add'].concat(_toConsumableArray(asgDevDeps), ['-D']));
|
|
135
232
|
case 35:
|
|
136
233
|
case "end":
|
|
137
|
-
return
|
|
234
|
+
return _context2.stop();
|
|
138
235
|
}
|
|
139
|
-
},
|
|
236
|
+
}, _callee2, null, [[3, 9]]);
|
|
140
237
|
}));
|
|
141
238
|
return _addAsgDependencies.apply(this, arguments);
|
|
142
239
|
}
|
|
143
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;
|
|
144
243
|
var pkgs = require(join(cwd, 'package.json'));
|
|
145
244
|
var _pkgs$infra = pkgs.infra,
|
|
146
245
|
infra = _pkgs$infra === void 0 ? {} : _pkgs$infra,
|
|
147
246
|
appKey = pkgs.appKey;
|
|
148
|
-
|
|
247
|
+
var projectUrl = '';
|
|
248
|
+
if (JENKINS_BUILD) {
|
|
249
|
+
projectUrl = infra.ssh || infra.url;
|
|
250
|
+
} else {
|
|
251
|
+
projectUrl = infra.http || infra.url;
|
|
252
|
+
}
|
|
253
|
+
if (!projectUrl || !appKey) {
|
|
149
254
|
printErrorAndExit('Please check the infra and appKey in package.json.');
|
|
150
255
|
}
|
|
151
|
-
var args = yParser(process.argv.slice(2));
|
|
152
|
-
var JENKINS_BUILD = args.jenkinsBuild || args.JENKINSBUILD || args.jenkins_build || args.JENKINS_BUILD;
|
|
153
256
|
var APP_ENV = args.env || args.ENV || '';
|
|
154
257
|
var ASG_BRANCH = args.asg_branch || args.ASG_BRANCH || '';
|
|
155
258
|
var RESOURCE_URL = '';
|
|
156
259
|
var SUB_APP = '';
|
|
157
260
|
var archStr = 'unknown';
|
|
158
|
-
if (
|
|
261
|
+
if (projectUrl.includes('teams-pro')) {
|
|
159
262
|
archStr = 'PRO';
|
|
160
|
-
} else if (
|
|
263
|
+
} else if (projectUrl.includes('teams-max')) {
|
|
161
264
|
archStr = 'MAX';
|
|
162
265
|
RESOURCE_URL = args.versionUrl || args.RESOURCE_URL || '';
|
|
163
266
|
SUB_APP = args.subApp || args.SUB_APP || '';
|
|
@@ -165,7 +268,7 @@ function getCfg() {
|
|
|
165
268
|
return {
|
|
166
269
|
appKey: appKey,
|
|
167
270
|
infra: {
|
|
168
|
-
url:
|
|
271
|
+
url: projectUrl,
|
|
169
272
|
arch: archStr
|
|
170
273
|
},
|
|
171
274
|
ASG_DIR: asgDir,
|
|
@@ -196,75 +299,84 @@ function fetchRemoteRepository() {
|
|
|
196
299
|
return _fetchRemoteRepository.apply(this, arguments);
|
|
197
300
|
}
|
|
198
301
|
function _fetchRemoteRepository() {
|
|
199
|
-
_fetchRemoteRepository = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
200
|
-
var cfg, infra, directory, ASG_BRANCH, JENKINS_BUILD, remoteUrl, doesExist, _yield$
|
|
201
|
-
return _regeneratorRuntime().wrap(function
|
|
202
|
-
while (1) switch (
|
|
302
|
+
_fetchRemoteRepository = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
303
|
+
var cfg, infra, directory, ASG_BRANCH, JENKINS_BUILD, remoteUrl, doesExist, timer, _yield$Promise$race, syncUp, infraBranchsOutput, infraBranchArray, filteredBranches, defaultBrancheIdx, questions;
|
|
304
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
305
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
203
306
|
case 0:
|
|
204
307
|
cfg = getCfg();
|
|
205
308
|
infra = cfg.infra, directory = cfg.ASG_DIR, ASG_BRANCH = cfg.ASG_BRANCH, JENKINS_BUILD = cfg.JENKINS_BUILD;
|
|
206
309
|
remoteUrl = infra.url;
|
|
207
310
|
doesExist = checkDirectoryExistsSync(directory);
|
|
208
311
|
if (doesExist) {
|
|
209
|
-
|
|
312
|
+
_context3.next = 14;
|
|
210
313
|
break;
|
|
211
314
|
}
|
|
212
315
|
logStep('Cloning the repository from GitHub...');
|
|
213
316
|
execa.sync('git', ['clone', '-b', 'feature-asg', remoteUrl, directory]);
|
|
214
317
|
logStep('Cloning completed.');
|
|
215
318
|
logStep('Installing dependencies...');
|
|
216
|
-
|
|
319
|
+
_context3.next = 11;
|
|
217
320
|
return addAsgDependencies(cfg);
|
|
218
321
|
case 11:
|
|
219
322
|
logStep('Installation completed.');
|
|
220
|
-
|
|
323
|
+
_context3.next = 26;
|
|
221
324
|
break;
|
|
222
325
|
case 14:
|
|
223
326
|
if (!(JENKINS_BUILD && !ASG_BRANCH)) {
|
|
224
|
-
|
|
327
|
+
_context3.next = 19;
|
|
225
328
|
break;
|
|
226
329
|
}
|
|
227
330
|
logStep('Jenkins build detected. Skipping sync up.');
|
|
228
|
-
return
|
|
331
|
+
return _context3.abrupt("return");
|
|
229
332
|
case 19:
|
|
230
333
|
if (JENKINS_BUILD) {
|
|
231
|
-
|
|
334
|
+
_context3.next = 26;
|
|
232
335
|
break;
|
|
233
336
|
}
|
|
234
|
-
|
|
235
|
-
return inquirer.prompt([{
|
|
337
|
+
_context3.next = 22;
|
|
338
|
+
return Promise.race([inquirer.prompt([{
|
|
236
339
|
type: 'confirm',
|
|
237
340
|
name: 'syncUp',
|
|
238
|
-
message: '同步远端仓库',
|
|
341
|
+
message: '同步远端仓库(5s后跳过同步)',
|
|
239
342
|
default: 'Y'
|
|
240
|
-
}])
|
|
343
|
+
}]).then(function (answer) {
|
|
344
|
+
timer && clearTimeout(timer);
|
|
345
|
+
return answer;
|
|
346
|
+
}), new Promise(function (resolve) {
|
|
347
|
+
timer = setTimeout(function () {
|
|
348
|
+
return resolve({
|
|
349
|
+
syncUp: false
|
|
350
|
+
});
|
|
351
|
+
}, 5e3);
|
|
352
|
+
})]);
|
|
241
353
|
case 22:
|
|
242
|
-
_yield$
|
|
243
|
-
syncUp = _yield$
|
|
354
|
+
_yield$Promise$race = _context3.sent;
|
|
355
|
+
syncUp = _yield$Promise$race.syncUp;
|
|
244
356
|
if (syncUp) {
|
|
245
|
-
|
|
357
|
+
_context3.next = 26;
|
|
246
358
|
break;
|
|
247
359
|
}
|
|
248
|
-
return
|
|
360
|
+
return _context3.abrupt("return");
|
|
249
361
|
case 26:
|
|
250
362
|
if (!(!doesExist && JENKINS_BUILD && !ASG_BRANCH)) {
|
|
251
|
-
|
|
363
|
+
_context3.next = 29;
|
|
252
364
|
break;
|
|
253
365
|
}
|
|
254
366
|
printErrorAndExit('Jenkins build detected. The branch parameter is missing!');
|
|
255
|
-
return
|
|
367
|
+
return _context3.abrupt("return");
|
|
256
368
|
case 29:
|
|
257
369
|
logStep('Synchronizing with the remote repository...');
|
|
258
370
|
process.chdir(directory);
|
|
259
|
-
|
|
371
|
+
_context3.prev = 31;
|
|
260
372
|
execa.sync('git', ['fetch', 'origin', '--prune']);
|
|
261
373
|
if (!(JENKINS_BUILD && ASG_BRANCH)) {
|
|
262
|
-
|
|
374
|
+
_context3.next = 38;
|
|
263
375
|
break;
|
|
264
376
|
}
|
|
265
377
|
execa.sync('git', ['checkout', ASG_BRANCH]);
|
|
266
378
|
logStep("Anto switched to branch:", ASG_BRANCH);
|
|
267
|
-
|
|
379
|
+
_context3.next = 59;
|
|
268
380
|
break;
|
|
269
381
|
case 38:
|
|
270
382
|
// 获取远程分支列表
|
|
@@ -286,7 +398,7 @@ function _fetchRemoteRepository() {
|
|
|
286
398
|
}
|
|
287
399
|
|
|
288
400
|
// 提示用户选择分支
|
|
289
|
-
|
|
401
|
+
_context3.next = 46;
|
|
290
402
|
return inquirer.prompt([{
|
|
291
403
|
type: 'list',
|
|
292
404
|
name: 'branch',
|
|
@@ -300,29 +412,36 @@ function _fetchRemoteRepository() {
|
|
|
300
412
|
}
|
|
301
413
|
}]);
|
|
302
414
|
case 46:
|
|
303
|
-
questions =
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
415
|
+
questions = _context3.sent;
|
|
416
|
+
_context3.prev = 47;
|
|
417
|
+
execa.sync('git', ['checkout', '-q', questions.branch]);
|
|
418
|
+
logStep("Switched to branch:", questions.branch);
|
|
419
|
+
logStep('Installing dependencies...');
|
|
420
|
+
_context3.next = 53;
|
|
421
|
+
return addIntegrateDeps(cfg);
|
|
422
|
+
case 53:
|
|
423
|
+
logStep('Installation completed.');
|
|
424
|
+
_context3.next = 59;
|
|
425
|
+
break;
|
|
426
|
+
case 56:
|
|
427
|
+
_context3.prev = 56;
|
|
428
|
+
_context3.t0 = _context3["catch"](47);
|
|
429
|
+
printErrorAndExit("Failed to switch to branch '".concat(questions.branch, "'. Reason: ").concat(_context3.t0.message));
|
|
430
|
+
case 59:
|
|
431
|
+
_context3.next = 64;
|
|
313
432
|
break;
|
|
314
|
-
case
|
|
315
|
-
|
|
316
|
-
|
|
433
|
+
case 61:
|
|
434
|
+
_context3.prev = 61;
|
|
435
|
+
_context3.t1 = _context3["catch"](31);
|
|
317
436
|
// 获取分支列表时的错误处理
|
|
318
|
-
printErrorAndExit("An error occurred while fetching remote branches: ".concat(
|
|
319
|
-
case
|
|
437
|
+
printErrorAndExit("An error occurred while fetching remote branches: ".concat(_context3.t1.message));
|
|
438
|
+
case 64:
|
|
320
439
|
process.chdir(cwd);
|
|
321
|
-
case
|
|
440
|
+
case 65:
|
|
322
441
|
case "end":
|
|
323
|
-
return
|
|
442
|
+
return _context3.stop();
|
|
324
443
|
}
|
|
325
|
-
},
|
|
444
|
+
}, _callee3, null, [[31, 61], [47, 56]]);
|
|
326
445
|
}));
|
|
327
446
|
return _fetchRemoteRepository.apply(this, arguments);
|
|
328
447
|
}
|
package/lib/utils/index.js
CHANGED
|
@@ -35,12 +35,61 @@ function pickDependencies(dependencies, isDev) {
|
|
|
35
35
|
);
|
|
36
36
|
return dependenciesList.map(([key, value]) => `${key}@${value}`);
|
|
37
37
|
}
|
|
38
|
+
async function addIntegrateDeps(cfg) {
|
|
39
|
+
const { infra, ASG_DIR } = cfg;
|
|
40
|
+
const pkgs = require(join(cwd, "package.json"));
|
|
41
|
+
const integration = pkgs.integration || [];
|
|
42
|
+
if (!integration.length) {
|
|
43
|
+
logStep("No integration packages are required.");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
let dependencies = {};
|
|
47
|
+
let devDependencies = {};
|
|
48
|
+
try {
|
|
49
|
+
const asgDependencies = require(join(ASG_DIR, "base", "integrationDeps.js")) || {};
|
|
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
|
+
);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
printErrorAndExit(
|
|
72
|
+
"The Asgard directory does not exist.",
|
|
73
|
+
`Reason: ${error.message}`
|
|
74
|
+
);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const asgDeps = pickDependencies(dependencies);
|
|
78
|
+
const asgDevDeps = pickDependencies(devDependencies, true);
|
|
79
|
+
if ((infra == null ? void 0 : infra.arch) === "PRO") {
|
|
80
|
+
!!asgDeps.length && await exec("yarn", ["add", ...asgDeps]);
|
|
81
|
+
!!asgDevDeps.length && await exec("yarn", ["add", ...asgDevDeps, "-D"]);
|
|
82
|
+
} else if ((infra == null ? void 0 : infra.arch) === "MAX") {
|
|
83
|
+
!!asgDeps.length && await exec("pnpm", ["add", ...asgDeps]);
|
|
84
|
+
!!asgDevDeps.length && await exec("pnpm", ["add", ...asgDevDeps, "-D"]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
38
87
|
async function addAsgDependencies(cfg) {
|
|
39
88
|
const { infra, ASG_DIR } = cfg;
|
|
40
89
|
let dependencies = {};
|
|
41
90
|
let devDependencies = {};
|
|
42
91
|
try {
|
|
43
|
-
asgDependencies = require(join(ASG_DIR, "base", "dependencies.js")) || {};
|
|
92
|
+
const asgDependencies = require(join(ASG_DIR, "base", "dependencies.js")) || {};
|
|
44
93
|
dependencies = asgDependencies.dependencies || {};
|
|
45
94
|
devDependencies = asgDependencies.devDependencies || {};
|
|
46
95
|
} catch (error) {
|
|
@@ -61,21 +110,27 @@ async function addAsgDependencies(cfg) {
|
|
|
61
110
|
}
|
|
62
111
|
}
|
|
63
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;
|
|
64
115
|
const pkgs = require(join(cwd, "package.json"));
|
|
65
116
|
const { infra = {}, appKey } = pkgs;
|
|
66
|
-
|
|
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) {
|
|
67
124
|
printErrorAndExit("Please check the infra and appKey in package.json.");
|
|
68
125
|
}
|
|
69
|
-
const args = yParser(process.argv.slice(2));
|
|
70
|
-
const JENKINS_BUILD = args.jenkinsBuild || args.JENKINSBUILD || args.jenkins_build || args.JENKINS_BUILD;
|
|
71
126
|
const APP_ENV = args.env || args.ENV || "";
|
|
72
127
|
const ASG_BRANCH = args.asg_branch || args.ASG_BRANCH || "";
|
|
73
128
|
let RESOURCE_URL = "";
|
|
74
129
|
let SUB_APP = "";
|
|
75
130
|
let archStr = "unknown";
|
|
76
|
-
if (
|
|
131
|
+
if (projectUrl.includes("teams-pro")) {
|
|
77
132
|
archStr = "PRO";
|
|
78
|
-
} else if (
|
|
133
|
+
} else if (projectUrl.includes("teams-max")) {
|
|
79
134
|
archStr = "MAX";
|
|
80
135
|
RESOURCE_URL = args.versionUrl || args.RESOURCE_URL || "";
|
|
81
136
|
SUB_APP = args.subApp || args.SUB_APP || "";
|
|
@@ -83,7 +138,7 @@ function getCfg() {
|
|
|
83
138
|
return {
|
|
84
139
|
appKey,
|
|
85
140
|
infra: {
|
|
86
|
-
url:
|
|
141
|
+
url: projectUrl,
|
|
87
142
|
arch: archStr
|
|
88
143
|
},
|
|
89
144
|
ASG_DIR: asgDir,
|
|
@@ -123,13 +178,22 @@ async function fetchRemoteRepository() {
|
|
|
123
178
|
return;
|
|
124
179
|
} else {
|
|
125
180
|
if (!JENKINS_BUILD) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
181
|
+
let timer;
|
|
182
|
+
const { syncUp } = await Promise.race([
|
|
183
|
+
inquirer.prompt([
|
|
184
|
+
{
|
|
185
|
+
type: "confirm",
|
|
186
|
+
name: "syncUp",
|
|
187
|
+
message: "\u540C\u6B65\u8FDC\u7AEF\u4ED3\u5E93(5s\u540E\u8DF3\u8FC7\u540C\u6B65)",
|
|
188
|
+
default: "Y"
|
|
189
|
+
}
|
|
190
|
+
]).then((answer) => {
|
|
191
|
+
timer && clearTimeout(timer);
|
|
192
|
+
return answer;
|
|
193
|
+
}),
|
|
194
|
+
new Promise((resolve) => {
|
|
195
|
+
timer = setTimeout(() => resolve({ syncUp: false }), 5e3);
|
|
196
|
+
})
|
|
133
197
|
]);
|
|
134
198
|
if (!syncUp)
|
|
135
199
|
return;
|
|
@@ -179,6 +243,9 @@ async function fetchRemoteRepository() {
|
|
|
179
243
|
try {
|
|
180
244
|
execa.sync("git", ["checkout", "-q", questions.branch]);
|
|
181
245
|
logStep(`Switched to branch:`, questions.branch);
|
|
246
|
+
logStep("Installing dependencies...");
|
|
247
|
+
await addIntegrateDeps(cfg);
|
|
248
|
+
logStep("Installation completed.");
|
|
182
249
|
} catch (error) {
|
|
183
250
|
printErrorAndExit(
|
|
184
251
|
`Failed to switch to branch '${questions.branch}'. Reason: ${error.message}`
|