@modern-js/new-action 2.49.4 → 2.50.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.
@@ -0,0 +1,31 @@
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 constants_exports = {};
20
+ __export(constants_exports, {
21
+ enableAlreadyText: () => enableAlreadyText
22
+ });
23
+ module.exports = __toCommonJS(constants_exports);
24
+ const enableAlreadyText = {
25
+ zh: "当前功能已开启,请确认对应插件依赖是否已安装。若需重新开启该功能,请移除插件依赖后再次尝试。",
26
+ en: "The current function has been enabled. Please confirm whether the corresponding plugin dependencies have been installed. If you need to re-enable this function, please remove the plugin dependencies and try again."
27
+ };
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ enableAlreadyText
31
+ });
@@ -27,6 +27,7 @@ var import_codesmith_formily = require("@modern-js/codesmith-formily");
27
27
  var import_generator_common = require("@modern-js/generator-common");
28
28
  var import_generator_utils = require("@modern-js/generator-utils");
29
29
  var import_utils = require("./utils");
30
+ var import_constants = require("./constants");
30
31
  const ModuleNewAction = async (options) => {
31
32
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd(), needInstall = true } = options;
32
33
  let UserConfig = {};
@@ -35,8 +36,9 @@ const ModuleNewAction = async (options) => {
35
36
  } catch (e) {
36
37
  throw new Error("config is not a valid json");
37
38
  }
39
+ const language = UserConfig.locale || locale;
38
40
  import_generator_common.i18n.changeLanguage({
39
- locale: UserConfig.locale || locale
41
+ locale: language
40
42
  });
41
43
  const smith = new import_codesmith.CodeSmith({
42
44
  debug,
@@ -65,11 +67,14 @@ const ModuleNewAction = async (options) => {
65
67
  process.exit(1);
66
68
  }
67
69
  const ans = await formilyAPI.getInputBySchemaFunc(import_generator_common.getModuleNewActionSchema, {
68
- ...UserConfig,
69
- funcMap
70
+ ...UserConfig
70
71
  });
71
72
  const actionType = ans.actionType;
72
73
  const action = ans[actionType];
74
+ if (actionType === import_generator_common.ActionType.Function && funcMap[action]) {
75
+ smith.logger.error(import_constants.enableAlreadyText[language]);
76
+ return;
77
+ }
73
78
  const generator = (0, import_utils.getGeneratorPath)(import_generator_common.ModuleNewActionGenerators[actionType][action], distTag);
74
79
  if (!generator) {
75
80
  throw new Error(`no valid option`);
package/dist/cjs/mwa.js CHANGED
@@ -27,6 +27,7 @@ var import_codesmith_formily = require("@modern-js/codesmith-formily");
27
27
  var import_generator_common = require("@modern-js/generator-common");
28
28
  var import_generator_utils = require("@modern-js/generator-utils");
29
29
  var import_utils = require("./utils");
30
+ var import_constants = require("./constants");
30
31
  const MWANewAction = async (options) => {
31
32
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd(), needInstall = true } = options;
32
33
  let UserConfig = {};
@@ -35,8 +36,9 @@ const MWANewAction = async (options) => {
35
36
  } catch (e) {
36
37
  throw new Error("config is not a valid json");
37
38
  }
39
+ const language = UserConfig.locale || locale;
38
40
  import_generator_common.i18n.changeLanguage({
39
- locale: UserConfig.locale || locale
41
+ locale: language
40
42
  });
41
43
  const smith = new import_codesmith.CodeSmith({
42
44
  debug,
@@ -62,12 +64,14 @@ const MWANewAction = async (options) => {
62
64
  refactorMap[refactor] = enable;
63
65
  });
64
66
  const ans = await formilyAPI.getInputBySchemaFunc(import_generator_common.getMWANewActionSchema, {
65
- ...UserConfig,
66
- funcMap,
67
- refactorMap
67
+ ...UserConfig
68
68
  });
69
69
  const actionType = ans.actionType;
70
70
  const action = ans[actionType];
71
+ if (actionType === import_generator_common.ActionType.Function && funcMap[action] || actionType === import_generator_common.ActionType.Refactor && refactorMap[action]) {
72
+ smith.logger.error(import_constants.enableAlreadyText[language]);
73
+ return;
74
+ }
71
75
  const generator = (0, import_utils.getGeneratorPath)(import_generator_common.MWANewActionGenerators[actionType][action], distTag);
72
76
  if (!generator) {
73
77
  throw new Error(`no valid option`);
@@ -0,0 +1,7 @@
1
+ const enableAlreadyText = {
2
+ zh: "当前功能已开启,请确认对应插件依赖是否已安装。若需重新开启该功能,请移除插件依赖后再次尝试。",
3
+ en: "The current function has been enabled. Please confirm whether the corresponding plugin dependencies have been installed. If you need to re-enable this function, please remove the plugin dependencies and try again."
4
+ };
5
+ export {
6
+ enableAlreadyText
7
+ };
@@ -1,9 +1,10 @@
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 { i18n, getModuleNewActionSchema, ModuleActionFunctions, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, ModuleNewActionGenerators, Solution, ModuleNewActionPluginName, ModuleNewActionPluginDependence } from "@modern-js/generator-common";
4
+ import { i18n, getModuleNewActionSchema, ModuleActionFunctions, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, ModuleNewActionGenerators, ActionType, Solution, ModuleNewActionPluginName, ModuleNewActionPluginDependence } from "@modern-js/generator-common";
5
5
  import { getPackageManager, getModernPluginVersion } from "@modern-js/generator-utils";
6
6
  import { alreadyRepo, getGeneratorPath, hasEnabledFunction, usePluginNameExport } from "./utils";
7
+ import { enableAlreadyText } from "./constants";
7
8
  const ModuleNewAction = async (options) => {
8
9
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd(), needInstall = true } = options;
9
10
  let UserConfig = {};
@@ -12,8 +13,9 @@ const ModuleNewAction = async (options) => {
12
13
  } catch (e) {
13
14
  throw new Error("config is not a valid json");
14
15
  }
16
+ const language = UserConfig.locale || locale;
15
17
  i18n.changeLanguage({
16
- locale: UserConfig.locale || locale
18
+ locale: language
17
19
  });
18
20
  const smith = new CodeSmith({
19
21
  debug,
@@ -42,11 +44,14 @@ const ModuleNewAction = async (options) => {
42
44
  process.exit(1);
43
45
  }
44
46
  const ans = await formilyAPI.getInputBySchemaFunc(getModuleNewActionSchema, {
45
- ...UserConfig,
46
- funcMap
47
+ ...UserConfig
47
48
  });
48
49
  const actionType = ans.actionType;
49
50
  const action = ans[actionType];
51
+ if (actionType === ActionType.Function && funcMap[action]) {
52
+ smith.logger.error(enableAlreadyText[language]);
53
+ return;
54
+ }
50
55
  const generator = getGeneratorPath(ModuleNewActionGenerators[actionType][action], distTag);
51
56
  if (!generator) {
52
57
  throw new Error(`no valid option`);
package/dist/esm/mwa.js CHANGED
@@ -1,9 +1,10 @@
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 { getMWANewActionSchema, MWAActionFunctions, MWAActionReactors, MWAActionFunctionsDependencies, MWAActionFunctionsAppendTypeContent, MWAActionReactorAppendTypeContent, MWAActionFunctionsDevDependencies, MWANewActionGenerators, i18n, Solution, MWAActionRefactorDependencies, MWANewActionPluginName, MWANewActionPluginDependence } from "@modern-js/generator-common";
4
+ import { getMWANewActionSchema, MWAActionFunctions, MWAActionReactors, MWAActionFunctionsDependencies, MWAActionFunctionsAppendTypeContent, MWAActionReactorAppendTypeContent, MWAActionFunctionsDevDependencies, MWANewActionGenerators, ActionType, i18n, Solution, MWAActionRefactorDependencies, MWANewActionPluginName, MWANewActionPluginDependence } from "@modern-js/generator-common";
5
5
  import { getModernPluginVersion, getPackageManager } from "@modern-js/generator-utils";
6
6
  import { alreadyRepo, getGeneratorPath, hasEnabledFunction, usePluginNameExport } from "./utils";
7
+ import { enableAlreadyText } from "./constants";
7
8
  const MWANewAction = async (options) => {
8
9
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd(), needInstall = true } = options;
9
10
  let UserConfig = {};
@@ -12,8 +13,9 @@ const MWANewAction = async (options) => {
12
13
  } catch (e) {
13
14
  throw new Error("config is not a valid json");
14
15
  }
16
+ const language = UserConfig.locale || locale;
15
17
  i18n.changeLanguage({
16
- locale: UserConfig.locale || locale
18
+ locale: language
17
19
  });
18
20
  const smith = new CodeSmith({
19
21
  debug,
@@ -39,12 +41,14 @@ const MWANewAction = async (options) => {
39
41
  refactorMap[refactor] = enable;
40
42
  });
41
43
  const ans = await formilyAPI.getInputBySchemaFunc(getMWANewActionSchema, {
42
- ...UserConfig,
43
- funcMap,
44
- refactorMap
44
+ ...UserConfig
45
45
  });
46
46
  const actionType = ans.actionType;
47
47
  const action = ans[actionType];
48
+ if (actionType === ActionType.Function && funcMap[action] || actionType === ActionType.Refactor && refactorMap[action]) {
49
+ smith.logger.error(enableAlreadyText[language]);
50
+ return;
51
+ }
48
52
  const generator = getGeneratorPath(MWANewActionGenerators[actionType][action], distTag);
49
53
  if (!generator) {
50
54
  throw new Error(`no valid option`);
@@ -0,0 +1 @@
1
+ export declare const enableAlreadyText: Record<string, string>;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.49.4",
18
+ "version": "2.50.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -36,9 +36,9 @@
36
36
  "@modern-js/codesmith": "2.3.5",
37
37
  "@modern-js/codesmith-formily": "2.3.5",
38
38
  "@swc/helpers": "0.5.3",
39
- "@modern-js/generator-common": "3.3.22",
40
- "@modern-js/generator-utils": "3.3.22",
41
- "@modern-js/utils": "2.49.4"
39
+ "@modern-js/generator-common": "3.3.23",
40
+ "@modern-js/utils": "2.50.0",
41
+ "@modern-js/generator-utils": "3.3.23"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/jest": "^29",
@@ -46,8 +46,8 @@
46
46
  "jest": "^29",
47
47
  "ts-node": "^10.9.1",
48
48
  "typescript": "^5",
49
- "@scripts/jest-config": "2.49.4",
50
- "@scripts/build": "2.49.4"
49
+ "@scripts/jest-config": "2.50.0",
50
+ "@scripts/build": "2.50.0"
51
51
  },
52
52
  "sideEffects": false,
53
53
  "publishConfig": {