@tmsfe/tmskit 0.0.45 → 0.0.47

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;
@@ -579,7 +604,10 @@ var defaultTmsConfig = {
579
604
  process.exit(1);
580
605
  }
581
606
  const tmsConfigFn = require(tmsConfigPath);
582
- const tmsConfig = typeof tmsConfigFn === 'function' ? tmsConfigFn() : tmsConfigFn;
607
+ const isDev = global.getData('isDev');
608
+ const tmsConfig = typeof tmsConfigFn === 'function' ? tmsConfigFn({
609
+ isDev
610
+ }) : tmsConfigFn;
583
611
 
584
612
  // 合并默认值
585
613
  return loadash.mergeWith({}, defaultTmsConfig$1, tmsConfig);
@@ -594,7 +622,10 @@ var defaultTmsConfig = {
594
622
  const tmsPrivatePath = configPath ? `${configPath}/${TMS_PRIVATE_FILENAME}` : resolve(TMS_PRIVATE_FILENAME);
595
623
  if (fs.existsSync(tmsPrivatePath)) {
596
624
  const tmsPrivateFn = require(tmsPrivatePath);
597
- tmsPrivateCf = typeof tmsPrivateFn === 'function' ? tmsPrivateFn() : tmsPrivateFn;
625
+ const isDev = global.getData('isDev');
626
+ tmsPrivateCf = typeof tmsPrivateFn === 'function' ? tmsPrivateFn({
627
+ isDev
628
+ }) : tmsPrivateFn;
598
629
  }
599
630
  return tmsPrivateCf;
600
631
  };
@@ -1310,28 +1341,6 @@ var extendCmd = {
1310
1341
  loadExtendCmd: loadExtendCmd$1
1311
1342
  };
1312
1343
 
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
1344
  const {
1336
1345
  fail: fail$7
1337
1346
  } = log$1;
@@ -4005,6 +4014,10 @@ const getSpecificModuleNames = (moduleArg, modules) => {
4005
4014
  return all.map(item => item.moduleName);
4006
4015
  };
4007
4016
  async function run(commandName, cmdOptions) {
4017
+ if (['dev', 'build'].includes(commandName)) {
4018
+ // 先缓存环境,因为tmsConfig可能会用到
4019
+ global.setData('isDev', commandName === 'dev');
4020
+ }
4008
4021
  // 用户本地的配置
4009
4022
  const tmsConfig = getTmsConfig$1();
4010
4023
  try {
@@ -4059,7 +4072,6 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
4059
4072
  });
4060
4073
  return;
4061
4074
  case 'dev':
4062
- global.setData('isDev', true);
4063
4075
  dev(tmsConfig, newModules);
4064
4076
  report$1('run:dev', {
4065
4077
  appName: tmsConfig.appName
@@ -4072,7 +4084,6 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
4072
4084
  });
4073
4085
  return;
4074
4086
  case 'build':
4075
- global.setData('isDev', false);
4076
4087
  build(tmsConfig, newModules);
4077
4088
  report$1('run:build', {
4078
4089
  appName: tmsConfig.appName
@@ -4185,7 +4196,7 @@ var entry = [{
4185
4196
 
4186
4197
  var require$$12 = {
4187
4198
  name: "@tmsfe/tmskit",
4188
- version: "0.0.45",
4199
+ version: "0.0.47",
4189
4200
  description: "tmskit",
4190
4201
  main: "dist/index.cjs",
4191
4202
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tmskit",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
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
  /**
@@ -23,7 +24,8 @@ const readTmsConfig = function (configPath) {
23
24
  process.exit(1);
24
25
  }
25
26
  const tmsConfigFn = require(tmsConfigPath);
26
- const tmsConfig = typeof tmsConfigFn === 'function' ? tmsConfigFn() : tmsConfigFn;
27
+ const isDev = global.getData('isDev');
28
+ const tmsConfig = typeof tmsConfigFn === 'function' ? tmsConfigFn({ isDev }) : tmsConfigFn;
27
29
 
28
30
  // 合并默认值
29
31
  return loadash.mergeWith({}, defaultTmsConfig, tmsConfig);
@@ -39,7 +41,8 @@ const readTmsPrivateCf = function (configPath) {
39
41
  const tmsPrivatePath = configPath ? `${configPath}/${TMS_PRIVATE_FILENAME}` : resolve(TMS_PRIVATE_FILENAME);
40
42
  if (fs.existsSync(tmsPrivatePath)) {
41
43
  const tmsPrivateFn = require(tmsPrivatePath);
42
- tmsPrivateCf = typeof tmsPrivateFn === 'function' ? tmsPrivateFn() : tmsPrivateFn;
44
+ const isDev = global.getData('isDev');
45
+ tmsPrivateCf = typeof tmsPrivateFn === 'function' ? tmsPrivateFn({ isDev }) : tmsPrivateFn;
43
46
  }
44
47
 
45
48
  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;