@modern-js/new-action 2.15.0 → 2.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 +24 -0
- package/dist/cjs/index.js +21 -20
- package/dist/cjs/module.js +45 -78
- package/dist/cjs/monorepo.js +28 -57
- package/dist/cjs/mwa.js +44 -85
- package/dist/cjs/utils/index.js +35 -51
- package/dist/esm/module.js +26 -58
- package/dist/esm/monorepo.js +5 -14
- package/dist/esm/mwa.js +25 -68
- package/dist/esm/utils/index.js +13 -15
- package/package.json +11 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @modern-js/new-action
|
|
2
2
|
|
|
3
|
+
## 2.17.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @modern-js/generator-common@3.1.11
|
|
8
|
+
- @modern-js/generator-utils@3.1.11
|
|
9
|
+
- @modern-js/utils@2.17.0
|
|
10
|
+
|
|
11
|
+
## 2.16.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 4e876ab: chore: package.json include the monorepo-relative directory
|
|
16
|
+
|
|
17
|
+
chore: 在 package.json 中声明 monorepo 的子路径
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [5954330]
|
|
20
|
+
- Updated dependencies [84a8008]
|
|
21
|
+
- Updated dependencies [7596520]
|
|
22
|
+
- Updated dependencies [4e876ab]
|
|
23
|
+
- @modern-js/utils@2.16.0
|
|
24
|
+
- @modern-js/generator-common@3.1.10
|
|
25
|
+
- @modern-js/generator-utils@3.1.10
|
|
26
|
+
|
|
3
27
|
## 2.15.0
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./utils"), exports);
|
|
6
|
+
_export_star(require("./mwa"), exports);
|
|
7
|
+
_export_star(require("./module"), exports);
|
|
8
|
+
_export_star(require("./monorepo"), exports);
|
|
9
|
+
function _export_star(from, to) {
|
|
10
|
+
Object.keys(from).forEach(function(k) {
|
|
11
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
12
|
+
Object.defineProperty(to, k, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function() {
|
|
15
|
+
return from[k];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return from;
|
|
21
|
+
}
|
package/dist/cjs/module.js
CHANGED
|
@@ -1,55 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var module_exports = {};
|
|
19
|
-
__export(module_exports, {
|
|
20
|
-
ModuleNewAction: () => ModuleNewAction
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ModuleNewAction", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => ModuleNewAction
|
|
21
8
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var import_utils = require("./utils");
|
|
9
|
+
const _lodash = require("@modern-js/utils/lodash");
|
|
10
|
+
const _codesmith = require("@modern-js/codesmith");
|
|
11
|
+
const _codesmithformily = require("@modern-js/codesmith-formily");
|
|
12
|
+
const _generatorcommon = require("@modern-js/generator-common");
|
|
13
|
+
const _generatorutils = require("@modern-js/generator-utils");
|
|
14
|
+
const _utils = require("./utils");
|
|
29
15
|
const ModuleNewAction = async (options) => {
|
|
30
|
-
const {
|
|
31
|
-
locale = "zh",
|
|
32
|
-
distTag = "",
|
|
33
|
-
debug = false,
|
|
34
|
-
registry = "",
|
|
35
|
-
config = "{}",
|
|
36
|
-
cwd = process.cwd()
|
|
37
|
-
} = options;
|
|
16
|
+
const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd() } = options;
|
|
38
17
|
let UserConfig = {};
|
|
39
18
|
try {
|
|
40
19
|
UserConfig = JSON.parse(config);
|
|
41
20
|
} catch (e) {
|
|
42
21
|
throw new Error("config is not a valid json");
|
|
43
22
|
}
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
_generatorcommon.i18n.changeLanguage({
|
|
24
|
+
locale: UserConfig.locale || locale
|
|
25
|
+
});
|
|
26
|
+
const smith = new _codesmith.CodeSmith({
|
|
46
27
|
debug,
|
|
47
28
|
registryUrl: registry
|
|
48
29
|
});
|
|
49
|
-
if (!(0,
|
|
30
|
+
if (!(0, _utils.alreadyRepo)(cwd)) {
|
|
50
31
|
smith.logger.warn("not valid modern.js repo");
|
|
51
32
|
}
|
|
52
|
-
const formilyAPI = new
|
|
33
|
+
const formilyAPI = new _codesmithformily.FormilyAPI({
|
|
53
34
|
materials: {},
|
|
54
35
|
config: {},
|
|
55
36
|
data: {},
|
|
@@ -57,14 +38,8 @@ const ModuleNewAction = async (options) => {
|
|
|
57
38
|
});
|
|
58
39
|
let hasOption = false;
|
|
59
40
|
const funcMap = {};
|
|
60
|
-
|
|
61
|
-
const enable = (0,
|
|
62
|
-
func,
|
|
63
|
-
import_generator_common.ModuleActionFunctionsDependencies,
|
|
64
|
-
import_generator_common.ModuleActionFunctionsDevDependencies,
|
|
65
|
-
import_generator_common.ModuleActionFunctionsPeerDependencies,
|
|
66
|
-
cwd
|
|
67
|
-
);
|
|
41
|
+
_generatorcommon.ModuleActionFunctions.forEach((func) => {
|
|
42
|
+
const enable = (0, _utils.hasEnabledFunction)(func, _generatorcommon.ModuleActionFunctionsDependencies, _generatorcommon.ModuleActionFunctionsDevDependencies, _generatorcommon.ModuleActionFunctionsPeerDependencies, cwd);
|
|
68
43
|
funcMap[func] = enable;
|
|
69
44
|
if (!enable) {
|
|
70
45
|
hasOption = true;
|
|
@@ -74,47 +49,43 @@ const ModuleNewAction = async (options) => {
|
|
|
74
49
|
smith.logger.warn("no option can be enabled");
|
|
75
50
|
process.exit(1);
|
|
76
51
|
}
|
|
77
|
-
const ans = await formilyAPI.getInputBySchemaFunc(
|
|
52
|
+
const ans = await formilyAPI.getInputBySchemaFunc(_generatorcommon.getModuleNewActionSchema, {
|
|
78
53
|
...UserConfig,
|
|
79
54
|
funcMap
|
|
80
55
|
});
|
|
81
56
|
const actionType = ans.actionType;
|
|
82
57
|
const action = ans[actionType];
|
|
83
|
-
const generator = (0,
|
|
84
|
-
import_generator_common.ModuleNewActionGenerators[actionType][action],
|
|
85
|
-
distTag
|
|
86
|
-
);
|
|
58
|
+
const generator = (0, _utils.getGeneratorPath)(_generatorcommon.ModuleNewActionGenerators[actionType][action], distTag);
|
|
87
59
|
if (!generator) {
|
|
88
60
|
throw new Error(`no valid option`);
|
|
89
61
|
}
|
|
90
|
-
const devDependency =
|
|
91
|
-
const dependency =
|
|
92
|
-
const peerDependency =
|
|
62
|
+
const devDependency = _generatorcommon.ModuleActionFunctionsDevDependencies[action];
|
|
63
|
+
const dependency = _generatorcommon.ModuleActionFunctionsDependencies[action];
|
|
64
|
+
const peerDependency = _generatorcommon.ModuleActionFunctionsPeerDependencies[action];
|
|
93
65
|
const getModulePluginVersion = (packageName) => {
|
|
94
|
-
return (0,
|
|
66
|
+
return (0, _generatorutils.getModernPluginVersion)(_generatorcommon.Solution.Module, packageName, {
|
|
95
67
|
registry,
|
|
96
68
|
distTag,
|
|
97
69
|
cwd
|
|
98
70
|
});
|
|
99
71
|
};
|
|
100
|
-
const finalConfig = (0,
|
|
101
|
-
UserConfig,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
);
|
|
72
|
+
const finalConfig = (0, _lodash.merge)(UserConfig, ans, {
|
|
73
|
+
locale: UserConfig.locale || locale,
|
|
74
|
+
packageManager: UserConfig.packageManager || await (0, _generatorutils.getPackageManager)(cwd),
|
|
75
|
+
distTag
|
|
76
|
+
}, {
|
|
77
|
+
devDependencies: devDependency ? {
|
|
78
|
+
[devDependency]: `${await getModulePluginVersion(devDependency)}`
|
|
79
|
+
} : {},
|
|
80
|
+
dependencies: dependency ? {
|
|
81
|
+
[dependency]: `${await getModulePluginVersion(dependency)}`
|
|
82
|
+
} : {},
|
|
83
|
+
peerDependencies: peerDependency ? {
|
|
84
|
+
[peerDependency]: `${await getModulePluginVersion(peerDependency)}`
|
|
85
|
+
} : {},
|
|
86
|
+
pluginName: _generatorcommon.ModuleNewActionPluginName[actionType][action],
|
|
87
|
+
pluginDependence: _generatorcommon.ModuleNewActionPluginDependence[actionType][action]
|
|
88
|
+
});
|
|
118
89
|
const task = [
|
|
119
90
|
{
|
|
120
91
|
name: generator,
|
|
@@ -129,7 +100,3 @@ const ModuleNewAction = async (options) => {
|
|
|
129
100
|
pwd: cwd
|
|
130
101
|
});
|
|
131
102
|
};
|
|
132
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
-
0 && (module.exports = {
|
|
134
|
-
ModuleNewAction
|
|
135
|
-
});
|
package/dist/cjs/monorepo.js
CHANGED
|
@@ -1,80 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var monorepo_exports = {};
|
|
29
|
-
__export(monorepo_exports, {
|
|
30
|
-
MonorepoNewAction: () => MonorepoNewAction
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
5
|
+
Object.defineProperty(exports, "MonorepoNewAction", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => MonorepoNewAction
|
|
8
|
+
});
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
10
|
+
const _lodash = require("@modern-js/utils/lodash");
|
|
11
|
+
const _codesmith = require("@modern-js/codesmith");
|
|
12
|
+
const _generatorcommon = require("@modern-js/generator-common");
|
|
13
|
+
const _generatorutils = require("@modern-js/generator-utils");
|
|
14
|
+
const _utils = require("./utils");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
39
20
|
const REPO_GENERATOR = "@modern-js/repo-generator";
|
|
40
21
|
const MonorepoNewAction = async (options) => {
|
|
41
|
-
const {
|
|
42
|
-
locale = "zh",
|
|
43
|
-
distTag = "",
|
|
44
|
-
debug = false,
|
|
45
|
-
registry = "",
|
|
46
|
-
config = "{}",
|
|
47
|
-
plugin = [],
|
|
48
|
-
cwd = process.cwd()
|
|
49
|
-
} = options;
|
|
22
|
+
const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", plugin = [], cwd = process.cwd() } = options;
|
|
50
23
|
let UserConfig = {};
|
|
51
24
|
try {
|
|
52
25
|
UserConfig = JSON.parse(config);
|
|
53
26
|
} catch (e) {
|
|
54
27
|
throw new Error("config is not a valid json");
|
|
55
28
|
}
|
|
56
|
-
|
|
57
|
-
|
|
29
|
+
_generatorcommon.i18n.changeLanguage({
|
|
30
|
+
locale: UserConfig.locale || locale
|
|
31
|
+
});
|
|
32
|
+
const smith = new _codesmith.CodeSmith({
|
|
58
33
|
debug,
|
|
59
34
|
registryUrl: registry
|
|
60
35
|
});
|
|
61
|
-
if (!(0,
|
|
36
|
+
if (!(0, _utils.alreadyRepo)(cwd)) {
|
|
62
37
|
smith.logger.warn("not valid modern.js repo");
|
|
63
38
|
}
|
|
64
39
|
const plugins = plugin.map((plugin2) => {
|
|
65
40
|
try {
|
|
66
|
-
return
|
|
41
|
+
return _path.default.join(require.resolve(plugin2), "../../");
|
|
67
42
|
} catch (e) {
|
|
68
43
|
try {
|
|
69
|
-
return
|
|
44
|
+
return _path.default.join(require.resolve(plugin2), "../../../../");
|
|
70
45
|
} catch (e2) {
|
|
71
46
|
return plugin2;
|
|
72
47
|
}
|
|
73
48
|
}
|
|
74
49
|
});
|
|
75
|
-
const finalConfig = (0,
|
|
50
|
+
const finalConfig = (0, _lodash.merge)(UserConfig, {
|
|
76
51
|
locale: UserConfig.locale || locale,
|
|
77
|
-
packageManager: UserConfig.packageManager || await (0,
|
|
52
|
+
packageManager: UserConfig.packageManager || await (0, _generatorutils.getPackageManager)(cwd),
|
|
78
53
|
isMonorepo: true,
|
|
79
54
|
distTag,
|
|
80
55
|
plugins
|
|
@@ -99,7 +74,3 @@ const MonorepoNewAction = async (options) => {
|
|
|
99
74
|
pwd: cwd
|
|
100
75
|
});
|
|
101
76
|
};
|
|
102
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
-
0 && (module.exports = {
|
|
104
|
-
MonorepoNewAction
|
|
105
|
-
});
|
package/dist/cjs/mwa.js
CHANGED
|
@@ -1,123 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var mwa_exports = {};
|
|
19
|
-
__export(mwa_exports, {
|
|
20
|
-
MWANewAction: () => MWANewAction
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "MWANewAction", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => MWANewAction
|
|
21
8
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var import_utils = require("./utils");
|
|
9
|
+
const _lodash = require("@modern-js/utils/lodash");
|
|
10
|
+
const _codesmith = require("@modern-js/codesmith");
|
|
11
|
+
const _codesmithformily = require("@modern-js/codesmith-formily");
|
|
12
|
+
const _generatorcommon = require("@modern-js/generator-common");
|
|
13
|
+
const _generatorutils = require("@modern-js/generator-utils");
|
|
14
|
+
const _utils = require("./utils");
|
|
29
15
|
const MWANewAction = async (options) => {
|
|
30
|
-
const {
|
|
31
|
-
locale = "zh",
|
|
32
|
-
distTag = "",
|
|
33
|
-
debug = false,
|
|
34
|
-
registry = "",
|
|
35
|
-
config = "{}",
|
|
36
|
-
cwd = process.cwd()
|
|
37
|
-
} = options;
|
|
16
|
+
const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd() } = options;
|
|
38
17
|
let UserConfig = {};
|
|
39
18
|
try {
|
|
40
19
|
UserConfig = JSON.parse(config);
|
|
41
20
|
} catch (e) {
|
|
42
21
|
throw new Error("config is not a valid json");
|
|
43
22
|
}
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
_generatorcommon.i18n.changeLanguage({
|
|
24
|
+
locale: UserConfig.locale || locale
|
|
25
|
+
});
|
|
26
|
+
const smith = new _codesmith.CodeSmith({
|
|
46
27
|
debug,
|
|
47
28
|
registryUrl: registry
|
|
48
29
|
});
|
|
49
|
-
if (!(0,
|
|
30
|
+
if (!(0, _utils.alreadyRepo)(cwd)) {
|
|
50
31
|
smith.logger.warn("not valid modern.js repo");
|
|
51
32
|
}
|
|
52
|
-
const formilyAPI = new
|
|
33
|
+
const formilyAPI = new _codesmithformily.FormilyAPI({
|
|
53
34
|
materials: {},
|
|
54
35
|
config: {},
|
|
55
36
|
data: {},
|
|
56
37
|
current: null
|
|
57
38
|
});
|
|
58
39
|
const funcMap = {};
|
|
59
|
-
|
|
60
|
-
const enable = (0,
|
|
61
|
-
func,
|
|
62
|
-
import_generator_common.MWAActionFunctionsDependencies,
|
|
63
|
-
import_generator_common.MWAActionFunctionsDevDependencies,
|
|
64
|
-
{},
|
|
65
|
-
cwd
|
|
66
|
-
);
|
|
40
|
+
_generatorcommon.MWAActionFunctions.forEach((func) => {
|
|
41
|
+
const enable = (0, _utils.hasEnabledFunction)(func, _generatorcommon.MWAActionFunctionsDependencies, _generatorcommon.MWAActionFunctionsDevDependencies, {}, cwd);
|
|
67
42
|
funcMap[func] = enable;
|
|
68
43
|
});
|
|
69
44
|
const refactorMap = {};
|
|
70
|
-
|
|
71
|
-
const enable = (0,
|
|
72
|
-
refactor,
|
|
73
|
-
import_generator_common.MWAActionRefactorDependencies,
|
|
74
|
-
{},
|
|
75
|
-
{},
|
|
76
|
-
cwd
|
|
77
|
-
);
|
|
45
|
+
_generatorcommon.MWAActionReactors.forEach((refactor) => {
|
|
46
|
+
const enable = (0, _utils.hasEnabledFunction)(refactor, _generatorcommon.MWAActionRefactorDependencies, {}, {}, cwd);
|
|
78
47
|
refactorMap[refactor] = enable;
|
|
79
48
|
});
|
|
80
|
-
const ans = await formilyAPI.getInputBySchemaFunc(
|
|
49
|
+
const ans = await formilyAPI.getInputBySchemaFunc(_generatorcommon.getMWANewActionSchema, {
|
|
81
50
|
...UserConfig,
|
|
82
51
|
funcMap,
|
|
83
52
|
refactorMap
|
|
84
53
|
});
|
|
85
54
|
const actionType = ans.actionType;
|
|
86
55
|
const action = ans[actionType];
|
|
87
|
-
const generator = (0,
|
|
88
|
-
import_generator_common.MWANewActionGenerators[actionType][action],
|
|
89
|
-
distTag
|
|
90
|
-
);
|
|
56
|
+
const generator = (0, _utils.getGeneratorPath)(_generatorcommon.MWANewActionGenerators[actionType][action], distTag);
|
|
91
57
|
if (!generator) {
|
|
92
58
|
throw new Error(`no valid option`);
|
|
93
59
|
}
|
|
94
60
|
const getMwaPluginVersion = (packageName) => {
|
|
95
|
-
return (0,
|
|
61
|
+
return (0, _generatorutils.getModernPluginVersion)(_generatorcommon.Solution.MWA, packageName, {
|
|
96
62
|
registry,
|
|
97
63
|
distTag,
|
|
98
64
|
cwd
|
|
99
65
|
});
|
|
100
66
|
};
|
|
101
|
-
const devDependency =
|
|
102
|
-
const dependency =
|
|
103
|
-
const finalConfig = (0,
|
|
104
|
-
UserConfig,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
pluginDependence: import_generator_common.MWANewActionPluginDependence[actionType][action]
|
|
119
|
-
}
|
|
120
|
-
);
|
|
67
|
+
const devDependency = _generatorcommon.MWAActionFunctionsDevDependencies[action];
|
|
68
|
+
const dependency = _generatorcommon.MWAActionFunctionsDependencies[action] || _generatorcommon.MWAActionRefactorDependencies[action];
|
|
69
|
+
const finalConfig = (0, _lodash.merge)(UserConfig, ans, {
|
|
70
|
+
locale: UserConfig.locale || locale,
|
|
71
|
+
packageManager: UserConfig.packageManager || await (0, _generatorutils.getPackageManager)(cwd),
|
|
72
|
+
distTag
|
|
73
|
+
}, {
|
|
74
|
+
devDependencies: devDependency ? {
|
|
75
|
+
[devDependency]: `${await getMwaPluginVersion(devDependency)}`
|
|
76
|
+
} : {},
|
|
77
|
+
dependencies: dependency ? {
|
|
78
|
+
[dependency]: `${await getMwaPluginVersion(dependency)}`
|
|
79
|
+
} : {},
|
|
80
|
+
appendTypeContent: _generatorcommon.MWAActionFunctionsAppendTypeContent[action] || _generatorcommon.MWAActionReactorAppendTypeContent[action],
|
|
81
|
+
pluginName: _generatorcommon.MWANewActionPluginName[actionType][action],
|
|
82
|
+
pluginDependence: _generatorcommon.MWANewActionPluginDependence[actionType][action]
|
|
83
|
+
});
|
|
121
84
|
const task = [
|
|
122
85
|
{
|
|
123
86
|
name: generator,
|
|
@@ -132,7 +95,3 @@ const MWANewAction = async (options) => {
|
|
|
132
95
|
pwd: cwd
|
|
133
96
|
});
|
|
134
97
|
};
|
|
135
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
-
0 && (module.exports = {
|
|
137
|
-
MWANewAction
|
|
138
|
-
});
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,89 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var utils_exports = {};
|
|
29
|
-
__export(utils_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
30
13
|
alreadyRepo: () => alreadyRepo,
|
|
31
|
-
|
|
14
|
+
readJson: () => readJson,
|
|
32
15
|
hasEnabledFunction: () => hasEnabledFunction,
|
|
33
|
-
|
|
16
|
+
getGeneratorPath: () => getGeneratorPath
|
|
34
17
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
18
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
19
|
+
const _utils = require("@modern-js/utils");
|
|
20
|
+
const _generatorutils = require("@modern-js/generator-utils");
|
|
21
|
+
function _interop_require_default(obj) {
|
|
22
|
+
return obj && obj.__esModule ? obj : {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
39
26
|
function alreadyRepo(cwd = process.cwd()) {
|
|
40
27
|
try {
|
|
41
|
-
return
|
|
28
|
+
return _generatorutils.fs.existsSync(_path.default.resolve(cwd, "package.json"));
|
|
42
29
|
} catch (e) {
|
|
43
30
|
return false;
|
|
44
31
|
}
|
|
45
32
|
}
|
|
46
33
|
const readJson = (jsonPath) => {
|
|
47
|
-
if (!
|
|
34
|
+
if (!_generatorutils.fs.existsSync(jsonPath)) {
|
|
48
35
|
return {};
|
|
49
36
|
}
|
|
50
|
-
const jsonStr =
|
|
37
|
+
const jsonStr = _generatorutils.fs.readFileSync(jsonPath, {
|
|
38
|
+
encoding: "utf8"
|
|
39
|
+
});
|
|
51
40
|
try {
|
|
52
|
-
return
|
|
41
|
+
return _utils.json5.parse(jsonStr);
|
|
53
42
|
} catch (error) {
|
|
54
43
|
throw Error(`${jsonPath} is not a valid json, please check and try again.`);
|
|
55
44
|
}
|
|
56
45
|
};
|
|
57
46
|
function hasEnabledFunction(action, dependencies, devDependencies, peerDependencies, cwd) {
|
|
58
|
-
|
|
59
|
-
const packageJsonPath = import_path.default.normalize(`${cwd}/package.json`);
|
|
47
|
+
const packageJsonPath = _path.default.normalize(`${cwd}/package.json`);
|
|
60
48
|
const packageJson = readJson(packageJsonPath);
|
|
61
49
|
if (!dependencies[action] && !devDependencies[action]) {
|
|
62
50
|
return false;
|
|
63
51
|
}
|
|
64
52
|
if (dependencies[action]) {
|
|
65
|
-
|
|
53
|
+
var _packageJson_dependencies;
|
|
54
|
+
return (_packageJson_dependencies = packageJson.dependencies) === null || _packageJson_dependencies === void 0 ? void 0 : _packageJson_dependencies[dependencies[action]];
|
|
66
55
|
}
|
|
67
56
|
if (peerDependencies[action]) {
|
|
68
|
-
|
|
57
|
+
var _packageJson_peerDependencies;
|
|
58
|
+
return (_packageJson_peerDependencies = packageJson.peerDependencies) === null || _packageJson_peerDependencies === void 0 ? void 0 : _packageJson_peerDependencies[peerDependencies[action]];
|
|
69
59
|
}
|
|
70
60
|
if (!peerDependencies[action] && devDependencies[action]) {
|
|
71
|
-
|
|
61
|
+
var _packageJson_devDependencies;
|
|
62
|
+
return (_packageJson_devDependencies = packageJson.devDependencies) === null || _packageJson_devDependencies === void 0 ? void 0 : _packageJson_devDependencies[devDependencies[action]];
|
|
72
63
|
}
|
|
73
64
|
return false;
|
|
74
65
|
}
|
|
75
66
|
function getGeneratorPath(generator, distTag) {
|
|
76
67
|
if (process.env.CODESMITH_ENV === "development") {
|
|
77
|
-
return
|
|
68
|
+
return _path.default.dirname(require.resolve(generator));
|
|
78
69
|
} else if (distTag) {
|
|
79
70
|
return `${generator}@${distTag}`;
|
|
80
71
|
}
|
|
81
72
|
return generator;
|
|
82
73
|
}
|
|
83
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
-
0 && (module.exports = {
|
|
85
|
-
alreadyRepo,
|
|
86
|
-
getGeneratorPath,
|
|
87
|
-
hasEnabledFunction,
|
|
88
|
-
readJson
|
|
89
|
-
});
|
package/dist/esm/module.js
CHANGED
|
@@ -1,39 +1,20 @@
|
|
|
1
1
|
import { merge } from "@modern-js/utils/lodash";
|
|
2
2
|
import { CodeSmith } from "@modern-js/codesmith";
|
|
3
3
|
import { FormilyAPI } from "@modern-js/codesmith-formily";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
getModuleNewActionSchema,
|
|
7
|
-
ModuleActionFunctions,
|
|
8
|
-
ModuleActionFunctionsDependencies,
|
|
9
|
-
ModuleActionFunctionsDevDependencies,
|
|
10
|
-
ModuleActionFunctionsPeerDependencies,
|
|
11
|
-
ModuleNewActionGenerators,
|
|
12
|
-
Solution,
|
|
13
|
-
ModuleNewActionPluginName,
|
|
14
|
-
ModuleNewActionPluginDependence
|
|
15
|
-
} from "@modern-js/generator-common";
|
|
16
|
-
import {
|
|
17
|
-
getPackageManager,
|
|
18
|
-
getModernPluginVersion
|
|
19
|
-
} from "@modern-js/generator-utils";
|
|
4
|
+
import { i18n, getModuleNewActionSchema, ModuleActionFunctions, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, ModuleNewActionGenerators, Solution, ModuleNewActionPluginName, ModuleNewActionPluginDependence } from "@modern-js/generator-common";
|
|
5
|
+
import { getPackageManager, getModernPluginVersion } from "@modern-js/generator-utils";
|
|
20
6
|
import { alreadyRepo, getGeneratorPath, hasEnabledFunction } from "./utils";
|
|
21
|
-
const ModuleNewAction = async (options) => {
|
|
22
|
-
const {
|
|
23
|
-
locale = "zh",
|
|
24
|
-
distTag = "",
|
|
25
|
-
debug = false,
|
|
26
|
-
registry = "",
|
|
27
|
-
config = "{}",
|
|
28
|
-
cwd = process.cwd()
|
|
29
|
-
} = options;
|
|
7
|
+
export const ModuleNewAction = async (options) => {
|
|
8
|
+
const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd() } = options;
|
|
30
9
|
let UserConfig = {};
|
|
31
10
|
try {
|
|
32
11
|
UserConfig = JSON.parse(config);
|
|
33
12
|
} catch (e) {
|
|
34
13
|
throw new Error("config is not a valid json");
|
|
35
14
|
}
|
|
36
|
-
i18n.changeLanguage({
|
|
15
|
+
i18n.changeLanguage({
|
|
16
|
+
locale: UserConfig.locale || locale
|
|
17
|
+
});
|
|
37
18
|
const smith = new CodeSmith({
|
|
38
19
|
debug,
|
|
39
20
|
registryUrl: registry
|
|
@@ -50,13 +31,7 @@ const ModuleNewAction = async (options) => {
|
|
|
50
31
|
let hasOption = false;
|
|
51
32
|
const funcMap = {};
|
|
52
33
|
ModuleActionFunctions.forEach((func) => {
|
|
53
|
-
const enable = hasEnabledFunction(
|
|
54
|
-
func,
|
|
55
|
-
ModuleActionFunctionsDependencies,
|
|
56
|
-
ModuleActionFunctionsDevDependencies,
|
|
57
|
-
ModuleActionFunctionsPeerDependencies,
|
|
58
|
-
cwd
|
|
59
|
-
);
|
|
34
|
+
const enable = hasEnabledFunction(func, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, cwd);
|
|
60
35
|
funcMap[func] = enable;
|
|
61
36
|
if (!enable) {
|
|
62
37
|
hasOption = true;
|
|
@@ -72,10 +47,7 @@ const ModuleNewAction = async (options) => {
|
|
|
72
47
|
});
|
|
73
48
|
const actionType = ans.actionType;
|
|
74
49
|
const action = ans[actionType];
|
|
75
|
-
const generator = getGeneratorPath(
|
|
76
|
-
ModuleNewActionGenerators[actionType][action],
|
|
77
|
-
distTag
|
|
78
|
-
);
|
|
50
|
+
const generator = getGeneratorPath(ModuleNewActionGenerators[actionType][action], distTag);
|
|
79
51
|
if (!generator) {
|
|
80
52
|
throw new Error(`no valid option`);
|
|
81
53
|
}
|
|
@@ -89,24 +61,23 @@ const ModuleNewAction = async (options) => {
|
|
|
89
61
|
cwd
|
|
90
62
|
});
|
|
91
63
|
};
|
|
92
|
-
const finalConfig = merge(
|
|
93
|
-
UserConfig,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
);
|
|
64
|
+
const finalConfig = merge(UserConfig, ans, {
|
|
65
|
+
locale: UserConfig.locale || locale,
|
|
66
|
+
packageManager: UserConfig.packageManager || await getPackageManager(cwd),
|
|
67
|
+
distTag
|
|
68
|
+
}, {
|
|
69
|
+
devDependencies: devDependency ? {
|
|
70
|
+
[devDependency]: `${await getModulePluginVersion(devDependency)}`
|
|
71
|
+
} : {},
|
|
72
|
+
dependencies: dependency ? {
|
|
73
|
+
[dependency]: `${await getModulePluginVersion(dependency)}`
|
|
74
|
+
} : {},
|
|
75
|
+
peerDependencies: peerDependency ? {
|
|
76
|
+
[peerDependency]: `${await getModulePluginVersion(peerDependency)}`
|
|
77
|
+
} : {},
|
|
78
|
+
pluginName: ModuleNewActionPluginName[actionType][action],
|
|
79
|
+
pluginDependence: ModuleNewActionPluginDependence[actionType][action]
|
|
80
|
+
});
|
|
110
81
|
const task = [
|
|
111
82
|
{
|
|
112
83
|
name: generator,
|
|
@@ -121,6 +92,3 @@ const ModuleNewAction = async (options) => {
|
|
|
121
92
|
pwd: cwd
|
|
122
93
|
});
|
|
123
94
|
};
|
|
124
|
-
export {
|
|
125
|
-
ModuleNewAction
|
|
126
|
-
};
|
package/dist/esm/monorepo.js
CHANGED
|
@@ -5,23 +5,17 @@ import { i18n } from "@modern-js/generator-common";
|
|
|
5
5
|
import { getPackageManager } from "@modern-js/generator-utils";
|
|
6
6
|
import { alreadyRepo } from "./utils";
|
|
7
7
|
const REPO_GENERATOR = "@modern-js/repo-generator";
|
|
8
|
-
const MonorepoNewAction = async (options) => {
|
|
9
|
-
const {
|
|
10
|
-
locale = "zh",
|
|
11
|
-
distTag = "",
|
|
12
|
-
debug = false,
|
|
13
|
-
registry = "",
|
|
14
|
-
config = "{}",
|
|
15
|
-
plugin = [],
|
|
16
|
-
cwd = process.cwd()
|
|
17
|
-
} = options;
|
|
8
|
+
export const MonorepoNewAction = async (options) => {
|
|
9
|
+
const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", plugin = [], cwd = process.cwd() } = options;
|
|
18
10
|
let UserConfig = {};
|
|
19
11
|
try {
|
|
20
12
|
UserConfig = JSON.parse(config);
|
|
21
13
|
} catch (e) {
|
|
22
14
|
throw new Error("config is not a valid json");
|
|
23
15
|
}
|
|
24
|
-
i18n.changeLanguage({
|
|
16
|
+
i18n.changeLanguage({
|
|
17
|
+
locale: UserConfig.locale || locale
|
|
18
|
+
});
|
|
25
19
|
const smith = new CodeSmith({
|
|
26
20
|
debug,
|
|
27
21
|
registryUrl: registry
|
|
@@ -67,6 +61,3 @@ const MonorepoNewAction = async (options) => {
|
|
|
67
61
|
pwd: cwd
|
|
68
62
|
});
|
|
69
63
|
};
|
|
70
|
-
export {
|
|
71
|
-
MonorepoNewAction
|
|
72
|
-
};
|
package/dist/esm/mwa.js
CHANGED
|
@@ -1,42 +1,20 @@
|
|
|
1
1
|
import { merge } from "@modern-js/utils/lodash";
|
|
2
2
|
import { CodeSmith } from "@modern-js/codesmith";
|
|
3
3
|
import { FormilyAPI } from "@modern-js/codesmith-formily";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
MWAActionFunctions,
|
|
7
|
-
MWAActionReactors,
|
|
8
|
-
MWAActionFunctionsDependencies,
|
|
9
|
-
MWAActionFunctionsAppendTypeContent,
|
|
10
|
-
MWAActionReactorAppendTypeContent,
|
|
11
|
-
MWAActionFunctionsDevDependencies,
|
|
12
|
-
MWANewActionGenerators,
|
|
13
|
-
i18n,
|
|
14
|
-
Solution,
|
|
15
|
-
MWAActionRefactorDependencies,
|
|
16
|
-
MWANewActionPluginName,
|
|
17
|
-
MWANewActionPluginDependence
|
|
18
|
-
} from "@modern-js/generator-common";
|
|
19
|
-
import {
|
|
20
|
-
getModernPluginVersion,
|
|
21
|
-
getPackageManager
|
|
22
|
-
} from "@modern-js/generator-utils";
|
|
4
|
+
import { getMWANewActionSchema, MWAActionFunctions, MWAActionReactors, MWAActionFunctionsDependencies, MWAActionFunctionsAppendTypeContent, MWAActionReactorAppendTypeContent, MWAActionFunctionsDevDependencies, MWANewActionGenerators, i18n, Solution, MWAActionRefactorDependencies, MWANewActionPluginName, MWANewActionPluginDependence } from "@modern-js/generator-common";
|
|
5
|
+
import { getModernPluginVersion, getPackageManager } from "@modern-js/generator-utils";
|
|
23
6
|
import { alreadyRepo, getGeneratorPath, hasEnabledFunction } from "./utils";
|
|
24
|
-
const MWANewAction = async (options) => {
|
|
25
|
-
const {
|
|
26
|
-
locale = "zh",
|
|
27
|
-
distTag = "",
|
|
28
|
-
debug = false,
|
|
29
|
-
registry = "",
|
|
30
|
-
config = "{}",
|
|
31
|
-
cwd = process.cwd()
|
|
32
|
-
} = options;
|
|
7
|
+
export const MWANewAction = async (options) => {
|
|
8
|
+
const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd() } = options;
|
|
33
9
|
let UserConfig = {};
|
|
34
10
|
try {
|
|
35
11
|
UserConfig = JSON.parse(config);
|
|
36
12
|
} catch (e) {
|
|
37
13
|
throw new Error("config is not a valid json");
|
|
38
14
|
}
|
|
39
|
-
i18n.changeLanguage({
|
|
15
|
+
i18n.changeLanguage({
|
|
16
|
+
locale: UserConfig.locale || locale
|
|
17
|
+
});
|
|
40
18
|
const smith = new CodeSmith({
|
|
41
19
|
debug,
|
|
42
20
|
registryUrl: registry
|
|
@@ -52,24 +30,12 @@ const MWANewAction = async (options) => {
|
|
|
52
30
|
});
|
|
53
31
|
const funcMap = {};
|
|
54
32
|
MWAActionFunctions.forEach((func) => {
|
|
55
|
-
const enable = hasEnabledFunction(
|
|
56
|
-
func,
|
|
57
|
-
MWAActionFunctionsDependencies,
|
|
58
|
-
MWAActionFunctionsDevDependencies,
|
|
59
|
-
{},
|
|
60
|
-
cwd
|
|
61
|
-
);
|
|
33
|
+
const enable = hasEnabledFunction(func, MWAActionFunctionsDependencies, MWAActionFunctionsDevDependencies, {}, cwd);
|
|
62
34
|
funcMap[func] = enable;
|
|
63
35
|
});
|
|
64
36
|
const refactorMap = {};
|
|
65
37
|
MWAActionReactors.forEach((refactor) => {
|
|
66
|
-
const enable = hasEnabledFunction(
|
|
67
|
-
refactor,
|
|
68
|
-
MWAActionRefactorDependencies,
|
|
69
|
-
{},
|
|
70
|
-
{},
|
|
71
|
-
cwd
|
|
72
|
-
);
|
|
38
|
+
const enable = hasEnabledFunction(refactor, MWAActionRefactorDependencies, {}, {}, cwd);
|
|
73
39
|
refactorMap[refactor] = enable;
|
|
74
40
|
});
|
|
75
41
|
const ans = await formilyAPI.getInputBySchemaFunc(getMWANewActionSchema, {
|
|
@@ -79,10 +45,7 @@ const MWANewAction = async (options) => {
|
|
|
79
45
|
});
|
|
80
46
|
const actionType = ans.actionType;
|
|
81
47
|
const action = ans[actionType];
|
|
82
|
-
const generator = getGeneratorPath(
|
|
83
|
-
MWANewActionGenerators[actionType][action],
|
|
84
|
-
distTag
|
|
85
|
-
);
|
|
48
|
+
const generator = getGeneratorPath(MWANewActionGenerators[actionType][action], distTag);
|
|
86
49
|
if (!generator) {
|
|
87
50
|
throw new Error(`no valid option`);
|
|
88
51
|
}
|
|
@@ -95,24 +58,21 @@ const MWANewAction = async (options) => {
|
|
|
95
58
|
};
|
|
96
59
|
const devDependency = MWAActionFunctionsDevDependencies[action];
|
|
97
60
|
const dependency = MWAActionFunctionsDependencies[action] || MWAActionRefactorDependencies[action];
|
|
98
|
-
const finalConfig = merge(
|
|
99
|
-
UserConfig,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
pluginDependence: MWANewActionPluginDependence[actionType][action]
|
|
114
|
-
}
|
|
115
|
-
);
|
|
61
|
+
const finalConfig = merge(UserConfig, ans, {
|
|
62
|
+
locale: UserConfig.locale || locale,
|
|
63
|
+
packageManager: UserConfig.packageManager || await getPackageManager(cwd),
|
|
64
|
+
distTag
|
|
65
|
+
}, {
|
|
66
|
+
devDependencies: devDependency ? {
|
|
67
|
+
[devDependency]: `${await getMwaPluginVersion(devDependency)}`
|
|
68
|
+
} : {},
|
|
69
|
+
dependencies: dependency ? {
|
|
70
|
+
[dependency]: `${await getMwaPluginVersion(dependency)}`
|
|
71
|
+
} : {},
|
|
72
|
+
appendTypeContent: MWAActionFunctionsAppendTypeContent[action] || MWAActionReactorAppendTypeContent[action],
|
|
73
|
+
pluginName: MWANewActionPluginName[actionType][action],
|
|
74
|
+
pluginDependence: MWANewActionPluginDependence[actionType][action]
|
|
75
|
+
});
|
|
116
76
|
const task = [
|
|
117
77
|
{
|
|
118
78
|
name: generator,
|
|
@@ -127,6 +87,3 @@ const MWANewAction = async (options) => {
|
|
|
127
87
|
pwd: cwd
|
|
128
88
|
});
|
|
129
89
|
};
|
|
130
|
-
export {
|
|
131
|
-
MWANewAction
|
|
132
|
-
};
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,43 +1,47 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { json5 } from "@modern-js/utils";
|
|
3
3
|
import { fs } from "@modern-js/generator-utils";
|
|
4
|
-
function alreadyRepo(cwd = process.cwd()) {
|
|
4
|
+
export function alreadyRepo(cwd = process.cwd()) {
|
|
5
5
|
try {
|
|
6
6
|
return fs.existsSync(path.resolve(cwd, "package.json"));
|
|
7
7
|
} catch (e) {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
const readJson = (jsonPath) => {
|
|
11
|
+
export const readJson = (jsonPath) => {
|
|
12
12
|
if (!fs.existsSync(jsonPath)) {
|
|
13
13
|
return {};
|
|
14
14
|
}
|
|
15
|
-
const jsonStr = fs.readFileSync(jsonPath, {
|
|
15
|
+
const jsonStr = fs.readFileSync(jsonPath, {
|
|
16
|
+
encoding: "utf8"
|
|
17
|
+
});
|
|
16
18
|
try {
|
|
17
19
|
return json5.parse(jsonStr);
|
|
18
20
|
} catch (error) {
|
|
19
21
|
throw Error(`${jsonPath} is not a valid json, please check and try again.`);
|
|
20
22
|
}
|
|
21
23
|
};
|
|
22
|
-
function hasEnabledFunction(action, dependencies, devDependencies, peerDependencies, cwd) {
|
|
23
|
-
var _a, _b, _c;
|
|
24
|
+
export function hasEnabledFunction(action, dependencies, devDependencies, peerDependencies, cwd) {
|
|
24
25
|
const packageJsonPath = path.normalize(`${cwd}/package.json`);
|
|
25
26
|
const packageJson = readJson(packageJsonPath);
|
|
26
27
|
if (!dependencies[action] && !devDependencies[action]) {
|
|
27
28
|
return false;
|
|
28
29
|
}
|
|
29
30
|
if (dependencies[action]) {
|
|
30
|
-
|
|
31
|
+
var _packageJson_dependencies;
|
|
32
|
+
return (_packageJson_dependencies = packageJson.dependencies) === null || _packageJson_dependencies === void 0 ? void 0 : _packageJson_dependencies[dependencies[action]];
|
|
31
33
|
}
|
|
32
34
|
if (peerDependencies[action]) {
|
|
33
|
-
|
|
35
|
+
var _packageJson_peerDependencies;
|
|
36
|
+
return (_packageJson_peerDependencies = packageJson.peerDependencies) === null || _packageJson_peerDependencies === void 0 ? void 0 : _packageJson_peerDependencies[peerDependencies[action]];
|
|
34
37
|
}
|
|
35
38
|
if (!peerDependencies[action] && devDependencies[action]) {
|
|
36
|
-
|
|
39
|
+
var _packageJson_devDependencies;
|
|
40
|
+
return (_packageJson_devDependencies = packageJson.devDependencies) === null || _packageJson_devDependencies === void 0 ? void 0 : _packageJson_devDependencies[devDependencies[action]];
|
|
37
41
|
}
|
|
38
42
|
return false;
|
|
39
43
|
}
|
|
40
|
-
function getGeneratorPath(generator, distTag) {
|
|
44
|
+
export function getGeneratorPath(generator, distTag) {
|
|
41
45
|
if (process.env.CODESMITH_ENV === "development") {
|
|
42
46
|
return path.dirname(require.resolve(generator));
|
|
43
47
|
} else if (distTag) {
|
|
@@ -45,9 +49,3 @@ function getGeneratorPath(generator, distTag) {
|
|
|
45
49
|
}
|
|
46
50
|
return generator;
|
|
47
51
|
}
|
|
48
|
-
export {
|
|
49
|
-
alreadyRepo,
|
|
50
|
-
getGeneratorPath,
|
|
51
|
-
hasEnabledFunction,
|
|
52
|
-
readJson
|
|
53
|
-
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
"description": "A Progressive React Framework for modern web development.",
|
|
4
4
|
"homepage": "https://modernjs.dev",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/modern.js/issues",
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/web-infra-dev/modern.js",
|
|
9
|
+
"directory": "packages/generator/new-action"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"keywords": [
|
|
9
13
|
"react",
|
|
@@ -11,7 +15,7 @@
|
|
|
11
15
|
"modern",
|
|
12
16
|
"modern.js"
|
|
13
17
|
],
|
|
14
|
-
"version": "2.
|
|
18
|
+
"version": "2.17.0",
|
|
15
19
|
"jsnext:source": "./src/index.ts",
|
|
16
20
|
"types": "./dist/types/index.d.ts",
|
|
17
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -29,17 +33,17 @@
|
|
|
29
33
|
"@babel/runtime": "^7.18.0",
|
|
30
34
|
"@modern-js/codesmith": "2.1.0",
|
|
31
35
|
"@modern-js/codesmith-formily": "2.1.0",
|
|
32
|
-
"@modern-js/generator-common": "3.1.
|
|
33
|
-
"@modern-js/generator-utils": "3.1.
|
|
34
|
-
"@modern-js/utils": "2.
|
|
36
|
+
"@modern-js/generator-common": "3.1.11",
|
|
37
|
+
"@modern-js/generator-utils": "3.1.11",
|
|
38
|
+
"@modern-js/utils": "2.17.0"
|
|
35
39
|
},
|
|
36
40
|
"devDependencies": {
|
|
37
41
|
"@types/jest": "^29",
|
|
38
42
|
"@types/node": "^14",
|
|
39
43
|
"jest": "^29",
|
|
40
44
|
"typescript": "^4",
|
|
41
|
-
"@scripts/build": "2.
|
|
42
|
-
"@scripts/jest-config": "2.
|
|
45
|
+
"@scripts/build": "2.17.0",
|
|
46
|
+
"@scripts/jest-config": "2.17.0"
|
|
43
47
|
},
|
|
44
48
|
"sideEffects": false,
|
|
45
49
|
"modernConfig": {
|