@modern-js/new-action 2.60.6 → 2.61.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/dist/cjs/index.js CHANGED
@@ -17,10 +17,8 @@ var src_exports = {};
17
17
  module.exports = __toCommonJS(src_exports);
18
18
  __reExport(src_exports, require("./utils"), module.exports);
19
19
  __reExport(src_exports, require("./mwa"), module.exports);
20
- __reExport(src_exports, require("./module"), module.exports);
21
20
  // Annotate the CommonJS export names for ESM import in node:
22
21
  0 && (module.exports = {
23
22
  ...require("./utils"),
24
- ...require("./mwa"),
25
- ...require("./module")
23
+ ...require("./mwa")
26
24
  });
package/dist/cjs/run.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  var import_commander = require("commander");
4
- var import_module = require("./module");
5
4
  var import_mwa = require("./mwa");
6
5
  var import_utils = require("./utils");
7
6
  const main = async () => {
@@ -20,7 +19,7 @@ const main = async () => {
20
19
  (0, import_mwa.MWANewAction)(config);
21
20
  break;
22
21
  case "module":
23
- (0, import_module.ModuleNewAction)(config);
22
+ console.error("Modern.js not support module new command yet, Please use Rslib");
24
23
  break;
25
24
  default:
26
25
  break;
package/dist/esm/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from "./utils";
2
2
  export * from "./mwa";
3
- export * from "./module";
package/dist/esm/run.js CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
- import { ModuleNewAction } from "./module";
4
3
  import { MWANewAction } from "./mwa";
5
4
  import { getSolutionByDependance } from "./utils";
6
5
  const main = async () => {
@@ -19,7 +18,7 @@ const main = async () => {
19
18
  MWANewAction(config);
20
19
  break;
21
20
  case "module":
22
- ModuleNewAction(config);
21
+ console.error("Modern.js not support module new command yet, Please use Rslib");
23
22
  break;
24
23
  default:
25
24
  break;
@@ -1,3 +1,2 @@
1
1
  export * from './utils';
2
2
  export * from './mwa';
3
- export * from './module';
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.60.6",
18
+ "version": "2.61.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -39,8 +39,8 @@
39
39
  "@modern-js/codesmith": "2.6.5",
40
40
  "@modern-js/codesmith-formily": "2.6.5",
41
41
  "@modern-js/codesmith-utils": "2.6.5",
42
- "@modern-js/generator-common": "3.7.2",
43
- "@modern-js/generator-utils": "3.7.2"
42
+ "@modern-js/generator-common": "3.7.3",
43
+ "@modern-js/generator-utils": "3.7.3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/jest": "^29",
@@ -48,8 +48,8 @@
48
48
  "jest": "^29",
49
49
  "ts-node": "^10.9.1",
50
50
  "typescript": "^5",
51
- "@scripts/build": "2.60.6",
52
- "@scripts/jest-config": "2.60.6"
51
+ "@scripts/build": "2.61.0",
52
+ "@scripts/jest-config": "2.61.0"
53
53
  },
54
54
  "sideEffects": false,
55
55
  "publishConfig": {
@@ -1,148 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var module_exports = {};
20
- __export(module_exports, {
21
- ModuleNewAction: () => ModuleNewAction
22
- });
23
- module.exports = __toCommonJS(module_exports);
24
- var import_codesmith = require("@modern-js/codesmith");
25
- var import_codesmith_formily = require("@modern-js/codesmith-formily");
26
- var import_lodash = require("@modern-js/codesmith-utils/lodash");
27
- var import_generator_common = require("@modern-js/generator-common");
28
- var import_generator_utils = require("@modern-js/generator-utils");
29
- var import_constants = require("./constants");
30
- var import_utils = require("./utils");
31
- const ModuleNewAction = async (options) => {
32
- var _smith_logger, _smith_logger1;
33
- const { locale = "zh", distTag = "", debug = false, registry, config = "{}", cwd = process.cwd(), needInstall = true } = options;
34
- let UserConfig = {};
35
- try {
36
- UserConfig = JSON.parse(config);
37
- } catch (e) {
38
- throw new Error("config is not a valid json");
39
- }
40
- const language = UserConfig.locale || locale;
41
- import_generator_common.i18n.changeLanguage({
42
- locale: language
43
- });
44
- const smith = new import_codesmith.CodeSmith({
45
- debug,
46
- registryUrl: registry === "" ? void 0 : registry
47
- });
48
- if (!(0, import_utils.alreadyRepo)(cwd)) {
49
- smith.logger.warn("not valid modern.js repo");
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
- ]);
58
- const formilyAPI = new import_codesmith_formily.FormilyAPI({
59
- materials: {},
60
- config: {},
61
- data: {},
62
- current: null
63
- });
64
- let hasOption = false;
65
- const funcMap = {};
66
- import_generator_common.ModuleActionFunctions.forEach((func) => {
67
- const enable = (0, import_utils.hasEnabledFunction)(func, import_generator_common.ModuleActionFunctionsDependencies, import_generator_common.ModuleActionFunctionsDevDependencies, import_generator_common.ModuleActionFunctionsPeerDependencies, cwd);
68
- funcMap[func] = enable;
69
- if (!enable) {
70
- hasOption = true;
71
- }
72
- });
73
- if (!hasOption) {
74
- smith.logger.warn("No option can be enabled, exit 1.", funcMap);
75
- process.exit(1);
76
- }
77
- const ans = await formilyAPI.getInputBySchemaFunc(import_generator_common.getModuleNewActionSchema, {
78
- ...UserConfig
79
- });
80
- const actionType = ans.actionType;
81
- const action = ans[actionType];
82
- if (actionType === import_generator_common.ActionType.Function && funcMap[action]) {
83
- smith.logger.error(import_constants.enableAlreadyText[language]);
84
- return;
85
- }
86
- const generator = (0, import_utils.getGeneratorPath)(import_generator_common.ModuleNewActionGenerators[actionType][action], distTag);
87
- if (!generator) {
88
- throw new Error(`no valid option`);
89
- }
90
- const devDependency = import_generator_common.ModuleActionFunctionsDevDependencies[action];
91
- const dependency = import_generator_common.ModuleActionFunctionsDependencies[action];
92
- const peerDependency = import_generator_common.ModuleActionFunctionsPeerDependencies[action];
93
- const getModulePluginVersion = (packageName) => {
94
- return (0, import_generator_utils.getModernPluginVersion)(import_generator_common.Solution.Module, packageName, {
95
- registry,
96
- distTag,
97
- cwd
98
- });
99
- };
100
- const shouldUsePluginNameExport = await (0, import_utils.usePluginNameExport)(import_generator_common.Solution.Module, {
101
- registry,
102
- distTag,
103
- cwd
104
- });
105
- const finalConfig = (0, import_lodash.merge)(UserConfig, {
106
- noNeedInstall: !needInstall
107
- }, ans, {
108
- locale: UserConfig.locale || locale,
109
- packageManager: UserConfig.packageManager || await (0, import_generator_utils.getPackageManager)(cwd),
110
- distTag
111
- }, {
112
- devDependencies: devDependency ? {
113
- [devDependency]: `${await getModulePluginVersion(devDependency)}`
114
- } : {},
115
- dependencies: dependency ? {
116
- [dependency]: `${await getModulePluginVersion(dependency)}`
117
- } : {},
118
- peerDependencies: peerDependency ? {
119
- [peerDependency]: `${await getModulePluginVersion(peerDependency)}`
120
- } : {},
121
- pluginName: import_generator_common.ModuleNewActionPluginName[actionType][action],
122
- pluginDependence: import_generator_common.ModuleNewActionPluginDependence[actionType][action],
123
- shouldUsePluginNameExport,
124
- isModuleProject: true
125
- });
126
- const task = [
127
- {
128
- name: generator,
129
- config: finalConfig
130
- }
131
- ];
132
- await Promise.all([
133
- prepareGlobalPromise,
134
- prepareGeneratorPromise
135
- ]);
136
- await smith.forge({
137
- tasks: task.map((runner) => ({
138
- generator: runner.name,
139
- config: runner.config
140
- })),
141
- pwd: cwd
142
- });
143
- (_smith_logger1 = smith.logger) === null || _smith_logger1 === void 0 ? void 0 : _smith_logger1.timing("🕒 Run Module New Tools", true);
144
- };
145
- // Annotate the CommonJS export names for ESM import in node:
146
- 0 && (module.exports = {
147
- ModuleNewAction
148
- });
@@ -1,124 +0,0 @@
1
- import { CodeSmith } from "@modern-js/codesmith";
2
- import { FormilyAPI } from "@modern-js/codesmith-formily";
3
- import { merge } from "@modern-js/codesmith-utils/lodash";
4
- import { ActionType, ModuleActionFunctions, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, ModuleNewActionGenerators, ModuleNewActionPluginDependence, ModuleNewActionPluginName, Solution, getModuleNewActionSchema, i18n } from "@modern-js/generator-common";
5
- import { getModernPluginVersion, getPackageManager } from "@modern-js/generator-utils";
6
- import { enableAlreadyText } from "./constants";
7
- import { alreadyRepo, getGeneratorPath, hasEnabledFunction, usePluginNameExport } from "./utils";
8
- const ModuleNewAction = async (options) => {
9
- var _smith_logger, _smith_logger1;
10
- const { locale = "zh", distTag = "", debug = false, registry, config = "{}", cwd = process.cwd(), needInstall = true } = options;
11
- let UserConfig = {};
12
- try {
13
- UserConfig = JSON.parse(config);
14
- } catch (e) {
15
- throw new Error("config is not a valid json");
16
- }
17
- const language = UserConfig.locale || locale;
18
- i18n.changeLanguage({
19
- locale: language
20
- });
21
- const smith = new CodeSmith({
22
- debug,
23
- registryUrl: registry === "" ? void 0 : registry
24
- });
25
- if (!alreadyRepo(cwd)) {
26
- smith.logger.warn("not valid modern.js repo");
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
- ]);
35
- const formilyAPI = new FormilyAPI({
36
- materials: {},
37
- config: {},
38
- data: {},
39
- current: null
40
- });
41
- let hasOption = false;
42
- const funcMap = {};
43
- ModuleActionFunctions.forEach((func) => {
44
- const enable = hasEnabledFunction(func, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, cwd);
45
- funcMap[func] = enable;
46
- if (!enable) {
47
- hasOption = true;
48
- }
49
- });
50
- if (!hasOption) {
51
- smith.logger.warn("No option can be enabled, exit 1.", funcMap);
52
- process.exit(1);
53
- }
54
- const ans = await formilyAPI.getInputBySchemaFunc(getModuleNewActionSchema, {
55
- ...UserConfig
56
- });
57
- const actionType = ans.actionType;
58
- const action = ans[actionType];
59
- if (actionType === ActionType.Function && funcMap[action]) {
60
- smith.logger.error(enableAlreadyText[language]);
61
- return;
62
- }
63
- const generator = getGeneratorPath(ModuleNewActionGenerators[actionType][action], distTag);
64
- if (!generator) {
65
- throw new Error(`no valid option`);
66
- }
67
- const devDependency = ModuleActionFunctionsDevDependencies[action];
68
- const dependency = ModuleActionFunctionsDependencies[action];
69
- const peerDependency = ModuleActionFunctionsPeerDependencies[action];
70
- const getModulePluginVersion = (packageName) => {
71
- return getModernPluginVersion(Solution.Module, packageName, {
72
- registry,
73
- distTag,
74
- cwd
75
- });
76
- };
77
- const shouldUsePluginNameExport = await usePluginNameExport(Solution.Module, {
78
- registry,
79
- distTag,
80
- cwd
81
- });
82
- const finalConfig = merge(UserConfig, {
83
- noNeedInstall: !needInstall
84
- }, ans, {
85
- locale: UserConfig.locale || locale,
86
- packageManager: UserConfig.packageManager || await getPackageManager(cwd),
87
- distTag
88
- }, {
89
- devDependencies: devDependency ? {
90
- [devDependency]: `${await getModulePluginVersion(devDependency)}`
91
- } : {},
92
- dependencies: dependency ? {
93
- [dependency]: `${await getModulePluginVersion(dependency)}`
94
- } : {},
95
- peerDependencies: peerDependency ? {
96
- [peerDependency]: `${await getModulePluginVersion(peerDependency)}`
97
- } : {},
98
- pluginName: ModuleNewActionPluginName[actionType][action],
99
- pluginDependence: ModuleNewActionPluginDependence[actionType][action],
100
- shouldUsePluginNameExport,
101
- isModuleProject: true
102
- });
103
- const task = [
104
- {
105
- name: generator,
106
- config: finalConfig
107
- }
108
- ];
109
- await Promise.all([
110
- prepareGlobalPromise,
111
- prepareGeneratorPromise
112
- ]);
113
- await smith.forge({
114
- tasks: task.map((runner) => ({
115
- generator: runner.name,
116
- config: runner.config
117
- })),
118
- pwd: cwd
119
- });
120
- (_smith_logger1 = smith.logger) === null || _smith_logger1 === void 0 ? void 0 : _smith_logger1.timing("🕒 Run Module New Tools", true);
121
- };
122
- export {
123
- ModuleNewAction
124
- };
@@ -1,11 +0,0 @@
1
- interface IModuleNewActionOption {
2
- locale?: string;
3
- distTag?: string;
4
- debug?: boolean;
5
- registry?: string;
6
- config?: string;
7
- cwd?: string;
8
- needInstall?: boolean;
9
- }
10
- export declare const ModuleNewAction: (options: IModuleNewActionOption) => Promise<void>;
11
- export {};