@tmsfe/tmskit 0.0.13 → 0.0.14
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/README.md +6 -1
- package/dist/index.cjs.js +61 -96
- package/package.json +5 -2
- package/src/core/mpCi.js +1 -1
- package/src/core/npm.js +3 -1
- package/src/core/symbolicLink.js +13 -7
- package/src/scripts/run/init/index.js +0 -7
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ tmskit create webapp
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
3. cd webapp
|
|
12
|
-
tmskit run dev -m <模块名>
|
|
12
|
+
tmskit run dev -m <模块名>
|
|
13
13
|
|
|
14
14
|
使用文档详见: https://open.go.qq.com/tmskit/
|
|
15
15
|
```
|
|
@@ -25,4 +25,9 @@ npm run dev
|
|
|
25
25
|
cd example
|
|
26
26
|
node /Users/odile/workspace/tms-frontend1/tools/tmskit/dist/index.cjs run dev
|
|
27
27
|
|
|
28
|
+
|
|
29
|
+
3. 发布tmskit
|
|
30
|
+
npm run pub:patch (小版本)
|
|
31
|
+
npm run pub:minor (中版本)
|
|
32
|
+
npm run pub:major (大版本)
|
|
28
33
|
```
|
package/dist/index.cjs.js
CHANGED
|
@@ -128,7 +128,7 @@ const program$1 = require$$0__default$1;
|
|
|
128
128
|
const leven = require$$1__default$1;
|
|
129
129
|
const ora = require$$2__default;
|
|
130
130
|
const path$b = require$$1__default$2;
|
|
131
|
-
const fs$
|
|
131
|
+
const fs$d = require$$0__default$2;
|
|
132
132
|
const shelljs$6 = require$$0__default$3;
|
|
133
133
|
const {
|
|
134
134
|
info: info$8
|
|
@@ -141,7 +141,7 @@ const shelljsOptions = {
|
|
|
141
141
|
|
|
142
142
|
const cwd = process.cwd();
|
|
143
143
|
|
|
144
|
-
function resolve$
|
|
144
|
+
function resolve$f(...args) {
|
|
145
145
|
return path$b.resolve(cwd, ...args);
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
@@ -198,7 +198,7 @@ function downloadRepoForGit$2(url, dest, branch) {
|
|
|
198
198
|
const cwd = process.cwd();
|
|
199
199
|
return new Promise((resolve, reject) => {
|
|
200
200
|
// 如果目标目录不存在
|
|
201
|
-
if (fs$
|
|
201
|
+
if (fs$d.existsSync(dest)) {
|
|
202
202
|
shelljs$6.rm('-rf', path$b.join(dest));
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -315,7 +315,7 @@ const relativeCwdPath$1 = function (file) {
|
|
|
315
315
|
};
|
|
316
316
|
|
|
317
317
|
var widgets = {
|
|
318
|
-
resolve: resolve$
|
|
318
|
+
resolve: resolve$f,
|
|
319
319
|
isObject: isObject$2,
|
|
320
320
|
isArray: isArray$1,
|
|
321
321
|
createTask: createTask$3,
|
|
@@ -350,7 +350,7 @@ const TMS_PRIVATE_FILENAME$1 = 'tms.private.config.js'; // 模块代码的默认
|
|
|
350
350
|
|
|
351
351
|
const DEFAULT_MODULE_DIR = 'modules'; // 模块代码的默认在modules子目录
|
|
352
352
|
|
|
353
|
-
const DEFAULT_CLOUD_MODULE_DIR
|
|
353
|
+
const DEFAULT_CLOUD_MODULE_DIR = './cloud'; // 模块的配置文件的名称
|
|
354
354
|
|
|
355
355
|
const MODULE_CONFIG_FILENAME$2 = 'module.config.json'; // 默认的webpack entry
|
|
356
356
|
|
|
@@ -383,12 +383,12 @@ var constant = /*#__PURE__*/Object.freeze({
|
|
|
383
383
|
ENV: ENV,
|
|
384
384
|
TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$2,
|
|
385
385
|
MODULE_CONFIG_INVALID_KEY: MODULE_CONFIG_INVALID_KEY$1,
|
|
386
|
-
DEFAULT_CLOUD_MODULE_DIR: DEFAULT_CLOUD_MODULE_DIR
|
|
386
|
+
DEFAULT_CLOUD_MODULE_DIR: DEFAULT_CLOUD_MODULE_DIR
|
|
387
387
|
});
|
|
388
388
|
|
|
389
389
|
var require$$4 = /*@__PURE__*/getAugmentedNamespace(constant);
|
|
390
390
|
|
|
391
|
-
const fs$
|
|
391
|
+
const fs$c = require$$0__default$2;
|
|
392
392
|
const path$9 = require$$1__default$2;
|
|
393
393
|
const {
|
|
394
394
|
info: info$7
|
|
@@ -402,12 +402,12 @@ const {
|
|
|
402
402
|
* @returns
|
|
403
403
|
*/
|
|
404
404
|
|
|
405
|
-
const isDirEmpty = dirname => fs$
|
|
405
|
+
const isDirEmpty = dirname => fs$c.promises.readdir(dirname).then(files => files.length === 0); // 判断是否是文件
|
|
406
406
|
|
|
407
407
|
|
|
408
408
|
const isFile = pathName => {
|
|
409
409
|
try {
|
|
410
|
-
const stat = fs$
|
|
410
|
+
const stat = fs$c.lstatSync(pathName);
|
|
411
411
|
return stat.isFile();
|
|
412
412
|
} catch {
|
|
413
413
|
return false;
|
|
@@ -420,8 +420,8 @@ const isFile = pathName => {
|
|
|
420
420
|
|
|
421
421
|
|
|
422
422
|
const ensureDirExist = dirname => {
|
|
423
|
-
if (!fs$
|
|
424
|
-
fs$
|
|
423
|
+
if (!fs$c.existsSync(dirname)) {
|
|
424
|
+
fs$c.mkdirSync(dirname, {
|
|
425
425
|
recursive: true
|
|
426
426
|
});
|
|
427
427
|
}
|
|
@@ -429,20 +429,20 @@ const ensureDirExist = dirname => {
|
|
|
429
429
|
|
|
430
430
|
|
|
431
431
|
const copyFile = function (src, dest) {
|
|
432
|
-
if (fs$
|
|
433
|
-
fs$
|
|
432
|
+
if (fs$c.existsSync(dest)) {
|
|
433
|
+
fs$c.unlinkSync(dest);
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
const dir = path$9.dirname(dest);
|
|
437
437
|
ensureDirExist(dir);
|
|
438
|
-
fs$
|
|
438
|
+
fs$c.copyFileSync(src, dest);
|
|
439
439
|
}; // 判断文件内容是否一致,不一致再进行拷贝
|
|
440
440
|
|
|
441
441
|
|
|
442
442
|
function diffContentCopyFile$3(originFile, destFile) {
|
|
443
|
-
if (fs$
|
|
444
|
-
const depDestContent = fs$
|
|
445
|
-
const depOriginContent = fs$
|
|
443
|
+
if (fs$c.existsSync(destFile)) {
|
|
444
|
+
const depDestContent = fs$c.readFileSync(destFile, 'utf8');
|
|
445
|
+
const depOriginContent = fs$c.readFileSync(originFile, 'utf8');
|
|
446
446
|
|
|
447
447
|
if (depDestContent !== depOriginContent) {
|
|
448
448
|
info$7(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
|
|
@@ -460,7 +460,7 @@ function ext$3(filePath, extensions) {
|
|
|
460
460
|
let extPath = ''; // try catch需要包裹:用来处理'./lib/timer'没有后缀的情况
|
|
461
461
|
|
|
462
462
|
try {
|
|
463
|
-
const stat = fs$
|
|
463
|
+
const stat = fs$c.lstatSync(newFilePath);
|
|
464
464
|
|
|
465
465
|
if (stat.isDirectory()) {
|
|
466
466
|
extPath = newFilePath[newFilePath.length - 1] === '/' ? 'index' : '/index';
|
|
@@ -471,7 +471,7 @@ function ext$3(filePath, extensions) {
|
|
|
471
471
|
for (const ext of extensions) {
|
|
472
472
|
const file = newFilePath.endsWith(ext) ? newFilePath : newFilePath + ext;
|
|
473
473
|
|
|
474
|
-
if (fs$
|
|
474
|
+
if (fs$c.existsSync(file)) {
|
|
475
475
|
return {
|
|
476
476
|
ext,
|
|
477
477
|
extPath: extPath + ext,
|
|
@@ -489,7 +489,7 @@ function ext$3(filePath, extensions) {
|
|
|
489
489
|
|
|
490
490
|
|
|
491
491
|
const fileInDir$3 = (dir, file) => {
|
|
492
|
-
if (!fs$
|
|
492
|
+
if (!fs$c.existsSync(dir) || !fs$c.existsSync(file)) {
|
|
493
493
|
return false;
|
|
494
494
|
}
|
|
495
495
|
|
|
@@ -532,10 +532,10 @@ const render$1 = (files, metalsmith, next) => {
|
|
|
532
532
|
|
|
533
533
|
var render_1 = render$1;
|
|
534
534
|
|
|
535
|
-
const fs$
|
|
535
|
+
const fs$b = require$$0__default$2;
|
|
536
536
|
const inquirer = require$$1__default$4;
|
|
537
537
|
const {
|
|
538
|
-
resolve: resolve$
|
|
538
|
+
resolve: resolve$e
|
|
539
539
|
} = widgets;
|
|
540
540
|
const {
|
|
541
541
|
TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$1
|
|
@@ -549,12 +549,12 @@ const {
|
|
|
549
549
|
const parseTemplateQuestions = dir => {
|
|
550
550
|
let prompts = [];
|
|
551
551
|
|
|
552
|
-
if (!fs$
|
|
552
|
+
if (!fs$b.existsSync(`${dir}/questions.json`)) {
|
|
553
553
|
return prompts;
|
|
554
554
|
}
|
|
555
555
|
|
|
556
556
|
try {
|
|
557
|
-
const json = JSON.parse(fs$
|
|
557
|
+
const json = JSON.parse(fs$b.readFileSync(`${dir}/questions.json`));
|
|
558
558
|
|
|
559
559
|
if (Array.isArray(json) && json.length > 0) {
|
|
560
560
|
json.forEach((item, index) => {
|
|
@@ -587,7 +587,7 @@ const isQuestionType = result => {
|
|
|
587
587
|
};
|
|
588
588
|
|
|
589
589
|
const ask$1 = templateDir => (files, metalsmith, next) => {
|
|
590
|
-
const prompts = parseTemplateQuestions(resolve$
|
|
590
|
+
const prompts = parseTemplateQuestions(resolve$e(templateDir, TEMPLATE_TKIT_DIR$1));
|
|
591
591
|
const metadata = metalsmith.metadata();
|
|
592
592
|
const filteredPrompts = prompts.filter(prompt => {
|
|
593
593
|
if (metadata[prompt.name] && `${metadata[prompt.name]}`.trim() !== '') {
|
|
@@ -630,7 +630,7 @@ const generator$1 = (buildDir, distDir, preMetadata) => new Promise((resolve, re
|
|
|
630
630
|
var generator_1 = generator$1;
|
|
631
631
|
|
|
632
632
|
const path$8 = require$$1__default$2;
|
|
633
|
-
const fs$
|
|
633
|
+
const fs$a = require$$0__default$2;
|
|
634
634
|
const shelljs$5 = require$$0__default$3;
|
|
635
635
|
const {
|
|
636
636
|
TEMPLATE_DIR,
|
|
@@ -640,7 +640,7 @@ const {
|
|
|
640
640
|
const {
|
|
641
641
|
downloadRepoForGit: downloadRepoForGit$1,
|
|
642
642
|
createTask: createTask$2,
|
|
643
|
-
resolve: resolve$
|
|
643
|
+
resolve: resolve$d
|
|
644
644
|
} = widgets;
|
|
645
645
|
const io$1 = io$2;
|
|
646
646
|
const {
|
|
@@ -657,7 +657,7 @@ const generator = generator_1;
|
|
|
657
657
|
|
|
658
658
|
async function createAppDir(targetDir) {
|
|
659
659
|
// 如果目录非空或者已经存在,提示用户,做选择
|
|
660
|
-
if (fs$
|
|
660
|
+
if (fs$a.existsSync(targetDir)) {
|
|
661
661
|
if (!(await io$1.isDirEmpty(targetDir))) {
|
|
662
662
|
fail$8('该目录名已经存在,换个项目名字吧~');
|
|
663
663
|
process.exit(1);
|
|
@@ -689,7 +689,7 @@ async function create(appName) {
|
|
|
689
689
|
}).then(() => {
|
|
690
690
|
shelljs$5.cd(appName);
|
|
691
691
|
|
|
692
|
-
const hooks = require(resolve$
|
|
692
|
+
const hooks = require(resolve$d(appName, TEMPLATE_TKIT_DIR, 'hooks.js'));
|
|
693
693
|
|
|
694
694
|
if (hooks.afterCreate) {
|
|
695
695
|
hooks.afterCreate.forEach(item => {
|
|
@@ -703,7 +703,7 @@ async function create(appName) {
|
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
705
|
|
|
706
|
-
shelljs$5.rm('-rf', resolve$
|
|
706
|
+
shelljs$5.rm('-rf', resolve$d(appName, TEMPLATE_TKIT_DIR));
|
|
707
707
|
succeed('项目创建完成.');
|
|
708
708
|
}).catch(err => {
|
|
709
709
|
fail$8(err.message);
|
|
@@ -736,14 +736,14 @@ var defaultTmsConfig$1 = {
|
|
|
736
736
|
* 用来读取处理tms.config.js与module.config.json字段
|
|
737
737
|
*/
|
|
738
738
|
const loadash = require$$0__default$6;
|
|
739
|
-
const fs$
|
|
739
|
+
const fs$9 = require$$0__default$2;
|
|
740
740
|
const {
|
|
741
741
|
TMS_CONFIG_FILENAME,
|
|
742
742
|
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$1,
|
|
743
743
|
TMS_PRIVATE_FILENAME
|
|
744
744
|
} = require$$4;
|
|
745
745
|
const {
|
|
746
|
-
resolve: resolve$
|
|
746
|
+
resolve: resolve$c,
|
|
747
747
|
isObject: isObject$1,
|
|
748
748
|
isArray
|
|
749
749
|
} = widgets;
|
|
@@ -758,9 +758,9 @@ const path$7 = require$$1__default$2;
|
|
|
758
758
|
*/
|
|
759
759
|
|
|
760
760
|
const readTmsConfig$1 = function (env) {
|
|
761
|
-
const tmsConfigPath = resolve$
|
|
761
|
+
const tmsConfigPath = resolve$c(TMS_CONFIG_FILENAME);
|
|
762
762
|
|
|
763
|
-
if (!fs$
|
|
763
|
+
if (!fs$9.existsSync(tmsConfigPath)) {
|
|
764
764
|
fail$7('当前执行目录没有tms.config.js的配置项,请进行配置');
|
|
765
765
|
process.exit(1);
|
|
766
766
|
}
|
|
@@ -808,9 +808,9 @@ const convertModules = modules => {
|
|
|
808
808
|
|
|
809
809
|
const readTmsPrivateCf$1 = function () {
|
|
810
810
|
let tmsPrivateCf = {};
|
|
811
|
-
const tmsPrivatePath = resolve$
|
|
811
|
+
const tmsPrivatePath = resolve$c(TMS_PRIVATE_FILENAME);
|
|
812
812
|
|
|
813
|
-
if (fs$
|
|
813
|
+
if (fs$9.existsSync(tmsPrivatePath)) {
|
|
814
814
|
tmsPrivateCf = require(tmsPrivatePath);
|
|
815
815
|
} // 处理modules字段
|
|
816
816
|
|
|
@@ -902,10 +902,10 @@ function getModuleConfig$1(modules = [], appName, moduleConfigFilename) {
|
|
|
902
902
|
modules.forEach(({
|
|
903
903
|
path
|
|
904
904
|
}) => {
|
|
905
|
-
const moduleConfigPath = resolve$
|
|
905
|
+
const moduleConfigPath = resolve$c(path, moduleConfigFilename);
|
|
906
906
|
|
|
907
|
-
if (fs$
|
|
908
|
-
const content = fs$
|
|
907
|
+
if (fs$9.existsSync(moduleConfigPath)) {
|
|
908
|
+
const content = fs$9.readFileSync(moduleConfigPath, 'utf-8');
|
|
909
909
|
modulesConfig[moduleConfigPath] = adaptMpCgContent(content, appName);
|
|
910
910
|
}
|
|
911
911
|
});
|
|
@@ -926,12 +926,12 @@ const tmsModulesMergeLocalModuleCfg$3 = (modules, appName) => {
|
|
|
926
926
|
path: relativePath,
|
|
927
927
|
name: moduleName
|
|
928
928
|
}, moduleIndex) => {
|
|
929
|
-
const moduleConfigPath = resolve$
|
|
929
|
+
const moduleConfigPath = resolve$c(relativePath, MODULE_CONFIG_FILENAME$1);
|
|
930
930
|
|
|
931
|
-
if (fs$
|
|
931
|
+
if (fs$9.existsSync(moduleConfigPath)) {
|
|
932
932
|
try {
|
|
933
933
|
let findModule = false;
|
|
934
|
-
let moduleConfigContent = fs$
|
|
934
|
+
let moduleConfigContent = fs$9.readFileSync(moduleConfigPath, 'utf-8');
|
|
935
935
|
moduleConfigContent = adaptMpCgContent(moduleConfigContent, appName);
|
|
936
936
|
const moduleContentArr = isObject$1(moduleConfigContent) ? [moduleConfigContent] : moduleConfigContent;
|
|
937
937
|
getValidModules$1(moduleContentArr).forEach(({
|
|
@@ -1041,7 +1041,7 @@ const {
|
|
|
1041
1041
|
global: global$5
|
|
1042
1042
|
} = global_1;
|
|
1043
1043
|
|
|
1044
|
-
function handleError$
|
|
1044
|
+
function handleError$4(error) {
|
|
1045
1045
|
const errMsg = typeof error === 'object' ? error.message : error;
|
|
1046
1046
|
const isDev = global$5.getData('isDev');
|
|
1047
1047
|
|
|
@@ -1054,13 +1054,13 @@ function handleError$5(error) {
|
|
|
1054
1054
|
}
|
|
1055
1055
|
|
|
1056
1056
|
var handleError_1 = {
|
|
1057
|
-
handleError: handleError$
|
|
1057
|
+
handleError: handleError$4
|
|
1058
1058
|
};
|
|
1059
1059
|
|
|
1060
1060
|
/**
|
|
1061
1061
|
* 生成编译后的app.json
|
|
1062
1062
|
*/
|
|
1063
|
-
const fs$
|
|
1063
|
+
const fs$8 = require$$0__default$2;
|
|
1064
1064
|
const {
|
|
1065
1065
|
MODULE_CONFIG_FILENAME,
|
|
1066
1066
|
MODULE_CONFIG_INVALID_KEY
|
|
@@ -1073,11 +1073,11 @@ const {
|
|
|
1073
1073
|
fail: fail$5
|
|
1074
1074
|
} = log$1;
|
|
1075
1075
|
const {
|
|
1076
|
-
resolve: resolve$
|
|
1076
|
+
resolve: resolve$b,
|
|
1077
1077
|
isObject
|
|
1078
1078
|
} = widgets;
|
|
1079
1079
|
const {
|
|
1080
|
-
handleError: handleError$
|
|
1080
|
+
handleError: handleError$3
|
|
1081
1081
|
} = handleError_1;
|
|
1082
1082
|
/**
|
|
1083
1083
|
* 更新appJson里面的主包配置
|
|
@@ -1123,12 +1123,12 @@ function updateMainPackages(appJson, mainPackages = []) {
|
|
|
1123
1123
|
|
|
1124
1124
|
|
|
1125
1125
|
const getAppJsonContent = sourceAppJsonPath => {
|
|
1126
|
-
if (!fs$
|
|
1126
|
+
if (!fs$8.existsSync(sourceAppJsonPath)) {
|
|
1127
1127
|
fail$5(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
|
|
1128
1128
|
process.exit(1);
|
|
1129
1129
|
}
|
|
1130
1130
|
|
|
1131
|
-
const appJson = JSON.parse(fs$
|
|
1131
|
+
const appJson = JSON.parse(fs$8.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
|
|
1132
1132
|
|
|
1133
1133
|
appJson.subpackages = [];
|
|
1134
1134
|
appJson.pages = []; // appJson.plugins = {};
|
|
@@ -1234,17 +1234,17 @@ function buildOutputAppJson$1(tmsConfig, modules) {
|
|
|
1234
1234
|
// 获取当前 modules 下的所有子模块的配置内容
|
|
1235
1235
|
const modulesConfig = getModuleConfig(modules, tmsConfig.appName, MODULE_CONFIG_FILENAME); // 获取app.json的配置
|
|
1236
1236
|
|
|
1237
|
-
const appJson = getAppJsonContent(resolve$
|
|
1237
|
+
const appJson = getAppJsonContent(resolve$b('./app.json')); // 更新app.json中的subpackages
|
|
1238
1238
|
|
|
1239
1239
|
updateSubpackages(appJson, modulesConfig); // 处理appJson中重复||冲突的地方
|
|
1240
1240
|
|
|
1241
1241
|
fixAppJson(appJson); // 更新主包,需在subpackages处理完成后执行, pages/
|
|
1242
1242
|
|
|
1243
1243
|
updateMainPackages(appJson, tmsConfig.mainPackages);
|
|
1244
|
-
fs$
|
|
1244
|
+
fs$8.writeFileSync(resolve$b(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
|
|
1245
1245
|
return appJson;
|
|
1246
1246
|
} catch (e) {
|
|
1247
|
-
handleError$
|
|
1247
|
+
handleError$3(`生成app.json出现错误: ${e}`);
|
|
1248
1248
|
}
|
|
1249
1249
|
}
|
|
1250
1250
|
|
|
@@ -1252,42 +1252,6 @@ var buildAppJson = {
|
|
|
1252
1252
|
buildOutputAppJson: buildOutputAppJson$1
|
|
1253
1253
|
};
|
|
1254
1254
|
|
|
1255
|
-
const fs$8 = require$$0__default$2;
|
|
1256
|
-
const {
|
|
1257
|
-
resolve: resolve$b
|
|
1258
|
-
} = widgets;
|
|
1259
|
-
const {
|
|
1260
|
-
handleError: handleError$3
|
|
1261
|
-
} = handleError_1;
|
|
1262
|
-
const {
|
|
1263
|
-
DEFAULT_CLOUD_MODULE_DIR
|
|
1264
|
-
} = require$$4;
|
|
1265
|
-
/**
|
|
1266
|
-
* 根据相关配置创建软链接
|
|
1267
|
-
* @param { object } tmsConfig
|
|
1268
|
-
*/
|
|
1269
|
-
|
|
1270
|
-
const symLink$1 = tmsConfig => {
|
|
1271
|
-
try {
|
|
1272
|
-
if (tmsConfig.cloudModules) {
|
|
1273
|
-
tmsConfig.cloudModules.forEach(item => {
|
|
1274
|
-
const path = resolve$b(DEFAULT_CLOUD_MODULE_DIR, item.name);
|
|
1275
|
-
fs$8.access(path, fs$8.constants.F_OK, res => {
|
|
1276
|
-
if (res) {
|
|
1277
|
-
fs$8.symlinkSync(resolve$b(item.path), path);
|
|
1278
|
-
}
|
|
1279
|
-
});
|
|
1280
|
-
});
|
|
1281
|
-
}
|
|
1282
|
-
} catch (e) {
|
|
1283
|
-
handleError$3(`创建软链错误: ${e}`);
|
|
1284
|
-
}
|
|
1285
|
-
};
|
|
1286
|
-
|
|
1287
|
-
var symbolicLink = {
|
|
1288
|
-
symLink: symLink$1
|
|
1289
|
-
};
|
|
1290
|
-
|
|
1291
1255
|
/**
|
|
1292
1256
|
* 下载第三方代码
|
|
1293
1257
|
*/
|
|
@@ -1556,7 +1520,7 @@ const getMpCi = ({
|
|
|
1556
1520
|
privateKey,
|
|
1557
1521
|
type,
|
|
1558
1522
|
projectPath,
|
|
1559
|
-
ignores: ['node_modules/**/*', ...ignores]
|
|
1523
|
+
ignores: ['node_modules/**/*', 'cloud/**/*', ...ignores]
|
|
1560
1524
|
});
|
|
1561
1525
|
}; // 用小程序ci工具构建小程序
|
|
1562
1526
|
|
|
@@ -1674,8 +1638,9 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1674
1638
|
const newShellJsOption = { ...shellJsOption,
|
|
1675
1639
|
cwd: packageJsonDir
|
|
1676
1640
|
};
|
|
1641
|
+
shell.cd(packageJsonDir);
|
|
1677
1642
|
shell.exec('tar -xvf ./node_modules.tar.gz -C ./', newShellJsOption);
|
|
1678
|
-
shell.rm('-rf', './node_modules');
|
|
1643
|
+
shell.rm('-rf', './node_modules.tar.gz');
|
|
1679
1644
|
}
|
|
1680
1645
|
};
|
|
1681
1646
|
|
|
@@ -1697,6 +1662,7 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1697
1662
|
const newShellJsOption = { ...shellJsOption,
|
|
1698
1663
|
cwd: cacheNMPath
|
|
1699
1664
|
};
|
|
1665
|
+
shell.cd(cacheNMPath);
|
|
1700
1666
|
shell.exec('tar -cvf ./node_modules.tar.gz ./node_modules', newShellJsOption);
|
|
1701
1667
|
shell.rm('-rf', './node_modules');
|
|
1702
1668
|
});
|
|
@@ -1891,9 +1857,6 @@ const {
|
|
|
1891
1857
|
const {
|
|
1892
1858
|
buildOutputAppJson
|
|
1893
1859
|
} = buildAppJson;
|
|
1894
|
-
const {
|
|
1895
|
-
symLink
|
|
1896
|
-
} = symbolicLink;
|
|
1897
1860
|
const {
|
|
1898
1861
|
MODULE_CODE_DIR: MODULE_CODE_DIR$1,
|
|
1899
1862
|
DEFAULT_COPY_CONFIG
|
|
@@ -1954,7 +1917,6 @@ async function task(tmsConfig, targetModules) {
|
|
|
1954
1917
|
await install$1(tmsConfig, newModules, false); // 动态生成编译后的app.json;
|
|
1955
1918
|
|
|
1956
1919
|
await createTask(buildOutputAppJson, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
|
|
1957
|
-
await createTask(symLink, '开始创建软链接', '创建软链接完成')(tmsConfig);
|
|
1958
1920
|
return newModules;
|
|
1959
1921
|
}
|
|
1960
1922
|
|
|
@@ -3294,7 +3256,7 @@ var entry = [{
|
|
|
3294
3256
|
|
|
3295
3257
|
var require$$7 = {
|
|
3296
3258
|
name: "@tmsfe/tmskit",
|
|
3297
|
-
version: "0.0.
|
|
3259
|
+
version: "0.0.14",
|
|
3298
3260
|
description: "tmskit",
|
|
3299
3261
|
main: "dist/index.cjs",
|
|
3300
3262
|
bin: {
|
|
@@ -3308,7 +3270,10 @@ var require$$7 = {
|
|
|
3308
3270
|
],
|
|
3309
3271
|
scripts: {
|
|
3310
3272
|
dev: "rollup -wc --environment TARGET:tmskit",
|
|
3311
|
-
build: "rollup -c --environment TARGET:tmskit"
|
|
3273
|
+
build: "rollup -c --environment TARGET:tmskit",
|
|
3274
|
+
"pub:patch": "sh build/publish.sh patch",
|
|
3275
|
+
"pub:minor": "sh build/publish.sh minor",
|
|
3276
|
+
"pub:major": "sh build/publish.sh major"
|
|
3312
3277
|
},
|
|
3313
3278
|
author: "tms·web",
|
|
3314
3279
|
license: "ISC",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmsfe/tmskit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "tmskit",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"bin": {
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"dev": "rollup -wc --environment TARGET:tmskit",
|
|
17
|
-
"build": "rollup -c --environment TARGET:tmskit"
|
|
17
|
+
"build": "rollup -c --environment TARGET:tmskit",
|
|
18
|
+
"pub:patch": "sh build/publish.sh patch",
|
|
19
|
+
"pub:minor": "sh build/publish.sh minor",
|
|
20
|
+
"pub:major": "sh build/publish.sh major"
|
|
18
21
|
},
|
|
19
22
|
"author": "tms·web",
|
|
20
23
|
"license": "ISC",
|
package/src/core/mpCi.js
CHANGED
package/src/core/npm.js
CHANGED
|
@@ -51,8 +51,9 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
51
51
|
...shellJsOption,
|
|
52
52
|
cwd: packageJsonDir,
|
|
53
53
|
};
|
|
54
|
+
shell.cd(packageJsonDir);
|
|
54
55
|
shell.exec('tar -xvf ./node_modules.tar.gz -C ./', newShellJsOption);
|
|
55
|
-
shell.rm('-rf', './node_modules');
|
|
56
|
+
shell.rm('-rf', './node_modules.tar.gz');
|
|
56
57
|
},
|
|
57
58
|
};
|
|
58
59
|
|
|
@@ -75,6 +76,7 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
75
76
|
...shellJsOption,
|
|
76
77
|
cwd: cacheNMPath,
|
|
77
78
|
};
|
|
79
|
+
shell.cd(cacheNMPath);
|
|
78
80
|
shell.exec('tar -cvf ./node_modules.tar.gz ./node_modules', newShellJsOption);
|
|
79
81
|
shell.rm('-rf', './node_modules');
|
|
80
82
|
});
|
package/src/core/symbolicLink.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const { resolve } = require('../utils/widgets');
|
|
3
3
|
const { handleError } = require('./handleError');
|
|
4
|
-
const {
|
|
4
|
+
const { ensureDirExist } = require('../utils/io');
|
|
5
|
+
const { warn } = require('../utils/log');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 根据相关配置创建软链接
|
|
@@ -9,14 +10,19 @@ const { DEFAULT_CLOUD_MODULE_DIR } = require('../config/constant');
|
|
|
9
10
|
*/
|
|
10
11
|
const symLink = (tmsConfig) => {
|
|
11
12
|
try {
|
|
13
|
+
ensureDirExist(resolve(tmsConfig.cloudDir));
|
|
12
14
|
if (tmsConfig.cloudModules) {
|
|
13
15
|
tmsConfig.cloudModules.forEach((item) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
16
|
+
const sourcePath = resolve(item.path);
|
|
17
|
+
const targetPath = resolve(tmsConfig.cloudDir, item.name);
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(sourcePath)) {
|
|
20
|
+
warn(`云函数${sourcePath}不存在`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!fs.existsSync(targetPath)) {
|
|
24
|
+
fs.symlinkSync(sourcePath, targetPath);
|
|
25
|
+
}
|
|
20
26
|
});
|
|
21
27
|
}
|
|
22
28
|
} catch (e) {
|
|
@@ -3,7 +3,6 @@ const fs = require('fs');
|
|
|
3
3
|
const io = require('../../../utils/io');
|
|
4
4
|
const { resolve, createTask } = require('../../../utils/widgets');
|
|
5
5
|
const { buildOutputAppJson } = require('../../../core/buildAppJson');
|
|
6
|
-
const { symLink } = require('../../../core/symbolicLink');
|
|
7
6
|
const { MODULE_CODE_DIR, DEFAULT_COPY_CONFIG } = require('../../../config/constant');
|
|
8
7
|
const { cloneModules } = require('../../../core/cloneModules');
|
|
9
8
|
const { tmsModulesMergeLocalModuleCfg, subModulesMergeDepModules } = require('../../../core/tmsMpconfig');
|
|
@@ -69,12 +68,6 @@ async function task(tmsConfig, targetModules) {
|
|
|
69
68
|
'生成编译后的app.json完成',
|
|
70
69
|
)(tmsConfig, newModules);
|
|
71
70
|
|
|
72
|
-
await createTask(
|
|
73
|
-
symLink,
|
|
74
|
-
'开始创建软链接',
|
|
75
|
-
'创建软链接完成',
|
|
76
|
-
)(tmsConfig);
|
|
77
|
-
|
|
78
71
|
return newModules;
|
|
79
72
|
}
|
|
80
73
|
async function init(tmsConfig, targetModules) {
|