@tmsfe/tmskit 0.0.43 → 0.0.44

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
@@ -542,6 +542,28 @@ var defaultTmsConfig = {
542
542
  }
543
543
  };
544
544
 
545
+ const global$c = {
546
+ data: {},
547
+ setData(...args) {
548
+ if (args.length === 1) {
549
+ Object.keys(args[0]).forEach(k => {
550
+ if (args[0][k]) {
551
+ this.data[k] = args[0][k];
552
+ }
553
+ });
554
+ } else {
555
+ const [name, value] = args;
556
+ this.data[name] = value;
557
+ }
558
+ },
559
+ getData(name) {
560
+ return this.data[name];
561
+ }
562
+ };
563
+ var global_1 = {
564
+ global: global$c
565
+ };
566
+
545
567
  /**
546
568
  * 用来读取处理tms.config.js与module.config.json字段
547
569
  */
@@ -564,6 +586,9 @@ var defaultTmsConfig = {
564
586
  getAbsolutePath
565
587
  } = widgets;
566
588
  const defaultTmsConfig$1 = defaultTmsConfig;
589
+ const {
590
+ global
591
+ } = global_1;
567
592
  const {
568
593
  fail
569
594
  } = log$1;
@@ -578,8 +603,11 @@ var defaultTmsConfig = {
578
603
  fail(`${path.dirname(tmsConfigPath)}没有找到tms.config.js,请进行配置`);
579
604
  process.exit(1);
580
605
  }
606
+ const isDev = global.getData('isDev');
581
607
  const tmsConfigFn = require(tmsConfigPath);
582
- const tmsConfig = typeof tmsConfigFn === 'function' ? tmsConfigFn() : tmsConfigFn;
608
+ const tmsConfig = typeof tmsConfigFn === 'function' ? tmsConfigFn({
609
+ isDev
610
+ }) : tmsConfigFn;
583
611
 
584
612
  // 合并默认值
585
613
  return loadash.mergeWith({}, defaultTmsConfig$1, tmsConfig);
@@ -593,8 +621,12 @@ var defaultTmsConfig = {
593
621
  let tmsPrivateCf = {};
594
622
  const tmsPrivatePath = configPath ? `${configPath}/${TMS_PRIVATE_FILENAME}` : resolve(TMS_PRIVATE_FILENAME);
595
623
  if (fs.existsSync(tmsPrivatePath)) {
624
+ const isDev = global.getData('isDev');
625
+ console.log(isDev, 'isDev');
596
626
  const tmsPrivateFn = require(tmsPrivatePath);
597
- tmsPrivateCf = typeof tmsPrivateFn === 'function' ? tmsPrivateFn() : tmsPrivateFn;
627
+ tmsPrivateCf = typeof tmsPrivateFn === 'function' ? tmsPrivateFn({
628
+ isDev
629
+ }) : tmsPrivateFn;
598
630
  }
599
631
  return tmsPrivateCf;
600
632
  };
@@ -1310,28 +1342,6 @@ var extendCmd = {
1310
1342
  loadExtendCmd: loadExtendCmd$1
1311
1343
  };
1312
1344
 
1313
- const global$c = {
1314
- data: {},
1315
- setData(...args) {
1316
- if (args.length === 1) {
1317
- Object.keys(args[0]).forEach(k => {
1318
- if (args[0][k]) {
1319
- this.data[k] = args[0][k];
1320
- }
1321
- });
1322
- } else {
1323
- const [name, value] = args;
1324
- this.data[name] = value;
1325
- }
1326
- },
1327
- getData(name) {
1328
- return this.data[name];
1329
- }
1330
- };
1331
- var global_1 = {
1332
- global: global$c
1333
- };
1334
-
1335
1345
  const {
1336
1346
  fail: fail$7
1337
1347
  } = log$1;
@@ -4005,6 +4015,10 @@ const getSpecificModuleNames = (moduleArg, modules) => {
4005
4015
  return all.map(item => item.moduleName);
4006
4016
  };
4007
4017
  async function run(commandName, cmdOptions) {
4018
+ if (['dev', 'build'].includes(commandName)) {
4019
+ // 先缓存环境,因为tmsConfig可能会用到
4020
+ global.setData('isDev', commandName === 'dev');
4021
+ }
4008
4022
  // 用户本地的配置
4009
4023
  const tmsConfig = getTmsConfig$1();
4010
4024
  try {
@@ -4059,7 +4073,6 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
4059
4073
  });
4060
4074
  return;
4061
4075
  case 'dev':
4062
- global.setData('isDev', true);
4063
4076
  dev(tmsConfig, newModules);
4064
4077
  report$1('run:dev', {
4065
4078
  appName: tmsConfig.appName
@@ -4072,7 +4085,6 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
4072
4085
  });
4073
4086
  return;
4074
4087
  case 'build':
4075
- global.setData('isDev', false);
4076
4088
  build(tmsConfig, newModules);
4077
4089
  report$1('run:build', {
4078
4090
  appName: tmsConfig.appName
@@ -4185,7 +4197,7 @@ var entry = [{
4185
4197
 
4186
4198
  var require$$12 = {
4187
4199
  name: "@tmsfe/tmskit",
4188
- version: "0.0.43",
4200
+ version: "0.0.44",
4189
4201
  description: "tmskit",
4190
4202
  main: "dist/index.cjs",
4191
4203
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tmskit",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "tmskit",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {
@@ -10,6 +10,7 @@ const JSON5 = require('json5');
10
10
  const { TMS_CONFIG_FILENAME, MODULE_CONFIG_FILENAME, TMS_PRIVATE_FILENAME } = require('../config/constant');
11
11
  const { resolve, isObject, isArray, getAbsolutePath } = require('../utils/widgets');
12
12
  const defaultTmsConfig = require('../config/defaultTmsConfig');
13
+ const { global } = require('../utils/global');
13
14
  const { fail } = require('../utils/log');
14
15
 
15
16
  /**
@@ -22,8 +23,9 @@ const readTmsConfig = function (configPath) {
22
23
  fail(`${path.dirname(tmsConfigPath)}没有找到tms.config.js,请进行配置`);
23
24
  process.exit(1);
24
25
  }
26
+ const isDev = global.getData('isDev');
25
27
  const tmsConfigFn = require(tmsConfigPath);
26
- const tmsConfig = typeof tmsConfigFn === 'function' ? tmsConfigFn() : tmsConfigFn;
28
+ const tmsConfig = typeof tmsConfigFn === 'function' ? tmsConfigFn({ isDev }) : tmsConfigFn;
27
29
 
28
30
  // 合并默认值
29
31
  return loadash.mergeWith({}, defaultTmsConfig, tmsConfig);
@@ -38,8 +40,10 @@ const readTmsPrivateCf = function (configPath) {
38
40
  let tmsPrivateCf = {};
39
41
  const tmsPrivatePath = configPath ? `${configPath}/${TMS_PRIVATE_FILENAME}` : resolve(TMS_PRIVATE_FILENAME);
40
42
  if (fs.existsSync(tmsPrivatePath)) {
43
+ const isDev = global.getData('isDev');
44
+ console.log(isDev, 'isDev');
41
45
  const tmsPrivateFn = require(tmsPrivatePath);
42
- tmsPrivateCf = typeof tmsPrivateFn === 'function' ? tmsPrivateFn() : tmsPrivateFn;
46
+ tmsPrivateCf = typeof tmsPrivateFn === 'function' ? tmsPrivateFn({ isDev }) : tmsPrivateFn;
43
47
  }
44
48
 
45
49
  return tmsPrivateCf;
@@ -50,6 +50,10 @@ const getSpecificModuleNames = (moduleArg, modules) => {
50
50
  };
51
51
 
52
52
  async function run(commandName, cmdOptions) {
53
+ if (['dev', 'build'].includes(commandName)) {
54
+ // 先缓存环境,因为tmsConfig可能会用到
55
+ global.setData('isDev', commandName === 'dev');
56
+ }
53
57
  // 用户本地的配置
54
58
  const tmsConfig = getTmsConfig();
55
59
  try {
@@ -101,7 +105,6 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
101
105
  report('run:init', { appName: tmsConfig.appName });
102
106
  return;
103
107
  case 'dev':
104
- global.setData('isDev', true);
105
108
  dev(tmsConfig, newModules);
106
109
  report('run:dev', { appName: tmsConfig.appName });
107
110
  return;
@@ -110,7 +113,6 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
110
113
  report('run:install', { appName: tmsConfig.appName });
111
114
  return;
112
115
  case 'build':
113
- global.setData('isDev', false);
114
116
  build(tmsConfig, newModules);
115
117
  report('run:build', { appName: tmsConfig.appName });
116
118
  return;