@tmsfe/tmskit 0.0.19 → 0.0.20
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/CHANGELOG.md +6 -1
- package/dist/index.cjs.js +963 -812
- package/package.json +10 -8
- package/src/compile/build.js +2 -2
- package/src/compile/dev.js +30 -25
- package/src/compile/watch.js +31 -12
- package/src/config/constant.js +24 -3
- package/src/core/buildAppJson.js +14 -21
- package/src/core/checkDependencies.js +34 -17
- package/src/core/cloneModules.js +5 -7
- package/src/core/handleError.js +7 -1
- package/src/core/npm.js +7 -2
- package/src/core/tmsMpconfig.js +87 -74
- package/src/entry.js +3 -3
- package/src/scripts/create/generator.js +1 -2
- package/src/scripts/create/index.js +73 -32
- package/src/scripts/run/build/index.js +5 -4
- package/src/scripts/run/dev/index.js +14 -13
- package/src/scripts/run/index.js +68 -54
- package/src/scripts/run/init/index.js +13 -12
- package/src/scripts/run/install/index.js +4 -3
|
@@ -5,7 +5,7 @@ const { resolve, createTask } = require('../../../utils/widgets');
|
|
|
5
5
|
const { buildOutputAppJson } = require('../../../core/buildAppJson');
|
|
6
6
|
const { MODULE_CODE_DIR, DEFAULT_COPY_CONFIG } = require('../../../config/constant');
|
|
7
7
|
const { cloneModules } = require('../../../core/cloneModules');
|
|
8
|
-
const {
|
|
8
|
+
const { getModulesByMergeDepModules, getSubPackages } = require('../../../core/tmsMpconfig');
|
|
9
9
|
const { fail, info } = require('../../../utils/log');
|
|
10
10
|
const install = require('../install');
|
|
11
11
|
|
|
@@ -53,12 +53,12 @@ async function task(tmsConfig, targetModules) {
|
|
|
53
53
|
'下载模块代码码完成',
|
|
54
54
|
)(MODULE_CODE_DIR, resolve('./'), targetModules);
|
|
55
55
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
//
|
|
59
|
-
|
|
56
|
+
// 获取所有模块,合并模块依赖的模块
|
|
57
|
+
const newModules = getModulesByMergeDepModules(tmsConfig, targetModules, true);
|
|
58
|
+
// 获取所有的分包
|
|
59
|
+
const newSubPackages = getSubPackages(newModules);
|
|
60
60
|
|
|
61
|
-
checkConfig(
|
|
61
|
+
checkConfig(newSubPackages);
|
|
62
62
|
|
|
63
63
|
// 拷贝相关配置文件到输出目录
|
|
64
64
|
await createTask(
|
|
@@ -68,7 +68,7 @@ async function task(tmsConfig, targetModules) {
|
|
|
68
68
|
)(tmsConfig, DEFAULT_COPY_CONFIG);
|
|
69
69
|
|
|
70
70
|
// install
|
|
71
|
-
await install(tmsConfig,
|
|
71
|
+
await install(tmsConfig, newSubPackages);
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
// 动态生成编译后的app.json;
|
|
@@ -78,15 +78,16 @@ async function task(tmsConfig, targetModules) {
|
|
|
78
78
|
'生成编译后的app.json完成',
|
|
79
79
|
)(tmsConfig, newModules);
|
|
80
80
|
|
|
81
|
-
return
|
|
81
|
+
return {
|
|
82
|
+
modules: newModules,
|
|
83
|
+
subPackages: newSubPackages,
|
|
84
|
+
};
|
|
82
85
|
}
|
|
83
86
|
async function init(tmsConfig, targetModules) {
|
|
84
87
|
try {
|
|
85
|
-
const
|
|
88
|
+
const taskRes = await task(tmsConfig, targetModules);
|
|
86
89
|
|
|
87
|
-
return
|
|
88
|
-
targetModules: newModules,
|
|
89
|
-
};
|
|
90
|
+
return taskRes;
|
|
90
91
|
} catch (error) {
|
|
91
92
|
const errMsg = typeof error === 'object' ? error.message : error;
|
|
92
93
|
fail(`初始化流程出现错误${errMsg}`);
|
|
@@ -11,7 +11,7 @@ const { fail, info } = require('../../../utils/log');
|
|
|
11
11
|
const { fileMd5 } = require('../../../utils/md5');
|
|
12
12
|
const { isDependenciesUpdate } = require('../../../core/checkDependencies');
|
|
13
13
|
|
|
14
|
-
async function install(tmsConfig, modules,
|
|
14
|
+
async function install(tmsConfig, modules, useCache = true) {
|
|
15
15
|
const cwd = process.cwd();
|
|
16
16
|
const npmInstallRes = await createTask(
|
|
17
17
|
npmInstall,
|
|
@@ -121,8 +121,9 @@ async function getMNPMd5(cwd) {
|
|
|
121
121
|
shelljs.cd(cwd);
|
|
122
122
|
if (fs.existsSync('miniprogram_npm')) {
|
|
123
123
|
shelljs.exec('tar -cvf ./miniprogram_npm.tar.gz ./miniprogram_npm', { cwd, ...shellJsOption });
|
|
124
|
-
const
|
|
125
|
-
|
|
124
|
+
const tarDir = path.join(cwd, './miniprogram_npm.tar.gz');
|
|
125
|
+
const md5Value = await fileMd5(tarDir);
|
|
126
|
+
shelljs.rm('-rf', tarDir);
|
|
126
127
|
return md5Value;
|
|
127
128
|
}
|
|
128
129
|
return '';
|