@modern-js/new-action 2.35.1 → 2.37.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
@@ -1,9 +1,28 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./utils"), module.exports);
19
+ __reExport(src_exports, require("./mwa"), module.exports);
20
+ __reExport(src_exports, require("./module"), module.exports);
21
+ __reExport(src_exports, require("./monorepo"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./utils"),
25
+ ...require("./mwa"),
26
+ ...require("./module"),
27
+ ...require("./monorepo")
4
28
  });
5
- const _export_star = require("@swc/helpers/_/_export_star");
6
- _export_star._(require("./utils"), exports);
7
- _export_star._(require("./mwa"), exports);
8
- _export_star._(require("./module"), exports);
9
- _export_star._(require("./monorepo"), exports);
@@ -1,19 +1,32 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "ModuleNewAction", {
6
- enumerable: true,
7
- get: function() {
8
- return ModuleNewAction;
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 });
9
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
10
22
  });
11
- const _lodash = require("@modern-js/utils/lodash");
12
- const _codesmith = require("@modern-js/codesmith");
13
- const _codesmithformily = require("@modern-js/codesmith-formily");
14
- const _generatorcommon = require("@modern-js/generator-common");
15
- const _generatorutils = require("@modern-js/generator-utils");
16
- const _utils = require("./utils");
23
+ module.exports = __toCommonJS(module_exports);
24
+ var import_lodash = require("@modern-js/utils/lodash");
25
+ var import_codesmith = require("@modern-js/codesmith");
26
+ var import_codesmith_formily = require("@modern-js/codesmith-formily");
27
+ var import_generator_common = require("@modern-js/generator-common");
28
+ var import_generator_utils = require("@modern-js/generator-utils");
29
+ var import_utils = require("./utils");
17
30
  const ModuleNewAction = async (options) => {
18
31
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd(), needInstall = true } = options;
19
32
  let UserConfig = {};
@@ -22,17 +35,17 @@ const ModuleNewAction = async (options) => {
22
35
  } catch (e) {
23
36
  throw new Error("config is not a valid json");
24
37
  }
25
- _generatorcommon.i18n.changeLanguage({
38
+ import_generator_common.i18n.changeLanguage({
26
39
  locale: UserConfig.locale || locale
27
40
  });
28
- const smith = new _codesmith.CodeSmith({
41
+ const smith = new import_codesmith.CodeSmith({
29
42
  debug,
30
43
  registryUrl: registry
31
44
  });
32
- if (!(0, _utils.alreadyRepo)(cwd)) {
45
+ if (!(0, import_utils.alreadyRepo)(cwd)) {
33
46
  smith.logger.warn("not valid modern.js repo");
34
47
  }
35
- const formilyAPI = new _codesmithformily.FormilyAPI({
48
+ const formilyAPI = new import_codesmith_formily.FormilyAPI({
36
49
  materials: {},
37
50
  config: {},
38
51
  data: {},
@@ -40,8 +53,8 @@ const ModuleNewAction = async (options) => {
40
53
  });
41
54
  let hasOption = false;
42
55
  const funcMap = {};
43
- _generatorcommon.ModuleActionFunctions.forEach((func) => {
44
- const enable = (0, _utils.hasEnabledFunction)(func, _generatorcommon.ModuleActionFunctionsDependencies, _generatorcommon.ModuleActionFunctionsDevDependencies, _generatorcommon.ModuleActionFunctionsPeerDependencies, cwd);
56
+ import_generator_common.ModuleActionFunctions.forEach((func) => {
57
+ const enable = (0, import_utils.hasEnabledFunction)(func, import_generator_common.ModuleActionFunctionsDependencies, import_generator_common.ModuleActionFunctionsDevDependencies, import_generator_common.ModuleActionFunctionsPeerDependencies, cwd);
45
58
  funcMap[func] = enable;
46
59
  if (!enable) {
47
60
  hasOption = true;
@@ -51,36 +64,36 @@ const ModuleNewAction = async (options) => {
51
64
  smith.logger.warn("no option can be enabled");
52
65
  process.exit(1);
53
66
  }
54
- const ans = await formilyAPI.getInputBySchemaFunc(_generatorcommon.getModuleNewActionSchema, {
67
+ const ans = await formilyAPI.getInputBySchemaFunc(import_generator_common.getModuleNewActionSchema, {
55
68
  ...UserConfig,
56
69
  funcMap
57
70
  });
58
71
  const actionType = ans.actionType;
59
72
  const action = ans[actionType];
60
- const generator = (0, _utils.getGeneratorPath)(_generatorcommon.ModuleNewActionGenerators[actionType][action], distTag);
73
+ const generator = (0, import_utils.getGeneratorPath)(import_generator_common.ModuleNewActionGenerators[actionType][action], distTag);
61
74
  if (!generator) {
62
75
  throw new Error(`no valid option`);
63
76
  }
64
- const devDependency = _generatorcommon.ModuleActionFunctionsDevDependencies[action];
65
- const dependency = _generatorcommon.ModuleActionFunctionsDependencies[action];
66
- const peerDependency = _generatorcommon.ModuleActionFunctionsPeerDependencies[action];
77
+ const devDependency = import_generator_common.ModuleActionFunctionsDevDependencies[action];
78
+ const dependency = import_generator_common.ModuleActionFunctionsDependencies[action];
79
+ const peerDependency = import_generator_common.ModuleActionFunctionsPeerDependencies[action];
67
80
  const getModulePluginVersion = (packageName) => {
68
- return (0, _generatorutils.getModernPluginVersion)(_generatorcommon.Solution.Module, packageName, {
81
+ return (0, import_generator_utils.getModernPluginVersion)(import_generator_common.Solution.Module, packageName, {
69
82
  registry,
70
83
  distTag,
71
84
  cwd
72
85
  });
73
86
  };
74
- const shouldUsePluginNameExport = await (0, _utils.usePluginNameExport)(_generatorcommon.Solution.Module, {
87
+ const shouldUsePluginNameExport = await (0, import_utils.usePluginNameExport)(import_generator_common.Solution.Module, {
75
88
  registry,
76
89
  distTag,
77
90
  cwd
78
91
  });
79
- const finalConfig = (0, _lodash.merge)(UserConfig, {
92
+ const finalConfig = (0, import_lodash.merge)(UserConfig, {
80
93
  noNeedInstall: !needInstall
81
94
  }, ans, {
82
95
  locale: UserConfig.locale || locale,
83
- packageManager: UserConfig.packageManager || await (0, _generatorutils.getPackageManager)(cwd),
96
+ packageManager: UserConfig.packageManager || await (0, import_generator_utils.getPackageManager)(cwd),
84
97
  distTag
85
98
  }, {
86
99
  devDependencies: devDependency ? {
@@ -92,8 +105,8 @@ const ModuleNewAction = async (options) => {
92
105
  peerDependencies: peerDependency ? {
93
106
  [peerDependency]: `${await getModulePluginVersion(peerDependency)}`
94
107
  } : {},
95
- pluginName: _generatorcommon.ModuleNewActionPluginName[actionType][action],
96
- pluginDependence: _generatorcommon.ModuleNewActionPluginDependence[actionType][action],
108
+ pluginName: import_generator_common.ModuleNewActionPluginName[actionType][action],
109
+ pluginDependence: import_generator_common.ModuleNewActionPluginDependence[actionType][action],
97
110
  shouldUsePluginNameExport
98
111
  });
99
112
  const task = [
@@ -110,3 +123,7 @@ const ModuleNewAction = async (options) => {
110
123
  pwd: cwd
111
124
  });
112
125
  };
126
+ // Annotate the CommonJS export names for ESM import in node:
127
+ 0 && (module.exports = {
128
+ ModuleNewAction
129
+ });
@@ -1,20 +1,42 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "MonorepoNewAction", {
6
- enumerable: true,
7
- get: function() {
8
- return MonorepoNewAction;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var monorepo_exports = {};
30
+ __export(monorepo_exports, {
31
+ MonorepoNewAction: () => MonorepoNewAction
10
32
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
13
- const _lodash = require("@modern-js/utils/lodash");
14
- const _codesmith = require("@modern-js/codesmith");
15
- const _generatorcommon = require("@modern-js/generator-common");
16
- const _generatorutils = require("@modern-js/generator-utils");
17
- const _utils = require("./utils");
33
+ module.exports = __toCommonJS(monorepo_exports);
34
+ var import_path = __toESM(require("path"));
35
+ var import_lodash = require("@modern-js/utils/lodash");
36
+ var import_codesmith = require("@modern-js/codesmith");
37
+ var import_generator_common = require("@modern-js/generator-common");
38
+ var import_generator_utils = require("@modern-js/generator-utils");
39
+ var import_utils = require("./utils");
18
40
  const REPO_GENERATOR = "@modern-js/repo-generator";
19
41
  const MonorepoNewAction = async (options) => {
20
42
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", plugin = [], cwd = process.cwd(), needInstall = true } = options;
@@ -24,30 +46,30 @@ const MonorepoNewAction = async (options) => {
24
46
  } catch (e) {
25
47
  throw new Error("config is not a valid json");
26
48
  }
27
- _generatorcommon.i18n.changeLanguage({
49
+ import_generator_common.i18n.changeLanguage({
28
50
  locale: UserConfig.locale || locale
29
51
  });
30
- const smith = new _codesmith.CodeSmith({
52
+ const smith = new import_codesmith.CodeSmith({
31
53
  debug,
32
54
  registryUrl: registry
33
55
  });
34
- if (!(0, _utils.alreadyRepo)(cwd)) {
56
+ if (!(0, import_utils.alreadyRepo)(cwd)) {
35
57
  smith.logger.warn("not valid modern.js repo");
36
58
  }
37
59
  const plugins = plugin.map((plugin2) => {
38
60
  try {
39
- return _path.default.join(require.resolve(plugin2), "../../");
61
+ return import_path.default.join(require.resolve(plugin2), "../../");
40
62
  } catch (e) {
41
63
  try {
42
- return _path.default.join(require.resolve(plugin2), "../../../../");
64
+ return import_path.default.join(require.resolve(plugin2), "../../../../");
43
65
  } catch (e2) {
44
66
  return plugin2;
45
67
  }
46
68
  }
47
69
  });
48
- const finalConfig = (0, _lodash.merge)(UserConfig, {
70
+ const finalConfig = (0, import_lodash.merge)(UserConfig, {
49
71
  locale: UserConfig.locale || locale,
50
- packageManager: UserConfig.packageManager || await (0, _generatorutils.getPackageManager)(cwd),
72
+ packageManager: UserConfig.packageManager || await (0, import_generator_utils.getPackageManager)(cwd),
51
73
  isMonorepo: true,
52
74
  distTag,
53
75
  plugins,
@@ -73,3 +95,7 @@ const MonorepoNewAction = async (options) => {
73
95
  pwd: cwd
74
96
  });
75
97
  };
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ MonorepoNewAction
101
+ });
package/dist/cjs/mwa.js CHANGED
@@ -1,19 +1,32 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "MWANewAction", {
6
- enumerable: true,
7
- get: function() {
8
- return MWANewAction;
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 });
9
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var mwa_exports = {};
20
+ __export(mwa_exports, {
21
+ MWANewAction: () => MWANewAction
10
22
  });
11
- const _lodash = require("@modern-js/utils/lodash");
12
- const _codesmith = require("@modern-js/codesmith");
13
- const _codesmithformily = require("@modern-js/codesmith-formily");
14
- const _generatorcommon = require("@modern-js/generator-common");
15
- const _generatorutils = require("@modern-js/generator-utils");
16
- const _utils = require("./utils");
23
+ module.exports = __toCommonJS(mwa_exports);
24
+ var import_lodash = require("@modern-js/utils/lodash");
25
+ var import_codesmith = require("@modern-js/codesmith");
26
+ var import_codesmith_formily = require("@modern-js/codesmith-formily");
27
+ var import_generator_common = require("@modern-js/generator-common");
28
+ var import_generator_utils = require("@modern-js/generator-utils");
29
+ var import_utils = require("./utils");
17
30
  const MWANewAction = async (options) => {
18
31
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd(), needInstall = true } = options;
19
32
  let UserConfig = {};
@@ -22,62 +35,62 @@ const MWANewAction = async (options) => {
22
35
  } catch (e) {
23
36
  throw new Error("config is not a valid json");
24
37
  }
25
- _generatorcommon.i18n.changeLanguage({
38
+ import_generator_common.i18n.changeLanguage({
26
39
  locale: UserConfig.locale || locale
27
40
  });
28
- const smith = new _codesmith.CodeSmith({
41
+ const smith = new import_codesmith.CodeSmith({
29
42
  debug,
30
43
  registryUrl: registry
31
44
  });
32
- if (!(0, _utils.alreadyRepo)(cwd)) {
45
+ if (!(0, import_utils.alreadyRepo)(cwd)) {
33
46
  smith.logger.warn("not valid modern.js repo");
34
47
  }
35
- const formilyAPI = new _codesmithformily.FormilyAPI({
48
+ const formilyAPI = new import_codesmith_formily.FormilyAPI({
36
49
  materials: {},
37
50
  config: {},
38
51
  data: {},
39
52
  current: null
40
53
  });
41
54
  const funcMap = {};
42
- _generatorcommon.MWAActionFunctions.forEach((func) => {
43
- const enable = (0, _utils.hasEnabledFunction)(func, _generatorcommon.MWAActionFunctionsDependencies, _generatorcommon.MWAActionFunctionsDevDependencies, {}, cwd);
55
+ import_generator_common.MWAActionFunctions.forEach((func) => {
56
+ const enable = (0, import_utils.hasEnabledFunction)(func, import_generator_common.MWAActionFunctionsDependencies, import_generator_common.MWAActionFunctionsDevDependencies, {}, cwd);
44
57
  funcMap[func] = enable;
45
58
  });
46
59
  const refactorMap = {};
47
- _generatorcommon.MWAActionReactors.forEach((refactor) => {
48
- const enable = (0, _utils.hasEnabledFunction)(refactor, _generatorcommon.MWAActionRefactorDependencies, {}, {}, cwd);
60
+ import_generator_common.MWAActionReactors.forEach((refactor) => {
61
+ const enable = (0, import_utils.hasEnabledFunction)(refactor, import_generator_common.MWAActionRefactorDependencies, {}, {}, cwd);
49
62
  refactorMap[refactor] = enable;
50
63
  });
51
- const ans = await formilyAPI.getInputBySchemaFunc(_generatorcommon.getMWANewActionSchema, {
64
+ const ans = await formilyAPI.getInputBySchemaFunc(import_generator_common.getMWANewActionSchema, {
52
65
  ...UserConfig,
53
66
  funcMap,
54
67
  refactorMap
55
68
  });
56
69
  const actionType = ans.actionType;
57
70
  const action = ans[actionType];
58
- const generator = (0, _utils.getGeneratorPath)(_generatorcommon.MWANewActionGenerators[actionType][action], distTag);
71
+ const generator = (0, import_utils.getGeneratorPath)(import_generator_common.MWANewActionGenerators[actionType][action], distTag);
59
72
  if (!generator) {
60
73
  throw new Error(`no valid option`);
61
74
  }
62
75
  const getMwaPluginVersion = (packageName) => {
63
- return (0, _generatorutils.getModernPluginVersion)(_generatorcommon.Solution.MWA, packageName, {
76
+ return (0, import_generator_utils.getModernPluginVersion)(import_generator_common.Solution.MWA, packageName, {
64
77
  registry,
65
78
  distTag,
66
79
  cwd
67
80
  });
68
81
  };
69
- const devDependency = _generatorcommon.MWAActionFunctionsDevDependencies[action];
70
- const dependency = _generatorcommon.MWAActionFunctionsDependencies[action] || _generatorcommon.MWAActionRefactorDependencies[action];
71
- const shouldUsePluginNameExport = await (0, _utils.usePluginNameExport)(_generatorcommon.Solution.MWA, {
82
+ const devDependency = import_generator_common.MWAActionFunctionsDevDependencies[action];
83
+ const dependency = import_generator_common.MWAActionFunctionsDependencies[action] || import_generator_common.MWAActionRefactorDependencies[action];
84
+ const shouldUsePluginNameExport = await (0, import_utils.usePluginNameExport)(import_generator_common.Solution.MWA, {
72
85
  registry,
73
86
  distTag,
74
87
  cwd
75
88
  });
76
- const finalConfig = (0, _lodash.merge)(UserConfig, {
89
+ const finalConfig = (0, import_lodash.merge)(UserConfig, {
77
90
  noNeedInstall: !needInstall
78
91
  }, ans, {
79
92
  locale: UserConfig.locale || locale,
80
- packageManager: UserConfig.packageManager || await (0, _generatorutils.getPackageManager)(cwd),
93
+ packageManager: UserConfig.packageManager || await (0, import_generator_utils.getPackageManager)(cwd),
81
94
  distTag
82
95
  }, {
83
96
  devDependencies: devDependency ? {
@@ -86,9 +99,9 @@ const MWANewAction = async (options) => {
86
99
  dependencies: dependency ? {
87
100
  [dependency]: `${await getMwaPluginVersion(dependency)}`
88
101
  } : {},
89
- appendTypeContent: _generatorcommon.MWAActionFunctionsAppendTypeContent[action] || _generatorcommon.MWAActionReactorAppendTypeContent[action],
90
- pluginName: _generatorcommon.MWANewActionPluginName[actionType][action],
91
- pluginDependence: _generatorcommon.MWANewActionPluginDependence[actionType][action],
102
+ appendTypeContent: import_generator_common.MWAActionFunctionsAppendTypeContent[action] || import_generator_common.MWAActionReactorAppendTypeContent[action],
103
+ pluginName: import_generator_common.MWANewActionPluginName[actionType][action],
104
+ pluginDependence: import_generator_common.MWANewActionPluginDependence[actionType][action],
92
105
  shouldUsePluginNameExport
93
106
  });
94
107
  const task = [
@@ -105,3 +118,7 @@ const MWANewAction = async (options) => {
105
118
  pwd: cwd
106
119
  });
107
120
  };
121
+ // Annotate the CommonJS export names for ESM import in node:
122
+ 0 && (module.exports = {
123
+ MWANewAction
124
+ });
@@ -1,58 +1,66 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- alreadyRepo: function() {
14
- return alreadyRepo;
15
- },
16
- readJson: function() {
17
- return readJson;
18
- },
19
- hasEnabledFunction: function() {
20
- return hasEnabledFunction;
21
- },
22
- getGeneratorPath: function() {
23
- return getGeneratorPath;
24
- },
25
- usePluginNameExport: function() {
26
- return usePluginNameExport;
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var utils_exports = {};
30
+ __export(utils_exports, {
31
+ alreadyRepo: () => alreadyRepo,
32
+ getGeneratorPath: () => getGeneratorPath,
33
+ hasEnabledFunction: () => hasEnabledFunction,
34
+ readJson: () => readJson,
35
+ usePluginNameExport: () => usePluginNameExport
28
36
  });
29
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
30
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
31
- const _utils = require("@modern-js/utils");
32
- const _generatorcommon = require("@modern-js/generator-common");
33
- const _generatorutils = require("@modern-js/generator-utils");
37
+ module.exports = __toCommonJS(utils_exports);
38
+ var import_path = __toESM(require("path"));
39
+ var import_utils = require("@modern-js/utils");
40
+ var import_generator_common = require("@modern-js/generator-common");
41
+ var import_generator_utils = require("@modern-js/generator-utils");
34
42
  function alreadyRepo(cwd = process.cwd()) {
35
43
  try {
36
- return _generatorutils.fs.existsSync(_path.default.resolve(cwd, "package.json"));
44
+ return import_generator_utils.fs.existsSync(import_path.default.resolve(cwd, "package.json"));
37
45
  } catch (e) {
38
46
  return false;
39
47
  }
40
48
  }
41
49
  const readJson = (jsonPath) => {
42
- if (!_generatorutils.fs.existsSync(jsonPath)) {
50
+ if (!import_generator_utils.fs.existsSync(jsonPath)) {
43
51
  return {};
44
52
  }
45
- const jsonStr = _generatorutils.fs.readFileSync(jsonPath, {
53
+ const jsonStr = import_generator_utils.fs.readFileSync(jsonPath, {
46
54
  encoding: "utf8"
47
55
  });
48
56
  try {
49
- return _utils.json5.parse(jsonStr);
57
+ return import_utils.json5.parse(jsonStr);
50
58
  } catch (error) {
51
59
  throw Error(`${jsonPath} is not a valid json, please check and try again.`);
52
60
  }
53
61
  };
54
62
  function hasEnabledFunction(action, dependencies, devDependencies, peerDependencies, cwd) {
55
- const packageJsonPath = _path.default.normalize(`${cwd}/package.json`);
63
+ const packageJsonPath = import_path.default.normalize(`${cwd}/package.json`);
56
64
  const packageJson = readJson(packageJsonPath);
57
65
  if (!dependencies[action] && !devDependencies[action]) {
58
66
  return false;
@@ -73,16 +81,24 @@ function hasEnabledFunction(action, dependencies, devDependencies, peerDependenc
73
81
  }
74
82
  function getGeneratorPath(generator, distTag) {
75
83
  if (process.env.CODESMITH_ENV === "development") {
76
- return _path.default.dirname(require.resolve(generator));
84
+ return import_path.default.dirname(require.resolve(generator));
77
85
  } else if (distTag) {
78
86
  return `${generator}@${distTag}`;
79
87
  }
80
88
  return generator;
81
89
  }
82
90
  async function usePluginNameExport(solution, options) {
83
- const solutionVersion = await (0, _generatorutils.getModernPluginVersion)(solution, _generatorcommon.SolutionToolsMap[_generatorcommon.Solution.MWA], options);
84
- if (_utils.semver.valid(solutionVersion) && _utils.semver.gte(solutionVersion, "2.0.0")) {
85
- return _utils.semver.gt(solutionVersion, "2.24.0");
91
+ const solutionVersion = await (0, import_generator_utils.getModernPluginVersion)(solution, import_generator_common.SolutionToolsMap[import_generator_common.Solution.MWA], options);
92
+ if (import_utils.semver.valid(solutionVersion) && import_utils.semver.gte(solutionVersion, "2.0.0")) {
93
+ return import_utils.semver.gt(solutionVersion, "2.24.0");
86
94
  }
87
95
  return true;
88
96
  }
97
+ // Annotate the CommonJS export names for ESM import in node:
98
+ 0 && (module.exports = {
99
+ alreadyRepo,
100
+ getGeneratorPath,
101
+ hasEnabledFunction,
102
+ readJson,
103
+ usePluginNameExport
104
+ });
@@ -4,7 +4,7 @@ import { FormilyAPI } from "@modern-js/codesmith-formily";
4
4
  import { i18n, getModuleNewActionSchema, ModuleActionFunctions, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, ModuleNewActionGenerators, 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
- export const ModuleNewAction = async (options) => {
7
+ const ModuleNewAction = async (options) => {
8
8
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd(), needInstall = true } = options;
9
9
  let UserConfig = {};
10
10
  try {
@@ -100,3 +100,6 @@ export const ModuleNewAction = async (options) => {
100
100
  pwd: cwd
101
101
  });
102
102
  };
103
+ export {
104
+ ModuleNewAction
105
+ };
@@ -5,7 +5,7 @@ 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
- export const MonorepoNewAction = async (options) => {
8
+ const MonorepoNewAction = async (options) => {
9
9
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", plugin = [], cwd = process.cwd(), needInstall = true } = options;
10
10
  let UserConfig = {};
11
11
  try {
@@ -62,3 +62,6 @@ export const MonorepoNewAction = async (options) => {
62
62
  pwd: cwd
63
63
  });
64
64
  };
65
+ export {
66
+ MonorepoNewAction
67
+ };
package/dist/esm/mwa.js CHANGED
@@ -4,7 +4,7 @@ import { FormilyAPI } from "@modern-js/codesmith-formily";
4
4
  import { getMWANewActionSchema, MWAActionFunctions, MWAActionReactors, MWAActionFunctionsDependencies, MWAActionFunctionsAppendTypeContent, MWAActionReactorAppendTypeContent, MWAActionFunctionsDevDependencies, MWANewActionGenerators, 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
- export const MWANewAction = async (options) => {
7
+ const MWANewAction = async (options) => {
8
8
  const { locale = "zh", distTag = "", debug = false, registry = "", config = "{}", cwd = process.cwd(), needInstall = true } = options;
9
9
  let UserConfig = {};
10
10
  try {
@@ -95,3 +95,6 @@ export const MWANewAction = async (options) => {
95
95
  pwd: cwd
96
96
  });
97
97
  };
98
+ export {
99
+ MWANewAction
100
+ };
@@ -2,14 +2,14 @@ import path from "path";
2
2
  import { json5, semver } from "@modern-js/utils";
3
3
  import { Solution, SolutionToolsMap } from "@modern-js/generator-common";
4
4
  import { fs, getModernPluginVersion } from "@modern-js/generator-utils";
5
- export function alreadyRepo(cwd = process.cwd()) {
5
+ function alreadyRepo(cwd = process.cwd()) {
6
6
  try {
7
7
  return fs.existsSync(path.resolve(cwd, "package.json"));
8
8
  } catch (e) {
9
9
  return false;
10
10
  }
11
11
  }
12
- export const readJson = (jsonPath) => {
12
+ const readJson = (jsonPath) => {
13
13
  if (!fs.existsSync(jsonPath)) {
14
14
  return {};
15
15
  }
@@ -22,7 +22,7 @@ export const readJson = (jsonPath) => {
22
22
  throw Error(`${jsonPath} is not a valid json, please check and try again.`);
23
23
  }
24
24
  };
25
- export function hasEnabledFunction(action, dependencies, devDependencies, peerDependencies, cwd) {
25
+ function hasEnabledFunction(action, dependencies, devDependencies, peerDependencies, cwd) {
26
26
  const packageJsonPath = path.normalize(`${cwd}/package.json`);
27
27
  const packageJson = readJson(packageJsonPath);
28
28
  if (!dependencies[action] && !devDependencies[action]) {
@@ -42,7 +42,7 @@ export function hasEnabledFunction(action, dependencies, devDependencies, peerDe
42
42
  }
43
43
  return false;
44
44
  }
45
- export function getGeneratorPath(generator, distTag) {
45
+ function getGeneratorPath(generator, distTag) {
46
46
  if (process.env.CODESMITH_ENV === "development") {
47
47
  return path.dirname(require.resolve(generator));
48
48
  } else if (distTag) {
@@ -50,10 +50,17 @@ export function getGeneratorPath(generator, distTag) {
50
50
  }
51
51
  return generator;
52
52
  }
53
- export async function usePluginNameExport(solution, options) {
53
+ async function usePluginNameExport(solution, options) {
54
54
  const solutionVersion = await getModernPluginVersion(solution, SolutionToolsMap[Solution.MWA], options);
55
55
  if (semver.valid(solutionVersion) && semver.gte(solutionVersion, "2.0.0")) {
56
56
  return semver.gt(solutionVersion, "2.24.0");
57
57
  }
58
58
  return true;
59
59
  }
60
+ export {
61
+ alreadyRepo,
62
+ getGeneratorPath,
63
+ hasEnabledFunction,
64
+ readJson,
65
+ usePluginNameExport
66
+ };
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.35.1",
18
+ "version": "2.37.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -33,17 +33,17 @@
33
33
  "@modern-js/codesmith": "2.2.5",
34
34
  "@modern-js/codesmith-formily": "2.2.5",
35
35
  "@swc/helpers": "0.5.1",
36
- "@modern-js/generator-common": "3.2.2",
37
- "@modern-js/generator-utils": "3.2.2",
38
- "@modern-js/utils": "2.35.1"
36
+ "@modern-js/generator-common": "3.2.4",
37
+ "@modern-js/generator-utils": "3.2.4",
38
+ "@modern-js/utils": "2.37.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/jest": "^29",
42
42
  "@types/node": "^14",
43
43
  "jest": "^29",
44
44
  "typescript": "^5",
45
- "@scripts/build": "2.35.1",
46
- "@scripts/jest-config": "2.35.1"
45
+ "@scripts/build": "2.37.0",
46
+ "@scripts/jest-config": "2.37.0"
47
47
  },
48
48
  "sideEffects": false,
49
49
  "publishConfig": {