@modern-js/new-action 1.15.0 → 1.18.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # @modern-js/new-action
2
2
 
3
+ ## 1.18.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8280920]
8
+ - Updated dependencies [4f77eb4]
9
+ - Updated dependencies [5227370]
10
+ - Updated dependencies [7928bae]
11
+ - @modern-js/utils@1.18.0
12
+ - @modern-js/generator-common@2.3.3
13
+ - @modern-js/generator-utils@2.3.3
14
+
15
+ ## 1.17.0
16
+
17
+ ### Patch Changes
18
+
19
+ - f3fab28: feat: new command use solution version
20
+
21
+ feat: new 命令使用当前工程方案对应版本的插件
22
+
23
+ - Updated dependencies [1b9176f]
24
+ - Updated dependencies [77d3a38]
25
+ - Updated dependencies [fb30bca]
26
+ - Updated dependencies [f3fab28]
27
+ - Updated dependencies [151329d]
28
+ - Updated dependencies [5af9472]
29
+ - Updated dependencies [6b6a534]
30
+ - Updated dependencies [6b43a2b]
31
+ - Updated dependencies [a7be124]
32
+ - Updated dependencies [31547b4]
33
+ - @modern-js/utils@1.17.0
34
+ - @modern-js/generator-common@2.3.1
35
+ - @modern-js/generator-utils@2.3.1
36
+
37
+ ## 1.16.0
38
+
39
+ ### Patch Changes
40
+
41
+ - 9d9bbfd05: feat: update codesmith package
42
+
43
+ feat: 升级 codesmith 包版本
44
+
45
+ - Updated dependencies [beecff68d]
46
+ - Updated dependencies [641592f52]
47
+ - Updated dependencies [3904b30a5]
48
+ - Updated dependencies [1100dd58c]
49
+ - Updated dependencies [e04e6e76a]
50
+ - Updated dependencies [94222750f]
51
+ - Updated dependencies [81c66e4a4]
52
+ - Updated dependencies [2c305b6f5]
53
+ - Updated dependencies [9d9bbfd05]
54
+ - @modern-js/generator-utils@2.3.0
55
+ - @modern-js/utils@1.16.0
56
+ - @modern-js/generator-common@2.3.0
57
+
3
58
  ## 1.15.0
4
59
 
5
60
  ### Patch Changes
@@ -1,9 +1,9 @@
1
1
  import { merge } from '@modern-js/utils/lodash';
2
2
  import { CodeSmith, GeneratorCore, MaterialsManager } from '@modern-js/codesmith';
3
3
  import { AppAPI, forEach } from '@modern-js/codesmith-api-app';
4
- import { i18n, ModuleNewActionSchema, ModuleActionFunctions, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, ModuleNewActionGenerators } from '@modern-js/generator-common';
5
- import { getPackageVersion, getPackageManager } from '@modern-js/generator-utils';
6
- import { alreadyRepo, hasEnabledFunction } from "./utils";
4
+ import { i18n, ModuleNewActionSchema, ModuleActionFunctions, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, ModuleNewActionGenerators, Solution } from '@modern-js/generator-common';
5
+ import { getPackageManager, getModernPluginVersion } from '@modern-js/generator-utils';
6
+ import { alreadyRepo, getGeneratorPath, hasEnabledFunction } from "./utils";
7
7
  export const ModuleNewAction = async options => {
8
8
  const {
9
9
  locale = 'zh',
@@ -68,31 +68,34 @@ export const ModuleNewAction = async options => {
68
68
  const ans = await appAPI.getInputBySchema(schema, UserConfig);
69
69
  const actionType = ans.actionType;
70
70
  const action = ans[actionType];
71
- let generator = ModuleNewActionGenerators[actionType] && ModuleNewActionGenerators[actionType][action];
71
+ const generator = getGeneratorPath(ModuleNewActionGenerators[actionType][action], distTag);
72
72
 
73
73
  if (!generator) {
74
74
  throw new Error(`no valid option`);
75
75
  }
76
76
 
77
- if (distTag) {
78
- generator = `${generator}@${distTag}`;
79
- }
80
-
81
77
  const devDependency = ModuleActionFunctionsDevDependencies[action];
82
78
  const dependency = ModuleActionFunctionsDependencies[action];
83
79
  const peerDependency = ModuleActionFunctionsPeerDependencies[action];
80
+
81
+ const getModulePluginVersion = packageName => {
82
+ return getModernPluginVersion(Solution.Module, packageName, {
83
+ registry
84
+ });
85
+ };
86
+
84
87
  const finalConfig = merge(UserConfig, ans, {
85
88
  locale: UserConfig.locale || locale,
86
89
  packageManager: UserConfig.packageManager || (await getPackageManager(cwd))
87
90
  }, {
88
91
  devDependencies: devDependency ? {
89
- [devDependency]: `^${await getPackageVersion(devDependency)}`
92
+ [devDependency]: `${await getModulePluginVersion(devDependency)}`
90
93
  } : {},
91
94
  dependencies: dependency ? {
92
- [dependency]: `^${await getPackageVersion(dependency)}`
95
+ [dependency]: `${await getModulePluginVersion(dependency)}`
93
96
  } : {},
94
97
  peerDependencies: peerDependency ? {
95
- [peerDependency]: `^${await getPackageVersion(peerDependency)}`
98
+ [peerDependency]: `${await getModulePluginVersion(peerDependency)}`
96
99
  } : {}
97
100
  });
98
101
  const task = [{
@@ -1,9 +1,9 @@
1
1
  import { merge } from '@modern-js/utils/lodash';
2
2
  import { CodeSmith, GeneratorCore, MaterialsManager } from '@modern-js/codesmith';
3
3
  import { AppAPI, forEach } from '@modern-js/codesmith-api-app';
4
- import { MWANewActionSchema, MWAActionFunctions, MWAActionFunctionsDependencies, MWAActionFunctionsAppendTypeContent, MWAActionFunctionsDevDependencies, MWANewActionGenerators, i18n } from '@modern-js/generator-common';
5
- import { getPackageManager, getPackageVersion } from '@modern-js/generator-utils';
6
- import { alreadyRepo, hasEnabledFunction } from "./utils";
4
+ import { MWANewActionSchema, MWAActionFunctions, MWAActionFunctionsDependencies, MWAActionFunctionsAppendTypeContent, MWAActionFunctionsDevDependencies, MWANewActionGenerators, i18n, Solution } from '@modern-js/generator-common';
5
+ import { getModernPluginVersion, getPackageManager } from '@modern-js/generator-utils';
6
+ import { alreadyRepo, getGeneratorPath, hasEnabledFunction } from "./utils";
7
7
  export const MWANewAction = async options => {
8
8
  const {
9
9
  locale = 'zh',
@@ -56,15 +56,17 @@ export const MWANewAction = async options => {
56
56
  const ans = await appAPI.getInputBySchema(schema, UserConfig);
57
57
  const actionType = ans.actionType;
58
58
  const action = ans[actionType];
59
- let generator = MWANewActionGenerators[actionType][action];
59
+ const generator = getGeneratorPath(MWANewActionGenerators[actionType][action], distTag);
60
60
 
61
61
  if (!generator) {
62
62
  throw new Error(`no valid option`);
63
63
  }
64
64
 
65
- if (distTag) {
66
- generator = `${generator}@${distTag}`;
67
- }
65
+ const getMwaPluginVersion = packageName => {
66
+ return getModernPluginVersion(Solution.MWA, packageName, {
67
+ registry
68
+ });
69
+ };
68
70
 
69
71
  const devDependency = MWAActionFunctionsDevDependencies[action];
70
72
  const dependency = MWAActionFunctionsDependencies[action];
@@ -73,10 +75,10 @@ export const MWANewAction = async options => {
73
75
  packageManager: UserConfig.packageManager || (await getPackageManager(cwd))
74
76
  }, {
75
77
  devDependencies: devDependency ? {
76
- [devDependency]: `^${await getPackageVersion(devDependency)}`
78
+ [devDependency]: `${await getMwaPluginVersion(devDependency)}`
77
79
  } : {},
78
80
  dependencies: dependency ? {
79
- [dependency]: `^${await getPackageVersion(dependency)}`
81
+ [dependency]: `${await getMwaPluginVersion(dependency)}`
80
82
  } : {},
81
83
  appendTypeContent: MWAActionFunctionsAppendTypeContent[action]
82
84
  });
@@ -50,4 +50,13 @@ export function hasEnabledFunction(action, dependencies, devDependencies, peerDe
50
50
  }
51
51
 
52
52
  return false;
53
+ }
54
+ export function getGeneratorPath(generator, distTag) {
55
+ if (process.env.CODESMITH_ENV === 'development') {
56
+ return path.dirname(require.resolve(generator));
57
+ } else if (distTag) {
58
+ return `${generator}@${distTag}`;
59
+ }
60
+
61
+ return generator;
53
62
  }
@@ -82,31 +82,34 @@ const ModuleNewAction = async options => {
82
82
  const ans = await appAPI.getInputBySchema(schema, UserConfig);
83
83
  const actionType = ans.actionType;
84
84
  const action = ans[actionType];
85
- let generator = _generatorCommon.ModuleNewActionGenerators[actionType] && _generatorCommon.ModuleNewActionGenerators[actionType][action];
85
+ const generator = (0, _utils.getGeneratorPath)(_generatorCommon.ModuleNewActionGenerators[actionType][action], distTag);
86
86
 
87
87
  if (!generator) {
88
88
  throw new Error(`no valid option`);
89
89
  }
90
90
 
91
- if (distTag) {
92
- generator = `${generator}@${distTag}`;
93
- }
94
-
95
91
  const devDependency = _generatorCommon.ModuleActionFunctionsDevDependencies[action];
96
92
  const dependency = _generatorCommon.ModuleActionFunctionsDependencies[action];
97
93
  const peerDependency = _generatorCommon.ModuleActionFunctionsPeerDependencies[action];
94
+
95
+ const getModulePluginVersion = packageName => {
96
+ return (0, _generatorUtils.getModernPluginVersion)(_generatorCommon.Solution.Module, packageName, {
97
+ registry
98
+ });
99
+ };
100
+
98
101
  const finalConfig = (0, _lodash.merge)(UserConfig, ans, {
99
102
  locale: UserConfig.locale || locale,
100
103
  packageManager: UserConfig.packageManager || (await (0, _generatorUtils.getPackageManager)(cwd))
101
104
  }, {
102
105
  devDependencies: devDependency ? {
103
- [devDependency]: `^${await (0, _generatorUtils.getPackageVersion)(devDependency)}`
106
+ [devDependency]: `${await getModulePluginVersion(devDependency)}`
104
107
  } : {},
105
108
  dependencies: dependency ? {
106
- [dependency]: `^${await (0, _generatorUtils.getPackageVersion)(dependency)}`
109
+ [dependency]: `${await getModulePluginVersion(dependency)}`
107
110
  } : {},
108
111
  peerDependencies: peerDependency ? {
109
- [peerDependency]: `^${await (0, _generatorUtils.getPackageVersion)(peerDependency)}`
112
+ [peerDependency]: `${await getModulePluginVersion(peerDependency)}`
110
113
  } : {}
111
114
  });
112
115
  const task = [{
@@ -70,15 +70,17 @@ const MWANewAction = async options => {
70
70
  const ans = await appAPI.getInputBySchema(schema, UserConfig);
71
71
  const actionType = ans.actionType;
72
72
  const action = ans[actionType];
73
- let generator = _generatorCommon.MWANewActionGenerators[actionType][action];
73
+ const generator = (0, _utils.getGeneratorPath)(_generatorCommon.MWANewActionGenerators[actionType][action], distTag);
74
74
 
75
75
  if (!generator) {
76
76
  throw new Error(`no valid option`);
77
77
  }
78
78
 
79
- if (distTag) {
80
- generator = `${generator}@${distTag}`;
81
- }
79
+ const getMwaPluginVersion = packageName => {
80
+ return (0, _generatorUtils.getModernPluginVersion)(_generatorCommon.Solution.MWA, packageName, {
81
+ registry
82
+ });
83
+ };
82
84
 
83
85
  const devDependency = _generatorCommon.MWAActionFunctionsDevDependencies[action];
84
86
  const dependency = _generatorCommon.MWAActionFunctionsDependencies[action];
@@ -87,10 +89,10 @@ const MWANewAction = async options => {
87
89
  packageManager: UserConfig.packageManager || (await (0, _generatorUtils.getPackageManager)(cwd))
88
90
  }, {
89
91
  devDependencies: devDependency ? {
90
- [devDependency]: `^${await (0, _generatorUtils.getPackageVersion)(devDependency)}`
92
+ [devDependency]: `${await getMwaPluginVersion(devDependency)}`
91
93
  } : {},
92
94
  dependencies: dependency ? {
93
- [dependency]: `^${await (0, _generatorUtils.getPackageVersion)(dependency)}`
95
+ [dependency]: `${await getMwaPluginVersion(dependency)}`
94
96
  } : {},
95
97
  appendTypeContent: _generatorCommon.MWAActionFunctionsAppendTypeContent[action]
96
98
  });
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.alreadyRepo = alreadyRepo;
7
+ exports.getGeneratorPath = getGeneratorPath;
7
8
  exports.hasEnabledFunction = hasEnabledFunction;
8
9
  exports.readJson = void 0;
9
10
 
@@ -69,4 +70,14 @@ function hasEnabledFunction(action, dependencies, devDependencies, peerDependenc
69
70
  }
70
71
 
71
72
  return false;
73
+ }
74
+
75
+ function getGeneratorPath(generator, distTag) {
76
+ if (process.env.CODESMITH_ENV === 'development') {
77
+ return _path.default.dirname(require.resolve(generator));
78
+ } else if (distTag) {
79
+ return `${generator}@${distTag}`;
80
+ }
81
+
82
+ return generator;
72
83
  }
@@ -1,4 +1,5 @@
1
1
  import { ActionFunction } from '@modern-js/generator-common';
2
2
  export declare function alreadyRepo(cwd?: string): boolean;
3
3
  export declare const readJson: (jsonPath: string) => any;
4
- export declare function hasEnabledFunction(action: ActionFunction, dependencies: Record<string, string>, devDependencies: Record<string, string>, peerDependencies: Record<string, string>, cwd: string): any;
4
+ export declare function hasEnabledFunction(action: ActionFunction, dependencies: Record<string, string>, devDependencies: Record<string, string>, peerDependencies: Record<string, string>, cwd: string): any;
5
+ export declare function getGeneratorPath(generator: string, distTag: string): string;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.15.0",
14
+ "version": "1.18.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -28,19 +28,19 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@babel/runtime": "^7.18.0",
31
- "@modern-js/codesmith": "^1.4.0",
32
- "@modern-js/codesmith-api-app": "^1.3.0",
33
- "@modern-js/generator-common": "2.2.1",
34
- "@modern-js/generator-utils": "2.2.1",
35
- "@modern-js/utils": "1.15.0"
31
+ "@modern-js/codesmith": "^1.5.0",
32
+ "@modern-js/codesmith-api-app": "^1.5.0",
33
+ "@modern-js/generator-common": "2.3.3",
34
+ "@modern-js/generator-utils": "2.3.3",
35
+ "@modern-js/utils": "1.18.0"
36
36
  },
37
37
  "devDependencies": {
38
+ "@scripts/build": "1.18.0",
39
+ "@scripts/jest-config": "1.18.0",
38
40
  "@types/jest": "^27",
39
41
  "@types/node": "^14",
40
- "typescript": "^4",
41
- "@scripts/build": "1.15.0",
42
42
  "jest": "^27",
43
- "@scripts/jest-config": "1.15.0"
43
+ "typescript": "^4"
44
44
  },
45
45
  "sideEffects": false,
46
46
  "modernConfig": {