@tmsfe/tmskit 0.0.32 → 0.0.33

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,10 @@ 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
+ targetFile = path$4.join(module.to, sourceFileName);
2787
+ }
2784
2788
  if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
2785
2789
  info$a(`删除${sourceFileName}`);
2786
2790
  shellJs$2.rm('-rf', targetFile);
@@ -2881,6 +2885,26 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
2881
2885
  },
2882
2886
  isDev
2883
2887
  }));
2888
+
2889
+ // 监听extendFiles
2890
+ if (tmsConfig.watchExtendFiles.length) {
2891
+ tmsConfig.watchExtendFiles.forEach(item => {
2892
+ mergeMap(compileTasksMap, compile(tmsConfig, {
2893
+ glob: item.rules,
2894
+ module: {
2895
+ custom: true,
2896
+ from: '',
2897
+ to: item.to
2898
+ },
2899
+ destPath: item.to,
2900
+ srcOption: {
2901
+ allowEmpty: true
2902
+ },
2903
+ isDev
2904
+ }));
2905
+ });
2906
+ }
2907
+
2884
2908
  // 监听模块的文件
2885
2909
  for (let moduleItem of modules) {
2886
2910
  // 处理默认参数
@@ -3050,7 +3074,6 @@ function delOtherPackages(tmsConfig, targetSubPackages) {
3050
3074
  }
3051
3075
  });
3052
3076
  }
3053
-
3054
3077
  async function dev$3(tmsConfig, targetModules) {
3055
3078
  var _tmsConfig$hooks;
3056
3079
  const {
@@ -3879,7 +3902,7 @@ var entry = [{
3879
3902
 
3880
3903
  var require$$12 = {
3881
3904
  name: "@tmsfe/tmskit",
3882
- version: "0.0.32",
3905
+ version: "0.0.33",
3883
3906
  description: "tmskit",
3884
3907
  main: "dist/index.cjs",
3885
3908
  bin: {
@@ -3913,6 +3936,7 @@ var require$$12 = {
3913
3936
  rollup: "^2.6.1"
3914
3937
  },
3915
3938
  whiteDependencies: {
3939
+ unzipper: "0.10.11"
3916
3940
  },
3917
3941
  dependencies: {
3918
3942
  "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.33",
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: '',
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,11 @@ 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
+ targetFile = path.join(module.to, sourceFileName);
62
+ }
63
63
  if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
64
64
  info(`删除${sourceFileName}`);
65
65
  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: {