@tmsfe/tmskit 0.0.32 → 0.0.34

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
@@ -505,6 +505,8 @@ var defaultTmsConfig = {
505
505
  sourceDir: './',
506
506
  /** 静态资源目录 */
507
507
  static: [],
508
+ /** 监听扩展文件 */
509
+ watchExtendFiles: [],
508
510
  /** 上传是的配置 https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html#%E7%BC%96%E8%AF%91%E8%AE%BE%E7%BD%AE */
509
511
  upload: {
510
512
  setting: {
@@ -2768,8 +2770,7 @@ const logTip = (fileName, sourceFile, targetFile, tipMap) => {
2768
2770
  };
2769
2771
  const getTargetFile$1 = (sourceFile, module, outputDir) => {
2770
2772
  const sourceFileRelativeModule = path$4.relative(resolve$a(module.from), sourceFile);
2771
- const targetFile = resolve$a(outputDir, module.to, sourceFileRelativeModule);
2772
- return targetFile;
2773
+ return resolve$a(outputDir, module.to, sourceFileRelativeModule);
2773
2774
  };
2774
2775
  var watch_1 = function (globValue, watchOptions, callback, module) {
2775
2776
  watch$2(globValue, {
@@ -2780,7 +2781,11 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
2780
2781
  const sourceFileDirArr = sourceFile.replace(/\\/g, '/').split('/');
2781
2782
  const sourceFileName = sourceFileDirArr.slice(sourceFileDirArr.length - 2).join('/');
2782
2783
  const tmsConfig = global$6.getData('tmsConfig');
2783
- const targetFile = getTargetFile$1(sourceFile, module, tmsConfig.outputDir);
2784
+ let targetFile = getTargetFile$1(sourceFile, module, tmsConfig.outputDir);
2785
+ if (module.custom) {
2786
+ const filePath = sourceFile.replace(/\\/g, '/').replace(module.from, '');
2787
+ targetFile = path$4.join(module.to, filePath);
2788
+ }
2784
2789
  if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
2785
2790
  info$a(`删除${sourceFileName}`);
2786
2791
  shellJs$2.rm('-rf', targetFile);
@@ -2881,6 +2886,26 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
2881
2886
  },
2882
2887
  isDev
2883
2888
  }));
2889
+
2890
+ // 监听extendFiles
2891
+ if (tmsConfig.watchExtendFiles.length) {
2892
+ tmsConfig.watchExtendFiles.forEach(item => {
2893
+ mergeMap(compileTasksMap, compile(tmsConfig, {
2894
+ glob: item.rules,
2895
+ module: {
2896
+ custom: true,
2897
+ from: item.from,
2898
+ to: item.to
2899
+ },
2900
+ destPath: item.to,
2901
+ srcOption: {
2902
+ allowEmpty: true
2903
+ },
2904
+ isDev
2905
+ }));
2906
+ });
2907
+ }
2908
+
2884
2909
  // 监听模块的文件
2885
2910
  for (let moduleItem of modules) {
2886
2911
  // 处理默认参数
@@ -3050,7 +3075,6 @@ function delOtherPackages(tmsConfig, targetSubPackages) {
3050
3075
  }
3051
3076
  });
3052
3077
  }
3053
-
3054
3078
  async function dev$3(tmsConfig, targetModules) {
3055
3079
  var _tmsConfig$hooks;
3056
3080
  const {
@@ -3879,7 +3903,7 @@ var entry = [{
3879
3903
 
3880
3904
  var require$$12 = {
3881
3905
  name: "@tmsfe/tmskit",
3882
- version: "0.0.32",
3906
+ version: "0.0.34",
3883
3907
  description: "tmskit",
3884
3908
  main: "dist/index.cjs",
3885
3909
  bin: {
@@ -3913,6 +3937,7 @@ var require$$12 = {
3913
3937
  rollup: "^2.6.1"
3914
3938
  },
3915
3939
  whiteDependencies: {
3940
+ unzipper: "0.10.11"
3916
3941
  },
3917
3942
  dependencies: {
3918
3943
  "ansi-colors": "1.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tmskit",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "tmskit",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {
@@ -25,6 +25,24 @@ module.exports = async (tmsConfig, modules, isDev = true) => {
25
25
  srcOption: { allowEmpty: true },
26
26
  isDev,
27
27
  }));
28
+
29
+ // 监听extendFiles
30
+ if (tmsConfig.watchExtendFiles.length) {
31
+ tmsConfig.watchExtendFiles.forEach((item) => {
32
+ mergeMap(compileTasksMap, compile(tmsConfig, {
33
+ glob: item.rules,
34
+ module: {
35
+ custom: true,
36
+ from: item.from,
37
+ to: item.to,
38
+ },
39
+ destPath: item.to,
40
+ srcOption: { allowEmpty: true },
41
+ isDev,
42
+ }));
43
+ });
44
+ }
45
+
28
46
  // 监听模块的文件
29
47
  for (let moduleItem of modules) {
30
48
  // 处理默认参数
@@ -48,7 +66,7 @@ module.exports = async (tmsConfig, modules, isDev = true) => {
48
66
  const excludes = moduleItem.exclude.map((ePath) => {
49
67
  const newPath = getAbsolutePath(ePath, srcModulePath);
50
68
  const ext = path.extname(ePath).slice(1);
51
- if (ext) {
69
+ if (ext) {
52
70
  return `!${resolve(srcModulePath, newPath)}`;
53
71
  }
54
72
  return `!${resolve(srcModulePath, newPath)}/**/*`;
@@ -71,7 +89,7 @@ module.exports = async (tmsConfig, modules, isDev = true) => {
71
89
 
72
90
  let glob = {};
73
91
  const ext = path.extname(item.from).slice(1);
74
- if (ext) {
92
+ if (ext) {
75
93
  glob = [item.from];
76
94
  } else {
77
95
  glob = [`${item.from}/**/*`];
@@ -91,12 +109,14 @@ module.exports = async (tmsConfig, modules, isDev = true) => {
91
109
  let sTime;
92
110
  let eTime;
93
111
  const spinner = ora();
112
+
94
113
  function start(cb) {
95
114
  info('启动编译...');
96
115
  spinner.start();
97
116
  sTime = new Date().getTime();
98
117
  cb();
99
118
  }
119
+
100
120
  async function end(cb) {
101
121
  if (isDev) {
102
122
  // 监听app.json
@@ -44,8 +44,7 @@ const logTip = (fileName, sourceFile, targetFile, tipMap) => {
44
44
 
45
45
  const getTargetFile = (sourceFile, module, outputDir) => {
46
46
  const sourceFileRelativeModule = path.relative(resolve(module.from), sourceFile);
47
- const targetFile = resolve(outputDir, module.to, sourceFileRelativeModule);
48
- return targetFile;
47
+ return resolve(outputDir, module.to, sourceFileRelativeModule);
49
48
  };
50
49
 
51
50
  module.exports = function (globValue, watchOptions, callback, module) {
@@ -56,10 +55,12 @@ module.exports = function (globValue, watchOptions, callback, module) {
56
55
  const sourceFile = vinyl.history[0];
57
56
  const sourceFileDirArr = sourceFile.replace(/\\/g, '/').split('/');
58
57
  const sourceFileName = sourceFileDirArr.slice(sourceFileDirArr.length - 2).join('/');
59
-
60
58
  const tmsConfig = global.getData('tmsConfig');
61
-
62
- const targetFile = getTargetFile(sourceFile, module, tmsConfig.outputDir);
59
+ let targetFile = getTargetFile(sourceFile, module, tmsConfig.outputDir);
60
+ if (module.custom) {
61
+ const filePath = sourceFile.replace(/\\/g, '/').replace(module.from, '');
62
+ targetFile = path.join(module.to, filePath);
63
+ }
63
64
  if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
64
65
  info(`删除${sourceFileName}`);
65
66
  shellJs.rm('-rf', targetFile);
@@ -13,6 +13,8 @@ module.exports = {
13
13
  sourceDir: './',
14
14
  /** 静态资源目录 */
15
15
  static: [],
16
+ /** 监听扩展文件 */
17
+ watchExtendFiles: [],
16
18
  /** 上传是的配置 https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html#%E7%BC%96%E8%AF%91%E8%AE%BE%E7%BD%AE */
17
19
  upload: {
18
20
  setting: {