@modern-js/new-action 2.60.3 → 2.60.4
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/cjs/module.js +16 -3
- package/dist/cjs/mwa.js +19 -2
- package/dist/cjs/run.js +2 -2
- package/dist/cjs/utils/index.js +5 -4
- package/dist/esm/module.js +16 -3
- package/dist/esm/mwa.js +19 -2
- package/dist/esm/run.js +2 -2
- package/dist/esm/utils/index.js +2 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/package.json +10 -8
package/dist/cjs/module.js
CHANGED
|
@@ -23,13 +23,14 @@ __export(module_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(module_exports);
|
|
24
24
|
var import_codesmith = require("@modern-js/codesmith");
|
|
25
25
|
var import_codesmith_formily = require("@modern-js/codesmith-formily");
|
|
26
|
+
var import_lodash = require("@modern-js/codesmith-utils/lodash");
|
|
26
27
|
var import_generator_common = require("@modern-js/generator-common");
|
|
27
28
|
var import_generator_utils = require("@modern-js/generator-utils");
|
|
28
|
-
var import_lodash = require("@modern-js/utils/lodash");
|
|
29
29
|
var import_constants = require("./constants");
|
|
30
30
|
var import_utils = require("./utils");
|
|
31
31
|
const ModuleNewAction = async (options) => {
|
|
32
|
-
|
|
32
|
+
var _smith_logger, _smith_logger1;
|
|
33
|
+
const { locale = "zh", distTag = "", debug = false, registry, config = "{}", cwd = process.cwd(), needInstall = true } = options;
|
|
33
34
|
let UserConfig = {};
|
|
34
35
|
try {
|
|
35
36
|
UserConfig = JSON.parse(config);
|
|
@@ -42,11 +43,18 @@ const ModuleNewAction = async (options) => {
|
|
|
42
43
|
});
|
|
43
44
|
const smith = new import_codesmith.CodeSmith({
|
|
44
45
|
debug,
|
|
45
|
-
registryUrl: registry
|
|
46
|
+
registryUrl: registry === "" ? void 0 : registry
|
|
46
47
|
});
|
|
47
48
|
if (!(0, import_utils.alreadyRepo)(cwd)) {
|
|
48
49
|
smith.logger.warn("not valid modern.js repo");
|
|
49
50
|
}
|
|
51
|
+
(_smith_logger = smith.logger) === null || _smith_logger === void 0 ? void 0 : _smith_logger.timing("🕒 Run Module New Tools");
|
|
52
|
+
const prepareGlobalPromise = smith.prepareGlobal();
|
|
53
|
+
const prepareGeneratorPromise = smith.prepareGenerators([
|
|
54
|
+
`@modern-js/dependence-generator@${distTag || "latest"}`,
|
|
55
|
+
`@modern-js/module-doc-generator@${distTag || "latest"}`,
|
|
56
|
+
`@modern-js/storybook-next-generator@${distTag || "latest"}`
|
|
57
|
+
]);
|
|
50
58
|
const formilyAPI = new import_codesmith_formily.FormilyAPI({
|
|
51
59
|
materials: {},
|
|
52
60
|
config: {},
|
|
@@ -121,6 +129,10 @@ const ModuleNewAction = async (options) => {
|
|
|
121
129
|
config: finalConfig
|
|
122
130
|
}
|
|
123
131
|
];
|
|
132
|
+
await Promise.all([
|
|
133
|
+
prepareGlobalPromise,
|
|
134
|
+
prepareGeneratorPromise
|
|
135
|
+
]);
|
|
124
136
|
await smith.forge({
|
|
125
137
|
tasks: task.map((runner) => ({
|
|
126
138
|
generator: runner.name,
|
|
@@ -128,6 +140,7 @@ const ModuleNewAction = async (options) => {
|
|
|
128
140
|
})),
|
|
129
141
|
pwd: cwd
|
|
130
142
|
});
|
|
143
|
+
(_smith_logger1 = smith.logger) === null || _smith_logger1 === void 0 ? void 0 : _smith_logger1.timing("🕒 Run Module New Tools", true);
|
|
131
144
|
};
|
|
132
145
|
// Annotate the CommonJS export names for ESM import in node:
|
|
133
146
|
0 && (module.exports = {
|
package/dist/cjs/mwa.js
CHANGED
|
@@ -23,13 +23,14 @@ __export(mwa_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(mwa_exports);
|
|
24
24
|
var import_codesmith = require("@modern-js/codesmith");
|
|
25
25
|
var import_codesmith_formily = require("@modern-js/codesmith-formily");
|
|
26
|
+
var import_lodash = require("@modern-js/codesmith-utils/lodash");
|
|
26
27
|
var import_generator_common = require("@modern-js/generator-common");
|
|
27
28
|
var import_generator_utils = require("@modern-js/generator-utils");
|
|
28
|
-
var import_lodash = require("@modern-js/utils/lodash");
|
|
29
29
|
var import_constants = require("./constants");
|
|
30
30
|
var import_utils = require("./utils");
|
|
31
31
|
const MWANewAction = async (options) => {
|
|
32
|
-
|
|
32
|
+
var _smith_logger, _smith_logger1;
|
|
33
|
+
const { locale = "zh", distTag = "", debug = false, registry, config = "{}", cwd = process.cwd(), needInstall = true } = options;
|
|
33
34
|
let UserConfig = {};
|
|
34
35
|
try {
|
|
35
36
|
UserConfig = JSON.parse(config);
|
|
@@ -47,6 +48,17 @@ const MWANewAction = async (options) => {
|
|
|
47
48
|
if (!(0, import_utils.alreadyRepo)(cwd)) {
|
|
48
49
|
smith.logger.warn("not valid modern.js repo");
|
|
49
50
|
}
|
|
51
|
+
(_smith_logger = smith.logger) === null || _smith_logger === void 0 ? void 0 : _smith_logger.timing("🕒 Run MWA New Tools");
|
|
52
|
+
const prepareGlobalPromise = smith.prepareGlobal();
|
|
53
|
+
const prepareGeneratorPromise = smith.prepareGenerators([
|
|
54
|
+
`@modern-js/dependence-generator@${distTag || "latest"}`,
|
|
55
|
+
`@modern-js/bff-generator@${distTag || "latest"}`,
|
|
56
|
+
`@modern-js/server-generator@${distTag || "latest"}`,
|
|
57
|
+
`@modern-js/entry-generator@${distTag || "latest"}`,
|
|
58
|
+
`@modern-js/ssg-generator@${distTag || "latest"}`,
|
|
59
|
+
`@modern-js/storybook-next-generator@${distTag || "latest"}`,
|
|
60
|
+
`@modern-js/tailwindcss-generator@${distTag || "latest"}`
|
|
61
|
+
]);
|
|
50
62
|
const formilyAPI = new import_codesmith_formily.FormilyAPI({
|
|
51
63
|
materials: {},
|
|
52
64
|
config: {},
|
|
@@ -114,6 +126,10 @@ const MWANewAction = async (options) => {
|
|
|
114
126
|
config: finalConfig
|
|
115
127
|
}
|
|
116
128
|
];
|
|
129
|
+
await Promise.all([
|
|
130
|
+
prepareGlobalPromise,
|
|
131
|
+
prepareGeneratorPromise
|
|
132
|
+
]);
|
|
117
133
|
await smith.forge({
|
|
118
134
|
tasks: task.map((runner) => ({
|
|
119
135
|
generator: runner.name,
|
|
@@ -121,6 +137,7 @@ const MWANewAction = async (options) => {
|
|
|
121
137
|
})),
|
|
122
138
|
pwd: cwd
|
|
123
139
|
});
|
|
140
|
+
(_smith_logger1 = smith.logger) === null || _smith_logger1 === void 0 ? void 0 : _smith_logger1.timing("🕒 Run MWA New Tools", true);
|
|
124
141
|
};
|
|
125
142
|
// Annotate the CommonJS export names for ESM import in node:
|
|
126
143
|
0 && (module.exports = {
|
package/dist/cjs/run.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var import_commander = require("
|
|
3
|
+
var import_commander = require("commander");
|
|
4
4
|
var import_module = require("./module");
|
|
5
5
|
var import_mwa = require("./mwa");
|
|
6
6
|
var import_utils = require("./utils");
|
|
7
7
|
const main = async () => {
|
|
8
8
|
const program = new import_commander.Command();
|
|
9
|
-
program.option("--solution <solution>", "solution", "").option("--config <config>", "config", "{}").option("--root-path <rootPath>", "project root path", "").action(async (params) => {
|
|
9
|
+
program.option("--solution <solution>", "solution", "").option("--config <config>", "config", "{}").option("--root-path <rootPath>", "project root path", "").option("--debug", "using debug mode to log something", false).option("--time", "show run generator time log", false).action(async (params) => {
|
|
10
10
|
if (!params.solution) {
|
|
11
11
|
params.solution = (0, import_utils.getSolutionByDependance)();
|
|
12
12
|
}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -37,9 +37,10 @@ __export(utils_exports, {
|
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(utils_exports);
|
|
39
39
|
var import_path = __toESM(require("path"));
|
|
40
|
+
var import_codesmith_utils = require("@modern-js/codesmith-utils");
|
|
40
41
|
var import_generator_common = require("@modern-js/generator-common");
|
|
41
42
|
var import_generator_utils = require("@modern-js/generator-utils");
|
|
42
|
-
var
|
|
43
|
+
var import_json5 = __toESM(require("json5"));
|
|
43
44
|
const swap = (obj) => {
|
|
44
45
|
return Object.keys(obj).reduce((acc, key) => {
|
|
45
46
|
acc[obj[key]] = key;
|
|
@@ -62,7 +63,7 @@ const readJson = (jsonPath) => {
|
|
|
62
63
|
encoding: "utf8"
|
|
63
64
|
});
|
|
64
65
|
try {
|
|
65
|
-
return
|
|
66
|
+
return import_json5.default.parse(jsonStr);
|
|
66
67
|
} catch (error) {
|
|
67
68
|
throw Error(`${jsonPath} is not a valid json, please check and try again.`);
|
|
68
69
|
}
|
|
@@ -97,8 +98,8 @@ function getGeneratorPath(generator, distTag) {
|
|
|
97
98
|
}
|
|
98
99
|
async function usePluginNameExport(solution, options) {
|
|
99
100
|
const solutionVersion = await (0, import_generator_utils.getModernPluginVersion)(solution, import_generator_common.SolutionToolsMap[import_generator_common.Solution.MWA], options);
|
|
100
|
-
if (
|
|
101
|
-
return
|
|
101
|
+
if (import_codesmith_utils.semver.valid(solutionVersion) && import_codesmith_utils.semver.gte(solutionVersion, "2.0.0")) {
|
|
102
|
+
return import_codesmith_utils.semver.gt(solutionVersion, "2.24.0");
|
|
102
103
|
}
|
|
103
104
|
return true;
|
|
104
105
|
}
|
package/dist/esm/module.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { CodeSmith } from "@modern-js/codesmith";
|
|
2
2
|
import { FormilyAPI } from "@modern-js/codesmith-formily";
|
|
3
|
+
import { merge } from "@modern-js/codesmith-utils/lodash";
|
|
3
4
|
import { ActionType, ModuleActionFunctions, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, ModuleNewActionGenerators, ModuleNewActionPluginDependence, ModuleNewActionPluginName, Solution, getModuleNewActionSchema, i18n } from "@modern-js/generator-common";
|
|
4
5
|
import { getModernPluginVersion, getPackageManager } from "@modern-js/generator-utils";
|
|
5
|
-
import { merge } from "@modern-js/utils/lodash";
|
|
6
6
|
import { enableAlreadyText } from "./constants";
|
|
7
7
|
import { alreadyRepo, getGeneratorPath, hasEnabledFunction, usePluginNameExport } from "./utils";
|
|
8
8
|
const ModuleNewAction = async (options) => {
|
|
9
|
-
|
|
9
|
+
var _smith_logger, _smith_logger1;
|
|
10
|
+
const { locale = "zh", distTag = "", debug = false, registry, config = "{}", cwd = process.cwd(), needInstall = true } = options;
|
|
10
11
|
let UserConfig = {};
|
|
11
12
|
try {
|
|
12
13
|
UserConfig = JSON.parse(config);
|
|
@@ -19,11 +20,18 @@ const ModuleNewAction = async (options) => {
|
|
|
19
20
|
});
|
|
20
21
|
const smith = new CodeSmith({
|
|
21
22
|
debug,
|
|
22
|
-
registryUrl: registry
|
|
23
|
+
registryUrl: registry === "" ? void 0 : registry
|
|
23
24
|
});
|
|
24
25
|
if (!alreadyRepo(cwd)) {
|
|
25
26
|
smith.logger.warn("not valid modern.js repo");
|
|
26
27
|
}
|
|
28
|
+
(_smith_logger = smith.logger) === null || _smith_logger === void 0 ? void 0 : _smith_logger.timing("🕒 Run Module New Tools");
|
|
29
|
+
const prepareGlobalPromise = smith.prepareGlobal();
|
|
30
|
+
const prepareGeneratorPromise = smith.prepareGenerators([
|
|
31
|
+
`@modern-js/dependence-generator@${distTag || "latest"}`,
|
|
32
|
+
`@modern-js/module-doc-generator@${distTag || "latest"}`,
|
|
33
|
+
`@modern-js/storybook-next-generator@${distTag || "latest"}`
|
|
34
|
+
]);
|
|
27
35
|
const formilyAPI = new FormilyAPI({
|
|
28
36
|
materials: {},
|
|
29
37
|
config: {},
|
|
@@ -98,6 +106,10 @@ const ModuleNewAction = async (options) => {
|
|
|
98
106
|
config: finalConfig
|
|
99
107
|
}
|
|
100
108
|
];
|
|
109
|
+
await Promise.all([
|
|
110
|
+
prepareGlobalPromise,
|
|
111
|
+
prepareGeneratorPromise
|
|
112
|
+
]);
|
|
101
113
|
await smith.forge({
|
|
102
114
|
tasks: task.map((runner) => ({
|
|
103
115
|
generator: runner.name,
|
|
@@ -105,6 +117,7 @@ const ModuleNewAction = async (options) => {
|
|
|
105
117
|
})),
|
|
106
118
|
pwd: cwd
|
|
107
119
|
});
|
|
120
|
+
(_smith_logger1 = smith.logger) === null || _smith_logger1 === void 0 ? void 0 : _smith_logger1.timing("🕒 Run Module New Tools", true);
|
|
108
121
|
};
|
|
109
122
|
export {
|
|
110
123
|
ModuleNewAction
|
package/dist/esm/mwa.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { CodeSmith } from "@modern-js/codesmith";
|
|
2
2
|
import { FormilyAPI } from "@modern-js/codesmith-formily";
|
|
3
|
+
import { merge } from "@modern-js/codesmith-utils/lodash";
|
|
3
4
|
import { ActionType, MWAActionFunctions, MWAActionFunctionsAppendTypeContent, MWAActionFunctionsDependencies, MWAActionFunctionsDevDependencies, MWAActionReactorAppendTypeContent, MWAActionReactors, MWAActionRefactorDependencies, MWANewActionGenerators, MWANewActionPluginDependence, MWANewActionPluginName, Solution, getMWANewActionSchema, i18n } from "@modern-js/generator-common";
|
|
4
5
|
import { getModernPluginVersion, getPackageManager } from "@modern-js/generator-utils";
|
|
5
|
-
import { merge } from "@modern-js/utils/lodash";
|
|
6
6
|
import { enableAlreadyText } from "./constants";
|
|
7
7
|
import { alreadyRepo, getGeneratorPath, hasEnabledFunction, usePluginNameExport } from "./utils";
|
|
8
8
|
const MWANewAction = async (options) => {
|
|
9
|
-
|
|
9
|
+
var _smith_logger, _smith_logger1;
|
|
10
|
+
const { locale = "zh", distTag = "", debug = false, registry, config = "{}", cwd = process.cwd(), needInstall = true } = options;
|
|
10
11
|
let UserConfig = {};
|
|
11
12
|
try {
|
|
12
13
|
UserConfig = JSON.parse(config);
|
|
@@ -24,6 +25,17 @@ const MWANewAction = async (options) => {
|
|
|
24
25
|
if (!alreadyRepo(cwd)) {
|
|
25
26
|
smith.logger.warn("not valid modern.js repo");
|
|
26
27
|
}
|
|
28
|
+
(_smith_logger = smith.logger) === null || _smith_logger === void 0 ? void 0 : _smith_logger.timing("🕒 Run MWA New Tools");
|
|
29
|
+
const prepareGlobalPromise = smith.prepareGlobal();
|
|
30
|
+
const prepareGeneratorPromise = smith.prepareGenerators([
|
|
31
|
+
`@modern-js/dependence-generator@${distTag || "latest"}`,
|
|
32
|
+
`@modern-js/bff-generator@${distTag || "latest"}`,
|
|
33
|
+
`@modern-js/server-generator@${distTag || "latest"}`,
|
|
34
|
+
`@modern-js/entry-generator@${distTag || "latest"}`,
|
|
35
|
+
`@modern-js/ssg-generator@${distTag || "latest"}`,
|
|
36
|
+
`@modern-js/storybook-next-generator@${distTag || "latest"}`,
|
|
37
|
+
`@modern-js/tailwindcss-generator@${distTag || "latest"}`
|
|
38
|
+
]);
|
|
27
39
|
const formilyAPI = new FormilyAPI({
|
|
28
40
|
materials: {},
|
|
29
41
|
config: {},
|
|
@@ -91,6 +103,10 @@ const MWANewAction = async (options) => {
|
|
|
91
103
|
config: finalConfig
|
|
92
104
|
}
|
|
93
105
|
];
|
|
106
|
+
await Promise.all([
|
|
107
|
+
prepareGlobalPromise,
|
|
108
|
+
prepareGeneratorPromise
|
|
109
|
+
]);
|
|
94
110
|
await smith.forge({
|
|
95
111
|
tasks: task.map((runner) => ({
|
|
96
112
|
generator: runner.name,
|
|
@@ -98,6 +114,7 @@ const MWANewAction = async (options) => {
|
|
|
98
114
|
})),
|
|
99
115
|
pwd: cwd
|
|
100
116
|
});
|
|
117
|
+
(_smith_logger1 = smith.logger) === null || _smith_logger1 === void 0 ? void 0 : _smith_logger1.timing("🕒 Run MWA New Tools", true);
|
|
101
118
|
};
|
|
102
119
|
export {
|
|
103
120
|
MWANewAction
|
package/dist/esm/run.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Command } from "
|
|
2
|
+
import { Command } from "commander";
|
|
3
3
|
import { ModuleNewAction } from "./module";
|
|
4
4
|
import { MWANewAction } from "./mwa";
|
|
5
5
|
import { getSolutionByDependance } from "./utils";
|
|
6
6
|
const main = async () => {
|
|
7
7
|
const program = new Command();
|
|
8
|
-
program.option("--solution <solution>", "solution", "").option("--config <config>", "config", "{}").option("--root-path <rootPath>", "project root path", "").action(async (params) => {
|
|
8
|
+
program.option("--solution <solution>", "solution", "").option("--config <config>", "config", "{}").option("--root-path <rootPath>", "project root path", "").option("--debug", "using debug mode to log something", false).option("--time", "show run generator time log", false).action(async (params) => {
|
|
9
9
|
if (!params.solution) {
|
|
10
10
|
params.solution = getSolutionByDependance();
|
|
11
11
|
}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
+
import { semver } from "@modern-js/codesmith-utils";
|
|
2
3
|
import { Solution, SolutionToolsMap } from "@modern-js/generator-common";
|
|
3
4
|
import { fs, getModernPluginVersion } from "@modern-js/generator-utils";
|
|
4
|
-
import
|
|
5
|
+
import json5 from "json5";
|
|
5
6
|
const swap = (obj) => {
|
|
6
7
|
return Object.keys(obj).reduce((acc, key) => {
|
|
7
8
|
acc[obj[key]] = key;
|
|
@@ -3,5 +3,5 @@ export declare function alreadyRepo(cwd?: string): boolean;
|
|
|
3
3
|
export declare const readJson: (jsonPath: string) => any;
|
|
4
4
|
export declare function hasEnabledFunction(action: ActionFunction | ActionRefactor, dependencies: Record<string, string>, devDependencies: Record<string, string>, peerDependencies: Record<string, string>, cwd: string): any;
|
|
5
5
|
export declare function getGeneratorPath(generator: string, distTag: string): string;
|
|
6
|
-
export declare function usePluginNameExport(solution: Solution, options: Record<string, string>): Promise<boolean>;
|
|
6
|
+
export declare function usePluginNameExport(solution: Solution, options: Record<string, string | undefined>): Promise<boolean>;
|
|
7
7
|
export declare const getSolutionByDependance: (jsonPath?: string) => string | undefined;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.60.
|
|
18
|
+
"version": "2.60.4",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -33,12 +33,14 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@modern-js/codesmith": "2.5.2",
|
|
37
|
-
"@modern-js/codesmith-formily": "2.5.2",
|
|
38
36
|
"@swc/helpers": "0.5.13",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"@modern-js/
|
|
37
|
+
"json5": "2.2.3",
|
|
38
|
+
"commander": "10.0.1",
|
|
39
|
+
"@modern-js/codesmith": "2.6.4",
|
|
40
|
+
"@modern-js/codesmith-formily": "2.6.4",
|
|
41
|
+
"@modern-js/codesmith-utils": "2.6.4",
|
|
42
|
+
"@modern-js/generator-utils": "3.7.0",
|
|
43
|
+
"@modern-js/generator-common": "3.7.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"@types/jest": "^29",
|
|
@@ -46,8 +48,8 @@
|
|
|
46
48
|
"jest": "^29",
|
|
47
49
|
"ts-node": "^10.9.1",
|
|
48
50
|
"typescript": "^5",
|
|
49
|
-
"@scripts/
|
|
50
|
-
"@scripts/
|
|
51
|
+
"@scripts/build": "2.60.4",
|
|
52
|
+
"@scripts/jest-config": "2.60.4"
|
|
51
53
|
},
|
|
52
54
|
"sideEffects": false,
|
|
53
55
|
"publishConfig": {
|