@tmsfe/tmskit 0.0.17 → 0.0.18
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 -2
- package/dist/index.cjs.js +320 -340
- package/package.json +1 -1
- package/src/compile/dev.js +6 -2
- package/src/config/constant.js +1 -3
- package/src/config/defaultTmsConfig.js +1 -1
- package/src/core/buildAppJson.js +29 -30
- package/src/core/cloneModules.js +3 -3
- package/src/core/tmsMpconfig.js +2 -37
- package/src/scripts/run/build/index.js +5 -2
- package/src/scripts/run/dev/index.js +7 -3
- package/src/scripts/run/index.js +33 -16
- package/src/scripts/run/install/index.js +1 -3
- package/src/utils/widgets.js +17 -0
package/package.json
CHANGED
package/src/compile/dev.js
CHANGED
|
@@ -3,7 +3,7 @@ const fs = require('fs');
|
|
|
3
3
|
const ora = require('ora');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const { parallel, series } = require('gulp');
|
|
6
|
-
const { resolve, mergeMap } = require('../utils/widgets');
|
|
6
|
+
const { resolve, mergeMap, filterField } = require('../utils/widgets');
|
|
7
7
|
const { buildOutputAppJson } = require('../core/buildAppJson');
|
|
8
8
|
const { DEFAULT_COPY_CONFIG } = require('../config/constant');
|
|
9
9
|
const compile = require('./compile');
|
|
@@ -154,7 +154,11 @@ module.exports = async (tmsConfig, newModules, isDev = true) => {
|
|
|
154
154
|
}
|
|
155
155
|
eTime = new Date().getTime() - sTime;
|
|
156
156
|
if (typeof tmsConfig?.hooks?.afterCompile === 'function') {
|
|
157
|
-
await tmsConfig?.hooks?.afterCompile({
|
|
157
|
+
await tmsConfig?.hooks?.afterCompile({
|
|
158
|
+
isDev,
|
|
159
|
+
tmsConfig: filterField(tmsConfig, ['gitAccount']),
|
|
160
|
+
modules: newModules,
|
|
161
|
+
});
|
|
158
162
|
}
|
|
159
163
|
spinner.succeed(chalk.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
|
|
160
164
|
spinner.stop();
|
package/src/config/constant.js
CHANGED
|
@@ -14,7 +14,7 @@ const TEMPLATE_DIR = path.resolve(CACHE_DIR, 'template');
|
|
|
14
14
|
const MODULE_CODE_DIR = path.resolve(CACHE_DIR, 'modules_code');
|
|
15
15
|
|
|
16
16
|
// 脚手架模板代码的具体路径
|
|
17
|
-
const TEMPLATE_PATH = path.resolve(TEMPLATE_DIR, 'tools/
|
|
17
|
+
const TEMPLATE_PATH = path.resolve(TEMPLATE_DIR, 'tools/tmskit-template');
|
|
18
18
|
|
|
19
19
|
// 脚手架的名称
|
|
20
20
|
const TMS_NAME = 'tmskit';
|
|
@@ -47,7 +47,6 @@ const ENV = {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
const TEMPLATE_TKIT_DIR = '_tmskit';
|
|
50
|
-
const MODULE_CONFIG_INVALID_KEY = ['entranceDeclare', 'entryPagePath'];
|
|
51
50
|
|
|
52
51
|
export {
|
|
53
52
|
HOME_DIR,
|
|
@@ -64,6 +63,5 @@ export {
|
|
|
64
63
|
MODULE_CODE_DIR,
|
|
65
64
|
ENV,
|
|
66
65
|
TEMPLATE_TKIT_DIR,
|
|
67
|
-
MODULE_CONFIG_INVALID_KEY,
|
|
68
66
|
DEFAULT_CLOUD_MODULE_DIR,
|
|
69
67
|
};
|
package/src/core/buildAppJson.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/* eslint-disable no-param-reassign */
|
|
5
5
|
const fs = require('fs');
|
|
6
|
-
const { MODULE_CONFIG_FILENAME
|
|
6
|
+
const { MODULE_CONFIG_FILENAME } = require('../config/constant');
|
|
7
7
|
const { getModuleConfig } = require('./tmsMpconfig');
|
|
8
8
|
const { fail } = require('../utils/log');
|
|
9
|
-
const { resolve, isObject } = require('../utils/widgets');
|
|
9
|
+
const { resolve, isObject, filterField } = require('../utils/widgets');
|
|
10
10
|
const { handleError } = require('./handleError');
|
|
11
11
|
const { global } = require('../utils/global');
|
|
12
12
|
|
|
@@ -56,8 +56,6 @@ const getAppJsonContent = (sourceAppJsonPath) => {
|
|
|
56
56
|
// 加入默认值
|
|
57
57
|
appJson.subpackages = [];
|
|
58
58
|
appJson.pages = [];
|
|
59
|
-
// appJson.plugins = {};
|
|
60
|
-
delete appJson.entranceDeclare;
|
|
61
59
|
return appJson;
|
|
62
60
|
};
|
|
63
61
|
/**
|
|
@@ -83,37 +81,35 @@ const fixAppJson = (appJson) => {
|
|
|
83
81
|
const pluginsMap = {};
|
|
84
82
|
Object.keys(appJson.plugins || {}).forEach(key => pluginsMap[key] = ['app.json']);
|
|
85
83
|
const subps = subpackages.map((subp) => {
|
|
86
|
-
const
|
|
84
|
+
const arrOfFileType = ['requiredBackgroundModes', 'embeddedAppIdList'];
|
|
85
|
+
const objOfFileType = ['preloadRule'];
|
|
87
86
|
Object.keys(subp).forEach((key) => {
|
|
88
|
-
if (key === 'dependencies') {
|
|
89
|
-
// eslint-disable-next-line
|
|
90
|
-
delete subp.dependencies;
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
87
|
if (key === 'plugins') {
|
|
94
88
|
Object.keys(subp.plugins).forEach((pk) => {
|
|
95
|
-
pluginsMap[pk]
|
|
89
|
+
pluginsMap[pk]
|
|
90
|
+
? pluginsMap[pk].push(`分包${subp.name}`)
|
|
91
|
+
: pluginsMap[pk] = [`分包${subp.name}`];
|
|
96
92
|
});
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
if (MODULE_CONFIG_INVALID_KEY.indexOf(key) > -1) {
|
|
100
|
-
// 如果分包配置中有不支持的key,则错误提醒
|
|
101
|
-
invalidKeys.push(key);
|
|
102
|
-
return;
|
|
103
93
|
}
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
// 分包里数组类型字段,提到appjson最上层
|
|
95
|
+
if (arrOfFileType.indexOf(key) > -1) {
|
|
106
96
|
const preVal = appJson[key];
|
|
107
|
-
preVal
|
|
108
|
-
.slice(0).concat(subp[key])))
|
|
109
|
-
|
|
97
|
+
preVal
|
|
98
|
+
? appJson[key] = Array.from(new Set(preVal.slice(0).concat(subp[key])))
|
|
99
|
+
: appJson[key] = subp[key].slice(0);
|
|
100
|
+
}
|
|
101
|
+
// 分包里对象类型字段,提到appjson最上层
|
|
102
|
+
if (objOfFileType.indexOf(key) > -1) {
|
|
103
|
+
const preloadRuleMap = appJson[key] || {};
|
|
104
|
+
subp[key] && Object.keys(subp[key]).forEach((page) => {
|
|
105
|
+
if (!preloadRuleMap[page]) {
|
|
106
|
+
preloadRuleMap[page] = subp[key][page];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
appJson[key] = preloadRuleMap;
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
|
-
|
|
113
|
-
fail(`不支持分包${subp?.name}配置${invalidKeys.join(',')}\n`);
|
|
114
|
-
}
|
|
115
|
-
invalidKeys.concat(['requiredBackgroundModes', 'embeddedAppIdList']).forEach(k => delete subp[k]);
|
|
116
|
-
return subp;
|
|
112
|
+
return filterField(subp, [...arrOfFileType, ...objOfFileType, 'dependencies']);
|
|
117
113
|
});
|
|
118
114
|
// 如果plugins重复,则错误提示
|
|
119
115
|
const pluginsErrMsg = Object.keys(pluginsMap).map((pk) => {
|
|
@@ -124,7 +120,7 @@ const fixAppJson = (appJson) => {
|
|
|
124
120
|
})
|
|
125
121
|
.reduce((pre, cur) => pre + cur, '');
|
|
126
122
|
if (pluginsErrMsg) {
|
|
127
|
-
|
|
123
|
+
throw new Error(`plugins配置出现错误:${pluginsErrMsg}`);
|
|
128
124
|
}
|
|
129
125
|
appJson.subpackages = subps;
|
|
130
126
|
};
|
|
@@ -149,12 +145,15 @@ function buildOutputAppJson(tmsConfig, modules) {
|
|
|
149
145
|
updateMainPackages(appJson, tmsConfig.mainPackages);
|
|
150
146
|
|
|
151
147
|
fs.writeFileSync(resolve(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
|
|
148
|
+
|
|
152
149
|
if (typeof tmsConfig?.hooks?.updateAppJson === 'function') {
|
|
153
150
|
tmsConfig?.hooks?.updateAppJson({
|
|
154
|
-
tmsConfig
|
|
151
|
+
tmsConfig: filterField(tmsConfig, ['gitAccount']),
|
|
152
|
+
modules,
|
|
153
|
+
appJson,
|
|
154
|
+
isDev: global.getData('isDev'),
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
|
-
|
|
158
157
|
return appJson;
|
|
159
158
|
} catch (e) {
|
|
160
159
|
handleError(`生成app.json出现错误: ${e}`);
|
package/src/core/cloneModules.js
CHANGED
|
@@ -18,11 +18,11 @@ const { global } = require('../utils/global');
|
|
|
18
18
|
*/
|
|
19
19
|
function replaceGitUrlAccount(httpRepoUrl, moduleName) {
|
|
20
20
|
// 用户本地的私有项目配置(用来配置环境\模块信息\账号信息)
|
|
21
|
-
const
|
|
21
|
+
const tmsConfig = global.getData('tmsConfig');
|
|
22
22
|
|
|
23
23
|
let gitUrl = httpRepoUrl;
|
|
24
|
-
const { username = '', pass = '' } =
|
|
25
|
-
||
|
|
24
|
+
const { username = '', pass = '' } = tmsConfig?.gitAccout?.[moduleName]
|
|
25
|
+
|| tmsConfig?.gitAccount?.[moduleName]
|
|
26
26
|
|| {};
|
|
27
27
|
|
|
28
28
|
const urlPrefixReg = /http(s)?:\/\//;
|
package/src/core/tmsMpconfig.js
CHANGED
|
@@ -7,7 +7,6 @@ const { TMS_CONFIG_FILENAME, MODULE_CONFIG_FILENAME, TMS_PRIVATE_FILENAME } = re
|
|
|
7
7
|
const { resolve, isObject, isArray } = require('../utils/widgets');
|
|
8
8
|
const defaultTmsConfig = require('../config/defaultTmsConfig');
|
|
9
9
|
const { fail } = require('../utils/log');
|
|
10
|
-
const path = require('path');
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* 读取tms.config.js
|
|
@@ -26,32 +25,9 @@ const readTmsConfig = function (env) {
|
|
|
26
25
|
// 合并默认值
|
|
27
26
|
loadash.mergeWith(tmsConfig, defaultTmsConfig);
|
|
28
27
|
|
|
29
|
-
// modules兼容处理
|
|
30
|
-
tmsConfig.modules = convertModules(tmsConfig.modules);
|
|
31
28
|
return tmsConfig;
|
|
32
29
|
};
|
|
33
30
|
|
|
34
|
-
// convertModules 处理默认值
|
|
35
|
-
const convertModules = (modules) => {
|
|
36
|
-
const newModules = [];
|
|
37
|
-
modules.forEach((module) => {
|
|
38
|
-
const newModule = {};
|
|
39
|
-
if (typeof module === 'string') {
|
|
40
|
-
// 路径字符串
|
|
41
|
-
Object.assign(newModule, {
|
|
42
|
-
name: path.basename(module),
|
|
43
|
-
path: module,
|
|
44
|
-
});
|
|
45
|
-
} else if (typeof module === 'object') {
|
|
46
|
-
Object.assign(newModule, module);
|
|
47
|
-
if (module.name === undefined) {
|
|
48
|
-
newModule.name = path.basename(module.path);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
newModules.push(newModule);
|
|
52
|
-
});
|
|
53
|
-
return newModules;
|
|
54
|
-
};
|
|
55
31
|
|
|
56
32
|
/**
|
|
57
33
|
* 读取tms.private.config.js
|
|
@@ -62,12 +38,7 @@ const readTmsPrivateCf = function () {
|
|
|
62
38
|
if (fs.existsSync(tmsPrivatePath)) {
|
|
63
39
|
tmsPrivateCf = require(tmsPrivatePath);
|
|
64
40
|
}
|
|
65
|
-
|
|
66
|
-
if (tmsPrivateCf.modules instanceof Array) {
|
|
67
|
-
Object.assign(tmsPrivateCf.modules, {
|
|
68
|
-
include: tmsPrivateCf.modules,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
41
|
+
|
|
71
42
|
return tmsPrivateCf;
|
|
72
43
|
};
|
|
73
44
|
|
|
@@ -80,11 +51,10 @@ const readTmsPrivateCf = function () {
|
|
|
80
51
|
const checkModules = function (tmsConfig, modules, isQuit = false) {
|
|
81
52
|
const targetModules = [];
|
|
82
53
|
modules.forEach((moduleName) => {
|
|
83
|
-
const module = tmsConfig.modules.find(module => module.name === moduleName);
|
|
54
|
+
const module = tmsConfig.modules.all.find(module => module.name === moduleName);
|
|
84
55
|
module && targetModules.push(module);
|
|
85
56
|
});
|
|
86
57
|
|
|
87
|
-
|
|
88
58
|
if (targetModules.length === 0) {
|
|
89
59
|
fail(`你启动的模块无效${modules.join(',')}无效,请检查tms.config.json>modules>${modules.join(',')}
|
|
90
60
|
>name字段与module.config.json的name字段是否一致`);
|
|
@@ -119,11 +89,6 @@ function adaptMpCgContent(fileContent, appName) {
|
|
|
119
89
|
i--; // eslint-disable-line
|
|
120
90
|
}
|
|
121
91
|
} else {
|
|
122
|
-
if (appName && content.mpConfig && content.mpConfig[appName]) {
|
|
123
|
-
content = { ...content, ...content.mpConfig[appName] };
|
|
124
|
-
delete content.mpConfig;
|
|
125
|
-
delete content.isSubpackages;
|
|
126
|
-
}
|
|
127
92
|
content = handleContent(appName, content);
|
|
128
93
|
}
|
|
129
94
|
return content;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const shelljs = require('shelljs');
|
|
2
|
-
const { resolve } = require('../../../utils/widgets');
|
|
2
|
+
const { resolve, filterField } = require('../../../utils/widgets');
|
|
3
3
|
const init = require('../init/index');
|
|
4
4
|
const compileBuild = require('../../../compile/build');
|
|
5
5
|
|
|
@@ -10,7 +10,10 @@ async function build(tmsConfig, targetModules, env) {
|
|
|
10
10
|
const { targetModules: newModules } = await init(tmsConfig, targetModules);
|
|
11
11
|
|
|
12
12
|
if (typeof tmsConfig?.hooks?.beforeCompile === 'function') {
|
|
13
|
-
await tmsConfig?.hooks?.beforeCompile({
|
|
13
|
+
await tmsConfig?.hooks?.beforeCompile({
|
|
14
|
+
isDev: false,
|
|
15
|
+
tmsConfig: filterField(tmsConfig, ['gitAccount']),
|
|
16
|
+
modules: newModules });
|
|
14
17
|
};
|
|
15
18
|
compileBuild(tmsConfig, newModules, env);
|
|
16
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const shelljs = require('shelljs');
|
|
2
2
|
const compileDev = require('../../../compile/dev');
|
|
3
|
-
const { resolve } = require('../../../utils/widgets');
|
|
3
|
+
const { resolve, filterField } = require('../../../utils/widgets');
|
|
4
4
|
const init = require('../init/index');
|
|
5
5
|
const { tmsModulesMergeLocalModuleCfg } = require('../../../core/tmsMpconfig');
|
|
6
6
|
const { info } = require('../../../utils/log');
|
|
@@ -10,7 +10,7 @@ const { CACHE_DIR } = require('../../../config/constant');
|
|
|
10
10
|
|
|
11
11
|
// 用户编译分包时,需要将dist中其他分包(主包不能删除)的内容删除,否则其他分包的内容混入到主包(导致主包的体积超2M)
|
|
12
12
|
function delOtherModule(tmsConfig, targetModules) {
|
|
13
|
-
const modules = tmsModulesMergeLocalModuleCfg(tmsConfig.modules, tmsConfig.appName);
|
|
13
|
+
const modules = tmsModulesMergeLocalModuleCfg(tmsConfig.modules.all, tmsConfig.appName);
|
|
14
14
|
const targetModulesName = targetModules.map(item => item.name);
|
|
15
15
|
modules.forEach((item) => {
|
|
16
16
|
if (item.root && targetModulesName.indexOf(item.name) === -1) {
|
|
@@ -36,7 +36,11 @@ async function dev(tmsConfig, targetModules, env) {
|
|
|
36
36
|
|
|
37
37
|
info('当前dev启动的有效模块', newModules.map(item => item.name).sort());
|
|
38
38
|
if (typeof tmsConfig?.hooks?.beforeCompile === 'function') {
|
|
39
|
-
await tmsConfig?.hooks?.beforeCompile({
|
|
39
|
+
await tmsConfig?.hooks?.beforeCompile({
|
|
40
|
+
isDev: true,
|
|
41
|
+
tmsConfig: filterField(tmsConfig, ['gitAccount']),
|
|
42
|
+
modules: newModules,
|
|
43
|
+
});
|
|
40
44
|
};
|
|
41
45
|
delOtherModule(tmsConfig, newModules);
|
|
42
46
|
compileDev(tmsConfig, newModules, env);
|
package/src/scripts/run/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
const loadash = require('lodash');
|
|
1
3
|
const init = require('./init/index');
|
|
2
4
|
const dev = require('./dev/index');
|
|
3
5
|
const build = require('./build/index');
|
|
@@ -25,34 +27,50 @@ const handleModuleArg = (cmd) => {
|
|
|
25
27
|
* @param {Object} modulePrivateCfg 私有配置里的模块
|
|
26
28
|
* @param {Array} moduleAll 当前小程序全部模块
|
|
27
29
|
*/
|
|
28
|
-
const getSpecificModules = (moduleArg,
|
|
30
|
+
const getSpecificModules = (moduleArg, modules) => {
|
|
29
31
|
if (moduleArg.length > 0) {
|
|
30
32
|
return moduleArg;
|
|
31
33
|
}
|
|
34
|
+
const { all, include, exclude, blockRemote } = modules;
|
|
32
35
|
// 单模块或多模块开发-用户在tms.private.js指定的模块
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
if (include?.length > 0) {
|
|
37
|
+
return include;
|
|
38
|
+
}
|
|
39
|
+
if (exclude?.length > 0) {
|
|
40
|
+
return all.filter(module => !exclude.includes(module.name)).map(item => item.name);
|
|
41
|
+
}
|
|
42
|
+
if (blockRemote === true) {
|
|
43
|
+
return all.filter(module => module.repoInfo === undefined).map(item => item.name);
|
|
44
|
+
}
|
|
45
|
+
return all.map(item => item.name);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const mergeConfig = (tmsConfig, tmsPrivateCf) => {
|
|
49
|
+
const modules = {};
|
|
50
|
+
if (Array.isArray(tmsConfig.modules)) {
|
|
51
|
+
modules.all = tmsConfig.modules;
|
|
52
|
+
tmsConfig.modules = modules;
|
|
43
53
|
}
|
|
44
|
-
|
|
54
|
+
// 合并默认值
|
|
55
|
+
const res = loadash.mergeWith(tmsConfig, tmsPrivateCf, (objValue, srcValue) => {
|
|
56
|
+
if (loadash.isArray(objValue) && objValue[0] && loadash.isObject(objValue[0])) {
|
|
57
|
+
return objValue.concat(srcValue);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return res;
|
|
45
62
|
};
|
|
46
63
|
|
|
47
64
|
async function run(commandName, cmd) {
|
|
48
|
-
//
|
|
65
|
+
// 用户本地的私有项目配置
|
|
49
66
|
const tmsPrivateCf = readTmsPrivateCf();
|
|
50
67
|
const { env = tmsPrivateCf?.env } = cmd;
|
|
51
|
-
|
|
68
|
+
let tmsConfig = readTmsConfig(env);
|
|
69
|
+
tmsConfig = mergeConfig(tmsConfig, tmsPrivateCf);
|
|
70
|
+
|
|
52
71
|
// 处理module参数
|
|
53
72
|
const specificModules = getSpecificModules(
|
|
54
73
|
handleModuleArg(cmd),
|
|
55
|
-
tmsPrivateCf.modules,
|
|
56
74
|
tmsConfig.modules,
|
|
57
75
|
);
|
|
58
76
|
|
|
@@ -76,7 +94,6 @@ async function run(commandName, cmd) {
|
|
|
76
94
|
global.setData({
|
|
77
95
|
env,
|
|
78
96
|
cmd,
|
|
79
|
-
tmsPrivateCf,
|
|
80
97
|
tmsConfig,
|
|
81
98
|
});
|
|
82
99
|
|
|
@@ -5,7 +5,6 @@ const { createTask, resolve } = require('../../../utils/widgets');
|
|
|
5
5
|
const { buildMpNpm } = require('../../../core/mpCi');
|
|
6
6
|
const { CACHE_DIR } = require('../../../config/constant');
|
|
7
7
|
const { mpNpmInstallAll } = require('../../../core/npm');
|
|
8
|
-
const { global } = require('../../../utils/global');
|
|
9
8
|
const { fail } = require('../../../utils/log');
|
|
10
9
|
|
|
11
10
|
async function install(tmsConfig, modules) {
|
|
@@ -28,13 +27,12 @@ async function install(tmsConfig, modules) {
|
|
|
28
27
|
'小程序npm install 完成',
|
|
29
28
|
)(modules, resolve(tmsConfig.outputDir), `${CACHE_DIR}/node_modules`);
|
|
30
29
|
|
|
31
|
-
const tmsPrivateCf = global.getData('tmsPrivateCf');
|
|
32
30
|
// 构建miniprogram_npm
|
|
33
31
|
await createTask(
|
|
34
32
|
buildMpNpm,
|
|
35
33
|
'开始构建miniprogram_npm',
|
|
36
34
|
'构建miniprogram_npm 完成',
|
|
37
|
-
)({ appId: tmsConfig.appId, projectPath: resolve('./'), privateKey:
|
|
35
|
+
)({ appId: tmsConfig.appId, projectPath: resolve('./'), privateKey: tmsConfig.privateKey });
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
module.exports = install;
|
package/src/utils/widgets.js
CHANGED
|
@@ -180,6 +180,22 @@ const relativeCwdPath = function (file) {
|
|
|
180
180
|
return path.relative(process.cwd(), file);
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
+
/**
|
|
184
|
+
* 从一个对象中,检索出去几个字段
|
|
185
|
+
* @param {*} obj
|
|
186
|
+
* @param {*} name
|
|
187
|
+
* @returns
|
|
188
|
+
*/
|
|
189
|
+
const filterField = (obj, filterNames = []) => {
|
|
190
|
+
const newObj = { ...obj };
|
|
191
|
+
filterNames.forEach((name) => {
|
|
192
|
+
if (newObj[name]) {
|
|
193
|
+
delete newObj[name];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
return newObj;
|
|
197
|
+
};
|
|
198
|
+
|
|
183
199
|
module.exports = {
|
|
184
200
|
resolve,
|
|
185
201
|
isObject,
|
|
@@ -192,4 +208,5 @@ module.exports = {
|
|
|
192
208
|
npmInstall,
|
|
193
209
|
mergeMap,
|
|
194
210
|
relativeCwdPath,
|
|
211
|
+
filterField,
|
|
195
212
|
};
|