@tmsfe/tmskit 0.0.5-beta.2 → 0.0.5-beta.3

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/dist/index.cjs.js CHANGED
@@ -74,7 +74,7 @@ const leven = require$$1__default;
74
74
  const ora = require$$2__default;
75
75
  const path$8 = require$$1__default$1;
76
76
  const fs$c = require$$0__default$1;
77
- const shelljs$5 = require$$5__default;
77
+ const shelljs$6 = require$$5__default;
78
78
  const download = require$$6__default;
79
79
  const chalk$3 = require$$0__default$2;
80
80
  const shelljsOptons = {
@@ -154,10 +154,10 @@ function downloadRepo(dest, downloadOptions = {
154
154
  } = downloadOptions;
155
155
 
156
156
  if (fs$c.existsSync(dest)) {
157
- shelljs$5.rm('-rf', dest);
157
+ shelljs$6.rm('-rf', dest);
158
158
  }
159
159
 
160
- shelljs$5.mkdir('-p', dest);
160
+ shelljs$6.mkdir('-p', dest);
161
161
  return new Promise(resolve => {
162
162
  download(`${repoUrl}#${branch}`, dest, {
163
163
  clone: true
@@ -186,13 +186,13 @@ function downloadRepoForGit$2(url, dest, branch) {
186
186
  return new Promise(resolve => {
187
187
  // 如果目标目录不存在
188
188
  if (fs$c.existsSync(dest)) {
189
- shelljs$5.rm('-rf', path$8.join(dest));
189
+ shelljs$6.rm('-rf', path$8.join(dest));
190
190
  }
191
191
 
192
- shelljs$5.mkdir('-p', dest);
193
- shelljs$5.cd(dest);
194
- shelljs$5.exec(`git clone ${url} ${dest} --branch ${branch} --depth 1`, shelljsOptons);
195
- shelljs$5.cd(cwd);
192
+ shelljs$6.mkdir('-p', dest);
193
+ shelljs$6.cd(dest);
194
+ shelljs$6.exec(`git clone ${url} ${dest} --branch ${branch} --depth 1`, shelljsOptons);
195
+ shelljs$6.cd(cwd);
196
196
  resolve();
197
197
  });
198
198
  }
@@ -561,7 +561,7 @@ var generator_1 = generator$1;
561
561
 
562
562
  const path$5 = require$$1__default$1;
563
563
  const fs$9 = require$$0__default$1;
564
- const shelljs$4 = require$$5__default;
564
+ const shelljs$5 = require$$5__default;
565
565
  const {
566
566
  TEMPLATE_DIR,
567
567
  TEMPLATE_PATH,
@@ -592,7 +592,7 @@ async function createAppDir(targetDir) {
592
592
  process.exit(1);
593
593
  }
594
594
  } else {
595
- shelljs$4.mkdir('-p', targetDir);
595
+ shelljs$5.mkdir('-p', targetDir);
596
596
  }
597
597
  }
598
598
  /**
@@ -616,23 +616,23 @@ async function create(appName) {
616
616
  appName,
617
617
  appType
618
618
  }).then(() => {
619
- shelljs$4.cd(appName);
619
+ shelljs$5.cd(appName);
620
620
 
621
621
  const hooks = require(resolve$a(appName, TEMPLATE_TKIT_DIR, 'hooks.js'));
622
622
 
623
623
  if (hooks.afterCreate) {
624
624
  hooks.afterCreate.forEach(item => {
625
625
  if (typeof item === 'function') {
626
- item.call(null, shelljs$4, {
626
+ item.call(null, shelljs$5, {
627
627
  appName
628
628
  });
629
629
  } else {
630
- shelljs$4.exec(item);
630
+ shelljs$5.exec(item);
631
631
  }
632
632
  });
633
633
  }
634
634
 
635
- shelljs$4.rm('-rf', resolve$a(appName, TEMPLATE_TKIT_DIR));
635
+ shelljs$5.rm('-rf', resolve$a(appName, TEMPLATE_TKIT_DIR));
636
636
  succeed('项目创建完成.');
637
637
  }).catch(err => {
638
638
  fail$8(err.message);
@@ -855,7 +855,7 @@ const {
855
855
  fail: fail$6
856
856
  } = log$2;
857
857
  const fs$7 = require$$0__default$1;
858
- const shelljs$3 = require$$5__default;
858
+ const shelljs$4 = require$$5__default;
859
859
  /**
860
860
  * 对克隆下来的模块进行相应的文件处理操作,比如收集处理模块信息,进行信息缓存等操作
861
861
  * @param { string } sourceDir 缓存文件夹
@@ -930,7 +930,7 @@ async function downLoadAndMoveModule(sourceDir, targetDir, moduleInfo) {
930
930
  }
931
931
 
932
932
  if (fs$7.existsSync(targetPath)) {
933
- shelljs$3.rm('-rf', targetPath);
933
+ shelljs$4.rm('-rf', targetPath);
934
934
  }
935
935
 
936
936
  await moveFile(sourcePath, targetPath, ['node_modules', '.git']);
@@ -962,7 +962,7 @@ var defaultTmsConfig$1 = {
962
962
  sourceDir: './',
963
963
 
964
964
  /** 源码Map */
965
- copyDir: []
965
+ copy: []
966
966
  }
967
967
  };
968
968
 
@@ -1356,7 +1356,7 @@ async function install$2(tmsConfig, modules, isCloud = true) {
1356
1356
 
1357
1357
  var install_1 = install$2;
1358
1358
 
1359
- const shelljs$2 = require$$5__default;
1359
+ const shelljs$3 = require$$5__default;
1360
1360
  const fs$4 = require$$0__default$1;
1361
1361
  const io = io$2;
1362
1362
  const {
@@ -1394,7 +1394,7 @@ const cpFilesToOutput = function (tmsConfig, targetModules, defaultFiles) {
1394
1394
  io.ensureDirExist(outputDir);
1395
1395
  defaultFiles.forEach(item => {
1396
1396
  if (fs$4.existsSync(resolve$5(item))) {
1397
- shelljs$2.cp('-rf', resolve$5(item), resolve$5(tmsConfig.gulp.outputDir, item));
1397
+ shelljs$3.cp('-rf', resolve$5(item), resolve$5(tmsConfig.gulp.outputDir, item));
1398
1398
  }
1399
1399
  }); // 拷贝模块的package.json到编译输出目录
1400
1400
 
@@ -1408,7 +1408,7 @@ const cpFilesToOutput = function (tmsConfig, targetModules, defaultFiles) {
1408
1408
 
1409
1409
  io.ensureDirExist(outputModuleDir);
1410
1410
  const modulePackagePath = resolve$5(item.path, 'package.json');
1411
- if (fs$4.existsSync(modulePackagePath)) shelljs$2.cp('-Rf', modulePackagePath, outputModuleDir);
1411
+ if (fs$4.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
1412
1412
  });
1413
1413
  };
1414
1414
 
@@ -1849,27 +1849,27 @@ var compile = function (tmsConfig, {
1849
1849
  const compile$1 = compile;
1850
1850
 
1851
1851
  function handleOtherGlob(glob) {
1852
- const otherArr = [];
1852
+ const otherArr = new Set();
1853
1853
  Object.keys(glob).forEach(globKey => {
1854
1854
  if (typeof glob[globKey] === 'string') {
1855
1855
  const data = glob[globKey].startsWith('!') ? glob[globKey] : `!${glob[globKey]}`;
1856
- otherArr.push(data);
1856
+ otherArr.add(data);
1857
1857
  }
1858
1858
 
1859
1859
  if (Array.isArray(glob[globKey])) {
1860
1860
  glob[globKey].forEach(value => {
1861
1861
  if (typeof value === 'string') {
1862
1862
  const data = value.startsWith('!') ? value : `!${value}`;
1863
- otherArr.push(data);
1863
+ otherArr.add(data);
1864
1864
  }
1865
1865
  });
1866
1866
  }
1867
1867
  });
1868
- return otherArr;
1868
+ return Array.from(otherArr);
1869
1869
  }
1870
1870
 
1871
1871
  module.exports = async (tmsConfig, newModules, isWatch = true) => {
1872
- var _tmsConfig$gulp;
1872
+ var _tmsConfig$gulp, _tmsConfig$gulp2;
1873
1873
 
1874
1874
  // 监听app.json
1875
1875
  if (isWatch) {
@@ -1904,7 +1904,7 @@ var compile = function (tmsConfig, {
1904
1904
  for (let module of newModules) {
1905
1905
  // 处理默认参数
1906
1906
  module = { ...{
1907
- excludes: []
1907
+ exclude: []
1908
1908
  },
1909
1909
  ...module
1910
1910
  };
@@ -1943,9 +1943,9 @@ var compile = function (tmsConfig, {
1943
1943
  } // 监听copy模块
1944
1944
 
1945
1945
 
1946
- if ((tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gulp = tmsConfig.gulp) === null || _tmsConfig$gulp === void 0 ? void 0 : _tmsConfig$gulp.copyDir.length) > 0) {
1947
- for (const item of (_tmsConfig$gulp2 = tmsConfig.gulp) === null || _tmsConfig$gulp2 === void 0 ? void 0 : _tmsConfig$gulp2.copyDir) {
1948
- var _tmsConfig$gulp2;
1946
+ if (tmsConfig !== null && tmsConfig !== void 0 && (_tmsConfig$gulp = tmsConfig.gulp) !== null && _tmsConfig$gulp !== void 0 && _tmsConfig$gulp.copy && (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gulp2 = tmsConfig.gulp) === null || _tmsConfig$gulp2 === void 0 ? void 0 : _tmsConfig$gulp2.copy.length) > 0) {
1947
+ for (const item of (_tmsConfig$gulp3 = tmsConfig.gulp) === null || _tmsConfig$gulp3 === void 0 ? void 0 : _tmsConfig$gulp3.copy) {
1948
+ var _tmsConfig$gulp3;
1949
1949
 
1950
1950
  const glob = {
1951
1951
  js: `${item.from}/**/*.{js,ts,wxs}`,
@@ -1979,10 +1979,10 @@ const path = require$$1__default$1;
1979
1979
  const {
1980
1980
  fail: fail$1
1981
1981
  } = log$2;
1982
- const shelljs$1 = require$$5__default;
1982
+ const shelljs$2 = require$$5__default;
1983
1983
 
1984
1984
  const getLatestVersion = npmName => {
1985
- const data = shelljs$1.exec(`npm view ${npmName} version`);
1985
+ const data = shelljs$2.exec(`npm view ${npmName} version`);
1986
1986
  return data.stdout || '0.0.0';
1987
1987
  };
1988
1988
  /**
@@ -2141,9 +2141,11 @@ async function dev$2(tmsConfig, targetModules, env) {
2141
2141
 
2142
2142
  var dev_1 = dev$2;
2143
2143
 
2144
+ const shelljs$1 = require$$5__default;
2144
2145
  const dev$1 = dev$3.exports;
2145
2146
 
2146
2147
  var build$2 = async (tmsConfig, newModules) => {
2148
+ shelljs$1.rm('-rf', tmsConfig.gulp.outputDir);
2147
2149
  dev$1(tmsConfig, newModules, false);
2148
2150
  };
2149
2151
 
@@ -2285,7 +2287,7 @@ var entry = [{
2285
2287
 
2286
2288
  var require$$6 = {
2287
2289
  name: "@tmsfe/tmskit",
2288
- version: "0.0.5-beta.2",
2290
+ version: "0.0.5-beta.3",
2289
2291
  description: "tmskit",
2290
2292
  main: "main.js",
2291
2293
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tmskit",
3
- "version": "0.0.5-beta.2",
3
+ "version": "0.0.5-beta.3",
4
4
  "description": "tmskit",
5
5
  "main": "main.js",
6
6
  "bin": {
@@ -13,6 +13,6 @@ module.exports = {
13
13
  /** 源码监听路径 */
14
14
  sourceDir: './',
15
15
  /** 源码Map */
16
- copyDir: [],
16
+ copy: [],
17
17
  },
18
18
  };
package/src/gulp/build.js CHANGED
@@ -1,6 +1,8 @@
1
-
1
+ const shelljs = require('shelljs');
2
2
  const dev = require('./dev');
3
3
 
4
4
  module.exports = async (tmsConfig, newModules) => {
5
+ shelljs.rm('-rf', tmsConfig.gulp.outputDir);
6
+
5
7
  dev(tmsConfig, newModules, false);
6
8
  };
package/src/gulp/dev.js CHANGED
@@ -5,21 +5,21 @@ const { DEFAULT_COPY_CONFIG } = require('../config/constant');
5
5
  const compile = require('./compile');
6
6
 
7
7
  function handleOtherGlob(glob) {
8
- const otherArr = [];
8
+ const otherArr = new Set();
9
9
  Object.keys(glob).forEach((globKey) => {
10
10
  if (typeof glob[globKey] === 'string') {
11
11
  const data = glob[globKey].startsWith('!') ? glob[globKey] : `!${glob[globKey]}`;
12
- otherArr.push(data);
12
+ otherArr.add(data);
13
13
  } if (Array.isArray(glob[globKey])) {
14
14
  glob[globKey].forEach((value) => {
15
15
  if (typeof value === 'string') {
16
16
  const data = value.startsWith('!') ? value : `!${value}`;
17
- otherArr.push(data);
17
+ otherArr.add(data);
18
18
  }
19
19
  });
20
20
  }
21
21
  });
22
- return otherArr;
22
+ return Array.from(otherArr);
23
23
  }
24
24
 
25
25
  module.exports = async (tmsConfig, newModules, isWatch = true) => {
@@ -49,7 +49,7 @@ module.exports = async (tmsConfig, newModules, isWatch = true) => {
49
49
  for (let module of newModules) {
50
50
  // 处理默认参数
51
51
  module = {
52
- ...{ excludes: [] },
52
+ ...{ exclude: [] },
53
53
  ...module,
54
54
  };
55
55
 
@@ -82,8 +82,8 @@ module.exports = async (tmsConfig, newModules, isWatch = true) => {
82
82
  }
83
83
 
84
84
  // 监听copy模块
85
- if (tmsConfig?.gulp?.copyDir.length > 0) {
86
- for (const item of tmsConfig.gulp?.copyDir) {
85
+ if (tmsConfig?.gulp?.copy && tmsConfig?.gulp?.copy.length > 0) {
86
+ for (const item of tmsConfig.gulp?.copy) {
87
87
  const glob = {
88
88
  js: `${item.from}/**/*.{js,ts,wxs}`,
89
89
  json: `${item.from}/**/*.json`,