@modern-js/base-generator 2.2.1 → 2.3.3

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.
Files changed (2) hide show
  1. package/dist/index.js +69 -110
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -35664,20 +35664,28 @@ var require_compiled = __commonJSMin((exports) => {
35664
35664
  var require_format = __commonJSMin((exports) => {
35665
35665
  "use strict";
35666
35666
  Object.defineProperty(exports, "__esModule", { value: true });
35667
- exports.formatProxyOptions = exports.formatWebpackMessages = void 0;
35668
- var friendlySyntaxErrorLabel = "Syntax error:";
35667
+ exports.formatWebpackMessages = void 0;
35668
+ var friendlySyntaxErrorLabel = "SyntaxError:";
35669
35669
  function isLikelyASyntaxError(message) {
35670
35670
  return message.includes(friendlySyntaxErrorLabel);
35671
35671
  }
35672
- function formatMessage(message) {
35673
- var _a;
35672
+ function formatMessage(stats) {
35674
35673
  let lines = [];
35675
- if (typeof message === "object") {
35676
- message = `${message.moduleName && `${message.moduleName}
35677
- `}${message.details || message.stack || message.message}`;
35674
+ let message;
35675
+ if (typeof stats === "object") {
35676
+ const fileName = stats.moduleName ? `File: ${stats.moduleName}
35677
+ ` : "";
35678
+ const mainMessage = stats.message;
35679
+ const details = stats.details ? `
35680
+ Details: ${stats.details}
35681
+ ` : "";
35682
+ const stack = stats.stack ? `
35683
+ ${stats.stack}` : "";
35684
+ message = `${fileName}${mainMessage}${details}${stack}`;
35685
+ } else {
35686
+ message = stats;
35678
35687
  }
35679
35688
  lines = message.split("\n");
35680
- lines = lines.filter((line3) => !/Module [A-z ]+\(from/.test(line3));
35681
35689
  lines = lines.map((line3) => {
35682
35690
  const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line3);
35683
35691
  if (!parsingError) {
@@ -35694,11 +35702,8 @@ var require_format = __commonJSMin((exports) => {
35694
35702
  lines.splice(1, 1);
35695
35703
  }
35696
35704
  lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
35697
- if ((_a = lines[1]) === null || _a === void 0 ? void 0 : _a.startsWith("Module not found: ")) {
35698
- lines = [
35699
- lines[0],
35700
- lines[1].replace("Error: ", "").replace("Module not found: Cannot find file:", "Cannot find file:").replace("[CaseSensitivePathsPlugin] ", "").replace("Cannot resolve 'file' or 'directory' ", "")
35701
- ];
35705
+ if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
35706
+ lines[1] = lines[1].replace("Error: ", "");
35702
35707
  }
35703
35708
  message = lines.join("\n");
35704
35709
  message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, "");
@@ -35725,29 +35730,6 @@ var require_format = __commonJSMin((exports) => {
35725
35730
  return result;
35726
35731
  }
35727
35732
  exports.formatWebpackMessages = formatWebpackMessages;
35728
- function formatProxyOptions(proxyOptions) {
35729
- const formattedProxy = [];
35730
- if (!Array.isArray(proxyOptions)) {
35731
- if ("target" in proxyOptions) {
35732
- formattedProxy.push(proxyOptions);
35733
- } else {
35734
- Array.prototype.push.apply(formattedProxy, Object.keys(proxyOptions).reduce((total, source) => {
35735
- const option = proxyOptions[source];
35736
- total.push({
35737
- context: source,
35738
- changeOrigin: true,
35739
- logLevel: "warn",
35740
- ...typeof option === "string" ? { target: option } : option
35741
- });
35742
- return total;
35743
- }, []));
35744
- }
35745
- } else {
35746
- formattedProxy.push(...proxyOptions);
35747
- }
35748
- return formattedProxy;
35749
- }
35750
- exports.formatProxyOptions = formatProxyOptions;
35751
35733
  });
35752
35734
  var require_logger = __commonJSMin((exports) => {
35753
35735
  "use strict";
@@ -36247,7 +36229,6 @@ var require_constants = __commonJSMin((exports) => {
36247
36229
  "@modern-js/plugin-electron": { cli: "@modern-js/plugin-electron/cli" },
36248
36230
  "@modern-js/plugin-testing": { cli: "@modern-js/plugin-testing/cli" },
36249
36231
  "@modern-js/plugin-storybook": { cli: "@modern-js/plugin-storybook/cli" },
36250
- "@modern-js/plugin-docsite": { cli: "@modern-js/plugin-docsite/cli" },
36251
36232
  "@modern-js/plugin-express": {
36252
36233
  cli: "@modern-js/plugin-express/cli",
36253
36234
  server: "@modern-js/plugin-express"
@@ -36265,7 +36246,6 @@ var require_constants = __commonJSMin((exports) => {
36265
36246
  server: "@modern-js/plugin-nest/server"
36266
36247
  },
36267
36248
  "@modern-js/plugin-unbundle": { cli: "@modern-js/plugin-unbundle" },
36268
- "@modern-js/plugin-server-build": { cli: "@modern-js/plugin-server-build" },
36269
36249
  "@modern-js/plugin-server": {
36270
36250
  cli: "@modern-js/plugin-server/cli",
36271
36251
  server: "@modern-js/plugin-server/server"
@@ -36273,26 +36253,12 @@ var require_constants = __commonJSMin((exports) => {
36273
36253
  "@modern-js/plugin-garfish": {
36274
36254
  cli: "@modern-js/plugin-garfish/cli"
36275
36255
  },
36276
- "@modern-js/plugin-jarvis": { cli: "@modern-js/plugin-jarvis/cli" },
36277
36256
  "@modern-js/plugin-tailwindcss": { cli: "@modern-js/plugin-tailwindcss/cli" },
36278
- "@modern-js/plugin-lambda-fc": { cli: "@modern-js/plugin-lambda-fc/cli" },
36279
- "@modern-js/plugin-lambda-scf": { cli: "@modern-js/plugin-lambda-scf/cli" },
36280
- "@modern-js/plugin-cdn-oss": { cli: "@modern-js/plugin-cdn-oss/cli" },
36281
- "@modern-js/plugin-cdn-cos": { cli: "@modern-js/plugin-cdn-cos/cli" },
36282
- "@modern-js/plugin-static-hosting": {
36283
- cli: "@modern-js/plugin-static-hosting/cli"
36284
- },
36285
36257
  "@modern-js/plugin-polyfill": {
36286
36258
  cli: "@modern-js/plugin-polyfill/cli",
36287
36259
  server: "@modern-js/plugin-polyfill"
36288
36260
  },
36289
- "@modern-js/plugin-multiprocess": {
36290
- cli: "@modern-js/plugin-multiprocess/cli"
36291
- },
36292
- "@modern-js/plugin-nocode": { cli: "@modern-js/plugin-nocode/cli" },
36293
- "@modern-js/plugin-design-token": {
36294
- cli: "@modern-js/plugin-design-token/cli"
36295
- }
36261
+ "@modern-js/plugin-nocode": { cli: "@modern-js/plugin-nocode/cli" }
36296
36262
  };
36297
36263
  exports.PLUGIN_SCHEMAS = {
36298
36264
  "@modern-js/runtime": [
@@ -37280,8 +37246,8 @@ var require_analyzeProject = __commonJSMin((exports) => {
37280
37246
  exports.isApiOnly = void 0;
37281
37247
  var path = __importStar(__require("path"));
37282
37248
  var compiled_1 = require_compiled();
37283
- var isApiOnly = async (appDirectory) => {
37284
- const srcDir = path.join(appDirectory, "src");
37249
+ var isApiOnly = async (appDirectory, entryDir) => {
37250
+ const srcDir = path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src");
37285
37251
  const existSrc = await compiled_1.fs.pathExists(srcDir);
37286
37252
  const options2 = (0, compiled_1.minimist)(process.argv.slice(2));
37287
37253
  return !existSrc || Boolean(options2["api-only"]);
@@ -37295,7 +37261,18 @@ var require_chainId = __commonJSMin((exports) => {
37295
37261
  exports.CHAIN_ID = {
37296
37262
  RULE: {
37297
37263
  MJS: "mjs",
37298
- LOADERS: "loaders"
37264
+ LOADERS: "loaders",
37265
+ FONT: "font",
37266
+ IMAGE: "image",
37267
+ MEDIA: "media",
37268
+ JS: "js",
37269
+ TS: "ts",
37270
+ CSS: "css",
37271
+ LESS: "less",
37272
+ SASS: "sass",
37273
+ SVG: "svg",
37274
+ SVG_INLINE: "svg-inline",
37275
+ SVG_URL: "svg-url"
37299
37276
  },
37300
37277
  ONE_OF: {
37301
37278
  JS: "js",
@@ -37321,6 +37298,8 @@ var require_chainId = __commonJSMin((exports) => {
37321
37298
  USE: {
37322
37299
  TS: "ts",
37323
37300
  CSS: "css",
37301
+ SASS: "sass",
37302
+ LESS: "less",
37324
37303
  URL: "url",
37325
37304
  FILE: "file",
37326
37305
  SVGR: "svgr",
@@ -37349,6 +37328,7 @@ var require_chainId = __commonJSMin((exports) => {
37349
37328
  INLINE_HTML: "inline-html",
37350
37329
  BUNDLE_ANALYZER: "bundle-analyze",
37351
37330
  BOTTOM_TEMPLATE: "bottom-template",
37331
+ HTML_CROSS_ORIGIN: "html-cross-origin",
37352
37332
  MINI_CSS_EXTRACT: "mini-css-extract",
37353
37333
  REACT_FAST_REFRESH: "react-fast-refresh",
37354
37334
  NODE_POLYFILL_PROVIDE: "node-polyfill-provide"
@@ -37364,6 +37344,32 @@ var require_chainId = __commonJSMin((exports) => {
37364
37344
  }
37365
37345
  };
37366
37346
  });
37347
+ var require_reactVersion = __commonJSMin((exports) => {
37348
+ "use strict";
37349
+ var __importDefault = exports && exports.__importDefault || function(mod) {
37350
+ return mod && mod.__esModule ? mod : { "default": mod };
37351
+ };
37352
+ Object.defineProperty(exports, "__esModule", { value: true });
37353
+ exports.isReact18 = void 0;
37354
+ var path_1 = __importDefault(__require("path"));
37355
+ var compiled_1 = require_compiled();
37356
+ var isReact18 = (cwd) => {
37357
+ const pkgPath = path_1.default.join(cwd, "package.json");
37358
+ if (!compiled_1.fs.existsSync(pkgPath)) {
37359
+ return false;
37360
+ }
37361
+ const pkgInfo = JSON.parse(compiled_1.fs.readFileSync(pkgPath, "utf8"));
37362
+ const deps = {
37363
+ ...pkgInfo.devDependencies,
37364
+ ...pkgInfo.dependencies
37365
+ };
37366
+ if (typeof deps.react !== "string") {
37367
+ return false;
37368
+ }
37369
+ return compiled_1.semver.satisfies(compiled_1.semver.minVersion(deps.react), ">=18.0.0");
37370
+ };
37371
+ exports.isReact18 = isReact18;
37372
+ });
37367
37373
  var require_dist = __commonJSMin((exports) => {
37368
37374
  "use strict";
37369
37375
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
@@ -37423,6 +37429,7 @@ var require_dist = __commonJSMin((exports) => {
37423
37429
  __exportStar(require_tryResolve(), exports);
37424
37430
  __exportStar(require_analyzeProject(), exports);
37425
37431
  __exportStar(require_chainId(), exports);
37432
+ __exportStar(require_reactVersion(), exports);
37426
37433
  });
37427
37434
  var require_esprima = __commonJSMin((exports, module2) => {
37428
37435
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -45792,6 +45799,7 @@ var require_generator = __commonJSMin((exports) => {
45792
45799
  this.materialsManager = materialsManager;
45793
45800
  this.outputPath = outputPath;
45794
45801
  this.event = new _events.EventEmitter();
45802
+ this.event.setMaxListeners(15);
45795
45803
  this._context = _objectSpread({
45796
45804
  materials: {},
45797
45805
  config: {},
@@ -99707,7 +99715,6 @@ var ZH_LOCALE = {
99707
99715
  mwa_storybook: "\u542F\u7528\u300CVisual Testing (Storybook)\u300D\u6A21\u5F0F",
99708
99716
  ssg: "\u542F\u7528\u300CSSG\u300D\u529F\u80FD",
99709
99717
  polyfill: "\u542F\u7528\u300C\u57FA\u4E8E UA \u7684 Polyfill\u300D\u529F\u80FD",
99710
- deploy: "\u542F\u7528\u300C\u90E8\u7F72\u300D\u529F\u80FD",
99711
99718
  proxy: "\u542F\u7528\u300C\u5168\u5C40\u4EE3\u7406\u300D"
99712
99719
  },
99713
99720
  element: {
@@ -99735,22 +99742,15 @@ var ZH_LOCALE = {
99735
99742
  no: "\u4E0D\u9700\u8981",
99736
99743
  electron: "Electron"
99737
99744
  },
99738
- needModifyConfig: {
99739
- self: "\u662F\u5426\u9700\u8981\u8C03\u6574\u9ED8\u8BA4\u914D\u7F6E?",
99740
- enableLess: "\u662F\u5426\u542F\u7528 Less \u652F\u6301?",
99741
- enableSass: "\u662F\u5426\u542F\u7528 Sass \u652F\u6301?"
99742
- },
99743
99745
  entry: {
99744
99746
  name: "\u8BF7\u586B\u5199\u5165\u53E3\u540D\u79F0",
99745
99747
  no_empty: "\u5165\u53E3\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\uFF01",
99746
99748
  no_pages: '\u5165\u53E3\u540D\u79F0\u4E0D\u652F\u6301 "pages"\uFF01',
99747
99749
  needModifyConfig: "\u662F\u5426\u9700\u8981\u8C03\u6574\u9ED8\u8BA4\u914D\u7F6E?",
99748
- disableStateManagement: "\u662F\u5426\u5173\u95ED\u300C\u5E94\u7528\u72B6\u6001\u7BA1\u7406\u300D\u529F\u80FD?",
99749
99750
  clientRoute: {
99750
99751
  self: "\u8BF7\u9009\u62E9\u5BA2\u6237\u7AEF\u8DEF\u7531\u65B9\u5F0F",
99751
- selfControlRoute: "\u542F\u7528\u81EA\u63A7\u8DEF\u7531",
99752
- conventionalRoute: "\u542F\u7528\u7EA6\u5B9A\u5F0F\u8DEF\u7531",
99753
- no: "\u4E0D\u542F\u7528"
99752
+ selfControlRoute: "\u81EA\u63A7\u8DEF\u7531",
99753
+ conventionalRoute: "\u7EA6\u5B9A\u5F0F\u8DEF\u7531"
99754
99754
  }
99755
99755
  },
99756
99756
  packageName: {
@@ -99776,23 +99776,6 @@ var ZH_LOCALE = {
99776
99776
  func: "\u51FD\u6570\u6A21\u5F0F",
99777
99777
  framework: "\u6846\u67B6\u6A21\u5F0F"
99778
99778
  }
99779
- },
99780
- deploy: {
99781
- cloud: {
99782
- self: "\u9ED8\u8BA4\u4F7F\u7528\u6846\u67B6\u5185\u7F6E\u7684\u4EA7\u54C1\u7EA7 Web \u670D\u52A1\u5668\uFF0C\u662F\u5426\u8C03\u6574\uFF1F"
99783
- },
99784
- cdn: {
99785
- self: "\u8BF7\u9009\u62E9 CDN \u5E73\u53F0",
99786
- oss: "\u963F\u91CC\u4E91 OSS",
99787
- cos: "\u817E\u8BAF\u4E91 COS",
99788
- no: "\u4E0D\u4F7F\u7528 CDN"
99789
- },
99790
- lambda: {
99791
- self: "\u8BF7\u9009\u62E9\u4E91\u51FD\u6570\u5E73\u53F0",
99792
- fc: "\u963F\u91CC\u4E91 FC",
99793
- scf: "\u817E\u8BAF\u4E91 SCF",
99794
- no: "\u4E0D\u4F7F\u7528\u4E91\u51FD\u6570\u90E8\u7F72"
99795
- }
99796
99779
  }
99797
99780
  };
99798
99781
  var EN_LOCALE = {
@@ -99834,7 +99817,6 @@ var EN_LOCALE = {
99834
99817
  mwa_storybook: "Enable Visual Testing (Storybook)",
99835
99818
  ssg: "Enable SSG",
99836
99819
  polyfill: "Enable UA-based Polyfill Feature",
99837
- deploy: "Enable Deploy",
99838
99820
  proxy: "Enable Global Proxy"
99839
99821
  },
99840
99822
  element: {
@@ -99872,21 +99854,15 @@ var EN_LOCALE = {
99872
99854
  no: "Not Enabled",
99873
99855
  electron: "Electron"
99874
99856
  },
99875
- needModifyConfig: {
99876
- self: "Modify the Default Configuration?",
99877
- enableLess: "Enable Less?",
99878
- enableSass: "Enable Sass?"
99879
- },
99880
99857
  entry: {
99881
99858
  name: "Entry name",
99882
99859
  no_empty: "The entry name cannot be empty!",
99883
99860
  no_pages: 'The entry name cannot be "pages"!',
99884
- disableStateManagement: "Disable App State Management?",
99861
+ needModifyConfig: "Modify the Default Configuration?",
99885
99862
  clientRoute: {
99886
99863
  self: "Client Routing",
99887
- selfControlRoute: "Enable Self Control Route",
99888
- conventionalRoute: "Enable Conventional Route",
99889
- no: "Not Enabled"
99864
+ selfControlRoute: "Self Control Route",
99865
+ conventionalRoute: "Conventional Route"
99890
99866
  }
99891
99867
  },
99892
99868
  framework: {
@@ -99902,23 +99878,6 @@ var EN_LOCALE = {
99902
99878
  func: "Function",
99903
99879
  framework: "Framework"
99904
99880
  }
99905
- },
99906
- deploy: {
99907
- cloud: {
99908
- self: "Modify the default Web Server?"
99909
- },
99910
- cdn: {
99911
- self: "Please select the cdn platform you want to use",
99912
- oss: "Aliyun OSS",
99913
- cos: "Tencent COS",
99914
- no: "Not Enabled"
99915
- },
99916
- lambda: {
99917
- self: "Please select the lambda you want to use",
99918
- fc: "Aliyun FC",
99919
- scf: "Tencent SCF",
99920
- no: "Not Enabled"
99921
- }
99922
99881
  }
99923
99882
  };
99924
99883
  var i18n = new I18n2();
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.2.1",
14
+ "version": "2.3.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./src/index.ts",
17
17
  "main": "./dist/index.js",
@@ -21,15 +21,15 @@
21
21
  ],
22
22
  "devDependencies": {
23
23
  "@babel/runtime": "^7.18.0",
24
- "@modern-js/codesmith": "^1.4.0",
25
- "@modern-js/codesmith-api-app": "^1.3.0",
26
- "@modern-js/generator-common": "2.2.1",
24
+ "@modern-js/codesmith": "^1.5.0",
25
+ "@modern-js/codesmith-api-app": "^1.5.0",
26
+ "@modern-js/generator-common": "2.3.3",
27
+ "@scripts/build": "1.18.0",
28
+ "@scripts/jest-config": "1.18.0",
27
29
  "@types/jest": "^27",
28
30
  "@types/node": "^14",
29
- "typescript": "^4",
30
- "@scripts/build": "1.15.0",
31
31
  "jest": "^27",
32
- "@scripts/jest-config": "1.15.0"
32
+ "typescript": "^4"
33
33
  },
34
34
  "sideEffects": false,
35
35
  "modernConfig": {