@modern-js/server-generator 3.4.16 → 3.5.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.
Files changed (3) hide show
  1. package/dist/index.js +578 -588
  2. package/package.json +7 -7
  3. package/src/index.ts +8 -8
package/dist/index.js CHANGED
@@ -210,7 +210,7 @@ var require_package = __commonJS({
210
210
  var require_ejs = __commonJS({
211
211
  "../../../../node_modules/.pnpm/ejs@3.1.9/node_modules/ejs/lib/ejs.js"(exports) {
212
212
  "use strict";
213
- var fs8 = require("fs");
213
+ var fs7 = require("fs");
214
214
  var path7 = require("path");
215
215
  var utils = require_utils();
216
216
  var scopeOptionWarned = false;
@@ -238,7 +238,7 @@ var require_ejs = __commonJS({
238
238
  var _BOM = /^\uFEFF/;
239
239
  var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
240
240
  exports.cache = utils.cache;
241
- exports.fileLoader = fs8.readFileSync;
241
+ exports.fileLoader = fs7.readFileSync;
242
242
  exports.localsName = _DEFAULT_LOCALS_NAME;
243
243
  exports.promiseImpl = new Function("return this;")().Promise;
244
244
  exports.resolveInclude = function(name, filename, isDir) {
@@ -256,7 +256,7 @@ var require_ejs = __commonJS({
256
256
  var filePath;
257
257
  if (paths.some(function(v) {
258
258
  filePath = exports.resolveInclude(name, v, true);
259
- return fs8.existsSync(filePath);
259
+ return fs7.existsSync(filePath);
260
260
  })) {
261
261
  return filePath;
262
262
  }
@@ -276,7 +276,7 @@ var require_ejs = __commonJS({
276
276
  } else {
277
277
  if (options.filename) {
278
278
  filePath = exports.resolveInclude(path8, options.filename);
279
- if (fs8.existsSync(filePath)) {
279
+ if (fs7.existsSync(filePath)) {
280
280
  includePath = filePath;
281
281
  }
282
282
  }
@@ -6612,8 +6612,8 @@ var require_lib = __commonJS({
6612
6612
  handlebars2.print = printer.print;
6613
6613
  module2.exports = handlebars2;
6614
6614
  function extension(module3, filename) {
6615
- var fs8 = require("fs");
6616
- var templateString = fs8.readFileSync(filename, "utf8");
6615
+ var fs7 = require("fs");
6616
+ var templateString = fs7.readFileSync(filename, "utf8");
6617
6617
  module3.exports = handlebars2.compile(templateString);
6618
6618
  }
6619
6619
  if (typeof require !== "undefined" && require.extensions) {
@@ -36072,7 +36072,7 @@ var require_iso2022 = __commonJS({
36072
36072
  var require_chardet = __commonJS({
36073
36073
  "../../../../node_modules/.pnpm/chardet@0.7.0/node_modules/chardet/index.js"(exports, module2) {
36074
36074
  "use strict";
36075
- var fs8 = require("fs");
36075
+ var fs7 = require("fs");
36076
36076
  var utf8 = require_utf8();
36077
36077
  var unicode = require_unicode();
36078
36078
  var mbcs = require_mbcs();
@@ -36146,29 +36146,29 @@ var require_chardet = __commonJS({
36146
36146
  var fd;
36147
36147
  var handler = function(err, buffer) {
36148
36148
  if (fd) {
36149
- fs8.closeSync(fd);
36149
+ fs7.closeSync(fd);
36150
36150
  }
36151
36151
  if (err)
36152
36152
  return cb(err, null);
36153
36153
  cb(null, self3.detect(buffer, opts));
36154
36154
  };
36155
36155
  if (opts && opts.sampleSize) {
36156
- fd = fs8.openSync(filepath, "r"), sample = Buffer.allocUnsafe(opts.sampleSize);
36157
- fs8.read(fd, sample, 0, opts.sampleSize, null, function(err) {
36156
+ fd = fs7.openSync(filepath, "r"), sample = Buffer.allocUnsafe(opts.sampleSize);
36157
+ fs7.read(fd, sample, 0, opts.sampleSize, null, function(err) {
36158
36158
  handler(err, sample);
36159
36159
  });
36160
36160
  return;
36161
36161
  }
36162
- fs8.readFile(filepath, handler);
36162
+ fs7.readFile(filepath, handler);
36163
36163
  };
36164
36164
  module2.exports.detectFileSync = function(filepath, opts) {
36165
36165
  if (opts && opts.sampleSize) {
36166
- var fd = fs8.openSync(filepath, "r"), sample2 = Buffer.allocUnsafe(opts.sampleSize);
36167
- fs8.readSync(fd, sample2, 0, opts.sampleSize);
36168
- fs8.closeSync(fd);
36166
+ var fd = fs7.openSync(filepath, "r"), sample2 = Buffer.allocUnsafe(opts.sampleSize);
36167
+ fs7.readSync(fd, sample2, 0, opts.sampleSize);
36168
+ fs7.closeSync(fd);
36169
36169
  return self3.detect(sample2, opts);
36170
36170
  }
36171
- return self3.detect(fs8.readFileSync(filepath), opts);
36171
+ return self3.detect(fs7.readFileSync(filepath), opts);
36172
36172
  };
36173
36173
  module2.exports.detectAll = function(buffer, opts) {
36174
36174
  if (typeof opts !== "object") {
@@ -39672,7 +39672,7 @@ var require_os_tmpdir = __commonJS({
39672
39672
  var require_tmp = __commonJS({
39673
39673
  "../../../../node_modules/.pnpm/tmp@0.0.33/node_modules/tmp/lib/tmp.js"(exports, module2) {
39674
39674
  "use strict";
39675
- var fs8 = require("fs");
39675
+ var fs7 = require("fs");
39676
39676
  var path7 = require("path");
39677
39677
  var crypto = require("crypto");
39678
39678
  var osTmpDir = require_os_tmpdir();
@@ -39736,7 +39736,7 @@ var require_tmp = __commonJS({
39736
39736
  return cb(new Error("Invalid template provided"));
39737
39737
  (function _getUniqueName() {
39738
39738
  const name = _generateTmpName(opts);
39739
- fs8.stat(name, function(err) {
39739
+ fs7.stat(name, function(err) {
39740
39740
  if (!err) {
39741
39741
  if (tries-- > 0)
39742
39742
  return _getUniqueName();
@@ -39755,7 +39755,7 @@ var require_tmp = __commonJS({
39755
39755
  do {
39756
39756
  const name = _generateTmpName(opts);
39757
39757
  try {
39758
- fs8.statSync(name);
39758
+ fs7.statSync(name);
39759
39759
  } catch (e) {
39760
39760
  return name;
39761
39761
  }
@@ -39768,14 +39768,14 @@ var require_tmp = __commonJS({
39768
39768
  tmpName(opts, function _tmpNameCreated(err, name) {
39769
39769
  if (err)
39770
39770
  return cb(err);
39771
- fs8.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
39771
+ fs7.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
39772
39772
  if (err2)
39773
39773
  return cb(err2);
39774
39774
  if (opts.discardDescriptor) {
39775
- return fs8.close(fd, function _discardCallback(err3) {
39775
+ return fs7.close(fd, function _discardCallback(err3) {
39776
39776
  if (err3) {
39777
39777
  try {
39778
- fs8.unlinkSync(name);
39778
+ fs7.unlinkSync(name);
39779
39779
  } catch (e) {
39780
39780
  if (!isENOENT(e)) {
39781
39781
  err3 = e;
@@ -39798,9 +39798,9 @@ var require_tmp = __commonJS({
39798
39798
  opts.postfix = opts.postfix || ".tmp";
39799
39799
  const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
39800
39800
  const name = tmpNameSync(opts);
39801
- var fd = fs8.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
39801
+ var fd = fs7.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
39802
39802
  if (opts.discardDescriptor) {
39803
- fs8.closeSync(fd);
39803
+ fs7.closeSync(fd);
39804
39804
  fd = void 0;
39805
39805
  }
39806
39806
  return {
@@ -39812,9 +39812,9 @@ var require_tmp = __commonJS({
39812
39812
  function _rmdirRecursiveSync(root) {
39813
39813
  const dirs = [root];
39814
39814
  do {
39815
- var dir2 = dirs.pop(), deferred = false, files = fs8.readdirSync(dir2);
39815
+ var dir2 = dirs.pop(), deferred = false, files = fs7.readdirSync(dir2);
39816
39816
  for (var i = 0, length = files.length; i < length; i++) {
39817
- var file2 = path7.join(dir2, files[i]), stat = fs8.lstatSync(file2);
39817
+ var file2 = path7.join(dir2, files[i]), stat = fs7.lstatSync(file2);
39818
39818
  if (stat.isDirectory()) {
39819
39819
  if (!deferred) {
39820
39820
  deferred = true;
@@ -39822,11 +39822,11 @@ var require_tmp = __commonJS({
39822
39822
  }
39823
39823
  dirs.push(file2);
39824
39824
  } else {
39825
- fs8.unlinkSync(file2);
39825
+ fs7.unlinkSync(file2);
39826
39826
  }
39827
39827
  }
39828
39828
  if (!deferred) {
39829
- fs8.rmdirSync(dir2);
39829
+ fs7.rmdirSync(dir2);
39830
39830
  }
39831
39831
  } while (dirs.length !== 0);
39832
39832
  }
@@ -39835,7 +39835,7 @@ var require_tmp = __commonJS({
39835
39835
  tmpName(opts, function _tmpNameCreated(err, name) {
39836
39836
  if (err)
39837
39837
  return cb(err);
39838
- fs8.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
39838
+ fs7.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
39839
39839
  if (err2)
39840
39840
  return cb(err2);
39841
39841
  cb(null, name, _prepareTmpDirRemoveCallback(name, opts));
@@ -39845,7 +39845,7 @@ var require_tmp = __commonJS({
39845
39845
  function dirSync(options) {
39846
39846
  var args = _parseArguments(options), opts = args[0];
39847
39847
  const name = tmpNameSync(opts);
39848
- fs8.mkdirSync(name, opts.mode || DIR_MODE);
39848
+ fs7.mkdirSync(name, opts.mode || DIR_MODE);
39849
39849
  return {
39850
39850
  name,
39851
39851
  removeCallback: _prepareTmpDirRemoveCallback(name, opts)
@@ -39855,7 +39855,7 @@ var require_tmp = __commonJS({
39855
39855
  const removeCallback = _prepareRemoveCallback(function _removeCallback(fdPath) {
39856
39856
  try {
39857
39857
  if (0 <= fdPath[0]) {
39858
- fs8.closeSync(fdPath[0]);
39858
+ fs7.closeSync(fdPath[0]);
39859
39859
  }
39860
39860
  } catch (e) {
39861
39861
  if (!isEBADF(e) && !isENOENT(e)) {
@@ -39863,7 +39863,7 @@ var require_tmp = __commonJS({
39863
39863
  }
39864
39864
  }
39865
39865
  try {
39866
- fs8.unlinkSync(fdPath[1]);
39866
+ fs7.unlinkSync(fdPath[1]);
39867
39867
  } catch (e) {
39868
39868
  if (!isENOENT(e)) {
39869
39869
  throw e;
@@ -39876,7 +39876,7 @@ var require_tmp = __commonJS({
39876
39876
  return removeCallback;
39877
39877
  }
39878
39878
  function _prepareTmpDirRemoveCallback(name, opts) {
39879
- const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs8.rmdirSync.bind(fs8);
39879
+ const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs7.rmdirSync.bind(fs7);
39880
39880
  const removeCallback = _prepareRemoveCallback(removeFunction, name);
39881
39881
  if (!opts.keep) {
39882
39882
  _removeObjects.unshift(removeCallback);
@@ -52688,476 +52688,16 @@ __export(src_exports, {
52688
52688
  module.exports = __toCommonJS(src_exports);
52689
52689
  var import_path7 = __toESM(require("path"));
52690
52690
 
52691
- // ../../generator-utils/dist/esm/index.js
52692
- var import_path2 = __toESM(require("path"));
52693
- var import_utils3 = require("@modern-js/utils");
52694
-
52695
- // ../../../cli/plugin-i18n/dist/esm-node/index.js
52696
- var import_lodash2 = require("@modern-js/utils/lodash");
52697
-
52698
- // ../../../cli/plugin-i18n/dist/esm-node/utils/index.js
52699
- var import_lodash = require("@modern-js/utils/lodash");
52700
- function getObjKeyMap(obj, prefix = "") {
52701
- const result = {};
52702
- Object.keys(obj).forEach((key) => {
52703
- if ((0, import_lodash.isString)(obj[key])) {
52704
- result[key] = prefix ? `${prefix}.${key}` : key;
52705
- } else if ((0, import_lodash.isObject)(obj[key])) {
52706
- result[key] = getObjKeyMap(obj[key], prefix ? `${prefix}.${key}` : key);
52707
- }
52708
- });
52709
- return result;
52710
- }
52711
-
52712
- // ../../../cli/plugin-i18n/dist/esm-node/index.js
52713
- var I18n = class {
52714
- format(msg, vars) {
52715
- return msg.replace(/\{(\w+)\}/g, (_match, capture) => Object.prototype.hasOwnProperty.call(vars, capture) ? vars[capture] : capture);
52716
- }
52717
- getMessage(lang, key, vars, fallbackText) {
52718
- const languages = Object.keys(this.languageMap);
52719
- const resultLang = languages.find((l) => l === lang);
52720
- if (!resultLang && languages.length === 0) {
52721
- return fallbackText || key;
52722
- }
52723
- const model = this.languageMap[resultLang || "en"];
52724
- if (!model) {
52725
- return fallbackText || key;
52726
- }
52727
- const message = (0, import_lodash2.get)(model, key);
52728
- const value = message || fallbackText || key;
52729
- if (typeof value === "string") {
52730
- return this.format(value, vars || {});
52731
- }
52732
- throw new Error("key is not a string");
52733
- }
52734
- init(language, languageMap) {
52735
- this.language = language || "en";
52736
- if (languageMap) {
52737
- this.languageMap = languageMap;
52738
- }
52739
- return getObjKeyMap(this.languageMap[this.language]);
52740
- }
52741
- changeLanguage(config) {
52742
- this.language = config.locale || "en";
52743
- }
52744
- t(key, vars, fallbackText) {
52745
- return this.getMessage(this.language, key, vars, fallbackText);
52746
- }
52747
- lang(lang) {
52748
- return {
52749
- t: (key, vars, fallbackText) => this.getMessage(lang, key, vars, fallbackText)
52750
- };
52751
- }
52752
- constructor() {
52753
- this.language = "en";
52754
- this.languageMap = {};
52755
- }
52756
- };
52757
-
52758
- // ../../generator-common/dist/esm-node/locale/zh.js
52759
- var ZH_LOCALE = {
52760
- solution: {
52761
- self: "请选择你想创建的工程类型",
52762
- mwa: "Web 应用",
52763
- module: "Npm 模块",
52764
- custom: "自定义",
52765
- default: "默认"
52766
- },
52767
- scenes: {
52768
- self: "请选择项目场景"
52769
- },
52770
- sub_solution: {
52771
- self: "请选择你想创建的工程类型",
52772
- mwa: "Web 应用",
52773
- module: "Npm 模块"
52774
- },
52775
- action: {
52776
- self: "请选择你想要的操作",
52777
- function: {
52778
- self: "启用可选功能",
52779
- question: "请选择功能名称",
52780
- tailwindcss: "启用「Tailwind CSS」 支持",
52781
- bff: "启用「BFF」功能",
52782
- micro_frontend: "启用「微前端」模式",
52783
- i18n: "启用「国际化(i18n)」功能",
52784
- storybookV7: "启用「Storybook」V7",
52785
- runtime_api: "启用「Runtime API」",
52786
- ssg: "启用「SSG」功能",
52787
- polyfill: "启用「基于 UA 的 Polyfill」功能",
52788
- proxy: "启用「全局代理」",
52789
- swc: "启用「SWC 编译」",
52790
- module_doc: "启动「模块文档」功能"
52791
- },
52792
- element: {
52793
- self: "创建工程元素",
52794
- question: "请选择创建元素类型",
52795
- entry: "新建「应用入口」",
52796
- server: "新建「自定义 Web Server」源码目录"
52797
- },
52798
- refactor: {
52799
- self: "自动重构",
52800
- question: "请选择重构类型",
52801
- react_router_5: "使用 React Router v5"
52802
- }
52803
- },
52804
- boolean: {
52805
- yes: "是",
52806
- no: "否"
52807
- },
52808
- language: {
52809
- self: "请选择开发语言"
52810
- },
52811
- packageManager: {
52812
- self: "请选择包管理工具"
52813
- },
52814
- entry: {
52815
- name: "请填写入口名称",
52816
- no_empty: "入口名称不能为空!",
52817
- no_pages: '入口名称不支持 "pages"!'
52818
- },
52819
- packageName: {
52820
- self: "请填写项目名称",
52821
- sub_name: "请填写子项目名称",
52822
- no_empty: "项目名称不能为空!"
52823
- },
52824
- packagePath: {
52825
- self: "请填写子项目目录名称",
52826
- no_empty: "目录名称不能为空!",
52827
- format: "目录名称只能使用小写字母、数字和分隔线(-)、下划线(_)和目录分隔符(/)"
52828
- },
52829
- framework: {
52830
- self: "请选择运行时框架",
52831
- egg: "Egg",
52832
- express: "Express",
52833
- koa: "Koa",
52834
- nest: "Nest"
52835
- },
52836
- bff: {
52837
- bffType: {
52838
- self: "请选择 BFF 类型",
52839
- func: "函数模式",
52840
- framework: "框架模式"
52841
- }
52842
- },
52843
- buildTools: {
52844
- self: "请选择构建工具",
52845
- webpack: "webpack",
52846
- rspack: "Rspack (实验性)"
52847
- }
52848
- };
52849
-
52850
- // ../../generator-common/dist/esm-node/locale/en.js
52851
- var EN_LOCALE = {
52852
- solution: {
52853
- self: "Please select the type of project you want to create:",
52854
- mwa: "Web App",
52855
- module: "Npm Module",
52856
- custom: "Custom Solution",
52857
- default: "Default"
52858
- },
52859
- scenes: {
52860
- self: "Please select the project scenario:"
52861
- },
52862
- sub_solution: {
52863
- self: "Please select the type of project you want to create:",
52864
- mwa: "Web App",
52865
- module: "Npm Module"
52866
- },
52867
- action: {
52868
- self: "Please select the operation you want:",
52869
- function: {
52870
- self: "Enable Features",
52871
- question: "Please select the feature name:",
52872
- tailwindcss: "Enable Tailwind CSS",
52873
- bff: "Enable BFF",
52874
- micro_frontend: "Enable Micro Frontend",
52875
- i18n: "Enable Internationalization (i18n)",
52876
- storybookV7: "Enable Storybook V7",
52877
- runtime_api: "Enable Runtime API",
52878
- ssg: "Enable SSG",
52879
- polyfill: "Enable UA-based Polyfill Feature",
52880
- proxy: "Enable Global Proxy",
52881
- swc: "Enable SWC Compile",
52882
- module_doc: "Enable Module Doc"
52883
- },
52884
- element: {
52885
- self: "Create Element",
52886
- question: "Please select the type of element to create:",
52887
- entry: 'New "entry"',
52888
- server: 'New "Custom Web Server" source code directory'
52889
- },
52890
- refactor: {
52891
- self: "Automatic Refactor",
52892
- question: "Please select the type of refactoring:",
52893
- react_router_5: "Use React Router v5"
52894
- }
52895
- },
52896
- boolean: {
52897
- yes: "Yes",
52898
- no: "No"
52899
- },
52900
- language: {
52901
- self: "Please select the programming language:"
52902
- },
52903
- packageManager: {
52904
- self: "Please select the package manager:"
52905
- },
52906
- entry: {
52907
- name: "Please fill in the entry name:",
52908
- no_empty: "The entry name cannot be empty!",
52909
- no_pages: 'The entry name cannot be "pages"!'
52910
- },
52911
- packageName: {
52912
- self: "Please fill in the project name:",
52913
- sub_name: "Please fill in the sub-project name:",
52914
- no_empty: "The package name cannot be empty!"
52915
- },
52916
- packagePath: {
52917
- self: "Please fill in the sub-project directory name:",
52918
- no_empty: "The package path cannot be empty!",
52919
- format: "Only lowercase letters, numbers and delimiters (-), and underscore (_), and directory delimiters (/) can be used in package path."
52920
- },
52921
- framework: {
52922
- self: "Please select the framework:",
52923
- egg: "Egg",
52924
- express: "Express",
52925
- koa: "Koa",
52926
- nest: "Nest"
52927
- },
52928
- bff: {
52929
- bffType: {
52930
- self: "Please select the BFF type:",
52931
- func: "Function",
52932
- framework: "Framework"
52933
- }
52934
- },
52935
- buildTools: {
52936
- self: "Please select the bundler:",
52937
- webpack: "webpack",
52938
- rspack: "Rspack (experimental)"
52939
- }
52940
- };
52941
-
52942
- // ../../generator-common/dist/esm-node/locale/index.js
52943
- var i18n = new I18n();
52944
- var localeKeys = i18n.init("en", {
52945
- zh: ZH_LOCALE,
52946
- en: EN_LOCALE
52947
- });
52948
-
52949
- // ../../generator-common/dist/esm-node/common/solution.js
52950
- var Solution;
52951
- (function(Solution2) {
52952
- Solution2["MWA"] = "mwa";
52953
- Solution2["Module"] = "module";
52954
- })(Solution || (Solution = {}));
52955
- var SolutionToolsMap = {
52956
- ["mwa"]: "@modern-js/app-tools",
52957
- ["module"]: "@modern-js/module-tools"
52958
- };
52959
- var DependenceGenerator = "@modern-js/dependence-generator";
52960
-
52961
- // ../../generator-common/dist/esm-node/common/language.js
52962
- var Language;
52963
- (function(Language2) {
52964
- Language2["TS"] = "ts";
52965
- Language2["JS"] = "js";
52966
- })(Language || (Language = {}));
52967
-
52968
- // ../../generator-utils/dist/esm/utils/stripAnsi.js
52969
- function ansiRegex({ onlyFirst = false } = {}) {
52970
- const pattern = [
52971
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
52972
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
52973
- ].join("|");
52974
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
52975
- }
52976
- function stripAnsi(string) {
52977
- if (typeof string !== "string") {
52978
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
52979
- }
52980
- return string.replace(ansiRegex(), "");
52981
- }
52982
-
52983
- // ../../generator-utils/dist/esm/utils/package.js
52984
- var import_utils2 = require("@modern-js/utils");
52985
- async function isPackageExist(packageName, registry2) {
52986
- if (await (0, import_utils2.canUseNpm)()) {
52987
- try {
52988
- const args = [
52989
- "view",
52990
- packageName,
52991
- "version"
52992
- ];
52993
- if (registry2) {
52994
- args.push(`--registry=${registry2}`);
52995
- }
52996
- const result = await (0, import_utils2.execa)("npm", args);
52997
- return (0, import_utils2.stripAnsi)(result.stdout);
52998
- } catch (e) {
52999
- return false;
53000
- }
53001
- }
53002
- throw new Error("not found npm, please install npm before");
53003
- }
53004
- async function isPackageDeprecated(packageName, registry2) {
53005
- if (await (0, import_utils2.canUseNpm)()) {
53006
- const args = [
53007
- "view",
53008
- packageName,
53009
- "deprecated"
53010
- ];
53011
- if (registry2) {
53012
- args.push(`--registry=${registry2}`);
53013
- }
53014
- const result = await (0, import_utils2.execa)("npm", args);
53015
- return (0, import_utils2.stripAnsi)(result.stdout);
53016
- }
53017
- throw new Error("not found npm, please install npm before");
53018
- }
53019
- function semverDecrease(version) {
53020
- const versionObj = import_utils2.semver.parse(version, {
53021
- loose: true
53022
- });
53023
- if (!versionObj) {
53024
- throw new Error(`Version ${version} is not valid semver`);
53025
- }
53026
- versionObj.build = [];
53027
- versionObj.prerelease = [];
53028
- versionObj.patch--;
53029
- const result = versionObj.format();
53030
- if (!import_utils2.semver.valid(result)) {
53031
- import_utils2.logger.debug(`Version ${result} is not valid semver`);
53032
- return version;
53033
- }
53034
- return result;
53035
- }
53036
- async function getAvailableVersion(packageName, currentVersion, registry2) {
53037
- let times = 5;
53038
- let version = currentVersion;
53039
- while (times) {
53040
- if (!await isPackageExist(`${packageName}@${version}`, registry2) || await isPackageDeprecated(`${packageName}@${version}`, registry2)) {
53041
- version = import_utils2.semver.inc(version, "patch");
53042
- times--;
53043
- continue;
53044
- }
53045
- return version;
53046
- }
53047
- times = 5;
53048
- while (times) {
53049
- version = semverDecrease(version);
53050
- if (!await isPackageExist(`${packageName}@${version}`, registry2) || await isPackageDeprecated(`${packageName}@${version}`, registry2)) {
53051
- times--;
53052
- continue;
53053
- }
53054
- return version;
53055
- }
53056
- return currentVersion;
53057
- }
53058
-
53059
- // ../../generator-utils/dist/esm/utils/getGeneratorPath.js
53060
- var import_path = __toESM(require("path"));
53061
- var getGeneratorPath = (generator, distTag, paths) => {
53062
- if (process.env.CODESMITH_ENV === "development") {
53063
- return import_path.default.dirname(require.resolve(generator, {
53064
- paths: paths !== null && paths !== void 0 ? paths : [
53065
- process.cwd()
53066
- ]
53067
- }));
53068
- } else if (distTag) {
53069
- return `${generator}@${distTag}`;
53070
- }
53071
- return generator;
53072
- };
53073
-
53074
- // ../../generator-utils/dist/esm/index.js
53075
- var import_utils4 = require("@modern-js/utils");
53076
- async function getPackageVersion(packageName, registry2) {
53077
- const spinner = (0, import_utils3.ora)({
53078
- text: "Load Generator...",
53079
- spinner: "runner"
53080
- }).start();
53081
- if (await (0, import_utils3.canUsePnpm)()) {
53082
- const args = [
53083
- "info",
53084
- packageName,
53085
- "version"
53086
- ];
53087
- if (registry2) {
53088
- args.push(`--registry=${registry2}`);
53089
- }
53090
- const result = await (0, import_utils3.execa)("pnpm", args);
53091
- spinner.stop();
53092
- return stripAnsi(result.stdout);
53093
- }
53094
- if (await (0, import_utils3.canUseNpm)()) {
53095
- const args = [
53096
- "view",
53097
- packageName,
53098
- "version"
53099
- ];
53100
- if (registry2) {
53101
- args.push(`--registry=${registry2}`);
53102
- }
53103
- const result = await (0, import_utils3.execa)("npm", args);
53104
- spinner.stop();
53105
- return stripAnsi(result.stdout);
53106
- }
53107
- spinner.stop();
53108
- throw new Error("not found npm, please install npm before");
53109
- }
53110
- async function getModernPluginVersion(solution, packageName, options = {
53111
- distTag: "latest"
53112
- }) {
53113
- const { cwd = process.cwd(), registry: registry2, distTag } = options;
53114
- const getLatetPluginVersion = async (tag) => {
53115
- const version = await getPackageVersion(`${packageName}@${tag || distTag || "latest"}`, registry2);
53116
- return version;
53117
- };
53118
- if (!packageName.startsWith("@modern-js") || packageName.includes("electron") || packageName.includes("codesmith") || packageName.includes("easy-form") || packageName.startsWith("@modern-js-reduck")) {
53119
- return getLatetPluginVersion("latest");
53120
- }
53121
- let pkgPath = import_path2.default.join(require.resolve(SolutionToolsMap[solution], {
53122
- paths: [
53123
- cwd
53124
- ]
53125
- }), "../../..", "package.json");
53126
- if (solution === Solution.Module) {
53127
- pkgPath = import_path2.default.join(require.resolve(SolutionToolsMap[solution], {
53128
- paths: [
53129
- cwd
53130
- ]
53131
- }), "../..", "package.json");
53132
- }
53133
- if (import_utils3.fs.existsSync(pkgPath)) {
53134
- const pkgInfo = import_utils3.fs.readJSONSync(pkgPath);
53135
- const modernVersion = pkgInfo.version;
53136
- if (typeof modernVersion !== "string") {
53137
- return getLatetPluginVersion();
53138
- }
53139
- const version = await getAvailableVersion(packageName, modernVersion, registry2);
53140
- if (!await isPackageExist(`${packageName}@${version}`)) {
53141
- return getLatetPluginVersion();
53142
- }
53143
- return version;
53144
- }
53145
- return getLatetPluginVersion();
53146
- }
53147
- function isTsProject(appDir) {
53148
- return import_utils3.fs.existsSync(import_path2.default.join(appDir, "tsconfig.json"));
53149
- }
53150
-
53151
52691
  // ../../../../node_modules/.pnpm/@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith/dist/esm-node/materials/FsResource.js
53152
- var import_path3 = __toESM(require("path"));
53153
- var import_utils5 = require("@modern-js/utils");
52692
+ var import_path = __toESM(require("path"));
52693
+ var import_utils = require("@modern-js/utils");
53154
52694
  var FS_RESOURCE = "_codesmith_core_fs_resource";
53155
52695
 
53156
52696
  // ../../../../node_modules/.pnpm/@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith/dist/esm-node/utils/fsExists.js
53157
- var import_utils6 = require("@modern-js/utils");
52697
+ var import_utils2 = require("@modern-js/utils");
53158
52698
  async function fsExists(path7) {
53159
52699
  try {
53160
- await import_utils6.fs.access(path7);
52700
+ await import_utils2.fs.access(path7);
53161
52701
  return true;
53162
52702
  } catch (e) {
53163
52703
  return false;
@@ -53203,16 +52743,16 @@ var EjsAPI = class {
53203
52743
  };
53204
52744
 
53205
52745
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-fs@2.4.1_@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith-api-fs/dist/esm-node/index.js
53206
- var import_path4 = __toESM(require("path"));
53207
- var import_utils8 = require("@modern-js/utils");
52746
+ var import_path2 = __toESM(require("path"));
52747
+ var import_utils4 = require("@modern-js/utils");
53208
52748
  var FsAPI = class {
53209
52749
  async renderFile(resource, target) {
53210
52750
  if (resource._type !== FS_RESOURCE) {
53211
52751
  throw new Error("resource not match");
53212
52752
  }
53213
- const filePath = import_path4.default.resolve(this.generatorCore.outputPath, target.toString());
53214
- await import_utils8.fs.mkdirp(import_path4.default.dirname(filePath));
53215
- await import_utils8.fs.copyFile(resource.filePath, filePath);
52753
+ const filePath = import_path2.default.resolve(this.generatorCore.outputPath, target.toString());
52754
+ await import_utils4.fs.mkdirp(import_path2.default.dirname(filePath));
52755
+ await import_utils4.fs.copyFile(resource.filePath, filePath);
53216
52756
  }
53217
52757
  async renderDir(material, findGlob, target, options) {
53218
52758
  const resourceMap = await material.find(findGlob, {
@@ -53230,10 +52770,10 @@ var FsAPI = class {
53230
52770
  };
53231
52771
 
53232
52772
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-git@2.4.1_@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith-api-git/dist/esm-node/utils/index.js
53233
- var import_utils9 = require("@modern-js/utils");
52773
+ var import_utils5 = require("@modern-js/utils");
53234
52774
  async function canUseGit() {
53235
52775
  try {
53236
- await (0, import_utils9.execa)("git", [
52776
+ await (0, import_utils5.execa)("git", [
53237
52777
  "--version"
53238
52778
  ], {
53239
52779
  env: process.env
@@ -53245,7 +52785,7 @@ async function canUseGit() {
53245
52785
  }
53246
52786
  async function isInGitRepo(cwd) {
53247
52787
  try {
53248
- await (0, import_utils9.execa)("git", [
52788
+ await (0, import_utils5.execa)("git", [
53249
52789
  "rev-parse",
53250
52790
  "--is-inside-work-tree"
53251
52791
  ], {
@@ -53258,13 +52798,13 @@ async function isInGitRepo(cwd) {
53258
52798
  }
53259
52799
  }
53260
52800
  async function initGitRepo(cwd, defaultBranch) {
53261
- await (0, import_utils9.execa)("git", [
52801
+ await (0, import_utils5.execa)("git", [
53262
52802
  "init"
53263
52803
  ], {
53264
52804
  env: process.env,
53265
52805
  cwd
53266
52806
  });
53267
- const { stdout } = await (0, import_utils9.execa)("git", [
52807
+ const { stdout } = await (0, import_utils5.execa)("git", [
53268
52808
  "symbolic-ref",
53269
52809
  "--short",
53270
52810
  "HEAD"
@@ -53273,7 +52813,7 @@ async function initGitRepo(cwd, defaultBranch) {
53273
52813
  cwd
53274
52814
  });
53275
52815
  if (stdout !== defaultBranch) {
53276
- await (0, import_utils9.execa)("git", [
52816
+ await (0, import_utils5.execa)("git", [
53277
52817
  "checkout",
53278
52818
  "-b",
53279
52819
  defaultBranch
@@ -53284,7 +52824,7 @@ async function initGitRepo(cwd, defaultBranch) {
53284
52824
  }
53285
52825
  }
53286
52826
  async function gitAdd(cwd) {
53287
- await (0, import_utils9.execa)("git", [
52827
+ await (0, import_utils5.execa)("git", [
53288
52828
  "add",
53289
52829
  "-A"
53290
52830
  ], {
@@ -53293,7 +52833,7 @@ async function gitAdd(cwd) {
53293
52833
  });
53294
52834
  }
53295
52835
  async function gitCommit(cwd, commitMessage) {
53296
- await (0, import_utils9.execa)("git", [
52836
+ await (0, import_utils5.execa)("git", [
53297
52837
  "commit",
53298
52838
  "-m",
53299
52839
  commitMessage,
@@ -53417,10 +52957,10 @@ var HandlebarsAPI = class {
53417
52957
  };
53418
52958
 
53419
52959
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.1/node_modules/@modern-js/codesmith-api-npm/dist/esm-node/utils/env.js
53420
- var import_utils12 = require("@modern-js/utils");
52960
+ var import_utils8 = require("@modern-js/utils");
53421
52961
  async function canUseNvm() {
53422
52962
  try {
53423
- await (0, import_utils12.execa)("source ~/.nvm/nvm.sh", {
52963
+ await (0, import_utils8.execa)("source ~/.nvm/nvm.sh", {
53424
52964
  env: process.env,
53425
52965
  shell: true
53426
52966
  });
@@ -53429,9 +52969,9 @@ async function canUseNvm() {
53429
52969
  return false;
53430
52970
  }
53431
52971
  }
53432
- async function canUseNpm3() {
52972
+ async function canUseNpm() {
53433
52973
  try {
53434
- await (0, import_utils12.execa)("npm", [
52974
+ await (0, import_utils8.execa)("npm", [
53435
52975
  "--version"
53436
52976
  ], {
53437
52977
  env: process.env
@@ -53441,9 +52981,9 @@ async function canUseNpm3() {
53441
52981
  return false;
53442
52982
  }
53443
52983
  }
53444
- async function canUseYarn2() {
52984
+ async function canUseYarn() {
53445
52985
  try {
53446
- await (0, import_utils12.execa)("yarn", [
52986
+ await (0, import_utils8.execa)("yarn", [
53447
52987
  "--version"
53448
52988
  ], {
53449
52989
  env: process.env
@@ -53453,9 +52993,9 @@ async function canUseYarn2() {
53453
52993
  return false;
53454
52994
  }
53455
52995
  }
53456
- async function canUsePnpm3() {
52996
+ async function canUsePnpm() {
53457
52997
  try {
53458
- await (0, import_utils12.execa)("pnpm", [
52998
+ await (0, import_utils8.execa)("pnpm", [
53459
52999
  "--version"
53460
53000
  ], {
53461
53001
  env: process.env
@@ -53467,9 +53007,9 @@ async function canUsePnpm3() {
53467
53007
  }
53468
53008
 
53469
53009
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.1/node_modules/@modern-js/codesmith-api-npm/dist/esm-node/utils/install.js
53470
- var import_utils13 = require("@modern-js/utils");
53010
+ var import_utils9 = require("@modern-js/utils");
53471
53011
  function execaWithStreamLog(command, args, options) {
53472
- const promise = (0, import_utils13.execa)(command, args, {
53012
+ const promise = (0, import_utils9.execa)(command, args, {
53473
53013
  ...options,
53474
53014
  stdin: "inherit",
53475
53015
  stdout: "inherit",
@@ -53478,7 +53018,7 @@ function execaWithStreamLog(command, args, options) {
53478
53018
  return promise;
53479
53019
  }
53480
53020
  async function runInstallWithNvm(command, options) {
53481
- await (0, import_utils13.execa)(`~/.nvm/nvm-exec ${command}`, {
53021
+ await (0, import_utils9.execa)(`~/.nvm/nvm-exec ${command}`, {
53482
53022
  ...options,
53483
53023
  shell: true,
53484
53024
  stdin: "inherit",
@@ -53487,7 +53027,7 @@ async function runInstallWithNvm(command, options) {
53487
53027
  });
53488
53028
  }
53489
53029
  async function npmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
53490
- const canUse = await canUseNpm3();
53030
+ const canUse = await canUseNpm();
53491
53031
  if (canUse) {
53492
53032
  const params = [
53493
53033
  "install"
@@ -53512,7 +53052,7 @@ async function npmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
53512
53052
  throw new Error("please install npm first");
53513
53053
  }
53514
53054
  async function yarnInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
53515
- const canUse = await canUseYarn2();
53055
+ const canUse = await canUseYarn();
53516
53056
  if (canUse) {
53517
53057
  const params = [
53518
53058
  "install"
@@ -53537,7 +53077,7 @@ async function yarnInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
53537
53077
  throw new Error("please install yarn first");
53538
53078
  }
53539
53079
  async function pnpmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
53540
- const canUse = await canUsePnpm3();
53080
+ const canUse = await canUsePnpm();
53541
53081
  if (canUse) {
53542
53082
  const params = [
53543
53083
  "install"
@@ -53972,7 +53512,7 @@ function pascalCase(input, options) {
53972
53512
  }
53973
53513
 
53974
53514
  // ../../../../node_modules/.pnpm/@formily+shared@2.2.24/node_modules/@formily/shared/esm/string.js
53975
- var ansiRegex2 = function() {
53515
+ var ansiRegex = function() {
53976
53516
  var pattern = [
53977
53517
  "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)",
53978
53518
  "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
@@ -53983,11 +53523,11 @@ var regex = "[\uD800-\uDBFF][\uDC00-\uDFFF]";
53983
53523
  var astralRegex = function(opts) {
53984
53524
  return opts && opts.exact ? new RegExp("^".concat(regex, "$")) : new RegExp(regex, "g");
53985
53525
  };
53986
- var stripAnsi3 = function(input) {
53987
- return typeof input === "string" ? input.replace(ansiRegex2(), "") : input;
53526
+ var stripAnsi = function(input) {
53527
+ return typeof input === "string" ? input.replace(ansiRegex(), "") : input;
53988
53528
  };
53989
53529
  var stringLength = function(input) {
53990
- return stripAnsi3(input).replace(astralRegex(), " ").length;
53530
+ return stripAnsi(input).replace(astralRegex(), " ").length;
53991
53531
  };
53992
53532
 
53993
53533
  // ../../../../node_modules/.pnpm/@formily+path@2.2.24/node_modules/@formily/path/esm/contexts.js
@@ -63150,7 +62690,7 @@ var Schema = (
63150
62690
  var import_inquirer = __toESM(require_inquirer());
63151
62691
 
63152
62692
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-formily@2.4.1_@modern-js+codesmith@2.4.1_typescript@5.3.3/node_modules/@modern-js/codesmith-formily/dist/esm-node/transform.js
63153
- var import_lodash3 = require("@modern-js/utils/lodash");
62693
+ var import_lodash = require("@modern-js/utils/lodash");
63154
62694
  function validateSchema(schema) {
63155
62695
  const { type, properties } = schema;
63156
62696
  if (type !== "object") {
@@ -63179,7 +62719,7 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
63179
62719
  const questionValidate = async (field2, input) => {
63180
62720
  if (fieldValidate) {
63181
62721
  var _result_error;
63182
- const result2 = await validate(input, (0, import_lodash3.isFunction)(fieldValidate) ? {
62722
+ const result2 = await validate(input, (0, import_lodash.isFunction)(fieldValidate) ? {
63183
62723
  validator: fieldValidate
63184
62724
  } : fieldValidate);
63185
62725
  if ((_result_error = result2.error) === null || _result_error === void 0 ? void 0 : _result_error.length) {
@@ -63203,14 +62743,14 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
63203
62743
  when: !configValue[field]
63204
62744
  };
63205
62745
  if (items) {
63206
- if ((0, import_lodash3.isArray)(defaultValue)) {
62746
+ if ((0, import_lodash.isArray)(defaultValue)) {
63207
62747
  return {
63208
62748
  ...result,
63209
62749
  type: "checkbox",
63210
62750
  choices: items.map((item) => ({
63211
62751
  type: "choice",
63212
- name: (0, import_lodash3.isObject)(item) ? item.label : item,
63213
- value: (0, import_lodash3.isObject)(item) ? item.value : item
62752
+ name: (0, import_lodash.isObject)(item) ? item.label : item,
62753
+ value: (0, import_lodash.isObject)(item) ? item.value : item
63214
62754
  }))
63215
62755
  };
63216
62756
  }
@@ -63219,8 +62759,8 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
63219
62759
  type: "list",
63220
62760
  choices: items.map((item) => ({
63221
62761
  type: "choice",
63222
- name: (0, import_lodash3.isObject)(item) ? item.label : item,
63223
- value: (0, import_lodash3.isObject)(item) ? item.value : item
62762
+ name: (0, import_lodash.isObject)(item) ? item.label : item,
62763
+ value: (0, import_lodash.isObject)(item) ? item.value : item
63224
62764
  }))
63225
62765
  };
63226
62766
  }
@@ -63235,7 +62775,7 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
63235
62775
  type: "input"
63236
62776
  };
63237
62777
  });
63238
- return (0, import_lodash3.flattenDeep)(questions);
62778
+ return (0, import_lodash.flattenDeep)(questions);
63239
62779
  }
63240
62780
  function transformForm(schema, configValue = {}, validateMap, initValue) {
63241
62781
  return getQuestionFromSchema(schema, configValue, validateMap, initValue);
@@ -63375,30 +62915,30 @@ var CLIReader = class {
63375
62915
  };
63376
62916
 
63377
62917
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.1_@modern-js+codesmith@2.4.1_typescript@5.3.3/node_modules/@modern-js/codesmith-api-app/dist/esm-node/index.js
63378
- var import_utils17 = require("@modern-js/utils");
63379
- var import_lodash7 = require("@modern-js/utils/lodash");
62918
+ var import_utils13 = require("@modern-js/utils");
62919
+ var import_lodash5 = require("@modern-js/utils/lodash");
63380
62920
  var import_comment_json = __toESM(require_src2());
63381
62921
  var import_inquirer2 = __toESM(require_inquirer2());
63382
62922
 
63383
62923
  // ../../../../node_modules/.pnpm/@modern-js+plugin-i18n@2.58.0/node_modules/@modern-js/plugin-i18n/dist/esm-node/index.js
63384
- var import_lodash5 = require("@modern-js/utils/lodash");
62924
+ var import_lodash3 = require("@modern-js/utils/lodash");
63385
62925
 
63386
62926
  // ../../../../node_modules/.pnpm/@modern-js+plugin-i18n@2.58.0/node_modules/@modern-js/plugin-i18n/dist/esm-node/utils/index.js
63387
- var import_lodash4 = require("@modern-js/utils/lodash");
63388
- function getObjKeyMap2(obj, prefix = "") {
62927
+ var import_lodash2 = require("@modern-js/utils/lodash");
62928
+ function getObjKeyMap(obj, prefix = "") {
63389
62929
  const result = {};
63390
62930
  Object.keys(obj).forEach((key) => {
63391
- if ((0, import_lodash4.isString)(obj[key])) {
62931
+ if ((0, import_lodash2.isString)(obj[key])) {
63392
62932
  result[key] = prefix ? `${prefix}.${key}` : key;
63393
- } else if ((0, import_lodash4.isObject)(obj[key])) {
63394
- result[key] = getObjKeyMap2(obj[key], prefix ? `${prefix}.${key}` : key);
62933
+ } else if ((0, import_lodash2.isObject)(obj[key])) {
62934
+ result[key] = getObjKeyMap(obj[key], prefix ? `${prefix}.${key}` : key);
63395
62935
  }
63396
62936
  });
63397
62937
  return result;
63398
62938
  }
63399
62939
 
63400
62940
  // ../../../../node_modules/.pnpm/@modern-js+plugin-i18n@2.58.0/node_modules/@modern-js/plugin-i18n/dist/esm-node/index.js
63401
- var I18n2 = class {
62941
+ var I18n = class {
63402
62942
  format(msg, vars) {
63403
62943
  return msg.replace(/\{(\w+)\}/g, (_match, capture) => Object.prototype.hasOwnProperty.call(vars, capture) ? vars[capture] : capture);
63404
62944
  }
@@ -63412,7 +62952,7 @@ var I18n2 = class {
63412
62952
  if (!model) {
63413
62953
  return fallbackText || key;
63414
62954
  }
63415
- const message = (0, import_lodash5.get)(model, key);
62955
+ const message = (0, import_lodash3.get)(model, key);
63416
62956
  const value = message || fallbackText || key;
63417
62957
  if (typeof value === "string") {
63418
62958
  return this.format(value, vars || {});
@@ -63424,7 +62964,7 @@ var I18n2 = class {
63424
62964
  if (languageMap) {
63425
62965
  this.languageMap = languageMap;
63426
62966
  }
63427
- return getObjKeyMap2(this.languageMap[this.language]);
62967
+ return getObjKeyMap(this.languageMap[this.language]);
63428
62968
  }
63429
62969
  changeLanguage(config) {
63430
62970
  this.language = config.locale || "en";
@@ -63444,7 +62984,7 @@ var I18n2 = class {
63444
62984
  };
63445
62985
 
63446
62986
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.1_@modern-js+codesmith@2.4.1_typescript@5.3.3/node_modules/@modern-js/codesmith-api-app/dist/esm-node/locale/en.js
63447
- var EN_LOCALE2 = {
62987
+ var EN_LOCALE = {
63448
62988
  environment: {
63449
62989
  node_version: "please upgrade node to lts version",
63450
62990
  nvm_install: "please install nvm first",
@@ -63471,7 +63011,7 @@ var EN_LOCALE2 = {
63471
63011
  };
63472
63012
 
63473
63013
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.1_@modern-js+codesmith@2.4.1_typescript@5.3.3/node_modules/@modern-js/codesmith-api-app/dist/esm-node/locale/zh.js
63474
- var ZH_LOCALE2 = {
63014
+ var ZH_LOCALE = {
63475
63015
  environment: {
63476
63016
  node_version: "请升级 Node 版本至 LIS",
63477
63017
  nvm_install: "检测到环境中未安装 nvm,请先安装 nvm",
@@ -63498,15 +63038,15 @@ var ZH_LOCALE2 = {
63498
63038
  };
63499
63039
 
63500
63040
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.1_@modern-js+codesmith@2.4.1_typescript@5.3.3/node_modules/@modern-js/codesmith-api-app/dist/esm-node/locale/index.js
63501
- var i18n2 = new I18n2();
63502
- var localeKeys2 = i18n2.init("zh", {
63503
- zh: ZH_LOCALE2,
63504
- en: EN_LOCALE2
63041
+ var i18n = new I18n();
63042
+ var localeKeys = i18n.init("zh", {
63043
+ zh: ZH_LOCALE,
63044
+ en: EN_LOCALE
63505
63045
  });
63506
63046
 
63507
63047
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.1_@modern-js+codesmith@2.4.1_typescript@5.3.3/node_modules/@modern-js/codesmith-api-app/dist/esm-node/utils/checkUseNvm.js
63508
- var import_path6 = __toESM(require("path"));
63509
- var import_utils16 = require("@modern-js/utils");
63048
+ var import_path4 = __toESM(require("path"));
63049
+ var import_utils12 = require("@modern-js/utils");
63510
63050
  var NODE_MAJOR_VERSION_MAP = {
63511
63051
  "lts/*": 18,
63512
63052
  "lts/argon": 4,
@@ -63519,7 +63059,7 @@ var NODE_MAJOR_VERSION_MAP = {
63519
63059
  "lts/hydrogen": 18
63520
63060
  };
63521
63061
  async function getNoteVersion() {
63522
- const result = await (0, import_utils16.execa)("node", [
63062
+ const result = await (0, import_utils12.execa)("node", [
63523
63063
  "--version"
63524
63064
  ]);
63525
63065
  return result.stdout.slice(1);
@@ -63528,13 +63068,13 @@ async function checkUseNvm(cwd, logger2) {
63528
63068
  if (process.platform.startsWith("win")) {
63529
63069
  return false;
63530
63070
  }
63531
- if (!await fsExists(import_path6.default.join(cwd, ".nvmrc"))) {
63071
+ if (!await fsExists(import_path4.default.join(cwd, ".nvmrc"))) {
63532
63072
  return false;
63533
63073
  }
63534
- const nvmrcContent = (await import_utils16.fs.readFile(import_path6.default.join(cwd, ".nvmrc"), "utf-8")).replace("\n", "");
63074
+ const nvmrcContent = (await import_utils12.fs.readFile(import_path4.default.join(cwd, ".nvmrc"), "utf-8")).replace("\n", "");
63535
63075
  const expectNodeVersion = NODE_MAJOR_VERSION_MAP[nvmrcContent] || nvmrcContent;
63536
63076
  const currentNodeVersion = await getNoteVersion();
63537
- if (expectNodeVersion === import_utils16.semver.major(currentNodeVersion)) {
63077
+ if (expectNodeVersion === import_utils12.semver.major(currentNodeVersion)) {
63538
63078
  return false;
63539
63079
  }
63540
63080
  if (!await canUseNvm()) {
@@ -63553,7 +63093,7 @@ async function checkUseNvm(cwd, logger2) {
63553
63093
  }
63554
63094
 
63555
63095
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.1_@modern-js+codesmith@2.4.1_typescript@5.3.3/node_modules/@modern-js/codesmith-api-app/dist/esm-node/utils/transform.js
63556
- var import_lodash6 = require("@modern-js/utils/lodash");
63096
+ var import_lodash4 = require("@modern-js/utils/lodash");
63557
63097
  function transformInquirerSchema(questions, configValue = {}, validateMap = {}, initValue = {}) {
63558
63098
  for (const question of questions) {
63559
63099
  question.default = initValue[question.name] || question.default;
@@ -63561,7 +63101,7 @@ function transformInquirerSchema(questions, configValue = {}, validateMap = {},
63561
63101
  question.validate = async (input, answers) => {
63562
63102
  if (originValidate) {
63563
63103
  const result = await originValidate(input, answers);
63564
- if ((0, import_lodash6.isString)(result)) {
63104
+ if ((0, import_lodash4.isString)(result)) {
63565
63105
  return result;
63566
63106
  }
63567
63107
  }
@@ -63583,13 +63123,13 @@ function transformInquirerSchema(questions, configValue = {}, validateMap = {},
63583
63123
  // ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.1_@modern-js+codesmith@2.4.1_typescript@5.3.3/node_modules/@modern-js/codesmith-api-app/dist/esm-node/index.js
63584
63124
  var AppAPI = class {
63585
63125
  async checkEnvironment(nodeVersion) {
63586
- if (import_utils17.semver.lt(process.versions.node, nodeVersion || "12.22.12")) {
63587
- this.generatorCore.logger.warn(i18n2.t(localeKeys2.environment.node_version));
63126
+ if (import_utils13.semver.lt(process.versions.node, nodeVersion || "12.22.12")) {
63127
+ this.generatorCore.logger.warn(i18n.t(localeKeys.environment.node_version));
63588
63128
  return false;
63589
63129
  }
63590
- if (!await canUseYarn2() && !await canUsePnpm3() && !await canUseNpm3()) {
63130
+ if (!await canUseYarn() && !await canUsePnpm() && !await canUseNpm()) {
63591
63131
  this.generatorCore.logger.debug("can't use yarn or pnpm or npm");
63592
- this.generatorCore.logger.warn(i18n2.t(localeKeys2.environment.yarn_pnpm_npm));
63132
+ this.generatorCore.logger.warn(i18n.t(localeKeys.environment.yarn_pnpm_npm));
63593
63133
  return false;
63594
63134
  }
63595
63135
  return true;
@@ -63606,7 +63146,7 @@ var AppAPI = class {
63606
63146
  }
63607
63147
  let intallPromise;
63608
63148
  if (command) {
63609
- intallPromise = (0, import_utils17.execa)(command, [], {
63149
+ intallPromise = (0, import_utils13.execa)(command, [], {
63610
63150
  shell: true,
63611
63151
  stdin: "inherit",
63612
63152
  stdout: "inherit",
@@ -63631,10 +63171,10 @@ var AppAPI = class {
63631
63171
  }
63632
63172
  try {
63633
63173
  await intallPromise;
63634
- this.generatorCore.logger.info(i18n2.t(localeKeys2.install.success));
63174
+ this.generatorCore.logger.info(i18n.t(localeKeys.install.success));
63635
63175
  } catch (e) {
63636
63176
  this.generatorCore.logger.warn(e);
63637
- this.generatorCore.logger.warn(i18n2.t(localeKeys2.install.failed, {
63177
+ this.generatorCore.logger.warn(i18n.t(localeKeys.install.failed, {
63638
63178
  command: command || `${packageManager} install`
63639
63179
  }));
63640
63180
  }
@@ -63655,16 +63195,16 @@ var AppAPI = class {
63655
63195
  }
63656
63196
  } catch (e) {
63657
63197
  this.generatorCore.logger.debug("Dependencies install failed", e);
63658
- this.generatorCore.logger.warn(i18n2.t(localeKeys2.install.failed_no_command));
63198
+ this.generatorCore.logger.warn(i18n.t(localeKeys.install.failed_no_command));
63659
63199
  }
63660
63200
  try {
63661
63201
  if (!isMonorepoSubProject && !customNoNeedGit && !inGitRepo) {
63662
63202
  await this.gitApi.addAndCommit(commitMessage || "feat: init");
63663
- this.generatorCore.logger.info(i18n2.t(localeKeys2.git.success));
63203
+ this.generatorCore.logger.info(i18n.t(localeKeys.git.success));
63664
63204
  }
63665
63205
  } catch (e) {
63666
63206
  this.generatorCore.logger.debug("Git repository create failed", e);
63667
- this.generatorCore.logger.warn(i18n2.t(localeKeys2.git.failed));
63207
+ this.generatorCore.logger.warn(i18n.t(localeKeys.git.failed));
63668
63208
  }
63669
63209
  }
63670
63210
  async forgeTemplate(templatePattern, filter, rename, parameters, type = "handlebars") {
@@ -63689,7 +63229,7 @@ var AppAPI = class {
63689
63229
  }
63690
63230
  } catch (e) {
63691
63231
  this.generatorCore.logger.debug("base forging failed:", e);
63692
- this.generatorCore.logger.warn(i18n2.t(localeKeys2.templated.failed));
63232
+ this.generatorCore.logger.warn(i18n.t(localeKeys.templated.failed));
63693
63233
  throw new Error("base forging failed");
63694
63234
  } finally {
63695
63235
  var _this_generatorCore_logger_timing1, _this_generatorCore_logger1;
@@ -63728,7 +63268,7 @@ var AppAPI = class {
63728
63268
  }
63729
63269
  } catch (e) {
63730
63270
  this.generatorCore.logger.debug("base forging failed:", e);
63731
- this.generatorCore.logger.warn(i18n2.t(localeKeys2.templated.failed));
63271
+ this.generatorCore.logger.warn(i18n.t(localeKeys.templated.failed));
63732
63272
  throw new Error("base forging failed");
63733
63273
  } finally {
63734
63274
  var _this_generatorCore_logger_timing1, _this_generatorCore_logger1;
@@ -63737,35 +63277,35 @@ var AppAPI = class {
63737
63277
  }
63738
63278
  async updateWorkspace(folder, workspaceName = "monorepo.code-workspace") {
63739
63279
  const { filePath } = this.generatorContext.materials.default.get(workspaceName);
63740
- if (!import_utils17.fs.existsSync(filePath)) {
63280
+ if (!import_utils13.fs.existsSync(filePath)) {
63741
63281
  return;
63742
63282
  }
63743
- const content = await import_utils17.fs.readFile(filePath);
63283
+ const content = await import_utils13.fs.readFile(filePath);
63744
63284
  const workspace = (0, import_comment_json.parse)(content.toString());
63745
63285
  workspace.folders = [
63746
63286
  folder,
63747
63287
  ...workspace.folders || []
63748
63288
  ];
63749
63289
  const indent = 2;
63750
- await import_utils17.fs.writeFile(filePath, (0, import_comment_json.stringify)(workspace, null, indent), {
63290
+ await import_utils13.fs.writeFile(filePath, (0, import_comment_json.stringify)(workspace, null, indent), {
63751
63291
  encoding: "utf-8"
63752
63292
  });
63753
63293
  }
63754
63294
  showSuccessInfo(successInfo) {
63755
- this.generatorCore.logger.info(successInfo || i18n2.t(localeKeys2.success.info));
63295
+ this.generatorCore.logger.info(successInfo || i18n.t(localeKeys.success.info));
63756
63296
  }
63757
63297
  async runSubGenerator(subGenerator, relativePwdPath, config) {
63758
63298
  try {
63759
63299
  await this.generatorCore.runSubGenerator(subGenerator, relativePwdPath, config);
63760
63300
  } catch (e) {
63761
- this.generatorCore.logger.warn(i18n2.t(localeKeys2.generator.failed));
63762
- this.generatorCore.logger.debug(i18n2.t(localeKeys2.generator.failed), e);
63301
+ this.generatorCore.logger.warn(i18n.t(localeKeys.generator.failed));
63302
+ this.generatorCore.logger.debug(i18n.t(localeKeys.generator.failed), e);
63763
63303
  throw new Error("run sub generator failed");
63764
63304
  }
63765
63305
  }
63766
63306
  mergeAnswers(answers, configValue) {
63767
- const inputData = (0, import_lodash7.merge)(answers, configValue);
63768
- this.generatorContext.config = (0, import_lodash7.merge)(this.generatorContext.config, inputData);
63307
+ const inputData = (0, import_lodash5.merge)(answers, configValue);
63308
+ this.generatorContext.config = (0, import_lodash5.merge)(this.generatorContext.config, inputData);
63769
63309
  return inputData;
63770
63310
  }
63771
63311
  async getInputBySchemaFunc(schemaFunc, configValue = {}, validateMap = {}, initValue = {}) {
@@ -63801,7 +63341,7 @@ var AppAPI = class {
63801
63341
  return this.mergeAnswers(answers, configValue);
63802
63342
  }
63803
63343
  constructor(generatorContext, generatorCore) {
63804
- this.i18n = i18n2;
63344
+ this.i18n = i18n;
63805
63345
  this.generatorCore = generatorCore;
63806
63346
  this.generatorContext = generatorContext;
63807
63347
  this.npmApi = new NpmAPI(generatorCore);
@@ -63873,15 +63413,465 @@ var JsonAPI = class {
63873
63413
  }
63874
63414
  };
63875
63415
 
63416
+ // ../../../cli/plugin-i18n/dist/esm-node/index.js
63417
+ var import_lodash7 = require("@modern-js/utils/lodash");
63418
+
63419
+ // ../../../cli/plugin-i18n/dist/esm-node/utils/index.js
63420
+ var import_lodash6 = require("@modern-js/utils/lodash");
63421
+ function getObjKeyMap2(obj, prefix = "") {
63422
+ const result = {};
63423
+ Object.keys(obj).forEach((key) => {
63424
+ if ((0, import_lodash6.isString)(obj[key])) {
63425
+ result[key] = prefix ? `${prefix}.${key}` : key;
63426
+ } else if ((0, import_lodash6.isObject)(obj[key])) {
63427
+ result[key] = getObjKeyMap2(obj[key], prefix ? `${prefix}.${key}` : key);
63428
+ }
63429
+ });
63430
+ return result;
63431
+ }
63432
+
63433
+ // ../../../cli/plugin-i18n/dist/esm-node/index.js
63434
+ var I18n2 = class {
63435
+ format(msg, vars) {
63436
+ return msg.replace(/\{(\w+)\}/g, (_match, capture) => Object.prototype.hasOwnProperty.call(vars, capture) ? vars[capture] : capture);
63437
+ }
63438
+ getMessage(lang, key, vars, fallbackText) {
63439
+ const languages = Object.keys(this.languageMap);
63440
+ const resultLang = languages.find((l) => l === lang);
63441
+ if (!resultLang && languages.length === 0) {
63442
+ return fallbackText || key;
63443
+ }
63444
+ const model = this.languageMap[resultLang || "en"];
63445
+ if (!model) {
63446
+ return fallbackText || key;
63447
+ }
63448
+ const message = (0, import_lodash7.get)(model, key);
63449
+ const value = message || fallbackText || key;
63450
+ if (typeof value === "string") {
63451
+ return this.format(value, vars || {});
63452
+ }
63453
+ throw new Error("key is not a string");
63454
+ }
63455
+ init(language, languageMap) {
63456
+ this.language = language || "en";
63457
+ if (languageMap) {
63458
+ this.languageMap = languageMap;
63459
+ }
63460
+ return getObjKeyMap2(this.languageMap[this.language]);
63461
+ }
63462
+ changeLanguage(config) {
63463
+ this.language = config.locale || "en";
63464
+ }
63465
+ t(key, vars, fallbackText) {
63466
+ return this.getMessage(this.language, key, vars, fallbackText);
63467
+ }
63468
+ lang(lang) {
63469
+ return {
63470
+ t: (key, vars, fallbackText) => this.getMessage(lang, key, vars, fallbackText)
63471
+ };
63472
+ }
63473
+ constructor() {
63474
+ this.language = "en";
63475
+ this.languageMap = {};
63476
+ }
63477
+ };
63478
+
63479
+ // ../../generator-common/dist/esm-node/locale/en.js
63480
+ var EN_LOCALE2 = {
63481
+ solution: {
63482
+ self: "Please select the type of project you want to create:",
63483
+ mwa: "Web App",
63484
+ module: "Npm Module",
63485
+ custom: "Custom Solution",
63486
+ default: "Default"
63487
+ },
63488
+ scenes: {
63489
+ self: "Please select the project scenario:"
63490
+ },
63491
+ sub_solution: {
63492
+ self: "Please select the type of project you want to create:",
63493
+ mwa: "Web App",
63494
+ module: "Npm Module"
63495
+ },
63496
+ action: {
63497
+ self: "Please select the operation you want:",
63498
+ function: {
63499
+ self: "Enable Features",
63500
+ question: "Please select the feature name:",
63501
+ tailwindcss: "Enable Tailwind CSS",
63502
+ bff: "Enable BFF",
63503
+ micro_frontend: "Enable Micro Frontend",
63504
+ i18n: "Enable Internationalization (i18n)",
63505
+ storybookV7: "Enable Storybook V7",
63506
+ runtime_api: "Enable Runtime API",
63507
+ ssg: "Enable SSG",
63508
+ polyfill: "Enable UA-based Polyfill Feature",
63509
+ proxy: "Enable Global Proxy",
63510
+ swc: "Enable SWC Compile",
63511
+ module_doc: "Enable Module Doc"
63512
+ },
63513
+ element: {
63514
+ self: "Create Element",
63515
+ question: "Please select the type of element to create:",
63516
+ entry: 'New "entry"',
63517
+ server: 'New "Custom Web Server" source code directory'
63518
+ },
63519
+ refactor: {
63520
+ self: "Automatic Refactor",
63521
+ question: "Please select the type of refactoring:",
63522
+ react_router_5: "Use React Router v5"
63523
+ }
63524
+ },
63525
+ boolean: {
63526
+ yes: "Yes",
63527
+ no: "No"
63528
+ },
63529
+ language: {
63530
+ self: "Please select the programming language:"
63531
+ },
63532
+ packageManager: {
63533
+ self: "Please select the package manager:"
63534
+ },
63535
+ entry: {
63536
+ name: "Please fill in the entry name:",
63537
+ no_empty: "The entry name cannot be empty!",
63538
+ no_pages: 'The entry name cannot be "pages"!'
63539
+ },
63540
+ packageName: {
63541
+ self: "Please fill in the project name:",
63542
+ sub_name: "Please fill in the sub-project name:",
63543
+ no_empty: "The package name cannot be empty!"
63544
+ },
63545
+ packagePath: {
63546
+ self: "Please fill in the sub-project directory name:",
63547
+ no_empty: "The package path cannot be empty!",
63548
+ format: "Only lowercase letters, numbers and delimiters (-), and underscore (_), and directory delimiters (/) can be used in package path."
63549
+ },
63550
+ framework: {
63551
+ self: "Please select the framework:",
63552
+ egg: "Egg",
63553
+ express: "Express",
63554
+ koa: "Koa",
63555
+ nest: "Nest"
63556
+ },
63557
+ bff: {
63558
+ bffType: {
63559
+ self: "Please select the BFF type:",
63560
+ func: "Function",
63561
+ framework: "Framework"
63562
+ }
63563
+ }
63564
+ };
63565
+
63566
+ // ../../generator-common/dist/esm-node/locale/zh.js
63567
+ var ZH_LOCALE2 = {
63568
+ solution: {
63569
+ self: "请选择你想创建的工程类型",
63570
+ mwa: "Web 应用",
63571
+ module: "Npm 模块",
63572
+ custom: "自定义",
63573
+ default: "默认"
63574
+ },
63575
+ scenes: {
63576
+ self: "请选择项目场景"
63577
+ },
63578
+ sub_solution: {
63579
+ self: "请选择你想创建的工程类型",
63580
+ mwa: "Web 应用",
63581
+ module: "Npm 模块"
63582
+ },
63583
+ action: {
63584
+ self: "请选择你想要的操作",
63585
+ function: {
63586
+ self: "启用可选功能",
63587
+ question: "请选择功能名称",
63588
+ tailwindcss: "启用「Tailwind CSS」 支持",
63589
+ bff: "启用「BFF」功能",
63590
+ micro_frontend: "启用「微前端」模式",
63591
+ i18n: "启用「国际化(i18n)」功能",
63592
+ storybookV7: "启用「Storybook」V7",
63593
+ runtime_api: "启用「Runtime API」",
63594
+ ssg: "启用「SSG」功能",
63595
+ polyfill: "启用「基于 UA 的 Polyfill」功能",
63596
+ proxy: "启用「全局代理」",
63597
+ swc: "启用「SWC 编译」",
63598
+ module_doc: "启动「模块文档」功能"
63599
+ },
63600
+ element: {
63601
+ self: "创建工程元素",
63602
+ question: "请选择创建元素类型",
63603
+ entry: "新建「应用入口」",
63604
+ server: "新建「自定义 Web Server」源码目录"
63605
+ },
63606
+ refactor: {
63607
+ self: "自动重构",
63608
+ question: "请选择重构类型",
63609
+ react_router_5: "使用 React Router v5"
63610
+ }
63611
+ },
63612
+ boolean: {
63613
+ yes: "是",
63614
+ no: "否"
63615
+ },
63616
+ language: {
63617
+ self: "请选择开发语言"
63618
+ },
63619
+ packageManager: {
63620
+ self: "请选择包管理工具"
63621
+ },
63622
+ entry: {
63623
+ name: "请填写入口名称",
63624
+ no_empty: "入口名称不能为空!",
63625
+ no_pages: '入口名称不支持 "pages"!'
63626
+ },
63627
+ packageName: {
63628
+ self: "请填写项目名称",
63629
+ sub_name: "请填写子项目名称",
63630
+ no_empty: "项目名称不能为空!"
63631
+ },
63632
+ packagePath: {
63633
+ self: "请填写子项目目录名称",
63634
+ no_empty: "目录名称不能为空!",
63635
+ format: "目录名称只能使用小写字母、数字和分隔线(-)、下划线(_)和目录分隔符(/)"
63636
+ },
63637
+ framework: {
63638
+ self: "请选择运行时框架",
63639
+ egg: "Egg",
63640
+ express: "Express",
63641
+ koa: "Koa",
63642
+ nest: "Nest"
63643
+ },
63644
+ bff: {
63645
+ bffType: {
63646
+ self: "请选择 BFF 类型",
63647
+ func: "函数模式",
63648
+ framework: "框架模式"
63649
+ }
63650
+ }
63651
+ };
63652
+
63653
+ // ../../generator-common/dist/esm-node/locale/index.js
63654
+ var i18n2 = new I18n2();
63655
+ var localeKeys2 = i18n2.init("en", {
63656
+ zh: ZH_LOCALE2,
63657
+ en: EN_LOCALE2
63658
+ });
63659
+
63660
+ // ../../generator-common/dist/esm-node/common/solution.js
63661
+ var Solution;
63662
+ (function(Solution2) {
63663
+ Solution2["MWA"] = "mwa";
63664
+ Solution2["Module"] = "module";
63665
+ })(Solution || (Solution = {}));
63666
+ var SolutionToolsMap = {
63667
+ ["mwa"]: "@modern-js/app-tools",
63668
+ ["module"]: "@modern-js/module-tools"
63669
+ };
63670
+ var DependenceGenerator = "@modern-js/dependence-generator";
63671
+
63672
+ // ../../generator-common/dist/esm-node/common/language.js
63673
+ var Language;
63674
+ (function(Language2) {
63675
+ Language2["TS"] = "ts";
63676
+ Language2["JS"] = "js";
63677
+ })(Language || (Language = {}));
63678
+
63679
+ // ../../generator-utils/dist/esm/index.js
63680
+ var import_path6 = __toESM(require("path"));
63681
+ var import_utils17 = require("@modern-js/utils");
63682
+
63683
+ // ../../generator-utils/dist/esm/utils/package.js
63684
+ var import_utils16 = require("@modern-js/utils");
63685
+ async function isPackageExist(packageName, registry2) {
63686
+ if (await (0, import_utils16.canUseNpm)()) {
63687
+ try {
63688
+ const args = [
63689
+ "view",
63690
+ packageName,
63691
+ "version"
63692
+ ];
63693
+ if (registry2) {
63694
+ args.push(`--registry=${registry2}`);
63695
+ }
63696
+ const result = await (0, import_utils16.execa)("npm", args);
63697
+ return (0, import_utils16.stripAnsi)(result.stdout);
63698
+ } catch (e) {
63699
+ return false;
63700
+ }
63701
+ }
63702
+ throw new Error("not found npm, please install npm before");
63703
+ }
63704
+ async function isPackageDeprecated(packageName, registry2) {
63705
+ if (await (0, import_utils16.canUseNpm)()) {
63706
+ const args = [
63707
+ "view",
63708
+ packageName,
63709
+ "deprecated"
63710
+ ];
63711
+ if (registry2) {
63712
+ args.push(`--registry=${registry2}`);
63713
+ }
63714
+ const result = await (0, import_utils16.execa)("npm", args);
63715
+ return (0, import_utils16.stripAnsi)(result.stdout);
63716
+ }
63717
+ throw new Error("not found npm, please install npm before");
63718
+ }
63719
+ function semverDecrease(version) {
63720
+ const versionObj = import_utils16.semver.parse(version, {
63721
+ loose: true
63722
+ });
63723
+ if (!versionObj) {
63724
+ throw new Error(`Version ${version} is not valid semver`);
63725
+ }
63726
+ versionObj.build = [];
63727
+ versionObj.prerelease = [];
63728
+ versionObj.patch--;
63729
+ const result = versionObj.format();
63730
+ if (!import_utils16.semver.valid(result)) {
63731
+ import_utils16.logger.debug(`Version ${result} is not valid semver`);
63732
+ return version;
63733
+ }
63734
+ return result;
63735
+ }
63736
+ async function getAvailableVersion(packageName, currentVersion, registry2) {
63737
+ let times = 5;
63738
+ let version = currentVersion;
63739
+ while (times) {
63740
+ if (!await isPackageExist(`${packageName}@${version}`, registry2) || await isPackageDeprecated(`${packageName}@${version}`, registry2)) {
63741
+ version = import_utils16.semver.inc(version, "patch");
63742
+ times--;
63743
+ continue;
63744
+ }
63745
+ return version;
63746
+ }
63747
+ times = 5;
63748
+ while (times) {
63749
+ version = semverDecrease(version);
63750
+ if (!await isPackageExist(`${packageName}@${version}`, registry2) || await isPackageDeprecated(`${packageName}@${version}`, registry2)) {
63751
+ times--;
63752
+ continue;
63753
+ }
63754
+ return version;
63755
+ }
63756
+ return currentVersion;
63757
+ }
63758
+
63759
+ // ../../generator-utils/dist/esm/utils/stripAnsi.js
63760
+ function ansiRegex2({ onlyFirst = false } = {}) {
63761
+ const pattern = [
63762
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
63763
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
63764
+ ].join("|");
63765
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
63766
+ }
63767
+ function stripAnsi3(string) {
63768
+ if (typeof string !== "string") {
63769
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
63770
+ }
63771
+ return string.replace(ansiRegex2(), "");
63772
+ }
63773
+
63774
+ // ../../generator-utils/dist/esm/utils/getGeneratorPath.js
63775
+ var import_path5 = __toESM(require("path"));
63776
+ var getGeneratorPath = (generator, distTag, paths) => {
63777
+ if (process.env.CODESMITH_ENV === "development") {
63778
+ return import_path5.default.dirname(require.resolve(generator, {
63779
+ paths: paths !== null && paths !== void 0 ? paths : [
63780
+ process.cwd()
63781
+ ]
63782
+ }));
63783
+ } else if (distTag) {
63784
+ return `${generator}@${distTag}`;
63785
+ }
63786
+ return generator;
63787
+ };
63788
+
63789
+ // ../../generator-utils/dist/esm/index.js
63790
+ var import_utils18 = require("@modern-js/utils");
63791
+ async function getPackageVersion(packageName, registry2) {
63792
+ const spinner = (0, import_utils17.ora)({
63793
+ text: "Load Generator...",
63794
+ spinner: "runner"
63795
+ }).start();
63796
+ if (await (0, import_utils17.canUsePnpm)()) {
63797
+ const args = [
63798
+ "info",
63799
+ packageName,
63800
+ "version"
63801
+ ];
63802
+ if (registry2) {
63803
+ args.push(`--registry=${registry2}`);
63804
+ }
63805
+ const result = await (0, import_utils17.execa)("pnpm", args);
63806
+ spinner.stop();
63807
+ return stripAnsi3(result.stdout);
63808
+ }
63809
+ if (await (0, import_utils17.canUseNpm)()) {
63810
+ const args = [
63811
+ "view",
63812
+ packageName,
63813
+ "version"
63814
+ ];
63815
+ if (registry2) {
63816
+ args.push(`--registry=${registry2}`);
63817
+ }
63818
+ const result = await (0, import_utils17.execa)("npm", args);
63819
+ spinner.stop();
63820
+ return stripAnsi3(result.stdout);
63821
+ }
63822
+ spinner.stop();
63823
+ throw new Error("not found npm, please install npm before");
63824
+ }
63825
+ async function getModernPluginVersion(solution, packageName, options = {
63826
+ distTag: "latest"
63827
+ }) {
63828
+ const { cwd = process.cwd(), registry: registry2, distTag } = options;
63829
+ const getLatetPluginVersion = async (tag) => {
63830
+ const version = await getPackageVersion(`${packageName}@${tag || distTag || "latest"}`, registry2);
63831
+ return version;
63832
+ };
63833
+ if (!packageName.startsWith("@modern-js") || packageName.includes("electron") || packageName.includes("codesmith") || packageName.includes("easy-form") || packageName.startsWith("@modern-js-reduck")) {
63834
+ return getLatetPluginVersion("latest");
63835
+ }
63836
+ let pkgPath = import_path6.default.join(require.resolve(SolutionToolsMap[solution], {
63837
+ paths: [
63838
+ cwd
63839
+ ]
63840
+ }), "../../..", "package.json");
63841
+ if (solution === Solution.Module) {
63842
+ pkgPath = import_path6.default.join(require.resolve(SolutionToolsMap[solution], {
63843
+ paths: [
63844
+ cwd
63845
+ ]
63846
+ }), "../..", "package.json");
63847
+ }
63848
+ if (import_utils17.fs.existsSync(pkgPath)) {
63849
+ const pkgInfo = import_utils17.fs.readJSONSync(pkgPath);
63850
+ const modernVersion = pkgInfo.version;
63851
+ if (typeof modernVersion !== "string") {
63852
+ return getLatetPluginVersion();
63853
+ }
63854
+ const version = await getAvailableVersion(packageName, modernVersion, registry2);
63855
+ if (!await isPackageExist(`${packageName}@${version}`)) {
63856
+ return getLatetPluginVersion();
63857
+ }
63858
+ return version;
63859
+ }
63860
+ return getLatetPluginVersion();
63861
+ }
63862
+ function isTsProject(appDir) {
63863
+ return import_utils17.fs.existsSync(import_path6.default.join(appDir, "tsconfig.json"));
63864
+ }
63865
+
63876
63866
  // src/index.ts
63877
63867
  function isEmptyServerDir(serverDir) {
63878
- const files = import_utils4.fs.readdirSync(serverDir);
63868
+ const files = import_utils18.fs.readdirSync(serverDir);
63879
63869
  if (files.length === 0) {
63880
63870
  return true;
63881
63871
  }
63882
63872
  return files.every((file) => {
63883
- if (import_utils4.fs.statSync(import_path7.default.join(serverDir, file)).isDirectory()) {
63884
- const childFiles = import_utils4.fs.readdirSync(import_path7.default.join(serverDir, file));
63873
+ if (import_utils18.fs.statSync(import_path7.default.join(serverDir, file)).isDirectory()) {
63874
+ const childFiles = import_utils18.fs.readdirSync(import_path7.default.join(serverDir, file));
63885
63875
  return childFiles.length === 0;
63886
63876
  }
63887
63877
  return false;
@@ -63891,8 +63881,8 @@ var handleTemplateFile = async (context, generator, appApi) => {
63891
63881
  const jsonAPI = new JsonAPI(generator);
63892
63882
  const appDir = context.materials.default.basePath;
63893
63883
  const serverDir = import_path7.default.join(appDir, "server");
63894
- if (import_utils4.fs.existsSync(serverDir) && !isEmptyServerDir(serverDir)) {
63895
- const files = import_utils4.fs.readdirSync("server");
63884
+ if (import_utils18.fs.existsSync(serverDir) && !isEmptyServerDir(serverDir)) {
63885
+ const files = import_utils18.fs.readdirSync("server");
63896
63886
  if (files.length > 0) {
63897
63887
  generator.logger.warn("'server' is already exist");
63898
63888
  process.exit(1);
@@ -63927,7 +63917,7 @@ var handleTemplateFile = async (context, generator, appApi) => {
63927
63917
  (resourceKey) => resourceKey.replace(`templates/base-template/${language}/`, "").replace(".handlebars", "")
63928
63918
  );
63929
63919
  if (language === Language.TS) {
63930
- const tsconfigJSON = (0, import_utils4.readTsConfigByFile)(import_path7.default.join(appDir, "tsconfig.json"));
63920
+ const tsconfigJSON = (0, import_utils18.readTsConfigByFile)(import_path7.default.join(appDir, "tsconfig.json"));
63931
63921
  if (!(tsconfigJSON.include || []).includes("server")) {
63932
63922
  await jsonAPI.update(
63933
63923
  context.materials.default.get(import_path7.default.join(appDir, "tsconfig.json")),
@@ -63946,7 +63936,7 @@ var handleTemplateFile = async (context, generator, appApi) => {
63946
63936
  var src_default = async (context, generator) => {
63947
63937
  const appApi = new AppAPI(context, generator);
63948
63938
  const { locale } = context.config;
63949
- i18n.changeLanguage({ locale });
63939
+ i18n2.changeLanguage({ locale });
63950
63940
  appApi.i18n.changeLanguage({ locale });
63951
63941
  if (!await appApi.checkEnvironment()) {
63952
63942
  process.exit(1);