@modern-js/entry-generator 3.4.16 → 3.4.17
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/index.js +462 -462
- package/package.json +7 -7
- package/src/index.ts +3 -3
package/dist/index.js
CHANGED
|
@@ -207,7 +207,7 @@ var require_package = __commonJS({
|
|
|
207
207
|
var require_ejs = __commonJS({
|
|
208
208
|
"../../../../node_modules/.pnpm/ejs@3.1.9/node_modules/ejs/lib/ejs.js"(exports) {
|
|
209
209
|
"use strict";
|
|
210
|
-
var
|
|
210
|
+
var fs7 = require("fs");
|
|
211
211
|
var path7 = require("path");
|
|
212
212
|
var utils = require_utils();
|
|
213
213
|
var scopeOptionWarned = false;
|
|
@@ -235,7 +235,7 @@ var require_ejs = __commonJS({
|
|
|
235
235
|
var _BOM = /^\uFEFF/;
|
|
236
236
|
var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
237
237
|
exports.cache = utils.cache;
|
|
238
|
-
exports.fileLoader =
|
|
238
|
+
exports.fileLoader = fs7.readFileSync;
|
|
239
239
|
exports.localsName = _DEFAULT_LOCALS_NAME;
|
|
240
240
|
exports.promiseImpl = new Function("return this;")().Promise;
|
|
241
241
|
exports.resolveInclude = function(name, filename, isDir) {
|
|
@@ -253,7 +253,7 @@ var require_ejs = __commonJS({
|
|
|
253
253
|
var filePath;
|
|
254
254
|
if (paths.some(function(v) {
|
|
255
255
|
filePath = exports.resolveInclude(name, v, true);
|
|
256
|
-
return
|
|
256
|
+
return fs7.existsSync(filePath);
|
|
257
257
|
})) {
|
|
258
258
|
return filePath;
|
|
259
259
|
}
|
|
@@ -273,7 +273,7 @@ var require_ejs = __commonJS({
|
|
|
273
273
|
} else {
|
|
274
274
|
if (options.filename) {
|
|
275
275
|
filePath = exports.resolveInclude(path8, options.filename);
|
|
276
|
-
if (
|
|
276
|
+
if (fs7.existsSync(filePath)) {
|
|
277
277
|
includePath = filePath;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
@@ -6609,8 +6609,8 @@ var require_lib = __commonJS({
|
|
|
6609
6609
|
handlebars2.print = printer.print;
|
|
6610
6610
|
module2.exports = handlebars2;
|
|
6611
6611
|
function extension(module3, filename) {
|
|
6612
|
-
var
|
|
6613
|
-
var templateString =
|
|
6612
|
+
var fs7 = require("fs");
|
|
6613
|
+
var templateString = fs7.readFileSync(filename, "utf8");
|
|
6614
6614
|
module3.exports = handlebars2.compile(templateString);
|
|
6615
6615
|
}
|
|
6616
6616
|
if (typeof require !== "undefined" && require.extensions) {
|
|
@@ -36069,7 +36069,7 @@ var require_iso2022 = __commonJS({
|
|
|
36069
36069
|
var require_chardet = __commonJS({
|
|
36070
36070
|
"../../../../node_modules/.pnpm/chardet@0.7.0/node_modules/chardet/index.js"(exports, module2) {
|
|
36071
36071
|
"use strict";
|
|
36072
|
-
var
|
|
36072
|
+
var fs7 = require("fs");
|
|
36073
36073
|
var utf8 = require_utf8();
|
|
36074
36074
|
var unicode = require_unicode();
|
|
36075
36075
|
var mbcs = require_mbcs();
|
|
@@ -36143,29 +36143,29 @@ var require_chardet = __commonJS({
|
|
|
36143
36143
|
var fd;
|
|
36144
36144
|
var handler = function(err, buffer) {
|
|
36145
36145
|
if (fd) {
|
|
36146
|
-
|
|
36146
|
+
fs7.closeSync(fd);
|
|
36147
36147
|
}
|
|
36148
36148
|
if (err)
|
|
36149
36149
|
return cb(err, null);
|
|
36150
36150
|
cb(null, self3.detect(buffer, opts));
|
|
36151
36151
|
};
|
|
36152
36152
|
if (opts && opts.sampleSize) {
|
|
36153
|
-
fd =
|
|
36154
|
-
|
|
36153
|
+
fd = fs7.openSync(filepath, "r"), sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
36154
|
+
fs7.read(fd, sample, 0, opts.sampleSize, null, function(err) {
|
|
36155
36155
|
handler(err, sample);
|
|
36156
36156
|
});
|
|
36157
36157
|
return;
|
|
36158
36158
|
}
|
|
36159
|
-
|
|
36159
|
+
fs7.readFile(filepath, handler);
|
|
36160
36160
|
};
|
|
36161
36161
|
module2.exports.detectFileSync = function(filepath, opts) {
|
|
36162
36162
|
if (opts && opts.sampleSize) {
|
|
36163
|
-
var fd =
|
|
36164
|
-
|
|
36165
|
-
|
|
36163
|
+
var fd = fs7.openSync(filepath, "r"), sample2 = Buffer.allocUnsafe(opts.sampleSize);
|
|
36164
|
+
fs7.readSync(fd, sample2, 0, opts.sampleSize);
|
|
36165
|
+
fs7.closeSync(fd);
|
|
36166
36166
|
return self3.detect(sample2, opts);
|
|
36167
36167
|
}
|
|
36168
|
-
return self3.detect(
|
|
36168
|
+
return self3.detect(fs7.readFileSync(filepath), opts);
|
|
36169
36169
|
};
|
|
36170
36170
|
module2.exports.detectAll = function(buffer, opts) {
|
|
36171
36171
|
if (typeof opts !== "object") {
|
|
@@ -39669,7 +39669,7 @@ var require_os_tmpdir = __commonJS({
|
|
|
39669
39669
|
var require_tmp = __commonJS({
|
|
39670
39670
|
"../../../../node_modules/.pnpm/tmp@0.0.33/node_modules/tmp/lib/tmp.js"(exports, module2) {
|
|
39671
39671
|
"use strict";
|
|
39672
|
-
var
|
|
39672
|
+
var fs7 = require("fs");
|
|
39673
39673
|
var path7 = require("path");
|
|
39674
39674
|
var crypto = require("crypto");
|
|
39675
39675
|
var osTmpDir = require_os_tmpdir();
|
|
@@ -39733,7 +39733,7 @@ var require_tmp = __commonJS({
|
|
|
39733
39733
|
return cb(new Error("Invalid template provided"));
|
|
39734
39734
|
(function _getUniqueName() {
|
|
39735
39735
|
const name = _generateTmpName(opts);
|
|
39736
|
-
|
|
39736
|
+
fs7.stat(name, function(err) {
|
|
39737
39737
|
if (!err) {
|
|
39738
39738
|
if (tries-- > 0)
|
|
39739
39739
|
return _getUniqueName();
|
|
@@ -39752,7 +39752,7 @@ var require_tmp = __commonJS({
|
|
|
39752
39752
|
do {
|
|
39753
39753
|
const name = _generateTmpName(opts);
|
|
39754
39754
|
try {
|
|
39755
|
-
|
|
39755
|
+
fs7.statSync(name);
|
|
39756
39756
|
} catch (e) {
|
|
39757
39757
|
return name;
|
|
39758
39758
|
}
|
|
@@ -39765,14 +39765,14 @@ var require_tmp = __commonJS({
|
|
|
39765
39765
|
tmpName(opts, function _tmpNameCreated(err, name) {
|
|
39766
39766
|
if (err)
|
|
39767
39767
|
return cb(err);
|
|
39768
|
-
|
|
39768
|
+
fs7.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
|
|
39769
39769
|
if (err2)
|
|
39770
39770
|
return cb(err2);
|
|
39771
39771
|
if (opts.discardDescriptor) {
|
|
39772
|
-
return
|
|
39772
|
+
return fs7.close(fd, function _discardCallback(err3) {
|
|
39773
39773
|
if (err3) {
|
|
39774
39774
|
try {
|
|
39775
|
-
|
|
39775
|
+
fs7.unlinkSync(name);
|
|
39776
39776
|
} catch (e) {
|
|
39777
39777
|
if (!isENOENT(e)) {
|
|
39778
39778
|
err3 = e;
|
|
@@ -39795,9 +39795,9 @@ var require_tmp = __commonJS({
|
|
|
39795
39795
|
opts.postfix = opts.postfix || ".tmp";
|
|
39796
39796
|
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
|
39797
39797
|
const name = tmpNameSync(opts);
|
|
39798
|
-
var fd =
|
|
39798
|
+
var fd = fs7.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
|
|
39799
39799
|
if (opts.discardDescriptor) {
|
|
39800
|
-
|
|
39800
|
+
fs7.closeSync(fd);
|
|
39801
39801
|
fd = void 0;
|
|
39802
39802
|
}
|
|
39803
39803
|
return {
|
|
@@ -39809,9 +39809,9 @@ var require_tmp = __commonJS({
|
|
|
39809
39809
|
function _rmdirRecursiveSync(root) {
|
|
39810
39810
|
const dirs = [root];
|
|
39811
39811
|
do {
|
|
39812
|
-
var dir2 = dirs.pop(), deferred = false, files =
|
|
39812
|
+
var dir2 = dirs.pop(), deferred = false, files = fs7.readdirSync(dir2);
|
|
39813
39813
|
for (var i = 0, length = files.length; i < length; i++) {
|
|
39814
|
-
var file2 = path7.join(dir2, files[i]), stat =
|
|
39814
|
+
var file2 = path7.join(dir2, files[i]), stat = fs7.lstatSync(file2);
|
|
39815
39815
|
if (stat.isDirectory()) {
|
|
39816
39816
|
if (!deferred) {
|
|
39817
39817
|
deferred = true;
|
|
@@ -39819,11 +39819,11 @@ var require_tmp = __commonJS({
|
|
|
39819
39819
|
}
|
|
39820
39820
|
dirs.push(file2);
|
|
39821
39821
|
} else {
|
|
39822
|
-
|
|
39822
|
+
fs7.unlinkSync(file2);
|
|
39823
39823
|
}
|
|
39824
39824
|
}
|
|
39825
39825
|
if (!deferred) {
|
|
39826
|
-
|
|
39826
|
+
fs7.rmdirSync(dir2);
|
|
39827
39827
|
}
|
|
39828
39828
|
} while (dirs.length !== 0);
|
|
39829
39829
|
}
|
|
@@ -39832,7 +39832,7 @@ var require_tmp = __commonJS({
|
|
|
39832
39832
|
tmpName(opts, function _tmpNameCreated(err, name) {
|
|
39833
39833
|
if (err)
|
|
39834
39834
|
return cb(err);
|
|
39835
|
-
|
|
39835
|
+
fs7.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
|
|
39836
39836
|
if (err2)
|
|
39837
39837
|
return cb(err2);
|
|
39838
39838
|
cb(null, name, _prepareTmpDirRemoveCallback(name, opts));
|
|
@@ -39842,7 +39842,7 @@ var require_tmp = __commonJS({
|
|
|
39842
39842
|
function dirSync(options) {
|
|
39843
39843
|
var args = _parseArguments(options), opts = args[0];
|
|
39844
39844
|
const name = tmpNameSync(opts);
|
|
39845
|
-
|
|
39845
|
+
fs7.mkdirSync(name, opts.mode || DIR_MODE);
|
|
39846
39846
|
return {
|
|
39847
39847
|
name,
|
|
39848
39848
|
removeCallback: _prepareTmpDirRemoveCallback(name, opts)
|
|
@@ -39852,7 +39852,7 @@ var require_tmp = __commonJS({
|
|
|
39852
39852
|
const removeCallback = _prepareRemoveCallback(function _removeCallback(fdPath) {
|
|
39853
39853
|
try {
|
|
39854
39854
|
if (0 <= fdPath[0]) {
|
|
39855
|
-
|
|
39855
|
+
fs7.closeSync(fdPath[0]);
|
|
39856
39856
|
}
|
|
39857
39857
|
} catch (e) {
|
|
39858
39858
|
if (!isEBADF(e) && !isENOENT(e)) {
|
|
@@ -39860,7 +39860,7 @@ var require_tmp = __commonJS({
|
|
|
39860
39860
|
}
|
|
39861
39861
|
}
|
|
39862
39862
|
try {
|
|
39863
|
-
|
|
39863
|
+
fs7.unlinkSync(fdPath[1]);
|
|
39864
39864
|
} catch (e) {
|
|
39865
39865
|
if (!isENOENT(e)) {
|
|
39866
39866
|
throw e;
|
|
@@ -39873,7 +39873,7 @@ var require_tmp = __commonJS({
|
|
|
39873
39873
|
return removeCallback;
|
|
39874
39874
|
}
|
|
39875
39875
|
function _prepareTmpDirRemoveCallback(name, opts) {
|
|
39876
|
-
const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync :
|
|
39876
|
+
const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs7.rmdirSync.bind(fs7);
|
|
39877
39877
|
const removeCallback = _prepareRemoveCallback(removeFunction, name);
|
|
39878
39878
|
if (!opts.keep) {
|
|
39879
39879
|
_removeObjects.unshift(removeCallback);
|
|
@@ -51056,335 +51056,17 @@ __export(src_exports, {
|
|
|
51056
51056
|
});
|
|
51057
51057
|
module.exports = __toCommonJS(src_exports);
|
|
51058
51058
|
var import_path7 = __toESM(require("path"));
|
|
51059
|
-
var import_lodash8 = require("@modern-js/utils/lodash");
|
|
51060
|
-
|
|
51061
|
-
// ../../generator-utils/dist/esm/index.js
|
|
51062
|
-
var import_path = __toESM(require("path"));
|
|
51063
|
-
var import_utils2 = require("@modern-js/utils");
|
|
51064
|
-
|
|
51065
|
-
// ../../../cli/plugin-i18n/dist/esm-node/index.js
|
|
51066
|
-
var import_lodash2 = require("@modern-js/utils/lodash");
|
|
51067
|
-
|
|
51068
|
-
// ../../../cli/plugin-i18n/dist/esm-node/utils/index.js
|
|
51069
|
-
var import_lodash = require("@modern-js/utils/lodash");
|
|
51070
|
-
function getObjKeyMap(obj, prefix = "") {
|
|
51071
|
-
const result = {};
|
|
51072
|
-
Object.keys(obj).forEach((key) => {
|
|
51073
|
-
if ((0, import_lodash.isString)(obj[key])) {
|
|
51074
|
-
result[key] = prefix ? `${prefix}.${key}` : key;
|
|
51075
|
-
} else if ((0, import_lodash.isObject)(obj[key])) {
|
|
51076
|
-
result[key] = getObjKeyMap(obj[key], prefix ? `${prefix}.${key}` : key);
|
|
51077
|
-
}
|
|
51078
|
-
});
|
|
51079
|
-
return result;
|
|
51080
|
-
}
|
|
51081
|
-
|
|
51082
|
-
// ../../../cli/plugin-i18n/dist/esm-node/index.js
|
|
51083
|
-
var I18n = class {
|
|
51084
|
-
format(msg, vars) {
|
|
51085
|
-
return msg.replace(/\{(\w+)\}/g, (_match, capture) => Object.prototype.hasOwnProperty.call(vars, capture) ? vars[capture] : capture);
|
|
51086
|
-
}
|
|
51087
|
-
getMessage(lang, key, vars, fallbackText) {
|
|
51088
|
-
const languages = Object.keys(this.languageMap);
|
|
51089
|
-
const resultLang = languages.find((l) => l === lang);
|
|
51090
|
-
if (!resultLang && languages.length === 0) {
|
|
51091
|
-
return fallbackText || key;
|
|
51092
|
-
}
|
|
51093
|
-
const model = this.languageMap[resultLang || "en"];
|
|
51094
|
-
if (!model) {
|
|
51095
|
-
return fallbackText || key;
|
|
51096
|
-
}
|
|
51097
|
-
const message = (0, import_lodash2.get)(model, key);
|
|
51098
|
-
const value = message || fallbackText || key;
|
|
51099
|
-
if (typeof value === "string") {
|
|
51100
|
-
return this.format(value, vars || {});
|
|
51101
|
-
}
|
|
51102
|
-
throw new Error("key is not a string");
|
|
51103
|
-
}
|
|
51104
|
-
init(language, languageMap) {
|
|
51105
|
-
this.language = language || "en";
|
|
51106
|
-
if (languageMap) {
|
|
51107
|
-
this.languageMap = languageMap;
|
|
51108
|
-
}
|
|
51109
|
-
return getObjKeyMap(this.languageMap[this.language]);
|
|
51110
|
-
}
|
|
51111
|
-
changeLanguage(config) {
|
|
51112
|
-
this.language = config.locale || "en";
|
|
51113
|
-
}
|
|
51114
|
-
t(key, vars, fallbackText) {
|
|
51115
|
-
return this.getMessage(this.language, key, vars, fallbackText);
|
|
51116
|
-
}
|
|
51117
|
-
lang(lang) {
|
|
51118
|
-
return {
|
|
51119
|
-
t: (key, vars, fallbackText) => this.getMessage(lang, key, vars, fallbackText)
|
|
51120
|
-
};
|
|
51121
|
-
}
|
|
51122
|
-
constructor() {
|
|
51123
|
-
this.language = "en";
|
|
51124
|
-
this.languageMap = {};
|
|
51125
|
-
}
|
|
51126
|
-
};
|
|
51127
|
-
|
|
51128
|
-
// ../../generator-common/dist/esm-node/locale/zh.js
|
|
51129
|
-
var ZH_LOCALE = {
|
|
51130
|
-
solution: {
|
|
51131
|
-
self: "请选择你想创建的工程类型",
|
|
51132
|
-
mwa: "Web 应用",
|
|
51133
|
-
module: "Npm 模块",
|
|
51134
|
-
custom: "自定义",
|
|
51135
|
-
default: "默认"
|
|
51136
|
-
},
|
|
51137
|
-
scenes: {
|
|
51138
|
-
self: "请选择项目场景"
|
|
51139
|
-
},
|
|
51140
|
-
sub_solution: {
|
|
51141
|
-
self: "请选择你想创建的工程类型",
|
|
51142
|
-
mwa: "Web 应用",
|
|
51143
|
-
module: "Npm 模块"
|
|
51144
|
-
},
|
|
51145
|
-
action: {
|
|
51146
|
-
self: "请选择你想要的操作",
|
|
51147
|
-
function: {
|
|
51148
|
-
self: "启用可选功能",
|
|
51149
|
-
question: "请选择功能名称",
|
|
51150
|
-
tailwindcss: "启用「Tailwind CSS」 支持",
|
|
51151
|
-
bff: "启用「BFF」功能",
|
|
51152
|
-
micro_frontend: "启用「微前端」模式",
|
|
51153
|
-
i18n: "启用「国际化(i18n)」功能",
|
|
51154
|
-
storybookV7: "启用「Storybook」V7",
|
|
51155
|
-
runtime_api: "启用「Runtime API」",
|
|
51156
|
-
ssg: "启用「SSG」功能",
|
|
51157
|
-
polyfill: "启用「基于 UA 的 Polyfill」功能",
|
|
51158
|
-
proxy: "启用「全局代理」",
|
|
51159
|
-
swc: "启用「SWC 编译」",
|
|
51160
|
-
module_doc: "启动「模块文档」功能"
|
|
51161
|
-
},
|
|
51162
|
-
element: {
|
|
51163
|
-
self: "创建工程元素",
|
|
51164
|
-
question: "请选择创建元素类型",
|
|
51165
|
-
entry: "新建「应用入口」",
|
|
51166
|
-
server: "新建「自定义 Web Server」源码目录"
|
|
51167
|
-
},
|
|
51168
|
-
refactor: {
|
|
51169
|
-
self: "自动重构",
|
|
51170
|
-
question: "请选择重构类型",
|
|
51171
|
-
react_router_5: "使用 React Router v5"
|
|
51172
|
-
}
|
|
51173
|
-
},
|
|
51174
|
-
boolean: {
|
|
51175
|
-
yes: "是",
|
|
51176
|
-
no: "否"
|
|
51177
|
-
},
|
|
51178
|
-
language: {
|
|
51179
|
-
self: "请选择开发语言"
|
|
51180
|
-
},
|
|
51181
|
-
packageManager: {
|
|
51182
|
-
self: "请选择包管理工具"
|
|
51183
|
-
},
|
|
51184
|
-
entry: {
|
|
51185
|
-
name: "请填写入口名称",
|
|
51186
|
-
no_empty: "入口名称不能为空!",
|
|
51187
|
-
no_pages: '入口名称不支持 "pages"!'
|
|
51188
|
-
},
|
|
51189
|
-
packageName: {
|
|
51190
|
-
self: "请填写项目名称",
|
|
51191
|
-
sub_name: "请填写子项目名称",
|
|
51192
|
-
no_empty: "项目名称不能为空!"
|
|
51193
|
-
},
|
|
51194
|
-
packagePath: {
|
|
51195
|
-
self: "请填写子项目目录名称",
|
|
51196
|
-
no_empty: "目录名称不能为空!",
|
|
51197
|
-
format: "目录名称只能使用小写字母、数字和分隔线(-)、下划线(_)和目录分隔符(/)"
|
|
51198
|
-
},
|
|
51199
|
-
framework: {
|
|
51200
|
-
self: "请选择运行时框架",
|
|
51201
|
-
egg: "Egg",
|
|
51202
|
-
express: "Express",
|
|
51203
|
-
koa: "Koa",
|
|
51204
|
-
nest: "Nest"
|
|
51205
|
-
},
|
|
51206
|
-
bff: {
|
|
51207
|
-
bffType: {
|
|
51208
|
-
self: "请选择 BFF 类型",
|
|
51209
|
-
func: "函数模式",
|
|
51210
|
-
framework: "框架模式"
|
|
51211
|
-
}
|
|
51212
|
-
},
|
|
51213
|
-
buildTools: {
|
|
51214
|
-
self: "请选择构建工具",
|
|
51215
|
-
webpack: "webpack",
|
|
51216
|
-
rspack: "Rspack (实验性)"
|
|
51217
|
-
}
|
|
51218
|
-
};
|
|
51219
|
-
|
|
51220
|
-
// ../../generator-common/dist/esm-node/locale/en.js
|
|
51221
|
-
var EN_LOCALE = {
|
|
51222
|
-
solution: {
|
|
51223
|
-
self: "Please select the type of project you want to create:",
|
|
51224
|
-
mwa: "Web App",
|
|
51225
|
-
module: "Npm Module",
|
|
51226
|
-
custom: "Custom Solution",
|
|
51227
|
-
default: "Default"
|
|
51228
|
-
},
|
|
51229
|
-
scenes: {
|
|
51230
|
-
self: "Please select the project scenario:"
|
|
51231
|
-
},
|
|
51232
|
-
sub_solution: {
|
|
51233
|
-
self: "Please select the type of project you want to create:",
|
|
51234
|
-
mwa: "Web App",
|
|
51235
|
-
module: "Npm Module"
|
|
51236
|
-
},
|
|
51237
|
-
action: {
|
|
51238
|
-
self: "Please select the operation you want:",
|
|
51239
|
-
function: {
|
|
51240
|
-
self: "Enable Features",
|
|
51241
|
-
question: "Please select the feature name:",
|
|
51242
|
-
tailwindcss: "Enable Tailwind CSS",
|
|
51243
|
-
bff: "Enable BFF",
|
|
51244
|
-
micro_frontend: "Enable Micro Frontend",
|
|
51245
|
-
i18n: "Enable Internationalization (i18n)",
|
|
51246
|
-
storybookV7: "Enable Storybook V7",
|
|
51247
|
-
runtime_api: "Enable Runtime API",
|
|
51248
|
-
ssg: "Enable SSG",
|
|
51249
|
-
polyfill: "Enable UA-based Polyfill Feature",
|
|
51250
|
-
proxy: "Enable Global Proxy",
|
|
51251
|
-
swc: "Enable SWC Compile",
|
|
51252
|
-
module_doc: "Enable Module Doc"
|
|
51253
|
-
},
|
|
51254
|
-
element: {
|
|
51255
|
-
self: "Create Element",
|
|
51256
|
-
question: "Please select the type of element to create:",
|
|
51257
|
-
entry: 'New "entry"',
|
|
51258
|
-
server: 'New "Custom Web Server" source code directory'
|
|
51259
|
-
},
|
|
51260
|
-
refactor: {
|
|
51261
|
-
self: "Automatic Refactor",
|
|
51262
|
-
question: "Please select the type of refactoring:",
|
|
51263
|
-
react_router_5: "Use React Router v5"
|
|
51264
|
-
}
|
|
51265
|
-
},
|
|
51266
|
-
boolean: {
|
|
51267
|
-
yes: "Yes",
|
|
51268
|
-
no: "No"
|
|
51269
|
-
},
|
|
51270
|
-
language: {
|
|
51271
|
-
self: "Please select the programming language:"
|
|
51272
|
-
},
|
|
51273
|
-
packageManager: {
|
|
51274
|
-
self: "Please select the package manager:"
|
|
51275
|
-
},
|
|
51276
|
-
entry: {
|
|
51277
|
-
name: "Please fill in the entry name:",
|
|
51278
|
-
no_empty: "The entry name cannot be empty!",
|
|
51279
|
-
no_pages: 'The entry name cannot be "pages"!'
|
|
51280
|
-
},
|
|
51281
|
-
packageName: {
|
|
51282
|
-
self: "Please fill in the project name:",
|
|
51283
|
-
sub_name: "Please fill in the sub-project name:",
|
|
51284
|
-
no_empty: "The package name cannot be empty!"
|
|
51285
|
-
},
|
|
51286
|
-
packagePath: {
|
|
51287
|
-
self: "Please fill in the sub-project directory name:",
|
|
51288
|
-
no_empty: "The package path cannot be empty!",
|
|
51289
|
-
format: "Only lowercase letters, numbers and delimiters (-), and underscore (_), and directory delimiters (/) can be used in package path."
|
|
51290
|
-
},
|
|
51291
|
-
framework: {
|
|
51292
|
-
self: "Please select the framework:",
|
|
51293
|
-
egg: "Egg",
|
|
51294
|
-
express: "Express",
|
|
51295
|
-
koa: "Koa",
|
|
51296
|
-
nest: "Nest"
|
|
51297
|
-
},
|
|
51298
|
-
bff: {
|
|
51299
|
-
bffType: {
|
|
51300
|
-
self: "Please select the BFF type:",
|
|
51301
|
-
func: "Function",
|
|
51302
|
-
framework: "Framework"
|
|
51303
|
-
}
|
|
51304
|
-
},
|
|
51305
|
-
buildTools: {
|
|
51306
|
-
self: "Please select the bundler:",
|
|
51307
|
-
webpack: "webpack",
|
|
51308
|
-
rspack: "Rspack (experimental)"
|
|
51309
|
-
}
|
|
51310
|
-
};
|
|
51311
|
-
|
|
51312
|
-
// ../../generator-common/dist/esm-node/locale/index.js
|
|
51313
|
-
var i18n = new I18n();
|
|
51314
|
-
var localeKeys = i18n.init("en", {
|
|
51315
|
-
zh: ZH_LOCALE,
|
|
51316
|
-
en: EN_LOCALE
|
|
51317
|
-
});
|
|
51318
|
-
|
|
51319
|
-
// ../../generator-common/dist/esm-node/common/boolean.js
|
|
51320
|
-
var BooleanConfig;
|
|
51321
|
-
(function(BooleanConfig2) {
|
|
51322
|
-
BooleanConfig2["NO"] = "no";
|
|
51323
|
-
BooleanConfig2["YES"] = "yes";
|
|
51324
|
-
})(BooleanConfig || (BooleanConfig = {}));
|
|
51325
|
-
|
|
51326
|
-
// ../../generator-common/dist/esm-node/mwa/entry.js
|
|
51327
|
-
var getEntryNameSchema = (extra = {}) => {
|
|
51328
|
-
return {
|
|
51329
|
-
type: "string",
|
|
51330
|
-
title: i18n.t(localeKeys.entry.name),
|
|
51331
|
-
default: "entry",
|
|
51332
|
-
"x-validator": (value) => {
|
|
51333
|
-
if (!value) {
|
|
51334
|
-
return i18n.t(localeKeys.entry.no_empty);
|
|
51335
|
-
}
|
|
51336
|
-
if (value === "pages") {
|
|
51337
|
-
return i18n.t(localeKeys.entry.no_pages);
|
|
51338
|
-
}
|
|
51339
|
-
return "";
|
|
51340
|
-
},
|
|
51341
|
-
"x-reactions": [
|
|
51342
|
-
{
|
|
51343
|
-
dependencies: [],
|
|
51344
|
-
fulfill: {
|
|
51345
|
-
state: {
|
|
51346
|
-
visible: !(extra === null || extra === void 0 ? void 0 : extra.isEmptySrc)
|
|
51347
|
-
}
|
|
51348
|
-
}
|
|
51349
|
-
}
|
|
51350
|
-
]
|
|
51351
|
-
};
|
|
51352
|
-
};
|
|
51353
|
-
var getEntrySchemaProperties = (extra) => {
|
|
51354
|
-
return {
|
|
51355
|
-
name: getEntryNameSchema(extra)
|
|
51356
|
-
};
|
|
51357
|
-
};
|
|
51358
|
-
var getEntrySchema = (extra = {}) => {
|
|
51359
|
-
return {
|
|
51360
|
-
type: "object",
|
|
51361
|
-
properties: getEntrySchemaProperties(extra)
|
|
51362
|
-
};
|
|
51363
|
-
};
|
|
51364
|
-
var MWADefaultEntryConfig = {
|
|
51365
|
-
needModifyMWAConfig: BooleanConfig.NO
|
|
51366
|
-
};
|
|
51367
|
-
|
|
51368
|
-
// ../../generator-utils/dist/esm/index.js
|
|
51369
|
-
var import_utils3 = require("@modern-js/utils");
|
|
51370
|
-
function isTsProject(appDir) {
|
|
51371
|
-
return import_utils2.fs.existsSync(import_path.default.join(appDir, "tsconfig.json"));
|
|
51372
|
-
}
|
|
51373
|
-
async function getPackageObj(context) {
|
|
51374
|
-
const pkgStr = (await context.materials.default.get(`package.json`).value()).content;
|
|
51375
|
-
return JSON.parse(pkgStr);
|
|
51376
|
-
}
|
|
51377
51059
|
|
|
51378
51060
|
// ../../../../node_modules/.pnpm/@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith/dist/esm-node/materials/FsResource.js
|
|
51379
|
-
var
|
|
51380
|
-
var
|
|
51061
|
+
var import_path = __toESM(require("path"));
|
|
51062
|
+
var import_utils = require("@modern-js/utils");
|
|
51381
51063
|
var FS_RESOURCE = "_codesmith_core_fs_resource";
|
|
51382
51064
|
|
|
51383
51065
|
// ../../../../node_modules/.pnpm/@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith/dist/esm-node/utils/fsExists.js
|
|
51384
|
-
var
|
|
51066
|
+
var import_utils2 = require("@modern-js/utils");
|
|
51385
51067
|
async function fsExists(path7) {
|
|
51386
51068
|
try {
|
|
51387
|
-
await
|
|
51069
|
+
await import_utils2.fs.access(path7);
|
|
51388
51070
|
return true;
|
|
51389
51071
|
} catch (e) {
|
|
51390
51072
|
return false;
|
|
@@ -51430,16 +51112,16 @@ var EjsAPI = class {
|
|
|
51430
51112
|
};
|
|
51431
51113
|
|
|
51432
51114
|
// ../../../../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
|
|
51433
|
-
var
|
|
51434
|
-
var
|
|
51115
|
+
var import_path2 = __toESM(require("path"));
|
|
51116
|
+
var import_utils4 = require("@modern-js/utils");
|
|
51435
51117
|
var FsAPI = class {
|
|
51436
51118
|
async renderFile(resource, target) {
|
|
51437
51119
|
if (resource._type !== FS_RESOURCE) {
|
|
51438
51120
|
throw new Error("resource not match");
|
|
51439
51121
|
}
|
|
51440
|
-
const filePath =
|
|
51441
|
-
await
|
|
51442
|
-
await
|
|
51122
|
+
const filePath = import_path2.default.resolve(this.generatorCore.outputPath, target.toString());
|
|
51123
|
+
await import_utils4.fs.mkdirp(import_path2.default.dirname(filePath));
|
|
51124
|
+
await import_utils4.fs.copyFile(resource.filePath, filePath);
|
|
51443
51125
|
}
|
|
51444
51126
|
async renderDir(material, findGlob, target, options) {
|
|
51445
51127
|
const resourceMap = await material.find(findGlob, {
|
|
@@ -51457,10 +51139,10 @@ var FsAPI = class {
|
|
|
51457
51139
|
};
|
|
51458
51140
|
|
|
51459
51141
|
// ../../../../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
|
|
51460
|
-
var
|
|
51142
|
+
var import_utils5 = require("@modern-js/utils");
|
|
51461
51143
|
async function canUseGit() {
|
|
51462
51144
|
try {
|
|
51463
|
-
await (0,
|
|
51145
|
+
await (0, import_utils5.execa)("git", [
|
|
51464
51146
|
"--version"
|
|
51465
51147
|
], {
|
|
51466
51148
|
env: process.env
|
|
@@ -51472,7 +51154,7 @@ async function canUseGit() {
|
|
|
51472
51154
|
}
|
|
51473
51155
|
async function isInGitRepo(cwd) {
|
|
51474
51156
|
try {
|
|
51475
|
-
await (0,
|
|
51157
|
+
await (0, import_utils5.execa)("git", [
|
|
51476
51158
|
"rev-parse",
|
|
51477
51159
|
"--is-inside-work-tree"
|
|
51478
51160
|
], {
|
|
@@ -51485,13 +51167,13 @@ async function isInGitRepo(cwd) {
|
|
|
51485
51167
|
}
|
|
51486
51168
|
}
|
|
51487
51169
|
async function initGitRepo(cwd, defaultBranch) {
|
|
51488
|
-
await (0,
|
|
51170
|
+
await (0, import_utils5.execa)("git", [
|
|
51489
51171
|
"init"
|
|
51490
51172
|
], {
|
|
51491
51173
|
env: process.env,
|
|
51492
51174
|
cwd
|
|
51493
51175
|
});
|
|
51494
|
-
const { stdout } = await (0,
|
|
51176
|
+
const { stdout } = await (0, import_utils5.execa)("git", [
|
|
51495
51177
|
"symbolic-ref",
|
|
51496
51178
|
"--short",
|
|
51497
51179
|
"HEAD"
|
|
@@ -51500,7 +51182,7 @@ async function initGitRepo(cwd, defaultBranch) {
|
|
|
51500
51182
|
cwd
|
|
51501
51183
|
});
|
|
51502
51184
|
if (stdout !== defaultBranch) {
|
|
51503
|
-
await (0,
|
|
51185
|
+
await (0, import_utils5.execa)("git", [
|
|
51504
51186
|
"checkout",
|
|
51505
51187
|
"-b",
|
|
51506
51188
|
defaultBranch
|
|
@@ -51511,7 +51193,7 @@ async function initGitRepo(cwd, defaultBranch) {
|
|
|
51511
51193
|
}
|
|
51512
51194
|
}
|
|
51513
51195
|
async function gitAdd(cwd) {
|
|
51514
|
-
await (0,
|
|
51196
|
+
await (0, import_utils5.execa)("git", [
|
|
51515
51197
|
"add",
|
|
51516
51198
|
"-A"
|
|
51517
51199
|
], {
|
|
@@ -51520,7 +51202,7 @@ async function gitAdd(cwd) {
|
|
|
51520
51202
|
});
|
|
51521
51203
|
}
|
|
51522
51204
|
async function gitCommit(cwd, commitMessage) {
|
|
51523
|
-
await (0,
|
|
51205
|
+
await (0, import_utils5.execa)("git", [
|
|
51524
51206
|
"commit",
|
|
51525
51207
|
"-m",
|
|
51526
51208
|
commitMessage,
|
|
@@ -51644,10 +51326,10 @@ var HandlebarsAPI = class {
|
|
|
51644
51326
|
};
|
|
51645
51327
|
|
|
51646
51328
|
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.1/node_modules/@modern-js/codesmith-api-npm/dist/esm-node/utils/env.js
|
|
51647
|
-
var
|
|
51329
|
+
var import_utils8 = require("@modern-js/utils");
|
|
51648
51330
|
async function canUseNvm() {
|
|
51649
51331
|
try {
|
|
51650
|
-
await (0,
|
|
51332
|
+
await (0, import_utils8.execa)("source ~/.nvm/nvm.sh", {
|
|
51651
51333
|
env: process.env,
|
|
51652
51334
|
shell: true
|
|
51653
51335
|
});
|
|
@@ -51656,9 +51338,9 @@ async function canUseNvm() {
|
|
|
51656
51338
|
return false;
|
|
51657
51339
|
}
|
|
51658
51340
|
}
|
|
51659
|
-
async function
|
|
51341
|
+
async function canUseNpm() {
|
|
51660
51342
|
try {
|
|
51661
|
-
await (0,
|
|
51343
|
+
await (0, import_utils8.execa)("npm", [
|
|
51662
51344
|
"--version"
|
|
51663
51345
|
], {
|
|
51664
51346
|
env: process.env
|
|
@@ -51668,9 +51350,9 @@ async function canUseNpm3() {
|
|
|
51668
51350
|
return false;
|
|
51669
51351
|
}
|
|
51670
51352
|
}
|
|
51671
|
-
async function
|
|
51353
|
+
async function canUseYarn() {
|
|
51672
51354
|
try {
|
|
51673
|
-
await (0,
|
|
51355
|
+
await (0, import_utils8.execa)("yarn", [
|
|
51674
51356
|
"--version"
|
|
51675
51357
|
], {
|
|
51676
51358
|
env: process.env
|
|
@@ -51680,9 +51362,9 @@ async function canUseYarn2() {
|
|
|
51680
51362
|
return false;
|
|
51681
51363
|
}
|
|
51682
51364
|
}
|
|
51683
|
-
async function
|
|
51365
|
+
async function canUsePnpm() {
|
|
51684
51366
|
try {
|
|
51685
|
-
await (0,
|
|
51367
|
+
await (0, import_utils8.execa)("pnpm", [
|
|
51686
51368
|
"--version"
|
|
51687
51369
|
], {
|
|
51688
51370
|
env: process.env
|
|
@@ -51694,9 +51376,9 @@ async function canUsePnpm3() {
|
|
|
51694
51376
|
}
|
|
51695
51377
|
|
|
51696
51378
|
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.1/node_modules/@modern-js/codesmith-api-npm/dist/esm-node/utils/install.js
|
|
51697
|
-
var
|
|
51379
|
+
var import_utils9 = require("@modern-js/utils");
|
|
51698
51380
|
function execaWithStreamLog(command, args, options) {
|
|
51699
|
-
const promise = (0,
|
|
51381
|
+
const promise = (0, import_utils9.execa)(command, args, {
|
|
51700
51382
|
...options,
|
|
51701
51383
|
stdin: "inherit",
|
|
51702
51384
|
stdout: "inherit",
|
|
@@ -51705,7 +51387,7 @@ function execaWithStreamLog(command, args, options) {
|
|
|
51705
51387
|
return promise;
|
|
51706
51388
|
}
|
|
51707
51389
|
async function runInstallWithNvm(command, options) {
|
|
51708
|
-
await (0,
|
|
51390
|
+
await (0, import_utils9.execa)(`~/.nvm/nvm-exec ${command}`, {
|
|
51709
51391
|
...options,
|
|
51710
51392
|
shell: true,
|
|
51711
51393
|
stdin: "inherit",
|
|
@@ -51714,7 +51396,7 @@ async function runInstallWithNvm(command, options) {
|
|
|
51714
51396
|
});
|
|
51715
51397
|
}
|
|
51716
51398
|
async function npmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
51717
|
-
const canUse = await
|
|
51399
|
+
const canUse = await canUseNpm();
|
|
51718
51400
|
if (canUse) {
|
|
51719
51401
|
const params = [
|
|
51720
51402
|
"install"
|
|
@@ -51739,7 +51421,7 @@ async function npmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
|
51739
51421
|
throw new Error("please install npm first");
|
|
51740
51422
|
}
|
|
51741
51423
|
async function yarnInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
51742
|
-
const canUse = await
|
|
51424
|
+
const canUse = await canUseYarn();
|
|
51743
51425
|
if (canUse) {
|
|
51744
51426
|
const params = [
|
|
51745
51427
|
"install"
|
|
@@ -51764,7 +51446,7 @@ async function yarnInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
|
51764
51446
|
throw new Error("please install yarn first");
|
|
51765
51447
|
}
|
|
51766
51448
|
async function pnpmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
51767
|
-
const canUse = await
|
|
51449
|
+
const canUse = await canUsePnpm();
|
|
51768
51450
|
if (canUse) {
|
|
51769
51451
|
const params = [
|
|
51770
51452
|
"install"
|
|
@@ -61377,7 +61059,7 @@ var Schema = (
|
|
|
61377
61059
|
var import_inquirer = __toESM(require_inquirer());
|
|
61378
61060
|
|
|
61379
61061
|
// ../../../../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
|
|
61380
|
-
var
|
|
61062
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
|
61381
61063
|
function validateSchema(schema) {
|
|
61382
61064
|
const { type, properties } = schema;
|
|
61383
61065
|
if (type !== "object") {
|
|
@@ -61406,7 +61088,7 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
|
|
|
61406
61088
|
const questionValidate = async (field2, input) => {
|
|
61407
61089
|
if (fieldValidate) {
|
|
61408
61090
|
var _result_error;
|
|
61409
|
-
const result2 = await validate(input, (0,
|
|
61091
|
+
const result2 = await validate(input, (0, import_lodash.isFunction)(fieldValidate) ? {
|
|
61410
61092
|
validator: fieldValidate
|
|
61411
61093
|
} : fieldValidate);
|
|
61412
61094
|
if ((_result_error = result2.error) === null || _result_error === void 0 ? void 0 : _result_error.length) {
|
|
@@ -61430,14 +61112,14 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
|
|
|
61430
61112
|
when: !configValue[field]
|
|
61431
61113
|
};
|
|
61432
61114
|
if (items) {
|
|
61433
|
-
if ((0,
|
|
61115
|
+
if ((0, import_lodash.isArray)(defaultValue)) {
|
|
61434
61116
|
return {
|
|
61435
61117
|
...result,
|
|
61436
61118
|
type: "checkbox",
|
|
61437
61119
|
choices: items.map((item) => ({
|
|
61438
61120
|
type: "choice",
|
|
61439
|
-
name: (0,
|
|
61440
|
-
value: (0,
|
|
61121
|
+
name: (0, import_lodash.isObject)(item) ? item.label : item,
|
|
61122
|
+
value: (0, import_lodash.isObject)(item) ? item.value : item
|
|
61441
61123
|
}))
|
|
61442
61124
|
};
|
|
61443
61125
|
}
|
|
@@ -61446,8 +61128,8 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
|
|
|
61446
61128
|
type: "list",
|
|
61447
61129
|
choices: items.map((item) => ({
|
|
61448
61130
|
type: "choice",
|
|
61449
|
-
name: (0,
|
|
61450
|
-
value: (0,
|
|
61131
|
+
name: (0, import_lodash.isObject)(item) ? item.label : item,
|
|
61132
|
+
value: (0, import_lodash.isObject)(item) ? item.value : item
|
|
61451
61133
|
}))
|
|
61452
61134
|
};
|
|
61453
61135
|
}
|
|
@@ -61462,7 +61144,7 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
|
|
|
61462
61144
|
type: "input"
|
|
61463
61145
|
};
|
|
61464
61146
|
});
|
|
61465
|
-
return (0,
|
|
61147
|
+
return (0, import_lodash.flattenDeep)(questions);
|
|
61466
61148
|
}
|
|
61467
61149
|
function transformForm(schema, configValue = {}, validateMap, initValue) {
|
|
61468
61150
|
return getQuestionFromSchema(schema, configValue, validateMap, initValue);
|
|
@@ -61602,30 +61284,30 @@ var CLIReader = class {
|
|
|
61602
61284
|
};
|
|
61603
61285
|
|
|
61604
61286
|
// ../../../../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
|
|
61605
|
-
var
|
|
61606
|
-
var
|
|
61287
|
+
var import_utils13 = require("@modern-js/utils");
|
|
61288
|
+
var import_lodash5 = require("@modern-js/utils/lodash");
|
|
61607
61289
|
var import_comment_json = __toESM(require_src2());
|
|
61608
61290
|
var import_inquirer2 = __toESM(require_inquirer2());
|
|
61609
61291
|
|
|
61610
61292
|
// ../../../../node_modules/.pnpm/@modern-js+plugin-i18n@2.58.0/node_modules/@modern-js/plugin-i18n/dist/esm-node/index.js
|
|
61611
|
-
var
|
|
61293
|
+
var import_lodash3 = require("@modern-js/utils/lodash");
|
|
61612
61294
|
|
|
61613
61295
|
// ../../../../node_modules/.pnpm/@modern-js+plugin-i18n@2.58.0/node_modules/@modern-js/plugin-i18n/dist/esm-node/utils/index.js
|
|
61614
|
-
var
|
|
61615
|
-
function
|
|
61296
|
+
var import_lodash2 = require("@modern-js/utils/lodash");
|
|
61297
|
+
function getObjKeyMap(obj, prefix = "") {
|
|
61616
61298
|
const result = {};
|
|
61617
61299
|
Object.keys(obj).forEach((key) => {
|
|
61618
|
-
if ((0,
|
|
61300
|
+
if ((0, import_lodash2.isString)(obj[key])) {
|
|
61619
61301
|
result[key] = prefix ? `${prefix}.${key}` : key;
|
|
61620
|
-
} else if ((0,
|
|
61621
|
-
result[key] =
|
|
61302
|
+
} else if ((0, import_lodash2.isObject)(obj[key])) {
|
|
61303
|
+
result[key] = getObjKeyMap(obj[key], prefix ? `${prefix}.${key}` : key);
|
|
61622
61304
|
}
|
|
61623
61305
|
});
|
|
61624
61306
|
return result;
|
|
61625
61307
|
}
|
|
61626
61308
|
|
|
61627
61309
|
// ../../../../node_modules/.pnpm/@modern-js+plugin-i18n@2.58.0/node_modules/@modern-js/plugin-i18n/dist/esm-node/index.js
|
|
61628
|
-
var
|
|
61310
|
+
var I18n = class {
|
|
61629
61311
|
format(msg, vars) {
|
|
61630
61312
|
return msg.replace(/\{(\w+)\}/g, (_match, capture) => Object.prototype.hasOwnProperty.call(vars, capture) ? vars[capture] : capture);
|
|
61631
61313
|
}
|
|
@@ -61639,7 +61321,7 @@ var I18n2 = class {
|
|
|
61639
61321
|
if (!model) {
|
|
61640
61322
|
return fallbackText || key;
|
|
61641
61323
|
}
|
|
61642
|
-
const message = (0,
|
|
61324
|
+
const message = (0, import_lodash3.get)(model, key);
|
|
61643
61325
|
const value = message || fallbackText || key;
|
|
61644
61326
|
if (typeof value === "string") {
|
|
61645
61327
|
return this.format(value, vars || {});
|
|
@@ -61651,7 +61333,7 @@ var I18n2 = class {
|
|
|
61651
61333
|
if (languageMap) {
|
|
61652
61334
|
this.languageMap = languageMap;
|
|
61653
61335
|
}
|
|
61654
|
-
return
|
|
61336
|
+
return getObjKeyMap(this.languageMap[this.language]);
|
|
61655
61337
|
}
|
|
61656
61338
|
changeLanguage(config) {
|
|
61657
61339
|
this.language = config.locale || "en";
|
|
@@ -61671,7 +61353,7 @@ var I18n2 = class {
|
|
|
61671
61353
|
};
|
|
61672
61354
|
|
|
61673
61355
|
// ../../../../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
|
|
61674
|
-
var
|
|
61356
|
+
var EN_LOCALE = {
|
|
61675
61357
|
environment: {
|
|
61676
61358
|
node_version: "please upgrade node to lts version",
|
|
61677
61359
|
nvm_install: "please install nvm first",
|
|
@@ -61698,7 +61380,7 @@ var EN_LOCALE2 = {
|
|
|
61698
61380
|
};
|
|
61699
61381
|
|
|
61700
61382
|
// ../../../../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
|
|
61701
|
-
var
|
|
61383
|
+
var ZH_LOCALE = {
|
|
61702
61384
|
environment: {
|
|
61703
61385
|
node_version: "请升级 Node 版本至 LIS",
|
|
61704
61386
|
nvm_install: "检测到环境中未安装 nvm,请先安装 nvm",
|
|
@@ -61725,15 +61407,15 @@ var ZH_LOCALE2 = {
|
|
|
61725
61407
|
};
|
|
61726
61408
|
|
|
61727
61409
|
// ../../../../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
|
|
61728
|
-
var
|
|
61729
|
-
var
|
|
61730
|
-
zh:
|
|
61731
|
-
en:
|
|
61410
|
+
var i18n = new I18n();
|
|
61411
|
+
var localeKeys = i18n.init("zh", {
|
|
61412
|
+
zh: ZH_LOCALE,
|
|
61413
|
+
en: EN_LOCALE
|
|
61732
61414
|
});
|
|
61733
61415
|
|
|
61734
61416
|
// ../../../../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
|
|
61735
|
-
var
|
|
61736
|
-
var
|
|
61417
|
+
var import_path4 = __toESM(require("path"));
|
|
61418
|
+
var import_utils12 = require("@modern-js/utils");
|
|
61737
61419
|
var NODE_MAJOR_VERSION_MAP = {
|
|
61738
61420
|
"lts/*": 18,
|
|
61739
61421
|
"lts/argon": 4,
|
|
@@ -61746,7 +61428,7 @@ var NODE_MAJOR_VERSION_MAP = {
|
|
|
61746
61428
|
"lts/hydrogen": 18
|
|
61747
61429
|
};
|
|
61748
61430
|
async function getNoteVersion() {
|
|
61749
|
-
const result = await (0,
|
|
61431
|
+
const result = await (0, import_utils12.execa)("node", [
|
|
61750
61432
|
"--version"
|
|
61751
61433
|
]);
|
|
61752
61434
|
return result.stdout.slice(1);
|
|
@@ -61755,13 +61437,13 @@ async function checkUseNvm(cwd, logger) {
|
|
|
61755
61437
|
if (process.platform.startsWith("win")) {
|
|
61756
61438
|
return false;
|
|
61757
61439
|
}
|
|
61758
|
-
if (!await fsExists(
|
|
61440
|
+
if (!await fsExists(import_path4.default.join(cwd, ".nvmrc"))) {
|
|
61759
61441
|
return false;
|
|
61760
61442
|
}
|
|
61761
|
-
const nvmrcContent = (await
|
|
61443
|
+
const nvmrcContent = (await import_utils12.fs.readFile(import_path4.default.join(cwd, ".nvmrc"), "utf-8")).replace("\n", "");
|
|
61762
61444
|
const expectNodeVersion = NODE_MAJOR_VERSION_MAP[nvmrcContent] || nvmrcContent;
|
|
61763
61445
|
const currentNodeVersion = await getNoteVersion();
|
|
61764
|
-
if (expectNodeVersion ===
|
|
61446
|
+
if (expectNodeVersion === import_utils12.semver.major(currentNodeVersion)) {
|
|
61765
61447
|
return false;
|
|
61766
61448
|
}
|
|
61767
61449
|
if (!await canUseNvm()) {
|
|
@@ -61780,7 +61462,7 @@ async function checkUseNvm(cwd, logger) {
|
|
|
61780
61462
|
}
|
|
61781
61463
|
|
|
61782
61464
|
// ../../../../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
|
|
61783
|
-
var
|
|
61465
|
+
var import_lodash4 = require("@modern-js/utils/lodash");
|
|
61784
61466
|
function transformInquirerSchema(questions, configValue = {}, validateMap = {}, initValue = {}) {
|
|
61785
61467
|
for (const question of questions) {
|
|
61786
61468
|
question.default = initValue[question.name] || question.default;
|
|
@@ -61788,7 +61470,7 @@ function transformInquirerSchema(questions, configValue = {}, validateMap = {},
|
|
|
61788
61470
|
question.validate = async (input, answers) => {
|
|
61789
61471
|
if (originValidate) {
|
|
61790
61472
|
const result = await originValidate(input, answers);
|
|
61791
|
-
if ((0,
|
|
61473
|
+
if ((0, import_lodash4.isString)(result)) {
|
|
61792
61474
|
return result;
|
|
61793
61475
|
}
|
|
61794
61476
|
}
|
|
@@ -61810,13 +61492,13 @@ function transformInquirerSchema(questions, configValue = {}, validateMap = {},
|
|
|
61810
61492
|
// ../../../../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
|
|
61811
61493
|
var AppAPI = class {
|
|
61812
61494
|
async checkEnvironment(nodeVersion) {
|
|
61813
|
-
if (
|
|
61814
|
-
this.generatorCore.logger.warn(
|
|
61495
|
+
if (import_utils13.semver.lt(process.versions.node, nodeVersion || "12.22.12")) {
|
|
61496
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.environment.node_version));
|
|
61815
61497
|
return false;
|
|
61816
61498
|
}
|
|
61817
|
-
if (!await
|
|
61499
|
+
if (!await canUseYarn() && !await canUsePnpm() && !await canUseNpm()) {
|
|
61818
61500
|
this.generatorCore.logger.debug("can't use yarn or pnpm or npm");
|
|
61819
|
-
this.generatorCore.logger.warn(
|
|
61501
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.environment.yarn_pnpm_npm));
|
|
61820
61502
|
return false;
|
|
61821
61503
|
}
|
|
61822
61504
|
return true;
|
|
@@ -61833,7 +61515,7 @@ var AppAPI = class {
|
|
|
61833
61515
|
}
|
|
61834
61516
|
let intallPromise;
|
|
61835
61517
|
if (command) {
|
|
61836
|
-
intallPromise = (0,
|
|
61518
|
+
intallPromise = (0, import_utils13.execa)(command, [], {
|
|
61837
61519
|
shell: true,
|
|
61838
61520
|
stdin: "inherit",
|
|
61839
61521
|
stdout: "inherit",
|
|
@@ -61858,10 +61540,10 @@ var AppAPI = class {
|
|
|
61858
61540
|
}
|
|
61859
61541
|
try {
|
|
61860
61542
|
await intallPromise;
|
|
61861
|
-
this.generatorCore.logger.info(
|
|
61543
|
+
this.generatorCore.logger.info(i18n.t(localeKeys.install.success));
|
|
61862
61544
|
} catch (e) {
|
|
61863
61545
|
this.generatorCore.logger.warn(e);
|
|
61864
|
-
this.generatorCore.logger.warn(
|
|
61546
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.install.failed, {
|
|
61865
61547
|
command: command || `${packageManager} install`
|
|
61866
61548
|
}));
|
|
61867
61549
|
}
|
|
@@ -61882,16 +61564,16 @@ var AppAPI = class {
|
|
|
61882
61564
|
}
|
|
61883
61565
|
} catch (e) {
|
|
61884
61566
|
this.generatorCore.logger.debug("Dependencies install failed", e);
|
|
61885
|
-
this.generatorCore.logger.warn(
|
|
61567
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.install.failed_no_command));
|
|
61886
61568
|
}
|
|
61887
61569
|
try {
|
|
61888
61570
|
if (!isMonorepoSubProject && !customNoNeedGit && !inGitRepo) {
|
|
61889
61571
|
await this.gitApi.addAndCommit(commitMessage || "feat: init");
|
|
61890
|
-
this.generatorCore.logger.info(
|
|
61572
|
+
this.generatorCore.logger.info(i18n.t(localeKeys.git.success));
|
|
61891
61573
|
}
|
|
61892
61574
|
} catch (e) {
|
|
61893
61575
|
this.generatorCore.logger.debug("Git repository create failed", e);
|
|
61894
|
-
this.generatorCore.logger.warn(
|
|
61576
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.git.failed));
|
|
61895
61577
|
}
|
|
61896
61578
|
}
|
|
61897
61579
|
async forgeTemplate(templatePattern, filter, rename, parameters, type = "handlebars") {
|
|
@@ -61916,7 +61598,7 @@ var AppAPI = class {
|
|
|
61916
61598
|
}
|
|
61917
61599
|
} catch (e) {
|
|
61918
61600
|
this.generatorCore.logger.debug("base forging failed:", e);
|
|
61919
|
-
this.generatorCore.logger.warn(
|
|
61601
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.templated.failed));
|
|
61920
61602
|
throw new Error("base forging failed");
|
|
61921
61603
|
} finally {
|
|
61922
61604
|
var _this_generatorCore_logger_timing1, _this_generatorCore_logger1;
|
|
@@ -61955,7 +61637,7 @@ var AppAPI = class {
|
|
|
61955
61637
|
}
|
|
61956
61638
|
} catch (e) {
|
|
61957
61639
|
this.generatorCore.logger.debug("base forging failed:", e);
|
|
61958
|
-
this.generatorCore.logger.warn(
|
|
61640
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.templated.failed));
|
|
61959
61641
|
throw new Error("base forging failed");
|
|
61960
61642
|
} finally {
|
|
61961
61643
|
var _this_generatorCore_logger_timing1, _this_generatorCore_logger1;
|
|
@@ -61964,35 +61646,35 @@ var AppAPI = class {
|
|
|
61964
61646
|
}
|
|
61965
61647
|
async updateWorkspace(folder, workspaceName = "monorepo.code-workspace") {
|
|
61966
61648
|
const { filePath } = this.generatorContext.materials.default.get(workspaceName);
|
|
61967
|
-
if (!
|
|
61649
|
+
if (!import_utils13.fs.existsSync(filePath)) {
|
|
61968
61650
|
return;
|
|
61969
61651
|
}
|
|
61970
|
-
const content = await
|
|
61652
|
+
const content = await import_utils13.fs.readFile(filePath);
|
|
61971
61653
|
const workspace = (0, import_comment_json.parse)(content.toString());
|
|
61972
61654
|
workspace.folders = [
|
|
61973
61655
|
folder,
|
|
61974
61656
|
...workspace.folders || []
|
|
61975
61657
|
];
|
|
61976
61658
|
const indent = 2;
|
|
61977
|
-
await
|
|
61659
|
+
await import_utils13.fs.writeFile(filePath, (0, import_comment_json.stringify)(workspace, null, indent), {
|
|
61978
61660
|
encoding: "utf-8"
|
|
61979
61661
|
});
|
|
61980
61662
|
}
|
|
61981
61663
|
showSuccessInfo(successInfo) {
|
|
61982
|
-
this.generatorCore.logger.info(successInfo ||
|
|
61664
|
+
this.generatorCore.logger.info(successInfo || i18n.t(localeKeys.success.info));
|
|
61983
61665
|
}
|
|
61984
61666
|
async runSubGenerator(subGenerator, relativePwdPath, config) {
|
|
61985
61667
|
try {
|
|
61986
61668
|
await this.generatorCore.runSubGenerator(subGenerator, relativePwdPath, config);
|
|
61987
61669
|
} catch (e) {
|
|
61988
|
-
this.generatorCore.logger.warn(
|
|
61989
|
-
this.generatorCore.logger.debug(
|
|
61670
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.generator.failed));
|
|
61671
|
+
this.generatorCore.logger.debug(i18n.t(localeKeys.generator.failed), e);
|
|
61990
61672
|
throw new Error("run sub generator failed");
|
|
61991
61673
|
}
|
|
61992
61674
|
}
|
|
61993
61675
|
mergeAnswers(answers, configValue) {
|
|
61994
|
-
const inputData = (0,
|
|
61995
|
-
this.generatorContext.config = (0,
|
|
61676
|
+
const inputData = (0, import_lodash5.merge)(answers, configValue);
|
|
61677
|
+
this.generatorContext.config = (0, import_lodash5.merge)(this.generatorContext.config, inputData);
|
|
61996
61678
|
return inputData;
|
|
61997
61679
|
}
|
|
61998
61680
|
async getInputBySchemaFunc(schemaFunc, configValue = {}, validateMap = {}, initValue = {}) {
|
|
@@ -62028,7 +61710,7 @@ var AppAPI = class {
|
|
|
62028
61710
|
return this.mergeAnswers(answers, configValue);
|
|
62029
61711
|
}
|
|
62030
61712
|
constructor(generatorContext, generatorCore) {
|
|
62031
|
-
this.i18n =
|
|
61713
|
+
this.i18n = i18n;
|
|
62032
61714
|
this.generatorCore = generatorCore;
|
|
62033
61715
|
this.generatorContext = generatorContext;
|
|
62034
61716
|
this.npmApi = new NpmAPI(generatorCore);
|
|
@@ -62039,19 +61721,353 @@ var AppAPI = class {
|
|
|
62039
61721
|
}
|
|
62040
61722
|
};
|
|
62041
61723
|
|
|
61724
|
+
// ../../../cli/plugin-i18n/dist/esm-node/index.js
|
|
61725
|
+
var import_lodash7 = require("@modern-js/utils/lodash");
|
|
61726
|
+
|
|
61727
|
+
// ../../../cli/plugin-i18n/dist/esm-node/utils/index.js
|
|
61728
|
+
var import_lodash6 = require("@modern-js/utils/lodash");
|
|
61729
|
+
function getObjKeyMap2(obj, prefix = "") {
|
|
61730
|
+
const result = {};
|
|
61731
|
+
Object.keys(obj).forEach((key) => {
|
|
61732
|
+
if ((0, import_lodash6.isString)(obj[key])) {
|
|
61733
|
+
result[key] = prefix ? `${prefix}.${key}` : key;
|
|
61734
|
+
} else if ((0, import_lodash6.isObject)(obj[key])) {
|
|
61735
|
+
result[key] = getObjKeyMap2(obj[key], prefix ? `${prefix}.${key}` : key);
|
|
61736
|
+
}
|
|
61737
|
+
});
|
|
61738
|
+
return result;
|
|
61739
|
+
}
|
|
61740
|
+
|
|
61741
|
+
// ../../../cli/plugin-i18n/dist/esm-node/index.js
|
|
61742
|
+
var I18n2 = class {
|
|
61743
|
+
format(msg, vars) {
|
|
61744
|
+
return msg.replace(/\{(\w+)\}/g, (_match, capture) => Object.prototype.hasOwnProperty.call(vars, capture) ? vars[capture] : capture);
|
|
61745
|
+
}
|
|
61746
|
+
getMessage(lang, key, vars, fallbackText) {
|
|
61747
|
+
const languages = Object.keys(this.languageMap);
|
|
61748
|
+
const resultLang = languages.find((l) => l === lang);
|
|
61749
|
+
if (!resultLang && languages.length === 0) {
|
|
61750
|
+
return fallbackText || key;
|
|
61751
|
+
}
|
|
61752
|
+
const model = this.languageMap[resultLang || "en"];
|
|
61753
|
+
if (!model) {
|
|
61754
|
+
return fallbackText || key;
|
|
61755
|
+
}
|
|
61756
|
+
const message = (0, import_lodash7.get)(model, key);
|
|
61757
|
+
const value = message || fallbackText || key;
|
|
61758
|
+
if (typeof value === "string") {
|
|
61759
|
+
return this.format(value, vars || {});
|
|
61760
|
+
}
|
|
61761
|
+
throw new Error("key is not a string");
|
|
61762
|
+
}
|
|
61763
|
+
init(language, languageMap) {
|
|
61764
|
+
this.language = language || "en";
|
|
61765
|
+
if (languageMap) {
|
|
61766
|
+
this.languageMap = languageMap;
|
|
61767
|
+
}
|
|
61768
|
+
return getObjKeyMap2(this.languageMap[this.language]);
|
|
61769
|
+
}
|
|
61770
|
+
changeLanguage(config) {
|
|
61771
|
+
this.language = config.locale || "en";
|
|
61772
|
+
}
|
|
61773
|
+
t(key, vars, fallbackText) {
|
|
61774
|
+
return this.getMessage(this.language, key, vars, fallbackText);
|
|
61775
|
+
}
|
|
61776
|
+
lang(lang) {
|
|
61777
|
+
return {
|
|
61778
|
+
t: (key, vars, fallbackText) => this.getMessage(lang, key, vars, fallbackText)
|
|
61779
|
+
};
|
|
61780
|
+
}
|
|
61781
|
+
constructor() {
|
|
61782
|
+
this.language = "en";
|
|
61783
|
+
this.languageMap = {};
|
|
61784
|
+
}
|
|
61785
|
+
};
|
|
61786
|
+
|
|
61787
|
+
// ../../generator-common/dist/esm-node/locale/en.js
|
|
61788
|
+
var EN_LOCALE2 = {
|
|
61789
|
+
solution: {
|
|
61790
|
+
self: "Please select the type of project you want to create:",
|
|
61791
|
+
mwa: "Web App",
|
|
61792
|
+
module: "Npm Module",
|
|
61793
|
+
custom: "Custom Solution",
|
|
61794
|
+
default: "Default"
|
|
61795
|
+
},
|
|
61796
|
+
scenes: {
|
|
61797
|
+
self: "Please select the project scenario:"
|
|
61798
|
+
},
|
|
61799
|
+
sub_solution: {
|
|
61800
|
+
self: "Please select the type of project you want to create:",
|
|
61801
|
+
mwa: "Web App",
|
|
61802
|
+
module: "Npm Module"
|
|
61803
|
+
},
|
|
61804
|
+
action: {
|
|
61805
|
+
self: "Please select the operation you want:",
|
|
61806
|
+
function: {
|
|
61807
|
+
self: "Enable Features",
|
|
61808
|
+
question: "Please select the feature name:",
|
|
61809
|
+
tailwindcss: "Enable Tailwind CSS",
|
|
61810
|
+
bff: "Enable BFF",
|
|
61811
|
+
micro_frontend: "Enable Micro Frontend",
|
|
61812
|
+
i18n: "Enable Internationalization (i18n)",
|
|
61813
|
+
storybookV7: "Enable Storybook V7",
|
|
61814
|
+
runtime_api: "Enable Runtime API",
|
|
61815
|
+
ssg: "Enable SSG",
|
|
61816
|
+
polyfill: "Enable UA-based Polyfill Feature",
|
|
61817
|
+
proxy: "Enable Global Proxy",
|
|
61818
|
+
swc: "Enable SWC Compile",
|
|
61819
|
+
module_doc: "Enable Module Doc"
|
|
61820
|
+
},
|
|
61821
|
+
element: {
|
|
61822
|
+
self: "Create Element",
|
|
61823
|
+
question: "Please select the type of element to create:",
|
|
61824
|
+
entry: 'New "entry"',
|
|
61825
|
+
server: 'New "Custom Web Server" source code directory'
|
|
61826
|
+
},
|
|
61827
|
+
refactor: {
|
|
61828
|
+
self: "Automatic Refactor",
|
|
61829
|
+
question: "Please select the type of refactoring:",
|
|
61830
|
+
react_router_5: "Use React Router v5"
|
|
61831
|
+
}
|
|
61832
|
+
},
|
|
61833
|
+
boolean: {
|
|
61834
|
+
yes: "Yes",
|
|
61835
|
+
no: "No"
|
|
61836
|
+
},
|
|
61837
|
+
language: {
|
|
61838
|
+
self: "Please select the programming language:"
|
|
61839
|
+
},
|
|
61840
|
+
packageManager: {
|
|
61841
|
+
self: "Please select the package manager:"
|
|
61842
|
+
},
|
|
61843
|
+
entry: {
|
|
61844
|
+
name: "Please fill in the entry name:",
|
|
61845
|
+
no_empty: "The entry name cannot be empty!",
|
|
61846
|
+
no_pages: 'The entry name cannot be "pages"!'
|
|
61847
|
+
},
|
|
61848
|
+
packageName: {
|
|
61849
|
+
self: "Please fill in the project name:",
|
|
61850
|
+
sub_name: "Please fill in the sub-project name:",
|
|
61851
|
+
no_empty: "The package name cannot be empty!"
|
|
61852
|
+
},
|
|
61853
|
+
packagePath: {
|
|
61854
|
+
self: "Please fill in the sub-project directory name:",
|
|
61855
|
+
no_empty: "The package path cannot be empty!",
|
|
61856
|
+
format: "Only lowercase letters, numbers and delimiters (-), and underscore (_), and directory delimiters (/) can be used in package path."
|
|
61857
|
+
},
|
|
61858
|
+
framework: {
|
|
61859
|
+
self: "Please select the framework:",
|
|
61860
|
+
egg: "Egg",
|
|
61861
|
+
express: "Express",
|
|
61862
|
+
koa: "Koa",
|
|
61863
|
+
nest: "Nest"
|
|
61864
|
+
},
|
|
61865
|
+
bff: {
|
|
61866
|
+
bffType: {
|
|
61867
|
+
self: "Please select the BFF type:",
|
|
61868
|
+
func: "Function",
|
|
61869
|
+
framework: "Framework"
|
|
61870
|
+
}
|
|
61871
|
+
},
|
|
61872
|
+
buildTools: {
|
|
61873
|
+
self: "Please select the bundler:",
|
|
61874
|
+
webpack: "webpack",
|
|
61875
|
+
rspack: "Rspack (experimental)"
|
|
61876
|
+
}
|
|
61877
|
+
};
|
|
61878
|
+
|
|
61879
|
+
// ../../generator-common/dist/esm-node/locale/zh.js
|
|
61880
|
+
var ZH_LOCALE2 = {
|
|
61881
|
+
solution: {
|
|
61882
|
+
self: "请选择你想创建的工程类型",
|
|
61883
|
+
mwa: "Web 应用",
|
|
61884
|
+
module: "Npm 模块",
|
|
61885
|
+
custom: "自定义",
|
|
61886
|
+
default: "默认"
|
|
61887
|
+
},
|
|
61888
|
+
scenes: {
|
|
61889
|
+
self: "请选择项目场景"
|
|
61890
|
+
},
|
|
61891
|
+
sub_solution: {
|
|
61892
|
+
self: "请选择你想创建的工程类型",
|
|
61893
|
+
mwa: "Web 应用",
|
|
61894
|
+
module: "Npm 模块"
|
|
61895
|
+
},
|
|
61896
|
+
action: {
|
|
61897
|
+
self: "请选择你想要的操作",
|
|
61898
|
+
function: {
|
|
61899
|
+
self: "启用可选功能",
|
|
61900
|
+
question: "请选择功能名称",
|
|
61901
|
+
tailwindcss: "启用「Tailwind CSS」 支持",
|
|
61902
|
+
bff: "启用「BFF」功能",
|
|
61903
|
+
micro_frontend: "启用「微前端」模式",
|
|
61904
|
+
i18n: "启用「国际化(i18n)」功能",
|
|
61905
|
+
storybookV7: "启用「Storybook」V7",
|
|
61906
|
+
runtime_api: "启用「Runtime API」",
|
|
61907
|
+
ssg: "启用「SSG」功能",
|
|
61908
|
+
polyfill: "启用「基于 UA 的 Polyfill」功能",
|
|
61909
|
+
proxy: "启用「全局代理」",
|
|
61910
|
+
swc: "启用「SWC 编译」",
|
|
61911
|
+
module_doc: "启动「模块文档」功能"
|
|
61912
|
+
},
|
|
61913
|
+
element: {
|
|
61914
|
+
self: "创建工程元素",
|
|
61915
|
+
question: "请选择创建元素类型",
|
|
61916
|
+
entry: "新建「应用入口」",
|
|
61917
|
+
server: "新建「自定义 Web Server」源码目录"
|
|
61918
|
+
},
|
|
61919
|
+
refactor: {
|
|
61920
|
+
self: "自动重构",
|
|
61921
|
+
question: "请选择重构类型",
|
|
61922
|
+
react_router_5: "使用 React Router v5"
|
|
61923
|
+
}
|
|
61924
|
+
},
|
|
61925
|
+
boolean: {
|
|
61926
|
+
yes: "是",
|
|
61927
|
+
no: "否"
|
|
61928
|
+
},
|
|
61929
|
+
language: {
|
|
61930
|
+
self: "请选择开发语言"
|
|
61931
|
+
},
|
|
61932
|
+
packageManager: {
|
|
61933
|
+
self: "请选择包管理工具"
|
|
61934
|
+
},
|
|
61935
|
+
entry: {
|
|
61936
|
+
name: "请填写入口名称",
|
|
61937
|
+
no_empty: "入口名称不能为空!",
|
|
61938
|
+
no_pages: '入口名称不支持 "pages"!'
|
|
61939
|
+
},
|
|
61940
|
+
packageName: {
|
|
61941
|
+
self: "请填写项目名称",
|
|
61942
|
+
sub_name: "请填写子项目名称",
|
|
61943
|
+
no_empty: "项目名称不能为空!"
|
|
61944
|
+
},
|
|
61945
|
+
packagePath: {
|
|
61946
|
+
self: "请填写子项目目录名称",
|
|
61947
|
+
no_empty: "目录名称不能为空!",
|
|
61948
|
+
format: "目录名称只能使用小写字母、数字和分隔线(-)、下划线(_)和目录分隔符(/)"
|
|
61949
|
+
},
|
|
61950
|
+
framework: {
|
|
61951
|
+
self: "请选择运行时框架",
|
|
61952
|
+
egg: "Egg",
|
|
61953
|
+
express: "Express",
|
|
61954
|
+
koa: "Koa",
|
|
61955
|
+
nest: "Nest"
|
|
61956
|
+
},
|
|
61957
|
+
bff: {
|
|
61958
|
+
bffType: {
|
|
61959
|
+
self: "请选择 BFF 类型",
|
|
61960
|
+
func: "函数模式",
|
|
61961
|
+
framework: "框架模式"
|
|
61962
|
+
}
|
|
61963
|
+
},
|
|
61964
|
+
buildTools: {
|
|
61965
|
+
self: "请选择构建工具",
|
|
61966
|
+
webpack: "webpack",
|
|
61967
|
+
rspack: "Rspack (实验性)"
|
|
61968
|
+
}
|
|
61969
|
+
};
|
|
61970
|
+
|
|
61971
|
+
// ../../generator-common/dist/esm-node/locale/index.js
|
|
61972
|
+
var i18n2 = new I18n2();
|
|
61973
|
+
var localeKeys2 = i18n2.init("en", {
|
|
61974
|
+
zh: ZH_LOCALE2,
|
|
61975
|
+
en: EN_LOCALE2
|
|
61976
|
+
});
|
|
61977
|
+
|
|
61978
|
+
// ../../generator-common/dist/esm-node/common/boolean.js
|
|
61979
|
+
var BooleanConfig;
|
|
61980
|
+
(function(BooleanConfig2) {
|
|
61981
|
+
BooleanConfig2["NO"] = "no";
|
|
61982
|
+
BooleanConfig2["YES"] = "yes";
|
|
61983
|
+
})(BooleanConfig || (BooleanConfig = {}));
|
|
61984
|
+
|
|
61985
|
+
// ../../generator-common/dist/esm-node/mwa/entry.js
|
|
61986
|
+
var getEntryNameSchema = (extra = {}) => {
|
|
61987
|
+
return {
|
|
61988
|
+
type: "string",
|
|
61989
|
+
title: i18n2.t(localeKeys2.entry.name),
|
|
61990
|
+
default: "entry",
|
|
61991
|
+
"x-validator": (value) => {
|
|
61992
|
+
if (!value) {
|
|
61993
|
+
return i18n2.t(localeKeys2.entry.no_empty);
|
|
61994
|
+
}
|
|
61995
|
+
if (value === "pages") {
|
|
61996
|
+
return i18n2.t(localeKeys2.entry.no_pages);
|
|
61997
|
+
}
|
|
61998
|
+
return "";
|
|
61999
|
+
},
|
|
62000
|
+
"x-reactions": [
|
|
62001
|
+
{
|
|
62002
|
+
dependencies: [],
|
|
62003
|
+
fulfill: {
|
|
62004
|
+
state: {
|
|
62005
|
+
visible: !(extra === null || extra === void 0 ? void 0 : extra.isEmptySrc)
|
|
62006
|
+
}
|
|
62007
|
+
}
|
|
62008
|
+
}
|
|
62009
|
+
]
|
|
62010
|
+
};
|
|
62011
|
+
};
|
|
62012
|
+
var getEntrySchemaProperties = (extra) => {
|
|
62013
|
+
return {
|
|
62014
|
+
name: getEntryNameSchema(extra)
|
|
62015
|
+
};
|
|
62016
|
+
};
|
|
62017
|
+
var getEntrySchema = (extra = {}) => {
|
|
62018
|
+
return {
|
|
62019
|
+
type: "object",
|
|
62020
|
+
properties: getEntrySchemaProperties(extra)
|
|
62021
|
+
};
|
|
62022
|
+
};
|
|
62023
|
+
var MWADefaultEntryConfig = {
|
|
62024
|
+
needModifyMWAConfig: BooleanConfig.NO
|
|
62025
|
+
};
|
|
62026
|
+
|
|
62027
|
+
// ../../generator-utils/dist/esm/index.js
|
|
62028
|
+
var import_path5 = __toESM(require("path"));
|
|
62029
|
+
var import_utils15 = require("@modern-js/utils");
|
|
62030
|
+
var import_utils16 = require("@modern-js/utils");
|
|
62031
|
+
function isTsProject(appDir) {
|
|
62032
|
+
return import_utils15.fs.existsSync(import_path5.default.join(appDir, "tsconfig.json"));
|
|
62033
|
+
}
|
|
62034
|
+
async function getPackageObj(context) {
|
|
62035
|
+
const pkgStr = (await context.materials.default.get(`package.json`).value()).content;
|
|
62036
|
+
return JSON.parse(pkgStr);
|
|
62037
|
+
}
|
|
62038
|
+
|
|
62039
|
+
// src/index.ts
|
|
62040
|
+
var import_lodash8 = require("@modern-js/utils/lodash");
|
|
62041
|
+
|
|
62042
|
+
// src/locale/en.ts
|
|
62043
|
+
var EN_LOCALE3 = {
|
|
62044
|
+
package_not_exist: 'project not exist "package.json"',
|
|
62045
|
+
success: "create entry success!"
|
|
62046
|
+
};
|
|
62047
|
+
|
|
62048
|
+
// src/locale/zh.ts
|
|
62049
|
+
var ZH_LOCALE3 = {
|
|
62050
|
+
package_not_exist: '当前项目不存在 "package.json"',
|
|
62051
|
+
success: "创建入口成功!"
|
|
62052
|
+
};
|
|
62053
|
+
|
|
62054
|
+
// src/locale/index.ts
|
|
62055
|
+
var i18n3 = new I18n2();
|
|
62056
|
+
var localeKeys3 = i18n3.init("en", { zh: ZH_LOCALE3, en: EN_LOCALE3 });
|
|
62057
|
+
|
|
62042
62058
|
// src/utils/index.ts
|
|
62043
62059
|
var import_path6 = __toESM(require("path"));
|
|
62044
62060
|
function isEmptySource(appDir, entriesDir) {
|
|
62045
62061
|
let files;
|
|
62046
62062
|
try {
|
|
62047
|
-
files =
|
|
62063
|
+
files = import_utils16.fs.readdirSync(import_path6.default.join(appDir, entriesDir));
|
|
62048
62064
|
} catch (error) {
|
|
62049
62065
|
return true;
|
|
62050
62066
|
}
|
|
62051
62067
|
const existValidFile = files.filter(
|
|
62052
62068
|
(file) => !/^\.[\w]+/.test(file) && !/\.[\w]+(\.js|\.jsx|\.ts|\.tsx|\.json|\.d.ts)$/.test(file)
|
|
62053
62069
|
).some((file) => {
|
|
62054
|
-
const stat =
|
|
62070
|
+
const stat = import_utils16.fs.statSync(import_path6.default.join(appDir, entriesDir, file));
|
|
62055
62071
|
if (stat.isDirectory()) {
|
|
62056
62072
|
return true;
|
|
62057
62073
|
}
|
|
@@ -62068,9 +62084,9 @@ function isSingleEntry(appDir, entriesDir) {
|
|
|
62068
62084
|
"index.tsx",
|
|
62069
62085
|
"App.jsx",
|
|
62070
62086
|
"App.tsx"
|
|
62071
|
-
].some((f) =>
|
|
62087
|
+
].some((f) => import_utils16.fs.existsSync(import_path6.default.join(appDir, entriesDir, f)));
|
|
62072
62088
|
if (!hasMainEntryFile) {
|
|
62073
|
-
const dirs =
|
|
62089
|
+
const dirs = import_utils16.fs.readdirSync(import_path6.default.join(appDir, entriesDir));
|
|
62074
62090
|
if (dirs.includes("pages")) {
|
|
62075
62091
|
return true;
|
|
62076
62092
|
}
|
|
@@ -62082,27 +62098,11 @@ function isSingleEntry(appDir, entriesDir) {
|
|
|
62082
62098
|
return hasMainEntryFile;
|
|
62083
62099
|
}
|
|
62084
62100
|
|
|
62085
|
-
// src/locale/zh.ts
|
|
62086
|
-
var ZH_LOCALE3 = {
|
|
62087
|
-
package_not_exist: '当前项目不存在 "package.json"',
|
|
62088
|
-
success: "创建入口成功!"
|
|
62089
|
-
};
|
|
62090
|
-
|
|
62091
|
-
// src/locale/en.ts
|
|
62092
|
-
var EN_LOCALE3 = {
|
|
62093
|
-
package_not_exist: 'project not exist "package.json"',
|
|
62094
|
-
success: "create entry success!"
|
|
62095
|
-
};
|
|
62096
|
-
|
|
62097
|
-
// src/locale/index.ts
|
|
62098
|
-
var i18n3 = new I18n();
|
|
62099
|
-
var localeKeys3 = i18n3.init("en", { zh: ZH_LOCALE3, en: EN_LOCALE3 });
|
|
62100
|
-
|
|
62101
62101
|
// src/index.ts
|
|
62102
62102
|
var handleInput = async (context, generator, appApi) => {
|
|
62103
62103
|
const appDir = context.materials.default.basePath;
|
|
62104
62104
|
const { entriesDir } = context.config;
|
|
62105
|
-
await
|
|
62105
|
+
await import_utils16.fs.ensureDir(import_path7.default.join(appDir, entriesDir));
|
|
62106
62106
|
const analysisInfo = {
|
|
62107
62107
|
isEmptySrc: isEmptySource(appDir, entriesDir),
|
|
62108
62108
|
isSingleEntry: isSingleEntry(appDir, entriesDir),
|
|
@@ -62118,16 +62118,16 @@ var refactorSingleEntry = async (context, generator) => {
|
|
|
62118
62118
|
const pkgName = pkgObj.name;
|
|
62119
62119
|
const { entriesDir } = context.config;
|
|
62120
62120
|
const oldFilePath = import_path7.default.join(context.materials.default.basePath, entriesDir);
|
|
62121
|
-
const oldFiles =
|
|
62122
|
-
if (
|
|
62123
|
-
const files =
|
|
62121
|
+
const oldFiles = import_utils16.fs.readdirSync(oldFilePath).filter((filePath) => {
|
|
62122
|
+
if (import_utils16.fs.statSync(import_path7.default.join(oldFilePath, filePath)).isDirectory()) {
|
|
62123
|
+
const files = import_utils16.fs.readdirSync(import_path7.default.join(oldFilePath, filePath));
|
|
62124
62124
|
return files.length;
|
|
62125
62125
|
}
|
|
62126
62126
|
return filePath !== ".eslintrc.json" && filePath !== ".eslintrc.js" && filePath !== "modern-app-env.d.ts" && filePath !== "modern.runtime.ts" && filePath !== "modern.runtime.js";
|
|
62127
62127
|
}).map(
|
|
62128
62128
|
(file) => import_path7.default.join(context.materials.default.basePath, entriesDir, file)
|
|
62129
62129
|
);
|
|
62130
|
-
|
|
62130
|
+
import_utils16.fs.mkdirpSync(
|
|
62131
62131
|
import_path7.default.join(context.materials.default.basePath, entriesDir, pkgName)
|
|
62132
62132
|
);
|
|
62133
62133
|
oldFiles.forEach((file) => {
|
|
@@ -62137,7 +62137,7 @@ var refactorSingleEntry = async (context, generator) => {
|
|
|
62137
62137
|
import_path7.default.join(entriesDir, pkgName)
|
|
62138
62138
|
)}`
|
|
62139
62139
|
);
|
|
62140
|
-
|
|
62140
|
+
import_utils16.fs.renameSync(
|
|
62141
62141
|
file,
|
|
62142
62142
|
file.replace(entriesDir, import_path7.default.join(entriesDir, pkgName))
|
|
62143
62143
|
);
|
|
@@ -62163,7 +62163,7 @@ var handleTemplateFile = async (context, generator, appApi) => {
|
|
|
62163
62163
|
var src_default = async (context, generator) => {
|
|
62164
62164
|
const appApi = new AppAPI(context, generator);
|
|
62165
62165
|
const { locale } = context.config;
|
|
62166
|
-
|
|
62166
|
+
i18n2.changeLanguage({ locale });
|
|
62167
62167
|
appApi.i18n.changeLanguage({ locale });
|
|
62168
62168
|
i18n3.changeLanguage({ locale });
|
|
62169
62169
|
if (!await appApi.checkEnvironment()) {
|