@tmsfe/tmskit 0.0.15 → 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 +20 -2
- package/README.md +2 -3
- package/build/publish.sh +34 -0
- package/dist/index.cjs.js +964 -602
- package/package.json +13 -2
- package/src/compile/compile.js +56 -35
- package/src/compile/dev.js +40 -31
- package/src/compile/plugins/gulp-watch/index.js +172 -0
- package/src/compile/plugins/mpJsonDep.js +1 -1
- package/src/compile/watch.js +51 -15
- package/src/config/constant.js +1 -3
- package/src/config/defaultTmsConfig.js +1 -1
- package/src/core/buildAppJson.js +43 -44
- package/src/core/cloneModules.js +3 -3
- package/src/core/tmsMpconfig.js +19 -57
- package/src/entry.js +12 -1
- package/src/scripts/run/build/index.js +7 -1
- package/src/scripts/run/cloud/index.js +12 -0
- package/src/scripts/run/dev/index.js +18 -10
- package/src/scripts/run/index.js +37 -16
- package/src/scripts/run/init/index.js +27 -15
- package/src/scripts/run/install/index.js +19 -12
- package/src/utils/io.js +20 -0
- package/src/utils/log.js +4 -4
- package/src/utils/widgets.js +20 -3
package/src/utils/io.js
CHANGED
|
@@ -97,6 +97,25 @@ const fileInDir = (dir, file) => {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
|
|
100
|
+
function findAllFilesOfDir(dir) {
|
|
101
|
+
const list = [];
|
|
102
|
+
function listFile(dir) {
|
|
103
|
+
const arr = fs.readdirSync(dir);
|
|
104
|
+
arr.forEach((item) => {
|
|
105
|
+
const fullPath = path.join(dir, item);
|
|
106
|
+
const stats = fs.statSync(fullPath);
|
|
107
|
+
if (stats.isDirectory()) {
|
|
108
|
+
listFile(fullPath);
|
|
109
|
+
} else {
|
|
110
|
+
list.push(fullPath);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return list;
|
|
114
|
+
}
|
|
115
|
+
listFile(dir);
|
|
116
|
+
return list;
|
|
117
|
+
}
|
|
118
|
+
|
|
100
119
|
module.exports = {
|
|
101
120
|
isDirEmpty,
|
|
102
121
|
copyFile,
|
|
@@ -105,4 +124,5 @@ module.exports = {
|
|
|
105
124
|
ext,
|
|
106
125
|
fileInDir,
|
|
107
126
|
isFile,
|
|
127
|
+
findAllFilesOfDir,
|
|
108
128
|
};
|
package/src/utils/log.js
CHANGED
|
@@ -14,7 +14,7 @@ const resetCfg = decodeURIComponent('%1B%5B0m'); // \033[0m转义后的字符按
|
|
|
14
14
|
const fail = (message = '') => {
|
|
15
15
|
const redStyleConfig = decodeURIComponent('%1B%5B41%3B30m'); // \033[41;30m转义后的字符按,console时输出红色文字
|
|
16
16
|
const greenFontStyleConfig = decodeURIComponent('%1B%5B41%3B37m'); // \033[41;30m转义后的字符按,console时输出红底白色文字
|
|
17
|
-
console.log(
|
|
17
|
+
console.log(`${moment().format('YYYY-MM-DD HH:mm:ss')}`, `${redStyleConfig} ERROR ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -25,7 +25,7 @@ const fail = (message = '') => {
|
|
|
25
25
|
const succeed = (message = '') => {
|
|
26
26
|
const greenStyleConfig = decodeURIComponent('%1B%5B42%3B30m'); // \033[42;30m转义后的字符按,console时输出绿色文字
|
|
27
27
|
const greenFontStyleConfig = decodeURIComponent('%1B%5B40%3B32m'); // \033[40;32m转义后的字符按,console时输出绿色文字
|
|
28
|
-
console.log(
|
|
28
|
+
console.log(`${moment().format('YYYY-MM-DD HH:mm:ss')}`, `${greenStyleConfig} Success ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
|
|
@@ -35,10 +35,10 @@ const succeed = (message = '') => {
|
|
|
35
35
|
* @returns {undefined} 无
|
|
36
36
|
*/
|
|
37
37
|
const warn = (message) => {
|
|
38
|
-
console.log(
|
|
38
|
+
console.log(`${moment().format('YYYY-MM-DD HH:mm:ss')}`, chalk.yellow(message));
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const info = (...args) => console.log(
|
|
41
|
+
const info = (...args) => console.log(`${moment().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
|
|
42
42
|
|
|
43
43
|
module.exports = {
|
|
44
44
|
fail,
|
package/src/utils/widgets.js
CHANGED
|
@@ -144,13 +144,13 @@ function createTask(task, startText, endText) {
|
|
|
144
144
|
return async (...args) => {
|
|
145
145
|
const start = Date.now();
|
|
146
146
|
|
|
147
|
-
const spinner = ora(
|
|
148
|
-
|
|
147
|
+
const spinner = ora();
|
|
148
|
+
info(startText);
|
|
149
149
|
spinner.start();
|
|
150
150
|
|
|
151
151
|
const result = await task(...args);
|
|
152
152
|
|
|
153
|
-
endText && spinner.succeed(`${endText},
|
|
153
|
+
endText && spinner.succeed(`${endText}, 耗时${cost(start) / 1000}s`);
|
|
154
154
|
spinner.stop();
|
|
155
155
|
|
|
156
156
|
return result;
|
|
@@ -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
|
};
|