@modern-js/new-action 1.4.0 → 1.17.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 +57 -0
- package/dist/js/modern/module.js +14 -11
- package/dist/js/modern/mwa.js +11 -9
- package/dist/js/modern/utils/index.js +9 -0
- package/dist/js/node/module.js +11 -8
- package/dist/js/node/mwa.js +8 -6
- package/dist/js/node/utils/index.js +11 -0
- package/dist/types/utils/index.d.ts +2 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# @modern-js/new-action
|
|
2
2
|
|
|
3
|
+
## 1.17.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f3fab28: feat: new command use solution version
|
|
8
|
+
|
|
9
|
+
feat: new 命令使用当前工程方案对应版本的插件
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [1b9176f]
|
|
12
|
+
- Updated dependencies [77d3a38]
|
|
13
|
+
- Updated dependencies [fb30bca]
|
|
14
|
+
- Updated dependencies [f3fab28]
|
|
15
|
+
- Updated dependencies [151329d]
|
|
16
|
+
- Updated dependencies [5af9472]
|
|
17
|
+
- Updated dependencies [6b6a534]
|
|
18
|
+
- Updated dependencies [6b43a2b]
|
|
19
|
+
- Updated dependencies [a7be124]
|
|
20
|
+
- Updated dependencies [31547b4]
|
|
21
|
+
- @modern-js/utils@1.17.0
|
|
22
|
+
- @modern-js/generator-common@2.3.1
|
|
23
|
+
- @modern-js/generator-utils@2.3.1
|
|
24
|
+
|
|
25
|
+
## 1.16.0
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 9d9bbfd05: feat: update codesmith package
|
|
30
|
+
|
|
31
|
+
feat: 升级 codesmith 包版本
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [beecff68d]
|
|
34
|
+
- Updated dependencies [641592f52]
|
|
35
|
+
- Updated dependencies [3904b30a5]
|
|
36
|
+
- Updated dependencies [1100dd58c]
|
|
37
|
+
- Updated dependencies [e04e6e76a]
|
|
38
|
+
- Updated dependencies [94222750f]
|
|
39
|
+
- Updated dependencies [81c66e4a4]
|
|
40
|
+
- Updated dependencies [2c305b6f5]
|
|
41
|
+
- Updated dependencies [9d9bbfd05]
|
|
42
|
+
- @modern-js/generator-utils@2.3.0
|
|
43
|
+
- @modern-js/utils@1.16.0
|
|
44
|
+
- @modern-js/generator-common@2.3.0
|
|
45
|
+
|
|
46
|
+
## 1.15.0
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [8658a78]
|
|
51
|
+
- Updated dependencies [05d4a4f]
|
|
52
|
+
- Updated dependencies [ad05af9]
|
|
53
|
+
- Updated dependencies [5d53d1c]
|
|
54
|
+
- Updated dependencies [9e6a0aa]
|
|
55
|
+
- Updated dependencies [37cd159]
|
|
56
|
+
- @modern-js/generator-common@2.2.1
|
|
57
|
+
- @modern-js/utils@1.15.0
|
|
58
|
+
- @modern-js/generator-utils@2.2.1
|
|
59
|
+
|
|
3
60
|
## 1.4.0
|
|
4
61
|
|
|
5
62
|
### Minor Changes
|
package/dist/js/modern/module.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
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]:
|
|
92
|
+
[devDependency]: `${await getModulePluginVersion(devDependency)}`
|
|
90
93
|
} : {},
|
|
91
94
|
dependencies: dependency ? {
|
|
92
|
-
[dependency]:
|
|
95
|
+
[dependency]: `${await getModulePluginVersion(dependency)}`
|
|
93
96
|
} : {},
|
|
94
97
|
peerDependencies: peerDependency ? {
|
|
95
|
-
[peerDependency]:
|
|
98
|
+
[peerDependency]: `${await getModulePluginVersion(peerDependency)}`
|
|
96
99
|
} : {}
|
|
97
100
|
});
|
|
98
101
|
const task = [{
|
package/dist/js/modern/mwa.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
|
|
66
|
-
|
|
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]:
|
|
78
|
+
[devDependency]: `${await getMwaPluginVersion(devDependency)}`
|
|
77
79
|
} : {},
|
|
78
80
|
dependencies: dependency ? {
|
|
79
|
-
[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
|
}
|
package/dist/js/node/module.js
CHANGED
|
@@ -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
|
-
|
|
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]:
|
|
106
|
+
[devDependency]: `${await getModulePluginVersion(devDependency)}`
|
|
104
107
|
} : {},
|
|
105
108
|
dependencies: dependency ? {
|
|
106
|
-
[dependency]:
|
|
109
|
+
[dependency]: `${await getModulePluginVersion(dependency)}`
|
|
107
110
|
} : {},
|
|
108
111
|
peerDependencies: peerDependency ? {
|
|
109
|
-
[peerDependency]:
|
|
112
|
+
[peerDependency]: `${await getModulePluginVersion(peerDependency)}`
|
|
110
113
|
} : {}
|
|
111
114
|
});
|
|
112
115
|
const task = [{
|
package/dist/js/node/mwa.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
80
|
-
|
|
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]:
|
|
92
|
+
[devDependency]: `${await getMwaPluginVersion(devDependency)}`
|
|
91
93
|
} : {},
|
|
92
94
|
dependencies: dependency ? {
|
|
93
|
-
[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.
|
|
14
|
+
"version": "1.17.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.
|
|
32
|
-
"@modern-js/codesmith-api-app": "^1.
|
|
33
|
-
"@modern-js/generator-common": "
|
|
34
|
-
"@modern-js/generator-utils": "
|
|
35
|
-
"@modern-js/utils": "
|
|
31
|
+
"@modern-js/codesmith": "^1.5.0",
|
|
32
|
+
"@modern-js/codesmith-api-app": "^1.5.0",
|
|
33
|
+
"@modern-js/generator-common": "2.3.1",
|
|
34
|
+
"@modern-js/generator-utils": "2.3.1",
|
|
35
|
+
"@modern-js/utils": "1.17.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
+
"@scripts/build": "1.17.0",
|
|
39
|
+
"@scripts/jest-config": "1.17.0",
|
|
38
40
|
"@types/jest": "^27",
|
|
39
41
|
"@types/node": "^14",
|
|
40
|
-
"typescript": "^4",
|
|
41
|
-
"@scripts/build": "0.0.0",
|
|
42
42
|
"jest": "^27",
|
|
43
|
-
"
|
|
43
|
+
"typescript": "^4"
|
|
44
44
|
},
|
|
45
45
|
"sideEffects": false,
|
|
46
46
|
"modernConfig": {
|