@lingxiteam/ebe-utils 0.0.13 → 0.0.15
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/index.d.ts +10 -2
- package/es/index.js +108 -86
- package/es/node/cli.js +40 -0
- package/es/node/ic.d.ts +5 -0
- package/es/node/ic.js +32 -0
- package/lib/node/cli.js +18 -0
- package/lib/node/ic.d.ts +5 -0
- package/lib/node/ic.js +40 -0
- package/lib/pcpublic/src/utils/messageApi.ts +2 -1
- package/lib/public/src/hooks/useLifeCycle.ts +15 -0
- package/lib/public/yarn.lock +11441 -0
- package/package.json +2 -2
package/es/index.d.ts
CHANGED
|
@@ -50,10 +50,17 @@ interface CodeOptions {
|
|
|
50
50
|
needTranslatePagePathToEnglish?: boolean;
|
|
51
51
|
autoDownloadOnBower?: boolean;
|
|
52
52
|
useEbeSetup?: boolean;
|
|
53
|
+
incrementalConstruction?: IncrementalConstruction;
|
|
54
|
+
}
|
|
55
|
+
interface IncrementalConstruction {
|
|
56
|
+
pageIds?: string[];
|
|
57
|
+
busiCompIds?: string[];
|
|
58
|
+
globalStoreChange?: boolean;
|
|
59
|
+
frontendHookChange?: boolean;
|
|
53
60
|
}
|
|
54
61
|
export declare const setWorkerJsUrl: (url: string) => void;
|
|
55
62
|
export declare const init: () => Promise<void>;
|
|
56
|
-
export declare const fetchData: ({ appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, }: CodeOptions) => Promise<{
|
|
63
|
+
export declare const fetchData: ({ appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, }: CodeOptions) => Promise<{
|
|
57
64
|
options: {
|
|
58
65
|
platform: string;
|
|
59
66
|
appId: string;
|
|
@@ -68,10 +75,11 @@ export declare const fetchData: ({ appId, services, platform, baseUrl, onProgres
|
|
|
68
75
|
models: Record<string, any>;
|
|
69
76
|
appInfo: Record<string, any>;
|
|
70
77
|
pagePathEnglishMapping: any;
|
|
78
|
+
incrementalConstruction: IncrementalConstruction | undefined;
|
|
71
79
|
};
|
|
72
80
|
cleanedTree: any;
|
|
73
81
|
}>;
|
|
74
|
-
export declare const codeCreate: ({ appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, autoDownloadOnBower, useEbeSetup, }: CodeOptions) => Promise<import("@lingxiteam/ebe/types/core").IPublisherResponse<string | import("../../types/core/publisher/zip").ZipBuffer> | {
|
|
82
|
+
export declare const codeCreate: ({ appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, autoDownloadOnBower, useEbeSetup, incrementalConstruction, }: CodeOptions) => Promise<import("@lingxiteam/ebe/types/core").IPublisherResponse<string | import("../../types/core/publisher/zip").ZipBuffer> | {
|
|
75
83
|
msg: unknown;
|
|
76
84
|
success: boolean;
|
|
77
85
|
}>;
|
package/es/index.js
CHANGED
|
@@ -128,29 +128,6 @@ export var removeObjectByRules = function removeObjectByRules(data, rules) {
|
|
|
128
128
|
}
|
|
129
129
|
return newData;
|
|
130
130
|
};
|
|
131
|
-
// 删除 defaultVersionId 字段 ,
|
|
132
|
-
// components 中的 compName 值为 View 时
|
|
133
|
-
// 当 props 中的 conten 字段等于 $$ 时 删除 conten
|
|
134
|
-
// const dsRules: IRulesType = {
|
|
135
|
-
// defaultVersionId: {
|
|
136
|
-
// rule: () => true,
|
|
137
|
-
// },
|
|
138
|
-
// components: {
|
|
139
|
-
// loopRule: (item) => item.compName,
|
|
140
|
-
// loop: {
|
|
141
|
-
// View: {
|
|
142
|
-
// rule: ({ diffraction }) => {
|
|
143
|
-
// return diffraction?.({
|
|
144
|
-
// props: {
|
|
145
|
-
// conten: '$$',
|
|
146
|
-
// },
|
|
147
|
-
// });
|
|
148
|
-
// },
|
|
149
|
-
// },
|
|
150
|
-
// },
|
|
151
|
-
// },
|
|
152
|
-
// };
|
|
153
|
-
|
|
154
131
|
export var treeForEach = function treeForEach(tree, callback) {
|
|
155
132
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
156
133
|
children: 'components'
|
|
@@ -270,53 +247,76 @@ export var init = /*#__PURE__*/function () {
|
|
|
270
247
|
return _ref3.apply(this, arguments);
|
|
271
248
|
};
|
|
272
249
|
}();
|
|
250
|
+
var getIsIncrementalConstruction = function getIsIncrementalConstruction(ic) {
|
|
251
|
+
return !!ic && ((ic === null || ic === void 0 ? void 0 : ic.busiCompIds) && ic.busiCompIds.length > 0 || (ic === null || ic === void 0 ? void 0 : ic.pageIds) && ic.pageIds.length > 0 || (ic === null || ic === void 0 ? void 0 : ic.frontendHookChange) || (ic === null || ic === void 0 ? void 0 : ic.globalStoreChange));
|
|
252
|
+
};
|
|
273
253
|
export var fetchData = /*#__PURE__*/function () {
|
|
274
254
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
|
|
275
|
-
var
|
|
255
|
+
var _ref6, _attrSpecPage;
|
|
256
|
+
var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, isIncrementalConstruction, attrSpecPage, appPageList, globalDataInfo, busiData, themeCss, frontendHookList, globalDataMap, appInfo, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, pages, _yield$services$qryBu, itemLists, _incrementalConstruct, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, _key, _pages$_key$pageConta, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageDSLS, getPlatform, options, cleanedTree;
|
|
276
257
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
277
258
|
while (1) switch (_context3.prev = _context3.next) {
|
|
278
259
|
case 0:
|
|
279
|
-
appId = _ref4.appId, services = _ref4.services, platform = _ref4.platform, baseUrl = _ref4.baseUrl, onProgress = _ref4.onProgress, needTranslatePagePathToEnglish = _ref4.needTranslatePagePathToEnglish;
|
|
280
|
-
|
|
260
|
+
appId = _ref4.appId, services = _ref4.services, platform = _ref4.platform, baseUrl = _ref4.baseUrl, onProgress = _ref4.onProgress, needTranslatePagePathToEnglish = _ref4.needTranslatePagePathToEnglish, incrementalConstruction = _ref4.incrementalConstruction;
|
|
261
|
+
isIncrementalConstruction = getIsIncrementalConstruction(incrementalConstruction);
|
|
262
|
+
attrSpecPage = {};
|
|
263
|
+
appPageList = (_ref6 = (incrementalConstruction === null || incrementalConstruction === void 0 ? void 0 : incrementalConstruction.pageIds) || []) === null || _ref6 === void 0 ? void 0 : _ref6.map(function (i) {
|
|
264
|
+
return {
|
|
265
|
+
pageId: i
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
globalDataInfo = {};
|
|
269
|
+
busiData = [];
|
|
270
|
+
themeCss = '';
|
|
271
|
+
frontendHookList = [];
|
|
272
|
+
globalDataMap = {};
|
|
273
|
+
_context3.next = 11;
|
|
281
274
|
return services.findApplication({
|
|
282
275
|
appId: appId
|
|
283
276
|
});
|
|
284
|
-
case
|
|
277
|
+
case 11:
|
|
285
278
|
appInfo = _context3.sent;
|
|
286
279
|
onProgress({
|
|
287
280
|
log: '获取应用信息',
|
|
288
281
|
progress: 1
|
|
289
282
|
});
|
|
290
|
-
|
|
291
|
-
|
|
283
|
+
if (!(!isIncrementalConstruction || incrementalConstruction !== null && incrementalConstruction !== void 0 && incrementalConstruction.frontendHookChange)) {
|
|
284
|
+
_context3.next = 17;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
_context3.next = 16;
|
|
288
|
+
return services.queryFrontendHookList({
|
|
289
|
+
appId: appId
|
|
290
|
+
});
|
|
291
|
+
case 16:
|
|
292
|
+
frontendHookList = _context3.sent;
|
|
293
|
+
case 17:
|
|
294
|
+
if (isIncrementalConstruction) {
|
|
295
|
+
_context3.next = 35;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
_context3.next = 20;
|
|
292
299
|
return services.qryAttrSpecPage({
|
|
293
300
|
appId: appId,
|
|
294
301
|
pageNum: 1,
|
|
295
302
|
pageSize: 999999
|
|
296
303
|
});
|
|
297
|
-
case
|
|
304
|
+
case 20:
|
|
298
305
|
attrSpecPage = _context3.sent;
|
|
299
306
|
onProgress({
|
|
300
307
|
log: '获取当前应用的全部页面',
|
|
301
308
|
progress: 2
|
|
302
309
|
});
|
|
303
310
|
// 根据 appId 获取当前应用的全部页面
|
|
304
|
-
_context3.next =
|
|
311
|
+
_context3.next = 24;
|
|
305
312
|
return services.qryPageInstListByAppId({
|
|
306
313
|
appId: appId,
|
|
307
314
|
terminalType: platform
|
|
308
315
|
});
|
|
309
|
-
case
|
|
310
|
-
|
|
311
|
-
_context3.
|
|
312
|
-
|
|
313
|
-
appId: appId
|
|
314
|
-
});
|
|
315
|
-
case 14:
|
|
316
|
-
frontendHookList = _context3.sent;
|
|
317
|
-
themeCss = '';
|
|
318
|
-
_context3.prev = 16;
|
|
319
|
-
_context3.next = 19;
|
|
316
|
+
case 24:
|
|
317
|
+
appPageList = _context3.sent;
|
|
318
|
+
_context3.prev = 25;
|
|
319
|
+
_context3.next = 28;
|
|
320
320
|
return Promise.race([new Promise(function (resolve, reject) {
|
|
321
321
|
services.getThemeCss({
|
|
322
322
|
appId: appId,
|
|
@@ -329,26 +329,26 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
329
329
|
resolve('');
|
|
330
330
|
}, 5000);
|
|
331
331
|
})]);
|
|
332
|
-
case
|
|
332
|
+
case 28:
|
|
333
333
|
themeCss = _context3.sent;
|
|
334
334
|
console.log('====获取主题成功');
|
|
335
|
-
_context3.next =
|
|
335
|
+
_context3.next = 35;
|
|
336
336
|
break;
|
|
337
|
-
case
|
|
338
|
-
_context3.prev =
|
|
339
|
-
_context3.t0 = _context3["catch"](
|
|
337
|
+
case 32:
|
|
338
|
+
_context3.prev = 32;
|
|
339
|
+
_context3.t0 = _context3["catch"](25);
|
|
340
340
|
console.error('====获取主题失败', _context3.t0);
|
|
341
|
-
case
|
|
341
|
+
case 35:
|
|
342
342
|
// 根据 appId 获取当前应用的使用的自定义组件
|
|
343
343
|
onProgress({
|
|
344
344
|
log: '获取当前应用的使用的自定义组件',
|
|
345
345
|
progress: 3
|
|
346
346
|
});
|
|
347
|
-
_context3.next =
|
|
347
|
+
_context3.next = 38;
|
|
348
348
|
return services.qryPageCompAssetList({
|
|
349
349
|
appId: appId
|
|
350
350
|
});
|
|
351
|
-
case
|
|
351
|
+
case 38:
|
|
352
352
|
temCompAssetList = _context3.sent;
|
|
353
353
|
// 兼容下割接数据,数组前面的自定义组件是新的
|
|
354
354
|
compAssetList = temCompAssetList.reduce(function (acc, current) {
|
|
@@ -359,20 +359,24 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
359
359
|
acc.push(current);
|
|
360
360
|
}
|
|
361
361
|
return acc;
|
|
362
|
-
}, []);
|
|
362
|
+
}, []);
|
|
363
|
+
if (!(!isIncrementalConstruction || incrementalConstruction !== null && incrementalConstruction !== void 0 && incrementalConstruction.globalStoreChange)) {
|
|
364
|
+
_context3.next = 47;
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
// 根据appId 获取全局数据源
|
|
363
368
|
onProgress({
|
|
364
369
|
log: '获取全局数据源',
|
|
365
370
|
progress: 4
|
|
366
371
|
});
|
|
367
|
-
_context3.next =
|
|
372
|
+
_context3.next = 44;
|
|
368
373
|
return services.queryFrontendDatasourcePage({
|
|
369
374
|
appId: appId,
|
|
370
375
|
pageSize: 10000
|
|
371
376
|
});
|
|
372
|
-
case
|
|
377
|
+
case 44:
|
|
373
378
|
globalDataInfo = _context3.sent;
|
|
374
|
-
dataSourceList = (globalDataInfo === null ||
|
|
375
|
-
globalDataMap = {};
|
|
379
|
+
dataSourceList = ((_globalDataInfo = globalDataInfo) === null || _globalDataInfo === void 0 ? void 0 : _globalDataInfo.list) || [];
|
|
376
380
|
dataSourceList.forEach(function (item) {
|
|
377
381
|
var frontendDatasourceContent = item.frontendDatasourceContent,
|
|
378
382
|
restItem = _objectWithoutProperties(item, _excluded);
|
|
@@ -383,35 +387,37 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
383
387
|
} catch (err) {}
|
|
384
388
|
return null;
|
|
385
389
|
});
|
|
390
|
+
case 47:
|
|
386
391
|
pageIdMapping = {};
|
|
387
|
-
appPageList = resultObject === null || resultObject === void 0 ? void 0 : resultObject.map(function (i) {
|
|
388
|
-
pageIdMapping[i.pagePath] = i.pageId;
|
|
389
|
-
return i;
|
|
390
|
-
});
|
|
391
392
|
lastPageId = ''; // 根据 pageId 获得 dsl
|
|
392
393
|
data = [];
|
|
393
394
|
onProgress({
|
|
394
395
|
log: '获取所有页面dsl',
|
|
395
396
|
progress: 5
|
|
396
397
|
});
|
|
397
|
-
_context3.next =
|
|
398
|
+
_context3.next = 53;
|
|
398
399
|
return Promise.all(appPageList.map(function (i) {
|
|
399
400
|
lastPageId = i.pageId;
|
|
401
|
+
pageIdMapping[i.pagePath] = i.pageId;
|
|
400
402
|
return services.findPageInstByVersionId({
|
|
401
403
|
appId: appId,
|
|
402
404
|
pageId: i.pageId
|
|
403
405
|
});
|
|
404
406
|
}));
|
|
405
|
-
case
|
|
407
|
+
case 53:
|
|
406
408
|
data = _context3.sent;
|
|
407
409
|
pages = getPageDsls(data);
|
|
410
|
+
if (isIncrementalConstruction) {
|
|
411
|
+
_context3.next = 66;
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
408
414
|
onProgress({
|
|
409
415
|
log: '获取所有业务组件dsl',
|
|
410
416
|
progress: 6
|
|
411
417
|
});
|
|
412
418
|
|
|
413
419
|
// 业务组件从被使用才生成改为全部生成
|
|
414
|
-
_context3.next =
|
|
420
|
+
_context3.next = 59;
|
|
415
421
|
return services.qryBusiCompPage({
|
|
416
422
|
appIds: [appId],
|
|
417
423
|
appId: appId,
|
|
@@ -420,10 +426,10 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
420
426
|
pageSize: 999999,
|
|
421
427
|
terminalType: platform
|
|
422
428
|
});
|
|
423
|
-
case
|
|
429
|
+
case 59:
|
|
424
430
|
_yield$services$qryBu = _context3.sent;
|
|
425
431
|
itemLists = _yield$services$qryBu.list;
|
|
426
|
-
_context3.next =
|
|
432
|
+
_context3.next = 63;
|
|
427
433
|
return Promise.all(itemLists.map(function (i) {
|
|
428
434
|
return services.findBusiCompById({
|
|
429
435
|
busiCompId: i.busiCompId,
|
|
@@ -431,8 +437,22 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
431
437
|
pageId: lastPageId
|
|
432
438
|
});
|
|
433
439
|
}));
|
|
434
|
-
case
|
|
440
|
+
case 63:
|
|
441
|
+
busiData = _context3.sent;
|
|
442
|
+
_context3.next = 69;
|
|
443
|
+
break;
|
|
444
|
+
case 66:
|
|
445
|
+
_context3.next = 68;
|
|
446
|
+
return Promise.all(((_incrementalConstruct = incrementalConstruction === null || incrementalConstruction === void 0 ? void 0 : incrementalConstruction.busiCompIds) !== null && _incrementalConstruct !== void 0 ? _incrementalConstruct : []).map(function (i) {
|
|
447
|
+
return services.findBusiCompById({
|
|
448
|
+
busiCompId: i,
|
|
449
|
+
appId: appId,
|
|
450
|
+
pageId: lastPageId
|
|
451
|
+
});
|
|
452
|
+
}));
|
|
453
|
+
case 68:
|
|
435
454
|
busiData = _context3.sent;
|
|
455
|
+
case 69:
|
|
436
456
|
// 过滤为空
|
|
437
457
|
busiPages = busiData.filter(Boolean).map(function (i, index) {
|
|
438
458
|
var _i$busiCompVersion;
|
|
@@ -455,7 +475,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
455
475
|
*/
|
|
456
476
|
// 获取翻译,尝试三次
|
|
457
477
|
getTranslateName = /*#__PURE__*/function () {
|
|
458
|
-
var
|
|
478
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(appId, chinese, rule) {
|
|
459
479
|
var _services$translateTo;
|
|
460
480
|
var count,
|
|
461
481
|
translateName,
|
|
@@ -497,7 +517,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
497
517
|
}, _callee2);
|
|
498
518
|
}));
|
|
499
519
|
return function getTranslateName(_x2, _x3, _x4) {
|
|
500
|
-
return
|
|
520
|
+
return _ref7.apply(this, arguments);
|
|
501
521
|
};
|
|
502
522
|
}();
|
|
503
523
|
chinese = busiPages === null || busiPages === void 0 ? void 0 : busiPages.map(function (item) {
|
|
@@ -505,14 +525,14 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
505
525
|
});
|
|
506
526
|
translateNames = {};
|
|
507
527
|
if (!(chinese.length > 0)) {
|
|
508
|
-
_context3.next =
|
|
528
|
+
_context3.next = 77;
|
|
509
529
|
break;
|
|
510
530
|
}
|
|
511
|
-
_context3.next =
|
|
531
|
+
_context3.next = 76;
|
|
512
532
|
return getTranslateName(appId, chinese, 'UPPER_CAMEL');
|
|
513
|
-
case
|
|
533
|
+
case 76:
|
|
514
534
|
translateNames = _context3.sent;
|
|
515
|
-
case
|
|
535
|
+
case 77:
|
|
516
536
|
// 翻译业务组件的名字
|
|
517
537
|
for (key = 0; key < busiPages.length; key++) {
|
|
518
538
|
onProgress({
|
|
@@ -524,7 +544,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
524
544
|
}
|
|
525
545
|
pagePathEnglishMapping = {};
|
|
526
546
|
if (!needTranslatePagePathToEnglish) {
|
|
527
|
-
_context3.next =
|
|
547
|
+
_context3.next = 89;
|
|
528
548
|
break;
|
|
529
549
|
}
|
|
530
550
|
pagePathEnglishSet = {};
|
|
@@ -546,14 +566,14 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
546
566
|
});
|
|
547
567
|
pagesTranslateNames = {};
|
|
548
568
|
if (!(pagesChinese.length > 0)) {
|
|
549
|
-
_context3.next =
|
|
569
|
+
_context3.next = 88;
|
|
550
570
|
break;
|
|
551
571
|
}
|
|
552
|
-
_context3.next =
|
|
572
|
+
_context3.next = 87;
|
|
553
573
|
return getTranslateName(appId, pagesChinese, 'UPPER_CAMEL');
|
|
554
|
-
case
|
|
574
|
+
case 87:
|
|
555
575
|
pagesTranslateNames = _context3.sent;
|
|
556
|
-
case
|
|
576
|
+
case 88:
|
|
557
577
|
// 翻译页面的名字
|
|
558
578
|
for (_key = 0; _key < pages.length; _key++) {
|
|
559
579
|
onProgress({
|
|
@@ -570,7 +590,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
570
590
|
pages[_key].pagePath = safeTranslateName;
|
|
571
591
|
}
|
|
572
592
|
}
|
|
573
|
-
case
|
|
593
|
+
case 89:
|
|
574
594
|
// 合并页面,生成器那边支持页面类型和业务组件类型
|
|
575
595
|
pageDSLS = [].concat(_toConsumableArray(pages), _toConsumableArray(busiPages));
|
|
576
596
|
getPlatform = function getPlatform(platFormtype) {
|
|
@@ -592,14 +612,15 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
592
612
|
appConfig: {
|
|
593
613
|
frontendHookList: frontendHookList
|
|
594
614
|
},
|
|
595
|
-
attrSpecPage: ((attrSpecPage === null ||
|
|
615
|
+
attrSpecPage: (((_attrSpecPage = attrSpecPage) === null || _attrSpecPage === void 0 ? void 0 : _attrSpecPage.list) || []).map(function (i) {
|
|
596
616
|
return i.attrNbr;
|
|
597
617
|
}),
|
|
598
618
|
themeCss: themeCss,
|
|
599
619
|
models: globalDataMap,
|
|
600
620
|
appInfo: clearAppInfo(appInfo),
|
|
601
621
|
// 英文路径的对应关系
|
|
602
|
-
pagePathEnglishMapping: pagePathEnglishMapping
|
|
622
|
+
pagePathEnglishMapping: pagePathEnglishMapping,
|
|
623
|
+
incrementalConstruction: incrementalConstruction
|
|
603
624
|
};
|
|
604
625
|
onProgress({
|
|
605
626
|
log: '清理无用数据',
|
|
@@ -611,23 +632,23 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
611
632
|
options: options,
|
|
612
633
|
cleanedTree: cleanedTree
|
|
613
634
|
});
|
|
614
|
-
case
|
|
635
|
+
case 96:
|
|
615
636
|
case "end":
|
|
616
637
|
return _context3.stop();
|
|
617
638
|
}
|
|
618
|
-
}, _callee3, null, [[
|
|
639
|
+
}, _callee3, null, [[25, 32]]);
|
|
619
640
|
}));
|
|
620
641
|
return function fetchData(_x) {
|
|
621
642
|
return _ref5.apply(this, arguments);
|
|
622
643
|
};
|
|
623
644
|
}();
|
|
624
645
|
export var codeCreate = /*#__PURE__*/function () {
|
|
625
|
-
var
|
|
626
|
-
var appId, services, platform, baseUrl, _onProgress,
|
|
646
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref8) {
|
|
647
|
+
var appId, services, platform, baseUrl, _onProgress, _ref8$needTranslatePa, needTranslatePagePathToEnglish, _ref8$autoDownloadOnB, autoDownloadOnBower, _ref8$useEbeSetup, useEbeSetup, incrementalConstruction, _yield$fetchData, cleanedTree, options, result, zipRes;
|
|
627
648
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
628
649
|
while (1) switch (_context4.prev = _context4.next) {
|
|
629
650
|
case 0:
|
|
630
|
-
appId =
|
|
651
|
+
appId = _ref8.appId, services = _ref8.services, platform = _ref8.platform, baseUrl = _ref8.baseUrl, _onProgress = _ref8.onProgress, _ref8$needTranslatePa = _ref8.needTranslatePagePathToEnglish, needTranslatePagePathToEnglish = _ref8$needTranslatePa === void 0 ? false : _ref8$needTranslatePa, _ref8$autoDownloadOnB = _ref8.autoDownloadOnBower, autoDownloadOnBower = _ref8$autoDownloadOnB === void 0 ? true : _ref8$autoDownloadOnB, _ref8$useEbeSetup = _ref8.useEbeSetup, useEbeSetup = _ref8$useEbeSetup === void 0 ? true : _ref8$useEbeSetup, incrementalConstruction = _ref8.incrementalConstruction;
|
|
631
652
|
_context4.prev = 1;
|
|
632
653
|
_context4.next = 4;
|
|
633
654
|
return fetchData({
|
|
@@ -636,7 +657,8 @@ export var codeCreate = /*#__PURE__*/function () {
|
|
|
636
657
|
platform: platform,
|
|
637
658
|
baseUrl: baseUrl,
|
|
638
659
|
onProgress: _onProgress,
|
|
639
|
-
needTranslatePagePathToEnglish: needTranslatePagePathToEnglish
|
|
660
|
+
needTranslatePagePathToEnglish: needTranslatePagePathToEnglish,
|
|
661
|
+
incrementalConstruction: incrementalConstruction
|
|
640
662
|
});
|
|
641
663
|
case 4:
|
|
642
664
|
_yield$fetchData = _context4.sent;
|
|
@@ -700,6 +722,6 @@ export var codeCreate = /*#__PURE__*/function () {
|
|
|
700
722
|
}, _callee4, null, [[1, 16]]);
|
|
701
723
|
}));
|
|
702
724
|
return function codeCreate(_x5) {
|
|
703
|
-
return
|
|
725
|
+
return _ref9.apply(this, arguments);
|
|
704
726
|
};
|
|
705
727
|
}();
|
package/es/node/cli.js
CHANGED
|
@@ -82,6 +82,46 @@ cli.command('move <path>', '通过提供的入口,将所有相关依赖复制
|
|
|
82
82
|
return _ref2.apply(this, arguments);
|
|
83
83
|
};
|
|
84
84
|
}());
|
|
85
|
+
// Incremental Construction
|
|
86
|
+
cli.command('ic', '通过提供的入口,将所有相关依赖复制到指定文件夹中').option('--o [outdir]', '指定拷贝产物路径', {
|
|
87
|
+
default: process.cwd()
|
|
88
|
+
}).option('--p [path]', '指定增量文件路径', {
|
|
89
|
+
default: 'ic'
|
|
90
|
+
}).action( /*#__PURE__*/function () {
|
|
91
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(option) {
|
|
92
|
+
var o, p, _require3, ic;
|
|
93
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
94
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
o = option.o, p = option.p;
|
|
97
|
+
_require3 = require("./ic"), ic = _require3.ic;
|
|
98
|
+
_context3.prev = 2;
|
|
99
|
+
_context3.next = 5;
|
|
100
|
+
return ic({
|
|
101
|
+
target: p,
|
|
102
|
+
outDir: o
|
|
103
|
+
});
|
|
104
|
+
case 5:
|
|
105
|
+
_context3.next = 11;
|
|
106
|
+
break;
|
|
107
|
+
case 7:
|
|
108
|
+
_context3.prev = 7;
|
|
109
|
+
_context3.t0 = _context3["catch"](2);
|
|
110
|
+
console.error(_context3.t0);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
case 11:
|
|
113
|
+
_context3.prev = 11;
|
|
114
|
+
return _context3.finish(11);
|
|
115
|
+
case 13:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context3.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee3, null, [[2, 7, 11, 13]]);
|
|
120
|
+
}));
|
|
121
|
+
return function (_x5) {
|
|
122
|
+
return _ref3.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
}());
|
|
85
125
|
cli.help();
|
|
86
126
|
cli.version(VERSION);
|
|
87
127
|
cli.parse();
|
package/es/node/ic.d.ts
ADDED
package/es/node/ic.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
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
|
+
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 { existsSync } from 'fs';
|
|
6
|
+
import { copyStatic } from "./copyStatic";
|
|
7
|
+
export function ic(_x) {
|
|
8
|
+
return _ic.apply(this, arguments);
|
|
9
|
+
}
|
|
10
|
+
function _ic() {
|
|
11
|
+
_ic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(icConfig) {
|
|
12
|
+
var target, outDir;
|
|
13
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15
|
+
case 0:
|
|
16
|
+
target = icConfig.target, outDir = icConfig.outDir;
|
|
17
|
+
if (existsSync(outDir)) {
|
|
18
|
+
// TODO: 这里可以增加 git 状态检测
|
|
19
|
+
console.log("\u5F00\u59CB\u540C\u6B65\u589E\u91CF\u4EA7\u7269 ".concat(target, " ---> ").concat(outDir));
|
|
20
|
+
copyStatic(target, outDir);
|
|
21
|
+
} else {
|
|
22
|
+
console.log('请将增量产物放入 `ic` 文件夹中,再执行增量同步命令');
|
|
23
|
+
console.log('你也可以使用 ebe ic --o newIcDir 来制定增量产物存放文件夹');
|
|
24
|
+
}
|
|
25
|
+
case 2:
|
|
26
|
+
case "end":
|
|
27
|
+
return _context.stop();
|
|
28
|
+
}
|
|
29
|
+
}, _callee);
|
|
30
|
+
}));
|
|
31
|
+
return _ic.apply(this, arguments);
|
|
32
|
+
}
|
package/lib/node/cli.js
CHANGED
|
@@ -32,6 +32,24 @@ cli.command("move <path>", "通过提供的入口,将所有相关依赖复制
|
|
|
32
32
|
} finally {
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
+
cli.command("ic", "通过提供的入口,将所有相关依赖复制到指定文件夹中").option("--o [outdir]", "指定拷贝产物路径", {
|
|
36
|
+
default: process.cwd()
|
|
37
|
+
}).option("--p [path]", "指定增量文件路径", {
|
|
38
|
+
default: "ic"
|
|
39
|
+
}).action(async (option) => {
|
|
40
|
+
const { o, p } = option;
|
|
41
|
+
const { ic } = require("./ic");
|
|
42
|
+
try {
|
|
43
|
+
await ic({
|
|
44
|
+
target: p,
|
|
45
|
+
outDir: o
|
|
46
|
+
});
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.error(e);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
} finally {
|
|
51
|
+
}
|
|
52
|
+
});
|
|
35
53
|
cli.help();
|
|
36
54
|
cli.version(import_constants.VERSION);
|
|
37
55
|
cli.parse();
|
package/lib/node/ic.d.ts
ADDED
package/lib/node/ic.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/node/ic.ts
|
|
20
|
+
var ic_exports = {};
|
|
21
|
+
__export(ic_exports, {
|
|
22
|
+
ic: () => ic
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ic_exports);
|
|
25
|
+
var import_fs = require("fs");
|
|
26
|
+
var import_copyStatic = require("./copyStatic");
|
|
27
|
+
async function ic(icConfig) {
|
|
28
|
+
const { target, outDir } = icConfig;
|
|
29
|
+
if ((0, import_fs.existsSync)(outDir)) {
|
|
30
|
+
console.log(`开始同步增量产物 ${target} ---> ${outDir}`);
|
|
31
|
+
(0, import_copyStatic.copyStatic)(target, outDir);
|
|
32
|
+
} else {
|
|
33
|
+
console.log("请将增量产物放入 `ic` 文件夹中,再执行增量同步命令");
|
|
34
|
+
console.log("你也可以使用 ebe ic --o newIcDir 来制定增量产物存放文件夹");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
ic
|
|
40
|
+
});
|