@tmsfe/tmskit 0.0.12 → 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.
@@ -55,12 +55,16 @@ async function run(commandName, cmd) {
55
55
  tmsConfig.modules,
56
56
  );
57
57
 
58
- const modules = checkModules(tmsConfig, [
59
- ...new Set([
60
- ...tmsConfig.mainPackages,
61
- ...specificModules,
62
- ]),
63
- ]);
58
+ const modules = checkModules(
59
+ tmsConfig,
60
+ [
61
+ ...new Set([
62
+ ...tmsConfig.mainPackages,
63
+ ...specificModules,
64
+ ]),
65
+ ],
66
+ true,
67
+ );
64
68
 
65
69
  // tms.config.js的modules 合并 module.config.json的配置项
66
70
  let newModules = tmsModulesMergeLocalModuleCfg(modules, tmsConfig.appName);
@@ -72,6 +76,7 @@ async function run(commandName, cmd) {
72
76
  env,
73
77
  cmd,
74
78
  tmsPrivateCf,
79
+ tmsConfig,
75
80
  });
76
81
 
77
82
  switch (commandName) {
@@ -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) {
package/src/utils/io.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { info } = require('../utils/log');
4
+ const { relativeCwdPath } = require('../utils/widgets');
4
5
  /**
5
6
  * 判断目录是否为空
6
7
  * @param {string} dirname 目录名
@@ -44,11 +45,11 @@ function diffContentCopyFile(originFile, destFile) {
44
45
  const depDestContent = fs.readFileSync(destFile, 'utf8');
45
46
  const depOriginContent = fs.readFileSync(originFile, 'utf8');
46
47
  if (depDestContent !== depOriginContent) {
47
- info(`拷贝${originFile}内容到${destFile}`);
48
+ info(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
48
49
  copyFile(originFile, destFile);
49
50
  }
50
51
  } else {
51
- info(`拷贝${originFile}内容到${destFile}`);
52
+ info(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
52
53
  copyFile(originFile, destFile);
53
54
  }
54
55
  }
package/src/utils/log.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const chalk = require('chalk');
2
+ const moment = require('moment');
2
3
 
3
4
  /**
4
5
  * 本文件提供无依赖的在终端打印彩色文字的方法。
@@ -13,7 +14,7 @@ const resetCfg = decodeURIComponent('%1B%5B0m'); // \033[0m转义后的字符按
13
14
  const fail = (message = '') => {
14
15
  const redStyleConfig = decodeURIComponent('%1B%5B41%3B30m'); // \033[41;30m转义后的字符按,console时输出红色文字
15
16
  const greenFontStyleConfig = decodeURIComponent('%1B%5B41%3B37m'); // \033[41;30m转义后的字符按,console时输出红底白色文字
16
- console.log(`${redStyleConfig} ERROR ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
17
+ console.log(`\n${moment().format('YYYY-MM-DD HH:mm:ss')}`, `${redStyleConfig} ERROR ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
17
18
  };
18
19
 
19
20
  /**
@@ -24,7 +25,7 @@ const fail = (message = '') => {
24
25
  const succeed = (message = '') => {
25
26
  const greenStyleConfig = decodeURIComponent('%1B%5B42%3B30m'); // \033[42;30m转义后的字符按,console时输出绿色文字
26
27
  const greenFontStyleConfig = decodeURIComponent('%1B%5B40%3B32m'); // \033[40;32m转义后的字符按,console时输出绿色文字
27
- console.log(`${greenStyleConfig} Success ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
28
+ console.log(`\n${moment().format('YYYY-MM-DD HH:mm:ss')}`, `${greenStyleConfig} Success ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
28
29
  };
29
30
 
30
31
 
@@ -34,10 +35,10 @@ const succeed = (message = '') => {
34
35
  * @returns {undefined} 无
35
36
  */
36
37
  const warn = (message) => {
37
- console.log(chalk.yellow(message));
38
+ console.log(`\n${moment().format('YYYY-MM-DD HH:mm:ss')}`, chalk.yellow(message));
38
39
  };
39
40
 
40
- const info = (...args) => console.log(...args);
41
+ const info = (...args) => console.log(`\n${moment().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
41
42
 
42
43
  module.exports = {
43
44
  fail,
@@ -114,7 +114,7 @@ function pullRepoForGit(dest, branch) {
114
114
  function npmInstall(dir) {
115
115
  return new Promise((resolve, reject) => {
116
116
  shelljs.exec(
117
- 'npx yarn --production --registry http://mirrors.tencent.com/npm/',
117
+ 'npm install --production --registry http://mirrors.tencent.com/npm/',
118
118
  { cwd: dir, silent: true },
119
119
  (code, stdout, stderr) => {
120
120
  if (code !== 0) {
@@ -147,7 +147,6 @@ function createTask(task, startText, endText) {
147
147
  const spinner = ora(startText);
148
148
 
149
149
  spinner.start();
150
- info('\n');
151
150
 
152
151
  const result = await task(...args);
153
152
 
@@ -165,6 +164,22 @@ function createTask(task, startText, endText) {
165
164
  */
166
165
  const camelize = str => str.replace(/-(\w)/g, (a, c) => (c ? c.toUpperCase() : ''));
167
166
 
167
+ const mergeMap = function (obj, src) {
168
+ for (const [k, v] of src) {
169
+ if (obj.has(k)) {
170
+ obj.set(k, obj.get(k) + v);
171
+ } else {
172
+ obj.set(k, v);
173
+ }
174
+ }
175
+
176
+ return obj;
177
+ };
178
+
179
+ const relativeCwdPath = function (file) {
180
+ return path.relative(process.cwd(), file);
181
+ };
182
+
168
183
  module.exports = {
169
184
  resolve,
170
185
  isObject,
@@ -175,4 +190,6 @@ module.exports = {
175
190
  suggestCommands,
176
191
  camelize,
177
192
  npmInstall,
193
+ mergeMap,
194
+ relativeCwdPath,
178
195
  };