@modern-js/bff-generator 3.4.15 → 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 +1234 -1204
- package/package.json +10 -10
- package/src/index.ts +17 -23
package/dist/index.js
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
8
11
|
var __commonJS = (cb, mod) => function __require() {
|
|
9
12
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
13
|
};
|
|
@@ -1569,15 +1572,15 @@ var require_runtime = __commonJS({
|
|
|
1569
1572
|
throw new _exception2["default"]("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version (" + compilerInfo[1] + ").");
|
|
1570
1573
|
}
|
|
1571
1574
|
}
|
|
1572
|
-
function template(templateSpec,
|
|
1573
|
-
if (!
|
|
1575
|
+
function template(templateSpec, env2) {
|
|
1576
|
+
if (!env2) {
|
|
1574
1577
|
throw new _exception2["default"]("No environment passed to template");
|
|
1575
1578
|
}
|
|
1576
1579
|
if (!templateSpec || !templateSpec.main) {
|
|
1577
1580
|
throw new _exception2["default"]("Unknown template object: " + typeof templateSpec);
|
|
1578
1581
|
}
|
|
1579
1582
|
templateSpec.main.decorator = templateSpec.main_d;
|
|
1580
|
-
|
|
1583
|
+
env2.VM.checkRevision(templateSpec.compiler);
|
|
1581
1584
|
var templateWasPrecompiledWithCompilerV7 = templateSpec.compiler && templateSpec.compiler[0] === 7;
|
|
1582
1585
|
function invokePartialWrapper(partial, context, options) {
|
|
1583
1586
|
if (options.hash) {
|
|
@@ -1586,14 +1589,14 @@ var require_runtime = __commonJS({
|
|
|
1586
1589
|
options.ids[0] = true;
|
|
1587
1590
|
}
|
|
1588
1591
|
}
|
|
1589
|
-
partial =
|
|
1592
|
+
partial = env2.VM.resolvePartial.call(this, partial, context, options);
|
|
1590
1593
|
var extendedOptions = Utils.extend({}, options, {
|
|
1591
1594
|
hooks: this.hooks,
|
|
1592
1595
|
protoAccessControl: this.protoAccessControl
|
|
1593
1596
|
});
|
|
1594
|
-
var result =
|
|
1595
|
-
if (result == null &&
|
|
1596
|
-
options.partials[options.name] =
|
|
1597
|
+
var result = env2.VM.invokePartial.call(this, partial, context, extendedOptions);
|
|
1598
|
+
if (result == null && env2.compile) {
|
|
1599
|
+
options.partials[options.name] = env2.compile(partial, templateSpec.compilerOptions, env2);
|
|
1597
1600
|
result = options.partials[options.name](context, extendedOptions);
|
|
1598
1601
|
}
|
|
1599
1602
|
if (result != null) {
|
|
@@ -1678,7 +1681,7 @@ var require_runtime = __commonJS({
|
|
|
1678
1681
|
},
|
|
1679
1682
|
// An empty object to use as replacement for null-contexts
|
|
1680
1683
|
nullContext: Object.seal({}),
|
|
1681
|
-
noop:
|
|
1684
|
+
noop: env2.VM.noop,
|
|
1682
1685
|
compilerInfo: templateSpec.compiler
|
|
1683
1686
|
};
|
|
1684
1687
|
function ret(context) {
|
|
@@ -1705,14 +1708,14 @@ var require_runtime = __commonJS({
|
|
|
1705
1708
|
ret.isTop = true;
|
|
1706
1709
|
ret._setup = function(options) {
|
|
1707
1710
|
if (!options.partial) {
|
|
1708
|
-
var mergedHelpers = Utils.extend({},
|
|
1711
|
+
var mergedHelpers = Utils.extend({}, env2.helpers, options.helpers);
|
|
1709
1712
|
wrapHelpersToPassLookupProperty(mergedHelpers, container);
|
|
1710
1713
|
container.helpers = mergedHelpers;
|
|
1711
1714
|
if (templateSpec.usePartial) {
|
|
1712
|
-
container.partials = container.mergeIfNeeded(options.partials,
|
|
1715
|
+
container.partials = container.mergeIfNeeded(options.partials, env2.partials);
|
|
1713
1716
|
}
|
|
1714
1717
|
if (templateSpec.usePartial || templateSpec.useDecorators) {
|
|
1715
|
-
container.decorators = Utils.extend({},
|
|
1718
|
+
container.decorators = Utils.extend({}, env2.decorators, options.decorators);
|
|
1716
1719
|
}
|
|
1717
1720
|
container.hooks = {};
|
|
1718
1721
|
container.protoAccessControl = _internalProtoAccess.createProtoAccessControl(options);
|
|
@@ -3514,7 +3517,7 @@ var require_compiler = __commonJS({
|
|
|
3514
3517
|
}
|
|
3515
3518
|
}
|
|
3516
3519
|
};
|
|
3517
|
-
function precompile(input, options,
|
|
3520
|
+
function precompile(input, options, env2) {
|
|
3518
3521
|
if (input == null || typeof input !== "string" && input.type !== "Program") {
|
|
3519
3522
|
throw new _exception2["default"]("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input);
|
|
3520
3523
|
}
|
|
@@ -3525,10 +3528,10 @@ var require_compiler = __commonJS({
|
|
|
3525
3528
|
if (options.compat) {
|
|
3526
3529
|
options.useDepths = true;
|
|
3527
3530
|
}
|
|
3528
|
-
var ast =
|
|
3529
|
-
return new
|
|
3531
|
+
var ast = env2.parse(input, options), environment = new env2.Compiler().compile(ast, options);
|
|
3532
|
+
return new env2.JavaScriptCompiler().compile(environment, options);
|
|
3530
3533
|
}
|
|
3531
|
-
function compile2(input, options,
|
|
3534
|
+
function compile2(input, options, env2) {
|
|
3532
3535
|
if (options === void 0)
|
|
3533
3536
|
options = {};
|
|
3534
3537
|
if (input == null || typeof input !== "string" && input.type !== "Program") {
|
|
@@ -3543,8 +3546,8 @@ var require_compiler = __commonJS({
|
|
|
3543
3546
|
}
|
|
3544
3547
|
var compiled = void 0;
|
|
3545
3548
|
function compileInput() {
|
|
3546
|
-
var ast =
|
|
3547
|
-
return
|
|
3549
|
+
var ast = env2.parse(input, options), environment = new env2.Compiler().compile(ast, options), templateSpec = new env2.JavaScriptCompiler().compile(environment, options, void 0, true);
|
|
3550
|
+
return env2.template(templateSpec);
|
|
3548
3551
|
}
|
|
3549
3552
|
function ret(context, execOptions) {
|
|
3550
3553
|
if (!compiled) {
|
|
@@ -6620,9 +6623,9 @@ var require_lib = __commonJS({
|
|
|
6620
6623
|
}
|
|
6621
6624
|
});
|
|
6622
6625
|
|
|
6623
|
-
// ../../../../node_modules/.pnpm/@modern-js+utils@2.58.
|
|
6626
|
+
// ../../../../node_modules/.pnpm/@modern-js+utils@2.58.1/node_modules/@modern-js/utils/dist/compiled/chalk/index.js
|
|
6624
6627
|
var require_chalk = __commonJS({
|
|
6625
|
-
"../../../../node_modules/.pnpm/@modern-js+utils@2.58.
|
|
6628
|
+
"../../../../node_modules/.pnpm/@modern-js+utils@2.58.1/node_modules/@modern-js/utils/dist/compiled/chalk/index.js"(exports, module2) {
|
|
6626
6629
|
"use strict";
|
|
6627
6630
|
(() => {
|
|
6628
6631
|
var e = { 44: (e2, t2, n2) => {
|
|
@@ -7751,13 +7754,13 @@ var require_chalk = __commonJS({
|
|
|
7751
7754
|
c = l.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(l.FORCE_COLOR, 10), 3);
|
|
7752
7755
|
}
|
|
7753
7756
|
}
|
|
7754
|
-
function
|
|
7757
|
+
function translateLevel2(e3) {
|
|
7755
7758
|
if (e3 === 0) {
|
|
7756
7759
|
return false;
|
|
7757
7760
|
}
|
|
7758
7761
|
return { level: e3, hasBasic: true, has256: e3 >= 2, has16m: e3 >= 3 };
|
|
7759
7762
|
}
|
|
7760
|
-
function
|
|
7763
|
+
function supportsColor2(e3, t3) {
|
|
7761
7764
|
if (c === 0) {
|
|
7762
7765
|
return 0;
|
|
7763
7766
|
}
|
|
@@ -7814,10 +7817,10 @@ var require_chalk = __commonJS({
|
|
|
7814
7817
|
return n3;
|
|
7815
7818
|
}
|
|
7816
7819
|
function getSupportLevel(e3) {
|
|
7817
|
-
const t3 =
|
|
7818
|
-
return
|
|
7820
|
+
const t3 = supportsColor2(e3, e3 && e3.isTTY);
|
|
7821
|
+
return translateLevel2(t3);
|
|
7819
7822
|
}
|
|
7820
|
-
e2.exports = { supportsColor: getSupportLevel, stdout:
|
|
7823
|
+
e2.exports = { supportsColor: getSupportLevel, stdout: translateLevel2(supportsColor2(true, s.isatty(1))), stderr: translateLevel2(supportsColor2(true, s.isatty(2))) };
|
|
7821
7824
|
}, 37: (e2) => {
|
|
7822
7825
|
"use strict";
|
|
7823
7826
|
e2.exports = require("os");
|
|
@@ -12743,7 +12746,7 @@ var require_innerFrom = __commonJS({
|
|
|
12743
12746
|
exports.fromIterable = fromIterable;
|
|
12744
12747
|
function fromAsyncIterable(asyncIterable) {
|
|
12745
12748
|
return new Observable_1.Observable(function(subscriber) {
|
|
12746
|
-
|
|
12749
|
+
process3(asyncIterable, subscriber).catch(function(err) {
|
|
12747
12750
|
return subscriber.error(err);
|
|
12748
12751
|
});
|
|
12749
12752
|
});
|
|
@@ -12753,7 +12756,7 @@ var require_innerFrom = __commonJS({
|
|
|
12753
12756
|
return fromAsyncIterable(isReadableStreamLike_1.readableStreamLikeToAsyncGenerator(readableStream));
|
|
12754
12757
|
}
|
|
12755
12758
|
exports.fromReadableStreamLike = fromReadableStreamLike;
|
|
12756
|
-
function
|
|
12759
|
+
function process3(asyncIterable, subscriber) {
|
|
12757
12760
|
var asyncIterable_1, asyncIterable_1_1;
|
|
12758
12761
|
var e_2, _a2;
|
|
12759
12762
|
return __awaiter6(this, void 0, void 0, function() {
|
|
@@ -20034,11 +20037,11 @@ var require_signals = __commonJS({
|
|
|
20034
20037
|
var require_signal_exit = __commonJS({
|
|
20035
20038
|
"../../../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports, module2) {
|
|
20036
20039
|
"use strict";
|
|
20037
|
-
var
|
|
20038
|
-
var processOk = function(
|
|
20039
|
-
return
|
|
20040
|
+
var process3 = global.process;
|
|
20041
|
+
var processOk = function(process4) {
|
|
20042
|
+
return process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
|
|
20040
20043
|
};
|
|
20041
|
-
if (!processOk(
|
|
20044
|
+
if (!processOk(process3)) {
|
|
20042
20045
|
module2.exports = function() {
|
|
20043
20046
|
return function() {
|
|
20044
20047
|
};
|
|
@@ -20046,15 +20049,15 @@ var require_signal_exit = __commonJS({
|
|
|
20046
20049
|
} else {
|
|
20047
20050
|
assert = require("assert");
|
|
20048
20051
|
signals = require_signals();
|
|
20049
|
-
isWin = /^win/i.test(
|
|
20052
|
+
isWin = /^win/i.test(process3.platform);
|
|
20050
20053
|
EE = require("events");
|
|
20051
20054
|
if (typeof EE !== "function") {
|
|
20052
20055
|
EE = EE.EventEmitter;
|
|
20053
20056
|
}
|
|
20054
|
-
if (
|
|
20055
|
-
emitter =
|
|
20057
|
+
if (process3.__signal_exit_emitter__) {
|
|
20058
|
+
emitter = process3.__signal_exit_emitter__;
|
|
20056
20059
|
} else {
|
|
20057
|
-
emitter =
|
|
20060
|
+
emitter = process3.__signal_exit_emitter__ = new EE();
|
|
20058
20061
|
emitter.count = 0;
|
|
20059
20062
|
emitter.emitted = {};
|
|
20060
20063
|
}
|
|
@@ -20091,12 +20094,12 @@ var require_signal_exit = __commonJS({
|
|
|
20091
20094
|
loaded = false;
|
|
20092
20095
|
signals.forEach(function(sig) {
|
|
20093
20096
|
try {
|
|
20094
|
-
|
|
20097
|
+
process3.removeListener(sig, sigListeners[sig]);
|
|
20095
20098
|
} catch (er) {
|
|
20096
20099
|
}
|
|
20097
20100
|
});
|
|
20098
|
-
|
|
20099
|
-
|
|
20101
|
+
process3.emit = originalProcessEmit;
|
|
20102
|
+
process3.reallyExit = originalProcessReallyExit;
|
|
20100
20103
|
emitter.count -= 1;
|
|
20101
20104
|
};
|
|
20102
20105
|
module2.exports.unload = unload;
|
|
@@ -20113,7 +20116,7 @@ var require_signal_exit = __commonJS({
|
|
|
20113
20116
|
if (!processOk(global.process)) {
|
|
20114
20117
|
return;
|
|
20115
20118
|
}
|
|
20116
|
-
var listeners =
|
|
20119
|
+
var listeners = process3.listeners(sig);
|
|
20117
20120
|
if (listeners.length === emitter.count) {
|
|
20118
20121
|
unload();
|
|
20119
20122
|
emit("exit", null, sig);
|
|
@@ -20121,7 +20124,7 @@ var require_signal_exit = __commonJS({
|
|
|
20121
20124
|
if (isWin && sig === "SIGHUP") {
|
|
20122
20125
|
sig = "SIGINT";
|
|
20123
20126
|
}
|
|
20124
|
-
|
|
20127
|
+
process3.kill(process3.pid, sig);
|
|
20125
20128
|
}
|
|
20126
20129
|
};
|
|
20127
20130
|
});
|
|
@@ -20137,36 +20140,36 @@ var require_signal_exit = __commonJS({
|
|
|
20137
20140
|
emitter.count += 1;
|
|
20138
20141
|
signals = signals.filter(function(sig) {
|
|
20139
20142
|
try {
|
|
20140
|
-
|
|
20143
|
+
process3.on(sig, sigListeners[sig]);
|
|
20141
20144
|
return true;
|
|
20142
20145
|
} catch (er) {
|
|
20143
20146
|
return false;
|
|
20144
20147
|
}
|
|
20145
20148
|
});
|
|
20146
|
-
|
|
20147
|
-
|
|
20149
|
+
process3.emit = processEmit;
|
|
20150
|
+
process3.reallyExit = processReallyExit;
|
|
20148
20151
|
};
|
|
20149
20152
|
module2.exports.load = load;
|
|
20150
|
-
originalProcessReallyExit =
|
|
20153
|
+
originalProcessReallyExit = process3.reallyExit;
|
|
20151
20154
|
processReallyExit = function processReallyExit2(code) {
|
|
20152
20155
|
if (!processOk(global.process)) {
|
|
20153
20156
|
return;
|
|
20154
20157
|
}
|
|
20155
|
-
|
|
20158
|
+
process3.exitCode = code || /* istanbul ignore next */
|
|
20156
20159
|
0;
|
|
20157
|
-
emit("exit",
|
|
20158
|
-
emit("afterexit",
|
|
20159
|
-
originalProcessReallyExit.call(
|
|
20160
|
+
emit("exit", process3.exitCode, null);
|
|
20161
|
+
emit("afterexit", process3.exitCode, null);
|
|
20162
|
+
originalProcessReallyExit.call(process3, process3.exitCode);
|
|
20160
20163
|
};
|
|
20161
|
-
originalProcessEmit =
|
|
20164
|
+
originalProcessEmit = process3.emit;
|
|
20162
20165
|
processEmit = function processEmit2(ev, arg) {
|
|
20163
20166
|
if (ev === "exit" && processOk(global.process)) {
|
|
20164
20167
|
if (arg !== void 0) {
|
|
20165
|
-
|
|
20168
|
+
process3.exitCode = arg;
|
|
20166
20169
|
}
|
|
20167
20170
|
var ret = originalProcessEmit.apply(this, arguments);
|
|
20168
|
-
emit("exit",
|
|
20169
|
-
emit("afterexit",
|
|
20171
|
+
emit("exit", process3.exitCode, null);
|
|
20172
|
+
emit("afterexit", process3.exitCode, null);
|
|
20170
20173
|
return ret;
|
|
20171
20174
|
} else {
|
|
20172
20175
|
return originalProcessEmit.apply(this, arguments);
|
|
@@ -51165,11 +51168,11 @@ var require_ms = __commonJS({
|
|
|
51165
51168
|
}
|
|
51166
51169
|
});
|
|
51167
51170
|
|
|
51168
|
-
// ../../../../node_modules/.pnpm/debug@4.3.4_supports-color@
|
|
51171
|
+
// ../../../../node_modules/.pnpm/debug@4.3.4_supports-color@9.3.1/node_modules/debug/src/common.js
|
|
51169
51172
|
var require_common2 = __commonJS({
|
|
51170
|
-
"../../../../node_modules/.pnpm/debug@4.3.4_supports-color@
|
|
51173
|
+
"../../../../node_modules/.pnpm/debug@4.3.4_supports-color@9.3.1/node_modules/debug/src/common.js"(exports, module2) {
|
|
51171
51174
|
"use strict";
|
|
51172
|
-
function setup(
|
|
51175
|
+
function setup(env2) {
|
|
51173
51176
|
createDebug.debug = createDebug;
|
|
51174
51177
|
createDebug.default = createDebug;
|
|
51175
51178
|
createDebug.coerce = coerce;
|
|
@@ -51178,8 +51181,8 @@ var require_common2 = __commonJS({
|
|
|
51178
51181
|
createDebug.enabled = enabled;
|
|
51179
51182
|
createDebug.humanize = require_ms();
|
|
51180
51183
|
createDebug.destroy = destroy2;
|
|
51181
|
-
Object.keys(
|
|
51182
|
-
createDebug[key] =
|
|
51184
|
+
Object.keys(env2).forEach((key) => {
|
|
51185
|
+
createDebug[key] = env2[key];
|
|
51183
51186
|
});
|
|
51184
51187
|
createDebug.names = [];
|
|
51185
51188
|
createDebug.skips = [];
|
|
@@ -51329,9 +51332,9 @@ var require_common2 = __commonJS({
|
|
|
51329
51332
|
}
|
|
51330
51333
|
});
|
|
51331
51334
|
|
|
51332
|
-
// ../../../../node_modules/.pnpm/debug@4.3.4_supports-color@
|
|
51335
|
+
// ../../../../node_modules/.pnpm/debug@4.3.4_supports-color@9.3.1/node_modules/debug/src/browser.js
|
|
51333
51336
|
var require_browser = __commonJS({
|
|
51334
|
-
"../../../../node_modules/.pnpm/debug@4.3.4_supports-color@
|
|
51337
|
+
"../../../../node_modules/.pnpm/debug@4.3.4_supports-color@9.3.1/node_modules/debug/src/browser.js"(exports, module2) {
|
|
51335
51338
|
"use strict";
|
|
51336
51339
|
exports.formatArgs = formatArgs;
|
|
51337
51340
|
exports.save = save;
|
|
@@ -51499,120 +51502,147 @@ var require_browser = __commonJS({
|
|
|
51499
51502
|
}
|
|
51500
51503
|
});
|
|
51501
51504
|
|
|
51502
|
-
// ../../../../node_modules/.pnpm/
|
|
51503
|
-
var
|
|
51504
|
-
|
|
51505
|
-
|
|
51506
|
-
|
|
51507
|
-
argv = argv || process.argv;
|
|
51508
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
51509
|
-
const pos = argv.indexOf(prefix + flag);
|
|
51510
|
-
const terminatorPos = argv.indexOf("--");
|
|
51511
|
-
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
|
|
51512
|
-
};
|
|
51513
|
-
}
|
|
51505
|
+
// ../../../../node_modules/.pnpm/supports-color@9.3.1/node_modules/supports-color/index.js
|
|
51506
|
+
var supports_color_exports = {};
|
|
51507
|
+
__export(supports_color_exports, {
|
|
51508
|
+
createSupportsColor: () => createSupportsColor,
|
|
51509
|
+
default: () => supports_color_default
|
|
51514
51510
|
});
|
|
51515
|
-
|
|
51516
|
-
|
|
51517
|
-
|
|
51518
|
-
|
|
51519
|
-
|
|
51520
|
-
|
|
51521
|
-
|
|
51522
|
-
|
|
51523
|
-
|
|
51524
|
-
|
|
51525
|
-
forceColor = false;
|
|
51526
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
51527
|
-
forceColor = true;
|
|
51511
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
51512
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
51513
|
+
const position = argv.indexOf(prefix + flag);
|
|
51514
|
+
const terminatorPosition = argv.indexOf("--");
|
|
51515
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
51516
|
+
}
|
|
51517
|
+
function envForceColor() {
|
|
51518
|
+
if ("FORCE_COLOR" in env) {
|
|
51519
|
+
if (env.FORCE_COLOR === "true") {
|
|
51520
|
+
return 1;
|
|
51528
51521
|
}
|
|
51529
|
-
if (
|
|
51530
|
-
|
|
51522
|
+
if (env.FORCE_COLOR === "false") {
|
|
51523
|
+
return 0;
|
|
51531
51524
|
}
|
|
51532
|
-
|
|
51533
|
-
|
|
51534
|
-
|
|
51535
|
-
|
|
51536
|
-
|
|
51537
|
-
|
|
51538
|
-
|
|
51539
|
-
|
|
51540
|
-
|
|
51541
|
-
|
|
51525
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
51526
|
+
}
|
|
51527
|
+
}
|
|
51528
|
+
function translateLevel(level) {
|
|
51529
|
+
if (level === 0) {
|
|
51530
|
+
return false;
|
|
51531
|
+
}
|
|
51532
|
+
return {
|
|
51533
|
+
level,
|
|
51534
|
+
hasBasic: true,
|
|
51535
|
+
has256: level >= 2,
|
|
51536
|
+
has16m: level >= 3
|
|
51537
|
+
};
|
|
51538
|
+
}
|
|
51539
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
51540
|
+
const noFlagForceColor = envForceColor();
|
|
51541
|
+
if (noFlagForceColor !== void 0) {
|
|
51542
|
+
flagForceColor = noFlagForceColor;
|
|
51543
|
+
}
|
|
51544
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
51545
|
+
if (forceColor === 0) {
|
|
51546
|
+
return 0;
|
|
51547
|
+
}
|
|
51548
|
+
if (sniffFlags) {
|
|
51549
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
51550
|
+
return 3;
|
|
51542
51551
|
}
|
|
51543
|
-
|
|
51544
|
-
|
|
51545
|
-
|
|
51546
|
-
|
|
51547
|
-
|
|
51548
|
-
|
|
51549
|
-
|
|
51550
|
-
|
|
51551
|
-
|
|
51552
|
-
|
|
51553
|
-
|
|
51554
|
-
|
|
51555
|
-
|
|
51556
|
-
|
|
51557
|
-
|
|
51558
|
-
|
|
51559
|
-
|
|
51560
|
-
|
|
51561
|
-
|
|
51562
|
-
|
|
51563
|
-
|
|
51564
|
-
|
|
51565
|
-
|
|
51566
|
-
|
|
51567
|
-
|
|
51568
|
-
|
|
51569
|
-
|
|
51570
|
-
|
|
51571
|
-
|
|
51572
|
-
|
|
51573
|
-
|
|
51574
|
-
|
|
51575
|
-
|
|
51576
|
-
|
|
51577
|
-
|
|
51578
|
-
|
|
51579
|
-
|
|
51580
|
-
|
|
51581
|
-
|
|
51582
|
-
|
|
51583
|
-
|
|
51552
|
+
if (hasFlag("color=256")) {
|
|
51553
|
+
return 2;
|
|
51554
|
+
}
|
|
51555
|
+
}
|
|
51556
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
51557
|
+
return 1;
|
|
51558
|
+
}
|
|
51559
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
51560
|
+
return 0;
|
|
51561
|
+
}
|
|
51562
|
+
const min = forceColor || 0;
|
|
51563
|
+
if (env.TERM === "dumb") {
|
|
51564
|
+
return min;
|
|
51565
|
+
}
|
|
51566
|
+
if (import_node_process.default.platform === "win32") {
|
|
51567
|
+
const osRelease = import_node_os.default.release().split(".");
|
|
51568
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
51569
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
51570
|
+
}
|
|
51571
|
+
return 1;
|
|
51572
|
+
}
|
|
51573
|
+
if ("CI" in env) {
|
|
51574
|
+
if ("GITHUB_ACTIONS" in env) {
|
|
51575
|
+
return 3;
|
|
51576
|
+
}
|
|
51577
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
51578
|
+
return 1;
|
|
51579
|
+
}
|
|
51580
|
+
return min;
|
|
51581
|
+
}
|
|
51582
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
51583
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
51584
|
+
}
|
|
51585
|
+
if (env.COLORTERM === "truecolor") {
|
|
51586
|
+
return 3;
|
|
51587
|
+
}
|
|
51588
|
+
if (env.TERM === "xterm-kitty") {
|
|
51589
|
+
return 3;
|
|
51590
|
+
}
|
|
51591
|
+
if ("TERM_PROGRAM" in env) {
|
|
51592
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
51593
|
+
switch (env.TERM_PROGRAM) {
|
|
51594
|
+
case "iTerm.app": {
|
|
51595
|
+
return version >= 3 ? 3 : 2;
|
|
51584
51596
|
}
|
|
51585
|
-
|
|
51597
|
+
case "Apple_Terminal": {
|
|
51586
51598
|
return 2;
|
|
51587
51599
|
}
|
|
51588
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
51589
|
-
return 1;
|
|
51590
|
-
}
|
|
51591
|
-
if ("COLORTERM" in env) {
|
|
51592
|
-
return 1;
|
|
51593
|
-
}
|
|
51594
|
-
if (env.TERM === "dumb") {
|
|
51595
|
-
return min;
|
|
51596
|
-
}
|
|
51597
|
-
return min;
|
|
51598
51600
|
}
|
|
51599
|
-
|
|
51600
|
-
|
|
51601
|
-
|
|
51601
|
+
}
|
|
51602
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
51603
|
+
return 2;
|
|
51604
|
+
}
|
|
51605
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
51606
|
+
return 1;
|
|
51607
|
+
}
|
|
51608
|
+
if ("COLORTERM" in env) {
|
|
51609
|
+
return 1;
|
|
51610
|
+
}
|
|
51611
|
+
return min;
|
|
51612
|
+
}
|
|
51613
|
+
function createSupportsColor(stream, options = {}) {
|
|
51614
|
+
const level = _supportsColor(stream, {
|
|
51615
|
+
streamIsTTY: stream && stream.isTTY,
|
|
51616
|
+
...options
|
|
51617
|
+
});
|
|
51618
|
+
return translateLevel(level);
|
|
51619
|
+
}
|
|
51620
|
+
var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
|
|
51621
|
+
var init_supports_color = __esm({
|
|
51622
|
+
"../../../../node_modules/.pnpm/supports-color@9.3.1/node_modules/supports-color/index.js"() {
|
|
51623
|
+
"use strict";
|
|
51624
|
+
import_node_process = __toESM(require("process"));
|
|
51625
|
+
import_node_os = __toESM(require("os"));
|
|
51626
|
+
import_node_tty = __toESM(require("tty"));
|
|
51627
|
+
({ env } = import_node_process.default);
|
|
51628
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
51629
|
+
flagForceColor = 0;
|
|
51630
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
51631
|
+
flagForceColor = 1;
|
|
51602
51632
|
}
|
|
51603
|
-
|
|
51604
|
-
|
|
51605
|
-
|
|
51606
|
-
stderr: getSupportLevel(process.stderr)
|
|
51633
|
+
supportsColor = {
|
|
51634
|
+
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
51635
|
+
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
51607
51636
|
};
|
|
51637
|
+
supports_color_default = supportsColor;
|
|
51608
51638
|
}
|
|
51609
51639
|
});
|
|
51610
51640
|
|
|
51611
|
-
// ../../../../node_modules/.pnpm/debug@4.3.4_supports-color@
|
|
51641
|
+
// ../../../../node_modules/.pnpm/debug@4.3.4_supports-color@9.3.1/node_modules/debug/src/node.js
|
|
51612
51642
|
var require_node2 = __commonJS({
|
|
51613
|
-
"../../../../node_modules/.pnpm/debug@4.3.4_supports-color@
|
|
51643
|
+
"../../../../node_modules/.pnpm/debug@4.3.4_supports-color@9.3.1/node_modules/debug/src/node.js"(exports, module2) {
|
|
51614
51644
|
"use strict";
|
|
51615
|
-
var
|
|
51645
|
+
var tty2 = require("tty");
|
|
51616
51646
|
var util = require("util");
|
|
51617
51647
|
exports.init = init;
|
|
51618
51648
|
exports.log = log;
|
|
@@ -51627,8 +51657,8 @@ var require_node2 = __commonJS({
|
|
|
51627
51657
|
);
|
|
51628
51658
|
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
51629
51659
|
try {
|
|
51630
|
-
const
|
|
51631
|
-
if (
|
|
51660
|
+
const supportsColor2 = (init_supports_color(), __toCommonJS(supports_color_exports));
|
|
51661
|
+
if (supportsColor2 && (supportsColor2.stderr || supportsColor2).level >= 2) {
|
|
51632
51662
|
exports.colors = [
|
|
51633
51663
|
20,
|
|
51634
51664
|
21,
|
|
@@ -51730,7 +51760,7 @@ var require_node2 = __commonJS({
|
|
|
51730
51760
|
return obj;
|
|
51731
51761
|
}, {});
|
|
51732
51762
|
function useColors() {
|
|
51733
|
-
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) :
|
|
51763
|
+
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty2.isatty(process.stderr.fd);
|
|
51734
51764
|
}
|
|
51735
51765
|
function formatArgs(args) {
|
|
51736
51766
|
const { namespace: name, useColors: useColors2 } = this;
|
|
@@ -51783,9 +51813,9 @@ var require_node2 = __commonJS({
|
|
|
51783
51813
|
}
|
|
51784
51814
|
});
|
|
51785
51815
|
|
|
51786
|
-
// ../../../../node_modules/.pnpm/debug@4.3.4_supports-color@
|
|
51816
|
+
// ../../../../node_modules/.pnpm/debug@4.3.4_supports-color@9.3.1/node_modules/debug/src/index.js
|
|
51787
51817
|
var require_src3 = __commonJS({
|
|
51788
|
-
"../../../../node_modules/.pnpm/debug@4.3.4_supports-color@
|
|
51818
|
+
"../../../../node_modules/.pnpm/debug@4.3.4_supports-color@9.3.1/node_modules/debug/src/index.js"(exports, module2) {
|
|
51789
51819
|
"use strict";
|
|
51790
51820
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
51791
51821
|
module2.exports = require_browser();
|
|
@@ -52659,701 +52689,240 @@ __export(src_exports, {
|
|
|
52659
52689
|
module.exports = __toCommonJS(src_exports);
|
|
52660
52690
|
var import_path6 = __toESM(require("path"));
|
|
52661
52691
|
|
|
52662
|
-
//
|
|
52692
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith/dist/esm-node/materials/FsResource.js
|
|
52663
52693
|
var import_path = __toESM(require("path"));
|
|
52664
|
-
var
|
|
52694
|
+
var import_utils = require("@modern-js/utils");
|
|
52695
|
+
var FS_RESOURCE = "_codesmith_core_fs_resource";
|
|
52665
52696
|
|
|
52666
|
-
//
|
|
52667
|
-
var
|
|
52697
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith/dist/esm-node/utils/fsExists.js
|
|
52698
|
+
var import_utils2 = require("@modern-js/utils");
|
|
52699
|
+
async function fsExists(path6) {
|
|
52700
|
+
try {
|
|
52701
|
+
await import_utils2.fs.access(path6);
|
|
52702
|
+
return true;
|
|
52703
|
+
} catch (e) {
|
|
52704
|
+
return false;
|
|
52705
|
+
}
|
|
52706
|
+
}
|
|
52668
52707
|
|
|
52669
|
-
//
|
|
52670
|
-
var
|
|
52671
|
-
function
|
|
52672
|
-
|
|
52673
|
-
Object.keys(obj).forEach((key) => {
|
|
52674
|
-
if ((0, import_lodash.isString)(obj[key])) {
|
|
52675
|
-
result[key] = prefix ? `${prefix}.${key}` : key;
|
|
52676
|
-
} else if ((0, import_lodash.isObject)(obj[key])) {
|
|
52677
|
-
result[key] = getObjKeyMap(obj[key], prefix ? `${prefix}.${key}` : key);
|
|
52678
|
-
}
|
|
52679
|
-
});
|
|
52680
|
-
return result;
|
|
52708
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-ejs@2.4.1_@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith-api-ejs/dist/esm-node/utils/renderString.js
|
|
52709
|
+
var import_ejs = __toESM(require_ejs());
|
|
52710
|
+
function renderString(template, fullData) {
|
|
52711
|
+
return import_ejs.default.render(template, fullData) || "";
|
|
52681
52712
|
}
|
|
52682
52713
|
|
|
52683
|
-
//
|
|
52684
|
-
var
|
|
52685
|
-
|
|
52686
|
-
|
|
52687
|
-
|
|
52688
|
-
getMessage(lang, key, vars, fallbackText) {
|
|
52689
|
-
const languages = Object.keys(this.languageMap);
|
|
52690
|
-
const resultLang = languages.find((l) => l === lang);
|
|
52691
|
-
if (!resultLang && languages.length === 0) {
|
|
52692
|
-
return fallbackText || key;
|
|
52693
|
-
}
|
|
52694
|
-
const model = this.languageMap[resultLang || "en"];
|
|
52695
|
-
if (!model) {
|
|
52696
|
-
return fallbackText || key;
|
|
52714
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-ejs@2.4.1_@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith-api-ejs/dist/esm-node/index.js
|
|
52715
|
+
var EjsAPI = class {
|
|
52716
|
+
async renderTemplate(templateResource, target, parameters = {}) {
|
|
52717
|
+
if (templateResource._type !== FS_RESOURCE) {
|
|
52718
|
+
throw new Error("resource not match");
|
|
52697
52719
|
}
|
|
52698
|
-
const
|
|
52699
|
-
|
|
52700
|
-
|
|
52701
|
-
return this.format(value, vars || {});
|
|
52720
|
+
const resourceValue = await templateResource.value();
|
|
52721
|
+
if (typeof resourceValue.content !== "string") {
|
|
52722
|
+
throw new Error(`resource.value is not string, resourceValue=${resourceValue}`);
|
|
52702
52723
|
}
|
|
52703
|
-
|
|
52724
|
+
await this.generatorCore.output.fs(target, renderString(resourceValue.content, parameters), {
|
|
52725
|
+
encoding: "utf-8"
|
|
52726
|
+
});
|
|
52704
52727
|
}
|
|
52705
|
-
|
|
52706
|
-
|
|
52707
|
-
|
|
52708
|
-
|
|
52709
|
-
}
|
|
52710
|
-
|
|
52728
|
+
async renderTemplateDir(material, findGlob, target, options) {
|
|
52729
|
+
const resourceMap = await material.find(findGlob, {
|
|
52730
|
+
nodir: true,
|
|
52731
|
+
...options
|
|
52732
|
+
});
|
|
52733
|
+
await Promise.all(
|
|
52734
|
+
// resourceKey is relate path. example: in `garr-master/package.json`, package.json is resourceKey
|
|
52735
|
+
Object.keys(resourceMap).map(async (resourceKey) => {
|
|
52736
|
+
this.generatorCore.logger.debug(`[renderDir] resourceKey=${resourceKey}`);
|
|
52737
|
+
await this.renderTemplate(material.get(resourceKey), target(resourceKey), options === null || options === void 0 ? void 0 : options.parameters);
|
|
52738
|
+
})
|
|
52739
|
+
);
|
|
52711
52740
|
}
|
|
52712
|
-
|
|
52713
|
-
this.
|
|
52741
|
+
constructor(generatorCore) {
|
|
52742
|
+
this.generatorCore = generatorCore;
|
|
52714
52743
|
}
|
|
52715
|
-
|
|
52716
|
-
|
|
52744
|
+
};
|
|
52745
|
+
|
|
52746
|
+
// ../../../../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
|
|
52747
|
+
var import_path2 = __toESM(require("path"));
|
|
52748
|
+
var import_utils4 = require("@modern-js/utils");
|
|
52749
|
+
var FsAPI = class {
|
|
52750
|
+
async renderFile(resource, target) {
|
|
52751
|
+
if (resource._type !== FS_RESOURCE) {
|
|
52752
|
+
throw new Error("resource not match");
|
|
52753
|
+
}
|
|
52754
|
+
const filePath = import_path2.default.resolve(this.generatorCore.outputPath, target.toString());
|
|
52755
|
+
await import_utils4.fs.mkdirp(import_path2.default.dirname(filePath));
|
|
52756
|
+
await import_utils4.fs.copyFile(resource.filePath, filePath);
|
|
52717
52757
|
}
|
|
52718
|
-
|
|
52719
|
-
|
|
52720
|
-
|
|
52721
|
-
|
|
52758
|
+
async renderDir(material, findGlob, target, options) {
|
|
52759
|
+
const resourceMap = await material.find(findGlob, {
|
|
52760
|
+
nodir: true,
|
|
52761
|
+
...options
|
|
52762
|
+
});
|
|
52763
|
+
await Promise.all(Object.keys(resourceMap).map(async (resourceKey) => {
|
|
52764
|
+
this.generatorCore.logger.debug(`[renderDir] resourceKey=${resourceKey}`);
|
|
52765
|
+
await this.renderFile(material.get(resourceKey), target(resourceKey));
|
|
52766
|
+
}));
|
|
52722
52767
|
}
|
|
52723
|
-
constructor() {
|
|
52724
|
-
this.
|
|
52725
|
-
this.languageMap = {};
|
|
52768
|
+
constructor(generatorCore) {
|
|
52769
|
+
this.generatorCore = generatorCore;
|
|
52726
52770
|
}
|
|
52727
52771
|
};
|
|
52728
52772
|
|
|
52729
|
-
//
|
|
52730
|
-
var
|
|
52731
|
-
|
|
52732
|
-
|
|
52733
|
-
|
|
52734
|
-
|
|
52735
|
-
|
|
52736
|
-
|
|
52737
|
-
|
|
52738
|
-
|
|
52739
|
-
|
|
52740
|
-
|
|
52741
|
-
|
|
52742
|
-
|
|
52743
|
-
|
|
52744
|
-
|
|
52745
|
-
|
|
52746
|
-
|
|
52747
|
-
|
|
52748
|
-
|
|
52749
|
-
|
|
52750
|
-
|
|
52751
|
-
|
|
52752
|
-
|
|
52753
|
-
|
|
52754
|
-
|
|
52755
|
-
|
|
52756
|
-
|
|
52757
|
-
|
|
52758
|
-
|
|
52759
|
-
|
|
52760
|
-
|
|
52761
|
-
|
|
52762
|
-
|
|
52763
|
-
|
|
52764
|
-
|
|
52765
|
-
|
|
52766
|
-
|
|
52767
|
-
|
|
52768
|
-
|
|
52769
|
-
|
|
52770
|
-
|
|
52771
|
-
|
|
52772
|
-
|
|
52773
|
+
// ../../../../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
|
|
52774
|
+
var import_utils5 = require("@modern-js/utils");
|
|
52775
|
+
async function canUseGit() {
|
|
52776
|
+
try {
|
|
52777
|
+
await (0, import_utils5.execa)("git", [
|
|
52778
|
+
"--version"
|
|
52779
|
+
], {
|
|
52780
|
+
env: process.env
|
|
52781
|
+
});
|
|
52782
|
+
return true;
|
|
52783
|
+
} catch (e) {
|
|
52784
|
+
return false;
|
|
52785
|
+
}
|
|
52786
|
+
}
|
|
52787
|
+
async function isInGitRepo(cwd) {
|
|
52788
|
+
try {
|
|
52789
|
+
await (0, import_utils5.execa)("git", [
|
|
52790
|
+
"rev-parse",
|
|
52791
|
+
"--is-inside-work-tree"
|
|
52792
|
+
], {
|
|
52793
|
+
env: process.env,
|
|
52794
|
+
cwd
|
|
52795
|
+
});
|
|
52796
|
+
return true;
|
|
52797
|
+
} catch (e) {
|
|
52798
|
+
return false;
|
|
52799
|
+
}
|
|
52800
|
+
}
|
|
52801
|
+
async function initGitRepo(cwd, defaultBranch) {
|
|
52802
|
+
await (0, import_utils5.execa)("git", [
|
|
52803
|
+
"init"
|
|
52804
|
+
], {
|
|
52805
|
+
env: process.env,
|
|
52806
|
+
cwd
|
|
52807
|
+
});
|
|
52808
|
+
const { stdout } = await (0, import_utils5.execa)("git", [
|
|
52809
|
+
"symbolic-ref",
|
|
52810
|
+
"--short",
|
|
52811
|
+
"HEAD"
|
|
52812
|
+
], {
|
|
52813
|
+
env: process.env,
|
|
52814
|
+
cwd
|
|
52815
|
+
});
|
|
52816
|
+
if (stdout !== defaultBranch) {
|
|
52817
|
+
await (0, import_utils5.execa)("git", [
|
|
52818
|
+
"checkout",
|
|
52819
|
+
"-b",
|
|
52820
|
+
defaultBranch
|
|
52821
|
+
], {
|
|
52822
|
+
env: process.env,
|
|
52823
|
+
cwd
|
|
52824
|
+
});
|
|
52825
|
+
}
|
|
52826
|
+
}
|
|
52827
|
+
async function gitAdd(cwd) {
|
|
52828
|
+
await (0, import_utils5.execa)("git", [
|
|
52829
|
+
"add",
|
|
52830
|
+
"-A"
|
|
52831
|
+
], {
|
|
52832
|
+
env: process.env,
|
|
52833
|
+
cwd
|
|
52834
|
+
});
|
|
52835
|
+
}
|
|
52836
|
+
async function gitCommit(cwd, commitMessage) {
|
|
52837
|
+
await (0, import_utils5.execa)("git", [
|
|
52838
|
+
"commit",
|
|
52839
|
+
"-m",
|
|
52840
|
+
commitMessage,
|
|
52841
|
+
"--no-verify"
|
|
52842
|
+
], {
|
|
52843
|
+
env: process.env,
|
|
52844
|
+
cwd
|
|
52845
|
+
});
|
|
52846
|
+
}
|
|
52847
|
+
|
|
52848
|
+
// ../../../../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/index.js
|
|
52849
|
+
var GitAPI = class {
|
|
52850
|
+
async isInGitRepo(cwd = this.generatorCore.outputPath) {
|
|
52851
|
+
const canUse = await canUseGit();
|
|
52852
|
+
if (canUse) {
|
|
52853
|
+
return isInGitRepo(cwd);
|
|
52773
52854
|
}
|
|
52774
|
-
|
|
52775
|
-
|
|
52776
|
-
|
|
52777
|
-
|
|
52778
|
-
|
|
52779
|
-
|
|
52780
|
-
|
|
52781
|
-
|
|
52782
|
-
|
|
52783
|
-
|
|
52784
|
-
|
|
52785
|
-
|
|
52786
|
-
|
|
52787
|
-
|
|
52788
|
-
|
|
52789
|
-
|
|
52790
|
-
|
|
52791
|
-
|
|
52792
|
-
|
|
52793
|
-
|
|
52794
|
-
|
|
52795
|
-
|
|
52796
|
-
self: "请填写子项目目录名称",
|
|
52797
|
-
no_empty: "目录名称不能为空!",
|
|
52798
|
-
format: "目录名称只能使用小写字母、数字和分隔线(-)、下划线(_)和目录分隔符(/)"
|
|
52799
|
-
},
|
|
52800
|
-
framework: {
|
|
52801
|
-
self: "请选择运行时框架",
|
|
52802
|
-
egg: "Egg",
|
|
52803
|
-
express: "Express",
|
|
52804
|
-
koa: "Koa",
|
|
52805
|
-
nest: "Nest"
|
|
52806
|
-
},
|
|
52807
|
-
bff: {
|
|
52808
|
-
bffType: {
|
|
52809
|
-
self: "请选择 BFF 类型",
|
|
52810
|
-
func: "函数模式",
|
|
52811
|
-
framework: "框架模式"
|
|
52855
|
+
throw new Error("git is not found");
|
|
52856
|
+
}
|
|
52857
|
+
async initGitRepo(cwd = this.generatorCore.outputPath, force = false) {
|
|
52858
|
+
const canUse = await canUseGit();
|
|
52859
|
+
if (!canUse) {
|
|
52860
|
+
throw new Error("git is not found");
|
|
52861
|
+
}
|
|
52862
|
+
const alreadyInit = await this.isInGitRepo(cwd);
|
|
52863
|
+
if (alreadyInit && !force) {
|
|
52864
|
+
this.generatorCore.logger.debug("already in a git repo, skip init");
|
|
52865
|
+
return;
|
|
52866
|
+
}
|
|
52867
|
+
try {
|
|
52868
|
+
const { config: { defaultBranch = "master" } } = this.generatorContext || {
|
|
52869
|
+
config: {
|
|
52870
|
+
defaultBranch: "master"
|
|
52871
|
+
}
|
|
52872
|
+
};
|
|
52873
|
+
await initGitRepo(cwd, defaultBranch);
|
|
52874
|
+
} catch (e) {
|
|
52875
|
+
this.generatorCore.logger.debug("[GitAPI.error]:", e);
|
|
52876
|
+
throw e;
|
|
52812
52877
|
}
|
|
52813
|
-
},
|
|
52814
|
-
buildTools: {
|
|
52815
|
-
self: "请选择构建工具",
|
|
52816
|
-
webpack: "webpack",
|
|
52817
|
-
rspack: "Rspack (实验性)"
|
|
52818
52878
|
}
|
|
52819
|
-
|
|
52820
|
-
|
|
52821
|
-
|
|
52822
|
-
|
|
52823
|
-
solution: {
|
|
52824
|
-
self: "Please select the type of project you want to create:",
|
|
52825
|
-
mwa: "Web App",
|
|
52826
|
-
module: "Npm Module",
|
|
52827
|
-
custom: "Custom Solution",
|
|
52828
|
-
default: "Default"
|
|
52829
|
-
},
|
|
52830
|
-
scenes: {
|
|
52831
|
-
self: "Please select the project scenario:"
|
|
52832
|
-
},
|
|
52833
|
-
sub_solution: {
|
|
52834
|
-
self: "Please select the type of project you want to create:",
|
|
52835
|
-
mwa: "Web App",
|
|
52836
|
-
module: "Npm Module"
|
|
52837
|
-
},
|
|
52838
|
-
action: {
|
|
52839
|
-
self: "Please select the operation you want:",
|
|
52840
|
-
function: {
|
|
52841
|
-
self: "Enable Features",
|
|
52842
|
-
question: "Please select the feature name:",
|
|
52843
|
-
tailwindcss: "Enable Tailwind CSS",
|
|
52844
|
-
bff: "Enable BFF",
|
|
52845
|
-
micro_frontend: "Enable Micro Frontend",
|
|
52846
|
-
i18n: "Enable Internationalization (i18n)",
|
|
52847
|
-
storybookV7: "Enable Storybook V7",
|
|
52848
|
-
runtime_api: "Enable Runtime API",
|
|
52849
|
-
ssg: "Enable SSG",
|
|
52850
|
-
polyfill: "Enable UA-based Polyfill Feature",
|
|
52851
|
-
proxy: "Enable Global Proxy",
|
|
52852
|
-
swc: "Enable SWC Compile",
|
|
52853
|
-
module_doc: "Enable Module Doc"
|
|
52854
|
-
},
|
|
52855
|
-
element: {
|
|
52856
|
-
self: "Create Element",
|
|
52857
|
-
question: "Please select the type of element to create:",
|
|
52858
|
-
entry: 'New "entry"',
|
|
52859
|
-
server: 'New "Custom Web Server" source code directory'
|
|
52860
|
-
},
|
|
52861
|
-
refactor: {
|
|
52862
|
-
self: "Automatic Refactor",
|
|
52863
|
-
question: "Please select the type of refactoring:",
|
|
52864
|
-
react_router_5: "Use React Router v5"
|
|
52879
|
+
async addAndCommit(commitMessage, cwd = this.generatorCore.outputPath) {
|
|
52880
|
+
const canUse = await canUseGit();
|
|
52881
|
+
if (!canUse) {
|
|
52882
|
+
throw new Error("git is not found");
|
|
52865
52883
|
}
|
|
52866
|
-
|
|
52867
|
-
|
|
52868
|
-
|
|
52869
|
-
|
|
52870
|
-
|
|
52871
|
-
|
|
52872
|
-
self: "Please select the programming language:"
|
|
52873
|
-
},
|
|
52874
|
-
packageManager: {
|
|
52875
|
-
self: "Please select the package manager:"
|
|
52876
|
-
},
|
|
52877
|
-
entry: {
|
|
52878
|
-
name: "Please fill in the entry name:",
|
|
52879
|
-
no_empty: "The entry name cannot be empty!",
|
|
52880
|
-
no_pages: 'The entry name cannot be "pages"!'
|
|
52881
|
-
},
|
|
52882
|
-
packageName: {
|
|
52883
|
-
self: "Please fill in the project name:",
|
|
52884
|
-
sub_name: "Please fill in the sub-project name:",
|
|
52885
|
-
no_empty: "The package name cannot be empty!"
|
|
52886
|
-
},
|
|
52887
|
-
packagePath: {
|
|
52888
|
-
self: "Please fill in the sub-project directory name:",
|
|
52889
|
-
no_empty: "The package path cannot be empty!",
|
|
52890
|
-
format: "Only lowercase letters, numbers and delimiters (-), and underscore (_), and directory delimiters (/) can be used in package path."
|
|
52891
|
-
},
|
|
52892
|
-
framework: {
|
|
52893
|
-
self: "Please select the framework:",
|
|
52894
|
-
egg: "Egg",
|
|
52895
|
-
express: "Express",
|
|
52896
|
-
koa: "Koa",
|
|
52897
|
-
nest: "Nest"
|
|
52898
|
-
},
|
|
52899
|
-
bff: {
|
|
52900
|
-
bffType: {
|
|
52901
|
-
self: "Please select the BFF type:",
|
|
52902
|
-
func: "Function",
|
|
52903
|
-
framework: "Framework"
|
|
52884
|
+
try {
|
|
52885
|
+
await gitAdd(cwd);
|
|
52886
|
+
await gitCommit(cwd, commitMessage);
|
|
52887
|
+
} catch (e) {
|
|
52888
|
+
this.generatorCore.logger.debug("[GitAPI.error]:", e);
|
|
52889
|
+
throw e;
|
|
52904
52890
|
}
|
|
52905
|
-
}
|
|
52906
|
-
|
|
52907
|
-
|
|
52908
|
-
|
|
52909
|
-
rspack: "Rspack (experimental)"
|
|
52891
|
+
}
|
|
52892
|
+
constructor(generatorCore, generatorContext) {
|
|
52893
|
+
this.generatorCore = generatorCore;
|
|
52894
|
+
this.generatorContext = generatorContext;
|
|
52910
52895
|
}
|
|
52911
52896
|
};
|
|
52912
52897
|
|
|
52913
|
-
//
|
|
52914
|
-
var
|
|
52915
|
-
|
|
52916
|
-
|
|
52917
|
-
|
|
52918
|
-
});
|
|
52919
|
-
|
|
52920
|
-
// ../../generator-common/dist/esm-node/common/solution.js
|
|
52921
|
-
var Solution;
|
|
52922
|
-
(function(Solution2) {
|
|
52923
|
-
Solution2["MWA"] = "mwa";
|
|
52924
|
-
Solution2["Module"] = "module";
|
|
52925
|
-
})(Solution || (Solution = {}));
|
|
52926
|
-
var SolutionToolsMap = {
|
|
52927
|
-
["mwa"]: "@modern-js/app-tools",
|
|
52928
|
-
["module"]: "@modern-js/module-tools"
|
|
52929
|
-
};
|
|
52930
|
-
|
|
52931
|
-
// ../../generator-common/dist/esm-node/common/language.js
|
|
52932
|
-
var Language;
|
|
52933
|
-
(function(Language2) {
|
|
52934
|
-
Language2["TS"] = "ts";
|
|
52935
|
-
Language2["JS"] = "js";
|
|
52936
|
-
})(Language || (Language = {}));
|
|
52937
|
-
|
|
52938
|
-
// ../../generator-common/dist/esm-node/mwa/common.js
|
|
52939
|
-
var Framework;
|
|
52940
|
-
(function(Framework2) {
|
|
52941
|
-
Framework2["Express"] = "express";
|
|
52942
|
-
Framework2["Koa"] = "koa";
|
|
52943
|
-
})(Framework || (Framework = {}));
|
|
52944
|
-
var BuildTools;
|
|
52945
|
-
(function(BuildTools2) {
|
|
52946
|
-
BuildTools2["Webpack"] = "webpack";
|
|
52947
|
-
BuildTools2["Rspack"] = "rspack";
|
|
52948
|
-
})(BuildTools || (BuildTools = {}));
|
|
52949
|
-
var getFrameworkSchema = (_extra = {}) => {
|
|
52950
|
-
return {
|
|
52951
|
-
type: "string",
|
|
52952
|
-
title: i18n.t(localeKeys.framework.self),
|
|
52953
|
-
enum: Object.values(Framework).map((framework) => ({
|
|
52954
|
-
value: framework,
|
|
52955
|
-
label: i18n.t(localeKeys.framework[framework])
|
|
52956
|
-
}))
|
|
52898
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-handlebars@2.4.1_@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith-api-handlebars/dist/esm-node/utils/renderString.js
|
|
52899
|
+
var import_handlebars = __toESM(require_lib());
|
|
52900
|
+
function renderString2(template, fullData, registers) {
|
|
52901
|
+
const helpers = {
|
|
52902
|
+
...registers === null || registers === void 0 ? void 0 : registers.helpers
|
|
52957
52903
|
};
|
|
52958
|
-
|
|
52959
|
-
|
|
52960
|
-
["express"]: `/// <reference types='@modern-js/plugin-express/types' />`,
|
|
52961
|
-
["koa"]: `/// <reference types='@modern-js/plugin-koa/types' />`
|
|
52962
|
-
};
|
|
52963
|
-
|
|
52964
|
-
// ../../generator-common/dist/esm-node/mwa/bff.js
|
|
52965
|
-
var BFFType;
|
|
52966
|
-
(function(BFFType2) {
|
|
52967
|
-
BFFType2["Func"] = "func";
|
|
52968
|
-
BFFType2["Framework"] = "framework";
|
|
52969
|
-
})(BFFType || (BFFType = {}));
|
|
52970
|
-
var getBFFTypeSchema = (_extra = {}) => {
|
|
52971
|
-
return {
|
|
52972
|
-
type: "string",
|
|
52973
|
-
title: i18n.t(localeKeys.bff.bffType.self),
|
|
52974
|
-
enum: Object.values(BFFType).map((bffType) => ({
|
|
52975
|
-
value: bffType,
|
|
52976
|
-
label: i18n.t(localeKeys.bff.bffType[bffType])
|
|
52977
|
-
}))
|
|
52978
|
-
};
|
|
52979
|
-
};
|
|
52980
|
-
var getBFFchemaProperties = (extra) => {
|
|
52981
|
-
return {
|
|
52982
|
-
bffType: getBFFTypeSchema(extra),
|
|
52983
|
-
framework: getFrameworkSchema(extra)
|
|
52984
|
-
};
|
|
52985
|
-
};
|
|
52986
|
-
var getBFFSchema = (extra = {}) => {
|
|
52987
|
-
return {
|
|
52988
|
-
type: "object",
|
|
52989
|
-
properties: getBFFchemaProperties(extra)
|
|
52904
|
+
const partials = {
|
|
52905
|
+
...registers === null || registers === void 0 ? void 0 : registers.partials
|
|
52990
52906
|
};
|
|
52991
|
-
|
|
52992
|
-
|
|
52993
|
-
|
|
52994
|
-
frameWork: Framework.Express
|
|
52995
|
-
};
|
|
52996
|
-
|
|
52997
|
-
// ../../generator-common/dist/esm-node/newAction/common/index.js
|
|
52998
|
-
var ActionType;
|
|
52999
|
-
(function(ActionType2) {
|
|
53000
|
-
ActionType2["Function"] = "function";
|
|
53001
|
-
ActionType2["Element"] = "element";
|
|
53002
|
-
ActionType2["Refactor"] = "refactor";
|
|
53003
|
-
})(ActionType || (ActionType = {}));
|
|
53004
|
-
var ActionElement;
|
|
53005
|
-
(function(ActionElement2) {
|
|
53006
|
-
ActionElement2["Entry"] = "entry";
|
|
53007
|
-
ActionElement2["Server"] = "server";
|
|
53008
|
-
})(ActionElement || (ActionElement = {}));
|
|
53009
|
-
var ActionFunction;
|
|
53010
|
-
(function(ActionFunction2) {
|
|
53011
|
-
ActionFunction2["TailwindCSS"] = "tailwindcss";
|
|
53012
|
-
ActionFunction2["BFF"] = "bff";
|
|
53013
|
-
ActionFunction2["MicroFrontend"] = "micro_frontend";
|
|
53014
|
-
ActionFunction2["I18n"] = "i18n";
|
|
53015
|
-
ActionFunction2["StorybookV7"] = "storybookV7";
|
|
53016
|
-
ActionFunction2["RuntimeApi"] = "runtimeApi";
|
|
53017
|
-
ActionFunction2["SSG"] = "ssg";
|
|
53018
|
-
ActionFunction2["Polyfill"] = "polyfill";
|
|
53019
|
-
ActionFunction2["Proxy"] = "proxy";
|
|
53020
|
-
ActionFunction2["SWC"] = "swc";
|
|
53021
|
-
ActionFunction2["ModuleDoc"] = "module_doc";
|
|
53022
|
-
})(ActionFunction || (ActionFunction = {}));
|
|
53023
|
-
var ActionRefactor;
|
|
53024
|
-
(function(ActionRefactor2) {
|
|
53025
|
-
ActionRefactor2["ReactRouter5"] = "react_router_5";
|
|
53026
|
-
})(ActionRefactor || (ActionRefactor = {}));
|
|
53027
|
-
|
|
53028
|
-
// ../../generator-common/dist/esm-node/newAction/mwa/index.js
|
|
53029
|
-
var MWAActionTypes = [
|
|
53030
|
-
ActionType.Element,
|
|
53031
|
-
ActionType.Function,
|
|
53032
|
-
ActionType.Refactor
|
|
53033
|
-
];
|
|
53034
|
-
var MWAActionFunctions = [
|
|
53035
|
-
ActionFunction.TailwindCSS,
|
|
53036
|
-
ActionFunction.BFF,
|
|
53037
|
-
ActionFunction.SSG,
|
|
53038
|
-
ActionFunction.SWC,
|
|
53039
|
-
ActionFunction.MicroFrontend,
|
|
53040
|
-
ActionFunction.Polyfill,
|
|
53041
|
-
ActionFunction.Proxy,
|
|
53042
|
-
ActionFunction.StorybookV7
|
|
53043
|
-
];
|
|
53044
|
-
var MWAActionElements = [
|
|
53045
|
-
ActionElement.Entry,
|
|
53046
|
-
ActionElement.Server
|
|
53047
|
-
];
|
|
53048
|
-
var MWAActionReactors = [
|
|
53049
|
-
ActionRefactor.ReactRouter5
|
|
53050
|
-
];
|
|
53051
|
-
var MWAActionTypesMap = {
|
|
53052
|
-
[ActionType.Element]: MWAActionElements,
|
|
53053
|
-
[ActionType.Function]: MWAActionFunctions,
|
|
53054
|
-
[ActionType.Refactor]: MWAActionReactors
|
|
53055
|
-
};
|
|
53056
|
-
var MWAActionFunctionsDevDependencies = {
|
|
53057
|
-
[ActionFunction.SSG]: "@modern-js/plugin-ssg",
|
|
53058
|
-
[ActionFunction.StorybookV7]: "@modern-js/storybook",
|
|
53059
|
-
[ActionFunction.Proxy]: "@modern-js/plugin-proxy",
|
|
53060
|
-
[ActionFunction.TailwindCSS]: "tailwindcss",
|
|
53061
|
-
[ActionFunction.SWC]: "@modern-js/plugin-swc"
|
|
53062
|
-
};
|
|
53063
|
-
var MWAActionFunctionsDependencies = {
|
|
53064
|
-
[ActionFunction.BFF]: "@modern-js/plugin-bff",
|
|
53065
|
-
[ActionFunction.MicroFrontend]: "@modern-js/plugin-garfish",
|
|
53066
|
-
[ActionFunction.TailwindCSS]: "@modern-js/plugin-tailwindcss",
|
|
53067
|
-
[ActionFunction.Polyfill]: "@modern-js/plugin-polyfill"
|
|
53068
|
-
};
|
|
53069
|
-
var MWAActionFunctionsAppendTypeContent = {
|
|
53070
|
-
[ActionFunction.MicroFrontend]: `/// <reference types='@modern-js/plugin-garfish/types' />`
|
|
53071
|
-
};
|
|
53072
|
-
var MWAActionRefactorDependencies = {
|
|
53073
|
-
[ActionRefactor.ReactRouter5]: "@modern-js/plugin-router-v5"
|
|
53074
|
-
};
|
|
53075
|
-
var MWAActionReactorAppendTypeContent = {
|
|
53076
|
-
[ActionRefactor.ReactRouter5]: `/// <reference types='@modern-js/plugin-router-v5/types' />`
|
|
53077
|
-
};
|
|
53078
|
-
var MWANewActionGenerators = {
|
|
53079
|
-
[ActionType.Element]: {
|
|
53080
|
-
[ActionElement.Entry]: "@modern-js/entry-generator",
|
|
53081
|
-
[ActionElement.Server]: "@modern-js/server-generator"
|
|
53082
|
-
},
|
|
53083
|
-
[ActionType.Function]: {
|
|
53084
|
-
[ActionFunction.TailwindCSS]: "@modern-js/tailwindcss-generator",
|
|
53085
|
-
[ActionFunction.BFF]: "@modern-js/bff-generator",
|
|
53086
|
-
[ActionFunction.MicroFrontend]: "@modern-js/dependence-generator",
|
|
53087
|
-
[ActionFunction.StorybookV7]: "@modern-js/storybook-next-generator",
|
|
53088
|
-
[ActionFunction.SSG]: "@modern-js/ssg-generator",
|
|
53089
|
-
[ActionFunction.Polyfill]: "@modern-js/dependence-generator",
|
|
53090
|
-
[ActionFunction.Proxy]: "@modern-js/dependence-generator",
|
|
53091
|
-
[ActionFunction.SWC]: "@modern-js/dependence-generator"
|
|
53092
|
-
},
|
|
53093
|
-
[ActionType.Refactor]: {
|
|
53094
|
-
[ActionRefactor.ReactRouter5]: "@modern-js/router-v5-generator"
|
|
53095
|
-
}
|
|
53096
|
-
};
|
|
53097
|
-
var MWANewActionPluginName = {
|
|
53098
|
-
[ActionType.Element]: {
|
|
53099
|
-
[ActionElement.Server]: "serverPlugin"
|
|
53100
|
-
},
|
|
53101
|
-
[ActionType.Function]: {
|
|
53102
|
-
[ActionFunction.TailwindCSS]: "tailwindcssPlugin",
|
|
53103
|
-
[ActionFunction.BFF]: "bffPlugin",
|
|
53104
|
-
[ActionFunction.MicroFrontend]: "garfishPlugin",
|
|
53105
|
-
[ActionFunction.SSG]: "ssgPlugin",
|
|
53106
|
-
[ActionFunction.Polyfill]: "polyfillPlugin",
|
|
53107
|
-
[ActionFunction.Proxy]: "proxyPlugin",
|
|
53108
|
-
[ActionFunction.SWC]: "swcPlugin"
|
|
53109
|
-
},
|
|
53110
|
-
[ActionType.Refactor]: {
|
|
53111
|
-
[ActionRefactor.ReactRouter5]: "routerPlugin"
|
|
53112
|
-
}
|
|
53113
|
-
};
|
|
53114
|
-
var MWANewActionPluginDependence = {
|
|
53115
|
-
[ActionType.Element]: {
|
|
53116
|
-
[ActionElement.Server]: "@modern-js/plugin-server"
|
|
53117
|
-
},
|
|
53118
|
-
[ActionType.Function]: {
|
|
53119
|
-
[ActionFunction.TailwindCSS]: "@modern-js/plugin-tailwindcss",
|
|
53120
|
-
[ActionFunction.BFF]: "@modern-js/plugin-bff",
|
|
53121
|
-
[ActionFunction.MicroFrontend]: "@modern-js/plugin-garfish",
|
|
53122
|
-
[ActionFunction.SSG]: "@modern-js/plugin-ssg",
|
|
53123
|
-
[ActionFunction.Polyfill]: "@modern-js/plugin-polyfill",
|
|
53124
|
-
[ActionFunction.Proxy]: "@modern-js/plugin-proxy",
|
|
53125
|
-
[ActionFunction.SWC]: "@modern-js/plugin-swc"
|
|
53126
|
-
},
|
|
53127
|
-
[ActionType.Refactor]: {
|
|
53128
|
-
[ActionRefactor.ReactRouter5]: "@modern-js/plugin-router-v5"
|
|
53129
|
-
}
|
|
53130
|
-
};
|
|
53131
|
-
var BFFPluginName = {
|
|
53132
|
-
[Framework.Express]: "expressPlugin",
|
|
53133
|
-
[Framework.Koa]: "koaPlugin"
|
|
53134
|
-
};
|
|
53135
|
-
var BFFPluginDependence = {
|
|
53136
|
-
[Framework.Express]: "@modern-js/plugin-express",
|
|
53137
|
-
[Framework.Koa]: "@modern-js/plugin-koa"
|
|
53138
|
-
};
|
|
53139
|
-
|
|
53140
|
-
// ../../generator-utils/dist/esm/utils/stripAnsi.js
|
|
53141
|
-
function ansiRegex({ onlyFirst = false } = {}) {
|
|
53142
|
-
const pattern = [
|
|
53143
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
53144
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
53145
|
-
].join("|");
|
|
53146
|
-
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
53147
|
-
}
|
|
53148
|
-
function stripAnsi(string) {
|
|
53149
|
-
if (typeof string !== "string") {
|
|
53150
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
53151
|
-
}
|
|
53152
|
-
return string.replace(ansiRegex(), "");
|
|
53153
|
-
}
|
|
53154
|
-
|
|
53155
|
-
// ../../generator-utils/dist/esm/utils/package.js
|
|
53156
|
-
var import_utils2 = require("@modern-js/utils");
|
|
53157
|
-
async function isPackageExist(packageName, registry2) {
|
|
53158
|
-
if (await (0, import_utils2.canUseNpm)()) {
|
|
53159
|
-
try {
|
|
53160
|
-
const args = [
|
|
53161
|
-
"view",
|
|
53162
|
-
packageName,
|
|
53163
|
-
"version"
|
|
53164
|
-
];
|
|
53165
|
-
if (registry2) {
|
|
53166
|
-
args.push(`--registry=${registry2}`);
|
|
53167
|
-
}
|
|
53168
|
-
const result = await (0, import_utils2.execa)("npm", args);
|
|
53169
|
-
return (0, import_utils2.stripAnsi)(result.stdout);
|
|
53170
|
-
} catch (e) {
|
|
53171
|
-
return false;
|
|
53172
|
-
}
|
|
53173
|
-
}
|
|
53174
|
-
throw new Error("not found npm, please install npm before");
|
|
53175
|
-
}
|
|
53176
|
-
async function isPackageDeprecated(packageName, registry2) {
|
|
53177
|
-
if (await (0, import_utils2.canUseNpm)()) {
|
|
53178
|
-
const args = [
|
|
53179
|
-
"view",
|
|
53180
|
-
packageName,
|
|
53181
|
-
"deprecated"
|
|
53182
|
-
];
|
|
53183
|
-
if (registry2) {
|
|
53184
|
-
args.push(`--registry=${registry2}`);
|
|
53185
|
-
}
|
|
53186
|
-
const result = await (0, import_utils2.execa)("npm", args);
|
|
53187
|
-
return (0, import_utils2.stripAnsi)(result.stdout);
|
|
53188
|
-
}
|
|
53189
|
-
throw new Error("not found npm, please install npm before");
|
|
53190
|
-
}
|
|
53191
|
-
function semverDecrease(version) {
|
|
53192
|
-
const versionObj = import_utils2.semver.parse(version, {
|
|
53193
|
-
loose: true
|
|
53194
|
-
});
|
|
53195
|
-
if (!versionObj) {
|
|
53196
|
-
throw new Error(`Version ${version} is not valid semver`);
|
|
53197
|
-
}
|
|
53198
|
-
versionObj.build = [];
|
|
53199
|
-
versionObj.prerelease = [];
|
|
53200
|
-
versionObj.patch--;
|
|
53201
|
-
const result = versionObj.format();
|
|
53202
|
-
if (!import_utils2.semver.valid(result)) {
|
|
53203
|
-
import_utils2.logger.debug(`Version ${result} is not valid semver`);
|
|
53204
|
-
return version;
|
|
53205
|
-
}
|
|
53206
|
-
return result;
|
|
53207
|
-
}
|
|
53208
|
-
async function getAvailableVersion(packageName, currentVersion, registry2) {
|
|
53209
|
-
let times = 5;
|
|
53210
|
-
let version = currentVersion;
|
|
53211
|
-
while (times) {
|
|
53212
|
-
if (!await isPackageExist(`${packageName}@${version}`, registry2) || await isPackageDeprecated(`${packageName}@${version}`, registry2)) {
|
|
53213
|
-
version = import_utils2.semver.inc(version, "patch");
|
|
53214
|
-
times--;
|
|
53215
|
-
continue;
|
|
53216
|
-
}
|
|
53217
|
-
return version;
|
|
53218
|
-
}
|
|
53219
|
-
times = 5;
|
|
53220
|
-
while (times) {
|
|
53221
|
-
version = semverDecrease(version);
|
|
53222
|
-
if (!await isPackageExist(`${packageName}@${version}`, registry2) || await isPackageDeprecated(`${packageName}@${version}`, registry2)) {
|
|
53223
|
-
times--;
|
|
53224
|
-
continue;
|
|
53225
|
-
}
|
|
53226
|
-
return version;
|
|
53227
|
-
}
|
|
53228
|
-
return currentVersion;
|
|
53229
|
-
}
|
|
53230
|
-
|
|
53231
|
-
// ../../generator-utils/dist/esm/utils/fsExist.js
|
|
53232
|
-
var import_utils3 = require("@modern-js/utils");
|
|
53233
|
-
async function fileExist(filePath) {
|
|
53234
|
-
try {
|
|
53235
|
-
const stat = await import_utils3.fs.stat(filePath);
|
|
53236
|
-
if (stat.isFile()) {
|
|
53237
|
-
return true;
|
|
53238
|
-
}
|
|
53239
|
-
return false;
|
|
53240
|
-
} catch (e) {
|
|
53241
|
-
return false;
|
|
53242
|
-
}
|
|
52907
|
+
Object.keys(helpers).forEach((h) => import_handlebars.default.registerHelper(h, helpers[h]));
|
|
52908
|
+
Object.keys(partials).forEach((p) => import_handlebars.default.registerPartial(p, partials[p]));
|
|
52909
|
+
return import_handlebars.default.compile(template)(fullData) || "";
|
|
53243
52910
|
}
|
|
53244
52911
|
|
|
53245
|
-
//
|
|
53246
|
-
var
|
|
53247
|
-
async
|
|
53248
|
-
|
|
53249
|
-
|
|
53250
|
-
|
|
53251
|
-
|
|
53252
|
-
if (await (0, import_utils4.canUsePnpm)()) {
|
|
53253
|
-
const args = [
|
|
53254
|
-
"info",
|
|
53255
|
-
packageName,
|
|
53256
|
-
"version"
|
|
53257
|
-
];
|
|
53258
|
-
if (registry2) {
|
|
53259
|
-
args.push(`--registry=${registry2}`);
|
|
53260
|
-
}
|
|
53261
|
-
const result = await (0, import_utils4.execa)("pnpm", args);
|
|
53262
|
-
spinner.stop();
|
|
53263
|
-
return stripAnsi(result.stdout);
|
|
53264
|
-
}
|
|
53265
|
-
if (await (0, import_utils4.canUseNpm)()) {
|
|
53266
|
-
const args = [
|
|
53267
|
-
"view",
|
|
53268
|
-
packageName,
|
|
53269
|
-
"version"
|
|
53270
|
-
];
|
|
53271
|
-
if (registry2) {
|
|
53272
|
-
args.push(`--registry=${registry2}`);
|
|
53273
|
-
}
|
|
53274
|
-
const result = await (0, import_utils4.execa)("npm", args);
|
|
53275
|
-
spinner.stop();
|
|
53276
|
-
return stripAnsi(result.stdout);
|
|
53277
|
-
}
|
|
53278
|
-
spinner.stop();
|
|
53279
|
-
throw new Error("not found npm, please install npm before");
|
|
53280
|
-
}
|
|
53281
|
-
async function getModernPluginVersion(solution, packageName, options = {
|
|
53282
|
-
distTag: "latest"
|
|
53283
|
-
}) {
|
|
53284
|
-
const { cwd = process.cwd(), registry: registry2, distTag } = options;
|
|
53285
|
-
const getLatetPluginVersion = async (tag) => {
|
|
53286
|
-
const version = await getPackageVersion(`${packageName}@${tag || distTag || "latest"}`, registry2);
|
|
53287
|
-
return version;
|
|
53288
|
-
};
|
|
53289
|
-
if (!packageName.startsWith("@modern-js") || packageName.includes("electron") || packageName.includes("codesmith") || packageName.includes("easy-form") || packageName.startsWith("@modern-js-reduck")) {
|
|
53290
|
-
return getLatetPluginVersion("latest");
|
|
53291
|
-
}
|
|
53292
|
-
let pkgPath = import_path.default.join(require.resolve(SolutionToolsMap[solution], {
|
|
53293
|
-
paths: [
|
|
53294
|
-
cwd
|
|
53295
|
-
]
|
|
53296
|
-
}), "../../..", "package.json");
|
|
53297
|
-
if (solution === Solution.Module) {
|
|
53298
|
-
pkgPath = import_path.default.join(require.resolve(SolutionToolsMap[solution], {
|
|
53299
|
-
paths: [
|
|
53300
|
-
cwd
|
|
53301
|
-
]
|
|
53302
|
-
}), "../..", "package.json");
|
|
53303
|
-
}
|
|
53304
|
-
if (import_utils4.fs.existsSync(pkgPath)) {
|
|
53305
|
-
const pkgInfo = import_utils4.fs.readJSONSync(pkgPath);
|
|
53306
|
-
const modernVersion = pkgInfo.version;
|
|
53307
|
-
if (typeof modernVersion !== "string") {
|
|
53308
|
-
return getLatetPluginVersion();
|
|
53309
|
-
}
|
|
53310
|
-
const version = await getAvailableVersion(packageName, modernVersion, registry2);
|
|
53311
|
-
if (!await isPackageExist(`${packageName}@${version}`)) {
|
|
53312
|
-
return getLatetPluginVersion();
|
|
53313
|
-
}
|
|
53314
|
-
return version;
|
|
53315
|
-
}
|
|
53316
|
-
return getLatetPluginVersion();
|
|
53317
|
-
}
|
|
53318
|
-
function isTsProject(appDir) {
|
|
53319
|
-
return import_utils4.fs.existsSync(import_path.default.join(appDir, "tsconfig.json"));
|
|
53320
|
-
}
|
|
53321
|
-
async function getModernConfigFile(appDir) {
|
|
53322
|
-
let exist = await fileExist(import_path.default.join(appDir, "modern.config.ts"));
|
|
53323
|
-
if (exist) {
|
|
53324
|
-
return "modern.config.ts";
|
|
53325
|
-
}
|
|
53326
|
-
exist = await fileExist(import_path.default.join(appDir, "modern.config.js"));
|
|
53327
|
-
if (exist) {
|
|
53328
|
-
return "modern.config.js";
|
|
52912
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-handlebars@2.4.1_@modern-js+codesmith@2.4.1/node_modules/@modern-js/codesmith-api-handlebars/dist/esm-node/index.js
|
|
52913
|
+
var HandlebarsAPI = class {
|
|
52914
|
+
async registerHelp(helpers) {
|
|
52915
|
+
this.registers.helpers = {
|
|
52916
|
+
...this.registers.helpers,
|
|
52917
|
+
...helpers
|
|
52918
|
+
};
|
|
53329
52919
|
}
|
|
53330
|
-
|
|
53331
|
-
|
|
53332
|
-
|
|
53333
|
-
|
|
53334
|
-
|
|
53335
|
-
var import_utils6 = require("@modern-js/utils");
|
|
53336
|
-
var FS_RESOURCE = "_codesmith_core_fs_resource";
|
|
53337
|
-
|
|
53338
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith@2.4.0/node_modules/@modern-js/codesmith/dist/esm-node/utils/fsExists.js
|
|
53339
|
-
var import_utils7 = require("@modern-js/utils");
|
|
53340
|
-
async function fsExists(path6) {
|
|
53341
|
-
try {
|
|
53342
|
-
await import_utils7.fs.access(path6);
|
|
53343
|
-
return true;
|
|
53344
|
-
} catch (e) {
|
|
53345
|
-
return false;
|
|
52920
|
+
async registerPartials(partials) {
|
|
52921
|
+
this.registers.partials = {
|
|
52922
|
+
...this.registers.partials,
|
|
52923
|
+
...partials
|
|
52924
|
+
};
|
|
53346
52925
|
}
|
|
53347
|
-
}
|
|
53348
|
-
|
|
53349
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-ejs@2.4.0_@modern-js+codesmith@2.4.0/node_modules/@modern-js/codesmith-api-ejs/dist/esm-node/utils/renderString.js
|
|
53350
|
-
var import_ejs = __toESM(require_ejs());
|
|
53351
|
-
function renderString(template, fullData) {
|
|
53352
|
-
return import_ejs.default.render(template, fullData) || "";
|
|
53353
|
-
}
|
|
53354
|
-
|
|
53355
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-ejs@2.4.0_@modern-js+codesmith@2.4.0/node_modules/@modern-js/codesmith-api-ejs/dist/esm-node/index.js
|
|
53356
|
-
var EjsAPI = class {
|
|
53357
52926
|
async renderTemplate(templateResource, target, parameters = {}) {
|
|
53358
52927
|
if (templateResource._type !== FS_RESOURCE) {
|
|
53359
52928
|
throw new Error("resource not match");
|
|
@@ -53362,7 +52931,7 @@ var EjsAPI = class {
|
|
|
53362
52931
|
if (typeof resourceValue.content !== "string") {
|
|
53363
52932
|
throw new Error(`resource.value is not string, resourceValue=${resourceValue}`);
|
|
53364
52933
|
}
|
|
53365
|
-
await this.generatorCore.output.fs(target,
|
|
52934
|
+
await this.generatorCore.output.fs(target, renderString2(resourceValue.content, parameters, this.registers), {
|
|
53366
52935
|
encoding: "utf-8"
|
|
53367
52936
|
});
|
|
53368
52937
|
}
|
|
@@ -53379,43 +52948,31 @@ var EjsAPI = class {
|
|
|
53379
52948
|
})
|
|
53380
52949
|
);
|
|
53381
52950
|
}
|
|
53382
|
-
constructor(generatorCore) {
|
|
52951
|
+
constructor(generatorCore, registers) {
|
|
53383
52952
|
this.generatorCore = generatorCore;
|
|
52953
|
+
this.registers = registers || {
|
|
52954
|
+
helpers: {},
|
|
52955
|
+
partials: {}
|
|
52956
|
+
};
|
|
53384
52957
|
}
|
|
53385
52958
|
};
|
|
53386
52959
|
|
|
53387
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-
|
|
53388
|
-
var
|
|
53389
|
-
|
|
53390
|
-
|
|
53391
|
-
|
|
53392
|
-
|
|
53393
|
-
|
|
53394
|
-
}
|
|
53395
|
-
const filePath = import_path3.default.resolve(this.generatorCore.outputPath, target.toString());
|
|
53396
|
-
await import_utils9.fs.mkdirp(import_path3.default.dirname(filePath));
|
|
53397
|
-
await import_utils9.fs.copyFile(resource.filePath, filePath);
|
|
53398
|
-
}
|
|
53399
|
-
async renderDir(material, findGlob, target, options) {
|
|
53400
|
-
const resourceMap = await material.find(findGlob, {
|
|
53401
|
-
nodir: true,
|
|
53402
|
-
...options
|
|
52960
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.1/node_modules/@modern-js/codesmith-api-npm/dist/esm-node/utils/env.js
|
|
52961
|
+
var import_utils8 = require("@modern-js/utils");
|
|
52962
|
+
async function canUseNvm() {
|
|
52963
|
+
try {
|
|
52964
|
+
await (0, import_utils8.execa)("source ~/.nvm/nvm.sh", {
|
|
52965
|
+
env: process.env,
|
|
52966
|
+
shell: true
|
|
53403
52967
|
});
|
|
53404
|
-
|
|
53405
|
-
|
|
53406
|
-
|
|
53407
|
-
}));
|
|
53408
|
-
}
|
|
53409
|
-
constructor(generatorCore) {
|
|
53410
|
-
this.generatorCore = generatorCore;
|
|
52968
|
+
return true;
|
|
52969
|
+
} catch (e) {
|
|
52970
|
+
return false;
|
|
53411
52971
|
}
|
|
53412
|
-
}
|
|
53413
|
-
|
|
53414
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-git@2.4.0_@modern-js+codesmith@2.4.0/node_modules/@modern-js/codesmith-api-git/dist/esm-node/utils/index.js
|
|
53415
|
-
var import_utils10 = require("@modern-js/utils");
|
|
53416
|
-
async function canUseGit() {
|
|
52972
|
+
}
|
|
52973
|
+
async function canUseNpm() {
|
|
53417
52974
|
try {
|
|
53418
|
-
await (0,
|
|
52975
|
+
await (0, import_utils8.execa)("npm", [
|
|
53419
52976
|
"--version"
|
|
53420
52977
|
], {
|
|
53421
52978
|
env: process.env
|
|
@@ -53425,276 +52982,78 @@ async function canUseGit() {
|
|
|
53425
52982
|
return false;
|
|
53426
52983
|
}
|
|
53427
52984
|
}
|
|
53428
|
-
async function
|
|
52985
|
+
async function canUseYarn() {
|
|
53429
52986
|
try {
|
|
53430
|
-
await (0,
|
|
53431
|
-
"
|
|
53432
|
-
"--is-inside-work-tree"
|
|
52987
|
+
await (0, import_utils8.execa)("yarn", [
|
|
52988
|
+
"--version"
|
|
53433
52989
|
], {
|
|
53434
|
-
env: process.env
|
|
53435
|
-
cwd
|
|
52990
|
+
env: process.env
|
|
53436
52991
|
});
|
|
53437
52992
|
return true;
|
|
53438
52993
|
} catch (e) {
|
|
53439
52994
|
return false;
|
|
53440
52995
|
}
|
|
53441
52996
|
}
|
|
53442
|
-
async function
|
|
53443
|
-
|
|
53444
|
-
"
|
|
53445
|
-
|
|
53446
|
-
env: process.env,
|
|
53447
|
-
cwd
|
|
53448
|
-
});
|
|
53449
|
-
const { stdout } = await (0, import_utils10.execa)("git", [
|
|
53450
|
-
"symbolic-ref",
|
|
53451
|
-
"--short",
|
|
53452
|
-
"HEAD"
|
|
53453
|
-
], {
|
|
53454
|
-
env: process.env,
|
|
53455
|
-
cwd
|
|
53456
|
-
});
|
|
53457
|
-
if (stdout !== defaultBranch) {
|
|
53458
|
-
await (0, import_utils10.execa)("git", [
|
|
53459
|
-
"checkout",
|
|
53460
|
-
"-b",
|
|
53461
|
-
defaultBranch
|
|
52997
|
+
async function canUsePnpm() {
|
|
52998
|
+
try {
|
|
52999
|
+
await (0, import_utils8.execa)("pnpm", [
|
|
53000
|
+
"--version"
|
|
53462
53001
|
], {
|
|
53463
|
-
env: process.env
|
|
53464
|
-
cwd
|
|
53002
|
+
env: process.env
|
|
53465
53003
|
});
|
|
53004
|
+
return true;
|
|
53005
|
+
} catch (e) {
|
|
53006
|
+
return false;
|
|
53466
53007
|
}
|
|
53467
53008
|
}
|
|
53468
|
-
|
|
53469
|
-
|
|
53470
|
-
|
|
53471
|
-
|
|
53472
|
-
|
|
53473
|
-
|
|
53474
|
-
|
|
53009
|
+
|
|
53010
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.1/node_modules/@modern-js/codesmith-api-npm/dist/esm-node/utils/install.js
|
|
53011
|
+
var import_utils9 = require("@modern-js/utils");
|
|
53012
|
+
function execaWithStreamLog(command, args, options) {
|
|
53013
|
+
const promise = (0, import_utils9.execa)(command, args, {
|
|
53014
|
+
...options,
|
|
53015
|
+
stdin: "inherit",
|
|
53016
|
+
stdout: "inherit",
|
|
53017
|
+
stderr: "inherit"
|
|
53475
53018
|
});
|
|
53019
|
+
return promise;
|
|
53476
53020
|
}
|
|
53477
|
-
async function
|
|
53478
|
-
await (0,
|
|
53479
|
-
|
|
53480
|
-
|
|
53481
|
-
|
|
53482
|
-
"
|
|
53483
|
-
|
|
53484
|
-
env: process.env,
|
|
53485
|
-
cwd
|
|
53021
|
+
async function runInstallWithNvm(command, options) {
|
|
53022
|
+
await (0, import_utils9.execa)(`~/.nvm/nvm-exec ${command}`, {
|
|
53023
|
+
...options,
|
|
53024
|
+
shell: true,
|
|
53025
|
+
stdin: "inherit",
|
|
53026
|
+
stdout: "inherit",
|
|
53027
|
+
stderr: "inherit"
|
|
53486
53028
|
});
|
|
53487
53029
|
}
|
|
53488
|
-
|
|
53489
|
-
|
|
53490
|
-
|
|
53491
|
-
|
|
53492
|
-
|
|
53493
|
-
|
|
53494
|
-
|
|
53495
|
-
|
|
53496
|
-
throw new Error("git is not found");
|
|
53497
|
-
}
|
|
53498
|
-
async initGitRepo(cwd = this.generatorCore.outputPath, force = false) {
|
|
53499
|
-
const canUse = await canUseGit();
|
|
53500
|
-
if (!canUse) {
|
|
53501
|
-
throw new Error("git is not found");
|
|
53030
|
+
async function npmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
53031
|
+
const canUse = await canUseNpm();
|
|
53032
|
+
if (canUse) {
|
|
53033
|
+
const params = [
|
|
53034
|
+
"install"
|
|
53035
|
+
];
|
|
53036
|
+
if (registryUrl) {
|
|
53037
|
+
params.push(`--registry=${registryUrl}`);
|
|
53502
53038
|
}
|
|
53503
|
-
|
|
53504
|
-
|
|
53505
|
-
this.generatorCore.logger.debug("already in a git repo, skip init");
|
|
53506
|
-
return;
|
|
53039
|
+
if (ignoreScripts) {
|
|
53040
|
+
params.push("--ignore-scripts");
|
|
53507
53041
|
}
|
|
53508
|
-
|
|
53509
|
-
|
|
53510
|
-
|
|
53511
|
-
|
|
53512
|
-
|
|
53513
|
-
};
|
|
53514
|
-
await initGitRepo(cwd, defaultBranch);
|
|
53515
|
-
} catch (e) {
|
|
53516
|
-
this.generatorCore.logger.debug("[GitAPI.error]:", e);
|
|
53517
|
-
throw e;
|
|
53042
|
+
if (useNvm) {
|
|
53043
|
+
return runInstallWithNvm(`npm ${params.join(" ")}`, {
|
|
53044
|
+
cwd,
|
|
53045
|
+
env: process.env
|
|
53046
|
+
});
|
|
53518
53047
|
}
|
|
53519
|
-
|
|
53520
|
-
|
|
53521
|
-
|
|
53522
|
-
|
|
53523
|
-
throw new Error("git is not found");
|
|
53524
|
-
}
|
|
53525
|
-
try {
|
|
53526
|
-
await gitAdd(cwd);
|
|
53527
|
-
await gitCommit(cwd, commitMessage);
|
|
53528
|
-
} catch (e) {
|
|
53529
|
-
this.generatorCore.logger.debug("[GitAPI.error]:", e);
|
|
53530
|
-
throw e;
|
|
53531
|
-
}
|
|
53532
|
-
}
|
|
53533
|
-
constructor(generatorCore, generatorContext) {
|
|
53534
|
-
this.generatorCore = generatorCore;
|
|
53535
|
-
this.generatorContext = generatorContext;
|
|
53536
|
-
}
|
|
53537
|
-
};
|
|
53538
|
-
|
|
53539
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-handlebars@2.4.0_@modern-js+codesmith@2.4.0/node_modules/@modern-js/codesmith-api-handlebars/dist/esm-node/utils/renderString.js
|
|
53540
|
-
var import_handlebars = __toESM(require_lib());
|
|
53541
|
-
function renderString2(template, fullData, registers) {
|
|
53542
|
-
const helpers = {
|
|
53543
|
-
...registers === null || registers === void 0 ? void 0 : registers.helpers
|
|
53544
|
-
};
|
|
53545
|
-
const partials = {
|
|
53546
|
-
...registers === null || registers === void 0 ? void 0 : registers.partials
|
|
53547
|
-
};
|
|
53548
|
-
Object.keys(helpers).forEach((h) => import_handlebars.default.registerHelper(h, helpers[h]));
|
|
53549
|
-
Object.keys(partials).forEach((p) => import_handlebars.default.registerPartial(p, partials[p]));
|
|
53550
|
-
return import_handlebars.default.compile(template)(fullData) || "";
|
|
53551
|
-
}
|
|
53552
|
-
|
|
53553
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-handlebars@2.4.0_@modern-js+codesmith@2.4.0/node_modules/@modern-js/codesmith-api-handlebars/dist/esm-node/index.js
|
|
53554
|
-
var HandlebarsAPI = class {
|
|
53555
|
-
async registerHelp(helpers) {
|
|
53556
|
-
this.registers.helpers = {
|
|
53557
|
-
...this.registers.helpers,
|
|
53558
|
-
...helpers
|
|
53559
|
-
};
|
|
53560
|
-
}
|
|
53561
|
-
async registerPartials(partials) {
|
|
53562
|
-
this.registers.partials = {
|
|
53563
|
-
...this.registers.partials,
|
|
53564
|
-
...partials
|
|
53565
|
-
};
|
|
53566
|
-
}
|
|
53567
|
-
async renderTemplate(templateResource, target, parameters = {}) {
|
|
53568
|
-
if (templateResource._type !== FS_RESOURCE) {
|
|
53569
|
-
throw new Error("resource not match");
|
|
53570
|
-
}
|
|
53571
|
-
const resourceValue = await templateResource.value();
|
|
53572
|
-
if (typeof resourceValue.content !== "string") {
|
|
53573
|
-
throw new Error(`resource.value is not string, resourceValue=${resourceValue}`);
|
|
53574
|
-
}
|
|
53575
|
-
await this.generatorCore.output.fs(target, renderString2(resourceValue.content, parameters, this.registers), {
|
|
53576
|
-
encoding: "utf-8"
|
|
53577
|
-
});
|
|
53578
|
-
}
|
|
53579
|
-
async renderTemplateDir(material, findGlob, target, options) {
|
|
53580
|
-
const resourceMap = await material.find(findGlob, {
|
|
53581
|
-
nodir: true,
|
|
53582
|
-
...options
|
|
53583
|
-
});
|
|
53584
|
-
await Promise.all(
|
|
53585
|
-
// resourceKey is relate path. example: in `garr-master/package.json`, package.json is resourceKey
|
|
53586
|
-
Object.keys(resourceMap).map(async (resourceKey) => {
|
|
53587
|
-
this.generatorCore.logger.debug(`[renderDir] resourceKey=${resourceKey}`);
|
|
53588
|
-
await this.renderTemplate(material.get(resourceKey), target(resourceKey), options === null || options === void 0 ? void 0 : options.parameters);
|
|
53589
|
-
})
|
|
53590
|
-
);
|
|
53591
|
-
}
|
|
53592
|
-
constructor(generatorCore, registers) {
|
|
53593
|
-
this.generatorCore = generatorCore;
|
|
53594
|
-
this.registers = registers || {
|
|
53595
|
-
helpers: {},
|
|
53596
|
-
partials: {}
|
|
53597
|
-
};
|
|
53598
|
-
}
|
|
53599
|
-
};
|
|
53600
|
-
|
|
53601
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.0/node_modules/@modern-js/codesmith-api-npm/dist/esm-node/utils/env.js
|
|
53602
|
-
var import_utils13 = require("@modern-js/utils");
|
|
53603
|
-
async function canUseNvm() {
|
|
53604
|
-
try {
|
|
53605
|
-
await (0, import_utils13.execa)("source ~/.nvm/nvm.sh", {
|
|
53606
|
-
env: process.env,
|
|
53607
|
-
shell: true
|
|
53608
|
-
});
|
|
53609
|
-
return true;
|
|
53610
|
-
} catch (e) {
|
|
53611
|
-
return false;
|
|
53612
|
-
}
|
|
53613
|
-
}
|
|
53614
|
-
async function canUseNpm3() {
|
|
53615
|
-
try {
|
|
53616
|
-
await (0, import_utils13.execa)("npm", [
|
|
53617
|
-
"--version"
|
|
53618
|
-
], {
|
|
53619
|
-
env: process.env
|
|
53620
|
-
});
|
|
53621
|
-
return true;
|
|
53622
|
-
} catch (e) {
|
|
53623
|
-
return false;
|
|
53624
|
-
}
|
|
53625
|
-
}
|
|
53626
|
-
async function canUseYarn2() {
|
|
53627
|
-
try {
|
|
53628
|
-
await (0, import_utils13.execa)("yarn", [
|
|
53629
|
-
"--version"
|
|
53630
|
-
], {
|
|
53631
|
-
env: process.env
|
|
53632
|
-
});
|
|
53633
|
-
return true;
|
|
53634
|
-
} catch (e) {
|
|
53635
|
-
return false;
|
|
53636
|
-
}
|
|
53637
|
-
}
|
|
53638
|
-
async function canUsePnpm3() {
|
|
53639
|
-
try {
|
|
53640
|
-
await (0, import_utils13.execa)("pnpm", [
|
|
53641
|
-
"--version"
|
|
53642
|
-
], {
|
|
53643
|
-
env: process.env
|
|
53644
|
-
});
|
|
53645
|
-
return true;
|
|
53646
|
-
} catch (e) {
|
|
53647
|
-
return false;
|
|
53648
|
-
}
|
|
53649
|
-
}
|
|
53650
|
-
|
|
53651
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.0/node_modules/@modern-js/codesmith-api-npm/dist/esm-node/utils/install.js
|
|
53652
|
-
var import_utils14 = require("@modern-js/utils");
|
|
53653
|
-
function execaWithStreamLog(command, args, options) {
|
|
53654
|
-
const promise = (0, import_utils14.execa)(command, args, {
|
|
53655
|
-
...options,
|
|
53656
|
-
stdin: "inherit",
|
|
53657
|
-
stdout: "inherit",
|
|
53658
|
-
stderr: "inherit"
|
|
53659
|
-
});
|
|
53660
|
-
return promise;
|
|
53661
|
-
}
|
|
53662
|
-
async function runInstallWithNvm(command, options) {
|
|
53663
|
-
await (0, import_utils14.execa)(`~/.nvm/nvm-exec ${command}`, {
|
|
53664
|
-
...options,
|
|
53665
|
-
shell: true,
|
|
53666
|
-
stdin: "inherit",
|
|
53667
|
-
stdout: "inherit",
|
|
53668
|
-
stderr: "inherit"
|
|
53669
|
-
});
|
|
53670
|
-
}
|
|
53671
|
-
async function npmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
53672
|
-
const canUse = await canUseNpm3();
|
|
53673
|
-
if (canUse) {
|
|
53674
|
-
const params = [
|
|
53675
|
-
"install"
|
|
53676
|
-
];
|
|
53677
|
-
if (registryUrl) {
|
|
53678
|
-
params.push(`--registry=${registryUrl}`);
|
|
53679
|
-
}
|
|
53680
|
-
if (ignoreScripts) {
|
|
53681
|
-
params.push("--ignore-scripts");
|
|
53682
|
-
}
|
|
53683
|
-
if (useNvm) {
|
|
53684
|
-
return runInstallWithNvm(`npm ${params.join(" ")}`, {
|
|
53685
|
-
cwd,
|
|
53686
|
-
env: process.env
|
|
53687
|
-
});
|
|
53688
|
-
}
|
|
53689
|
-
return execaWithStreamLog("npm", params, {
|
|
53690
|
-
cwd,
|
|
53691
|
-
env: process.env
|
|
53692
|
-
});
|
|
53048
|
+
return execaWithStreamLog("npm", params, {
|
|
53049
|
+
cwd,
|
|
53050
|
+
env: process.env
|
|
53051
|
+
});
|
|
53693
53052
|
}
|
|
53694
53053
|
throw new Error("please install npm first");
|
|
53695
53054
|
}
|
|
53696
53055
|
async function yarnInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
53697
|
-
const canUse = await
|
|
53056
|
+
const canUse = await canUseYarn();
|
|
53698
53057
|
if (canUse) {
|
|
53699
53058
|
const params = [
|
|
53700
53059
|
"install"
|
|
@@ -53719,7 +53078,7 @@ async function yarnInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
|
53719
53078
|
throw new Error("please install yarn first");
|
|
53720
53079
|
}
|
|
53721
53080
|
async function pnpmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
53722
|
-
const canUse = await
|
|
53081
|
+
const canUse = await canUsePnpm();
|
|
53723
53082
|
if (canUse) {
|
|
53724
53083
|
const params = [
|
|
53725
53084
|
"install"
|
|
@@ -53744,7 +53103,7 @@ async function pnpmInstall({ cwd, registryUrl, ignoreScripts, useNvm }) {
|
|
|
53744
53103
|
throw new Error("please install pnpm first");
|
|
53745
53104
|
}
|
|
53746
53105
|
|
|
53747
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.
|
|
53106
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-npm@2.4.1/node_modules/@modern-js/codesmith-api-npm/dist/esm-node/index.js
|
|
53748
53107
|
var NpmAPI = class {
|
|
53749
53108
|
npmInstall({ cwd, registryUrl, ignoreScripts }) {
|
|
53750
53109
|
return npmInstall({
|
|
@@ -54154,7 +53513,7 @@ function pascalCase(input, options) {
|
|
|
54154
53513
|
}
|
|
54155
53514
|
|
|
54156
53515
|
// ../../../../node_modules/.pnpm/@formily+shared@2.2.24/node_modules/@formily/shared/esm/string.js
|
|
54157
|
-
var
|
|
53516
|
+
var ansiRegex = function() {
|
|
54158
53517
|
var pattern = [
|
|
54159
53518
|
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)",
|
|
54160
53519
|
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
|
@@ -54165,11 +53524,11 @@ var regex = "[\uD800-\uDBFF][\uDC00-\uDFFF]";
|
|
|
54165
53524
|
var astralRegex = function(opts) {
|
|
54166
53525
|
return opts && opts.exact ? new RegExp("^".concat(regex, "$")) : new RegExp(regex, "g");
|
|
54167
53526
|
};
|
|
54168
|
-
var
|
|
54169
|
-
return typeof input === "string" ? input.replace(
|
|
53527
|
+
var stripAnsi = function(input) {
|
|
53528
|
+
return typeof input === "string" ? input.replace(ansiRegex(), "") : input;
|
|
54170
53529
|
};
|
|
54171
53530
|
var stringLength = function(input) {
|
|
54172
|
-
return
|
|
53531
|
+
return stripAnsi(input).replace(astralRegex(), " ").length;
|
|
54173
53532
|
};
|
|
54174
53533
|
|
|
54175
53534
|
// ../../../../node_modules/.pnpm/@formily+path@2.2.24/node_modules/@formily/path/esm/contexts.js
|
|
@@ -63328,11 +62687,11 @@ var Schema = (
|
|
|
63328
62687
|
}()
|
|
63329
62688
|
);
|
|
63330
62689
|
|
|
63331
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-formily@2.4.
|
|
62690
|
+
// ../../../../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/prompt.js
|
|
63332
62691
|
var import_inquirer = __toESM(require_inquirer());
|
|
63333
62692
|
|
|
63334
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-formily@2.4.
|
|
63335
|
-
var
|
|
62693
|
+
// ../../../../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
|
|
62694
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
|
63336
62695
|
function validateSchema(schema) {
|
|
63337
62696
|
const { type, properties } = schema;
|
|
63338
62697
|
if (type !== "object") {
|
|
@@ -63361,7 +62720,7 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
|
|
|
63361
62720
|
const questionValidate = async (field2, input) => {
|
|
63362
62721
|
if (fieldValidate) {
|
|
63363
62722
|
var _result_error;
|
|
63364
|
-
const result2 = await validate(input, (0,
|
|
62723
|
+
const result2 = await validate(input, (0, import_lodash.isFunction)(fieldValidate) ? {
|
|
63365
62724
|
validator: fieldValidate
|
|
63366
62725
|
} : fieldValidate);
|
|
63367
62726
|
if ((_result_error = result2.error) === null || _result_error === void 0 ? void 0 : _result_error.length) {
|
|
@@ -63385,14 +62744,14 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
|
|
|
63385
62744
|
when: !configValue[field]
|
|
63386
62745
|
};
|
|
63387
62746
|
if (items) {
|
|
63388
|
-
if ((0,
|
|
62747
|
+
if ((0, import_lodash.isArray)(defaultValue)) {
|
|
63389
62748
|
return {
|
|
63390
62749
|
...result,
|
|
63391
62750
|
type: "checkbox",
|
|
63392
62751
|
choices: items.map((item) => ({
|
|
63393
62752
|
type: "choice",
|
|
63394
|
-
name: (0,
|
|
63395
|
-
value: (0,
|
|
62753
|
+
name: (0, import_lodash.isObject)(item) ? item.label : item,
|
|
62754
|
+
value: (0, import_lodash.isObject)(item) ? item.value : item
|
|
63396
62755
|
}))
|
|
63397
62756
|
};
|
|
63398
62757
|
}
|
|
@@ -63401,8 +62760,8 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
|
|
|
63401
62760
|
type: "list",
|
|
63402
62761
|
choices: items.map((item) => ({
|
|
63403
62762
|
type: "choice",
|
|
63404
|
-
name: (0,
|
|
63405
|
-
value: (0,
|
|
62763
|
+
name: (0, import_lodash.isObject)(item) ? item.label : item,
|
|
62764
|
+
value: (0, import_lodash.isObject)(item) ? item.value : item
|
|
63406
62765
|
}))
|
|
63407
62766
|
};
|
|
63408
62767
|
}
|
|
@@ -63417,13 +62776,13 @@ function getQuestionFromSchema(schema, configValue = {}, validateMap, initValue)
|
|
|
63417
62776
|
type: "input"
|
|
63418
62777
|
};
|
|
63419
62778
|
});
|
|
63420
|
-
return (0,
|
|
62779
|
+
return (0, import_lodash.flattenDeep)(questions);
|
|
63421
62780
|
}
|
|
63422
62781
|
function transformForm(schema, configValue = {}, validateMap, initValue) {
|
|
63423
62782
|
return getQuestionFromSchema(schema, configValue, validateMap, initValue);
|
|
63424
62783
|
}
|
|
63425
62784
|
|
|
63426
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-formily@2.4.
|
|
62785
|
+
// ../../../../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/prompt.js
|
|
63427
62786
|
var compileRule = (rule, scope) => {
|
|
63428
62787
|
const state = Schema.compile(rule, {
|
|
63429
62788
|
$self: {},
|
|
@@ -63527,7 +62886,7 @@ async function prompt(schema, configValue = {}, validateMap, initValue) {
|
|
|
63527
62886
|
return answers;
|
|
63528
62887
|
}
|
|
63529
62888
|
|
|
63530
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-formily@2.4.
|
|
62889
|
+
// ../../../../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/inquirer.js
|
|
63531
62890
|
var CLIReader = class {
|
|
63532
62891
|
getAnswers() {
|
|
63533
62892
|
return this.answers;
|
|
@@ -63556,31 +62915,31 @@ var CLIReader = class {
|
|
|
63556
62915
|
}
|
|
63557
62916
|
};
|
|
63558
62917
|
|
|
63559
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.
|
|
63560
|
-
var
|
|
63561
|
-
var
|
|
62918
|
+
// ../../../../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
|
|
62919
|
+
var import_utils13 = require("@modern-js/utils");
|
|
62920
|
+
var import_lodash5 = require("@modern-js/utils/lodash");
|
|
63562
62921
|
var import_comment_json = __toESM(require_src2());
|
|
63563
62922
|
var import_inquirer2 = __toESM(require_inquirer2());
|
|
63564
62923
|
|
|
63565
62924
|
// ../../../../node_modules/.pnpm/@modern-js+plugin-i18n@2.58.0/node_modules/@modern-js/plugin-i18n/dist/esm-node/index.js
|
|
63566
|
-
var
|
|
62925
|
+
var import_lodash3 = require("@modern-js/utils/lodash");
|
|
63567
62926
|
|
|
63568
62927
|
// ../../../../node_modules/.pnpm/@modern-js+plugin-i18n@2.58.0/node_modules/@modern-js/plugin-i18n/dist/esm-node/utils/index.js
|
|
63569
|
-
var
|
|
63570
|
-
function
|
|
62928
|
+
var import_lodash2 = require("@modern-js/utils/lodash");
|
|
62929
|
+
function getObjKeyMap(obj, prefix = "") {
|
|
63571
62930
|
const result = {};
|
|
63572
62931
|
Object.keys(obj).forEach((key) => {
|
|
63573
|
-
if ((0,
|
|
62932
|
+
if ((0, import_lodash2.isString)(obj[key])) {
|
|
63574
62933
|
result[key] = prefix ? `${prefix}.${key}` : key;
|
|
63575
|
-
} else if ((0,
|
|
63576
|
-
result[key] =
|
|
62934
|
+
} else if ((0, import_lodash2.isObject)(obj[key])) {
|
|
62935
|
+
result[key] = getObjKeyMap(obj[key], prefix ? `${prefix}.${key}` : key);
|
|
63577
62936
|
}
|
|
63578
62937
|
});
|
|
63579
62938
|
return result;
|
|
63580
62939
|
}
|
|
63581
62940
|
|
|
63582
62941
|
// ../../../../node_modules/.pnpm/@modern-js+plugin-i18n@2.58.0/node_modules/@modern-js/plugin-i18n/dist/esm-node/index.js
|
|
63583
|
-
var
|
|
62942
|
+
var I18n = class {
|
|
63584
62943
|
format(msg, vars) {
|
|
63585
62944
|
return msg.replace(/\{(\w+)\}/g, (_match, capture) => Object.prototype.hasOwnProperty.call(vars, capture) ? vars[capture] : capture);
|
|
63586
62945
|
}
|
|
@@ -63594,7 +62953,7 @@ var I18n2 = class {
|
|
|
63594
62953
|
if (!model) {
|
|
63595
62954
|
return fallbackText || key;
|
|
63596
62955
|
}
|
|
63597
|
-
const message = (0,
|
|
62956
|
+
const message = (0, import_lodash3.get)(model, key);
|
|
63598
62957
|
const value = message || fallbackText || key;
|
|
63599
62958
|
if (typeof value === "string") {
|
|
63600
62959
|
return this.format(value, vars || {});
|
|
@@ -63606,7 +62965,7 @@ var I18n2 = class {
|
|
|
63606
62965
|
if (languageMap) {
|
|
63607
62966
|
this.languageMap = languageMap;
|
|
63608
62967
|
}
|
|
63609
|
-
return
|
|
62968
|
+
return getObjKeyMap(this.languageMap[this.language]);
|
|
63610
62969
|
}
|
|
63611
62970
|
changeLanguage(config) {
|
|
63612
62971
|
this.language = config.locale || "en";
|
|
@@ -63625,8 +62984,8 @@ var I18n2 = class {
|
|
|
63625
62984
|
}
|
|
63626
62985
|
};
|
|
63627
62986
|
|
|
63628
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.
|
|
63629
|
-
var
|
|
62987
|
+
// ../../../../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
|
|
62988
|
+
var EN_LOCALE = {
|
|
63630
62989
|
environment: {
|
|
63631
62990
|
node_version: "please upgrade node to lts version",
|
|
63632
62991
|
nvm_install: "please install nvm first",
|
|
@@ -63652,8 +63011,8 @@ var EN_LOCALE2 = {
|
|
|
63652
63011
|
}
|
|
63653
63012
|
};
|
|
63654
63013
|
|
|
63655
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.
|
|
63656
|
-
var
|
|
63014
|
+
// ../../../../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
|
|
63015
|
+
var ZH_LOCALE = {
|
|
63657
63016
|
environment: {
|
|
63658
63017
|
node_version: "请升级 Node 版本至 LIS",
|
|
63659
63018
|
nvm_install: "检测到环境中未安装 nvm,请先安装 nvm",
|
|
@@ -63679,16 +63038,16 @@ var ZH_LOCALE2 = {
|
|
|
63679
63038
|
}
|
|
63680
63039
|
};
|
|
63681
63040
|
|
|
63682
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.
|
|
63683
|
-
var
|
|
63684
|
-
var
|
|
63685
|
-
zh:
|
|
63686
|
-
en:
|
|
63041
|
+
// ../../../../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
|
|
63042
|
+
var i18n = new I18n();
|
|
63043
|
+
var localeKeys = i18n.init("zh", {
|
|
63044
|
+
zh: ZH_LOCALE,
|
|
63045
|
+
en: EN_LOCALE
|
|
63687
63046
|
});
|
|
63688
63047
|
|
|
63689
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.
|
|
63690
|
-
var
|
|
63691
|
-
var
|
|
63048
|
+
// ../../../../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
|
|
63049
|
+
var import_path4 = __toESM(require("path"));
|
|
63050
|
+
var import_utils12 = require("@modern-js/utils");
|
|
63692
63051
|
var NODE_MAJOR_VERSION_MAP = {
|
|
63693
63052
|
"lts/*": 18,
|
|
63694
63053
|
"lts/argon": 4,
|
|
@@ -63701,7 +63060,7 @@ var NODE_MAJOR_VERSION_MAP = {
|
|
|
63701
63060
|
"lts/hydrogen": 18
|
|
63702
63061
|
};
|
|
63703
63062
|
async function getNoteVersion() {
|
|
63704
|
-
const result = await (0,
|
|
63063
|
+
const result = await (0, import_utils12.execa)("node", [
|
|
63705
63064
|
"--version"
|
|
63706
63065
|
]);
|
|
63707
63066
|
return result.stdout.slice(1);
|
|
@@ -63710,13 +63069,13 @@ async function checkUseNvm(cwd, logger2) {
|
|
|
63710
63069
|
if (process.platform.startsWith("win")) {
|
|
63711
63070
|
return false;
|
|
63712
63071
|
}
|
|
63713
|
-
if (!await fsExists(
|
|
63072
|
+
if (!await fsExists(import_path4.default.join(cwd, ".nvmrc"))) {
|
|
63714
63073
|
return false;
|
|
63715
63074
|
}
|
|
63716
|
-
const nvmrcContent = (await
|
|
63075
|
+
const nvmrcContent = (await import_utils12.fs.readFile(import_path4.default.join(cwd, ".nvmrc"), "utf-8")).replace("\n", "");
|
|
63717
63076
|
const expectNodeVersion = NODE_MAJOR_VERSION_MAP[nvmrcContent] || nvmrcContent;
|
|
63718
63077
|
const currentNodeVersion = await getNoteVersion();
|
|
63719
|
-
if (expectNodeVersion ===
|
|
63078
|
+
if (expectNodeVersion === import_utils12.semver.major(currentNodeVersion)) {
|
|
63720
63079
|
return false;
|
|
63721
63080
|
}
|
|
63722
63081
|
if (!await canUseNvm()) {
|
|
@@ -63734,8 +63093,8 @@ async function checkUseNvm(cwd, logger2) {
|
|
|
63734
63093
|
}
|
|
63735
63094
|
}
|
|
63736
63095
|
|
|
63737
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.
|
|
63738
|
-
var
|
|
63096
|
+
// ../../../../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
|
|
63097
|
+
var import_lodash4 = require("@modern-js/utils/lodash");
|
|
63739
63098
|
function transformInquirerSchema(questions, configValue = {}, validateMap = {}, initValue = {}) {
|
|
63740
63099
|
for (const question of questions) {
|
|
63741
63100
|
question.default = initValue[question.name] || question.default;
|
|
@@ -63743,7 +63102,7 @@ function transformInquirerSchema(questions, configValue = {}, validateMap = {},
|
|
|
63743
63102
|
question.validate = async (input, answers) => {
|
|
63744
63103
|
if (originValidate) {
|
|
63745
63104
|
const result = await originValidate(input, answers);
|
|
63746
|
-
if ((0,
|
|
63105
|
+
if ((0, import_lodash4.isString)(result)) {
|
|
63747
63106
|
return result;
|
|
63748
63107
|
}
|
|
63749
63108
|
}
|
|
@@ -63762,16 +63121,16 @@ function transformInquirerSchema(questions, configValue = {}, validateMap = {},
|
|
|
63762
63121
|
return questions;
|
|
63763
63122
|
}
|
|
63764
63123
|
|
|
63765
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-app@2.4.
|
|
63124
|
+
// ../../../../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
|
|
63766
63125
|
var AppAPI = class {
|
|
63767
63126
|
async checkEnvironment(nodeVersion) {
|
|
63768
|
-
if (
|
|
63769
|
-
this.generatorCore.logger.warn(
|
|
63127
|
+
if (import_utils13.semver.lt(process.versions.node, nodeVersion || "12.22.12")) {
|
|
63128
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.environment.node_version));
|
|
63770
63129
|
return false;
|
|
63771
63130
|
}
|
|
63772
|
-
if (!await
|
|
63131
|
+
if (!await canUseYarn() && !await canUsePnpm() && !await canUseNpm()) {
|
|
63773
63132
|
this.generatorCore.logger.debug("can't use yarn or pnpm or npm");
|
|
63774
|
-
this.generatorCore.logger.warn(
|
|
63133
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.environment.yarn_pnpm_npm));
|
|
63775
63134
|
return false;
|
|
63776
63135
|
}
|
|
63777
63136
|
return true;
|
|
@@ -63788,7 +63147,7 @@ var AppAPI = class {
|
|
|
63788
63147
|
}
|
|
63789
63148
|
let intallPromise;
|
|
63790
63149
|
if (command) {
|
|
63791
|
-
intallPromise = (0,
|
|
63150
|
+
intallPromise = (0, import_utils13.execa)(command, [], {
|
|
63792
63151
|
shell: true,
|
|
63793
63152
|
stdin: "inherit",
|
|
63794
63153
|
stdout: "inherit",
|
|
@@ -63813,10 +63172,10 @@ var AppAPI = class {
|
|
|
63813
63172
|
}
|
|
63814
63173
|
try {
|
|
63815
63174
|
await intallPromise;
|
|
63816
|
-
this.generatorCore.logger.info(
|
|
63175
|
+
this.generatorCore.logger.info(i18n.t(localeKeys.install.success));
|
|
63817
63176
|
} catch (e) {
|
|
63818
63177
|
this.generatorCore.logger.warn(e);
|
|
63819
|
-
this.generatorCore.logger.warn(
|
|
63178
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.install.failed, {
|
|
63820
63179
|
command: command || `${packageManager} install`
|
|
63821
63180
|
}));
|
|
63822
63181
|
}
|
|
@@ -63837,16 +63196,16 @@ var AppAPI = class {
|
|
|
63837
63196
|
}
|
|
63838
63197
|
} catch (e) {
|
|
63839
63198
|
this.generatorCore.logger.debug("Dependencies install failed", e);
|
|
63840
|
-
this.generatorCore.logger.warn(
|
|
63199
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.install.failed_no_command));
|
|
63841
63200
|
}
|
|
63842
63201
|
try {
|
|
63843
63202
|
if (!isMonorepoSubProject && !customNoNeedGit && !inGitRepo) {
|
|
63844
63203
|
await this.gitApi.addAndCommit(commitMessage || "feat: init");
|
|
63845
|
-
this.generatorCore.logger.info(
|
|
63204
|
+
this.generatorCore.logger.info(i18n.t(localeKeys.git.success));
|
|
63846
63205
|
}
|
|
63847
63206
|
} catch (e) {
|
|
63848
63207
|
this.generatorCore.logger.debug("Git repository create failed", e);
|
|
63849
|
-
this.generatorCore.logger.warn(
|
|
63208
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.git.failed));
|
|
63850
63209
|
}
|
|
63851
63210
|
}
|
|
63852
63211
|
async forgeTemplate(templatePattern, filter, rename, parameters, type = "handlebars") {
|
|
@@ -63871,7 +63230,7 @@ var AppAPI = class {
|
|
|
63871
63230
|
}
|
|
63872
63231
|
} catch (e) {
|
|
63873
63232
|
this.generatorCore.logger.debug("base forging failed:", e);
|
|
63874
|
-
this.generatorCore.logger.warn(
|
|
63233
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.templated.failed));
|
|
63875
63234
|
throw new Error("base forging failed");
|
|
63876
63235
|
} finally {
|
|
63877
63236
|
var _this_generatorCore_logger_timing1, _this_generatorCore_logger1;
|
|
@@ -63910,7 +63269,7 @@ var AppAPI = class {
|
|
|
63910
63269
|
}
|
|
63911
63270
|
} catch (e) {
|
|
63912
63271
|
this.generatorCore.logger.debug("base forging failed:", e);
|
|
63913
|
-
this.generatorCore.logger.warn(
|
|
63272
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.templated.failed));
|
|
63914
63273
|
throw new Error("base forging failed");
|
|
63915
63274
|
} finally {
|
|
63916
63275
|
var _this_generatorCore_logger_timing1, _this_generatorCore_logger1;
|
|
@@ -63919,35 +63278,35 @@ var AppAPI = class {
|
|
|
63919
63278
|
}
|
|
63920
63279
|
async updateWorkspace(folder, workspaceName = "monorepo.code-workspace") {
|
|
63921
63280
|
const { filePath } = this.generatorContext.materials.default.get(workspaceName);
|
|
63922
|
-
if (!
|
|
63281
|
+
if (!import_utils13.fs.existsSync(filePath)) {
|
|
63923
63282
|
return;
|
|
63924
63283
|
}
|
|
63925
|
-
const content = await
|
|
63284
|
+
const content = await import_utils13.fs.readFile(filePath);
|
|
63926
63285
|
const workspace = (0, import_comment_json.parse)(content.toString());
|
|
63927
63286
|
workspace.folders = [
|
|
63928
63287
|
folder,
|
|
63929
63288
|
...workspace.folders || []
|
|
63930
63289
|
];
|
|
63931
63290
|
const indent = 2;
|
|
63932
|
-
await
|
|
63291
|
+
await import_utils13.fs.writeFile(filePath, (0, import_comment_json.stringify)(workspace, null, indent), {
|
|
63933
63292
|
encoding: "utf-8"
|
|
63934
63293
|
});
|
|
63935
63294
|
}
|
|
63936
63295
|
showSuccessInfo(successInfo) {
|
|
63937
|
-
this.generatorCore.logger.info(successInfo ||
|
|
63296
|
+
this.generatorCore.logger.info(successInfo || i18n.t(localeKeys.success.info));
|
|
63938
63297
|
}
|
|
63939
63298
|
async runSubGenerator(subGenerator, relativePwdPath, config) {
|
|
63940
63299
|
try {
|
|
63941
63300
|
await this.generatorCore.runSubGenerator(subGenerator, relativePwdPath, config);
|
|
63942
63301
|
} catch (e) {
|
|
63943
|
-
this.generatorCore.logger.warn(
|
|
63944
|
-
this.generatorCore.logger.debug(
|
|
63302
|
+
this.generatorCore.logger.warn(i18n.t(localeKeys.generator.failed));
|
|
63303
|
+
this.generatorCore.logger.debug(i18n.t(localeKeys.generator.failed), e);
|
|
63945
63304
|
throw new Error("run sub generator failed");
|
|
63946
63305
|
}
|
|
63947
63306
|
}
|
|
63948
63307
|
mergeAnswers(answers, configValue) {
|
|
63949
|
-
const inputData = (0,
|
|
63950
|
-
this.generatorContext.config = (0,
|
|
63308
|
+
const inputData = (0, import_lodash5.merge)(answers, configValue);
|
|
63309
|
+
this.generatorContext.config = (0, import_lodash5.merge)(this.generatorContext.config, inputData);
|
|
63951
63310
|
return inputData;
|
|
63952
63311
|
}
|
|
63953
63312
|
async getInputBySchemaFunc(schemaFunc, configValue = {}, validateMap = {}, initValue = {}) {
|
|
@@ -63983,7 +63342,7 @@ var AppAPI = class {
|
|
|
63983
63342
|
return this.mergeAnswers(answers, configValue);
|
|
63984
63343
|
}
|
|
63985
63344
|
constructor(generatorContext, generatorCore) {
|
|
63986
|
-
this.i18n =
|
|
63345
|
+
this.i18n = i18n;
|
|
63987
63346
|
this.generatorCore = generatorCore;
|
|
63988
63347
|
this.generatorContext = generatorContext;
|
|
63989
63348
|
this.npmApi = new NpmAPI(generatorCore);
|
|
@@ -63994,11 +63353,11 @@ var AppAPI = class {
|
|
|
63994
63353
|
}
|
|
63995
63354
|
};
|
|
63996
63355
|
|
|
63997
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-json@2.4.
|
|
63356
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-json@2.4.1/node_modules/@modern-js/codesmith-api-json/dist/esm-node/index.js
|
|
63998
63357
|
var import_comment_json2 = __toESM(require_src2());
|
|
63999
63358
|
var declarationUpdate = __toESM(require_dist());
|
|
64000
63359
|
|
|
64001
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-json@2.4.
|
|
63360
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-json@2.4.1/node_modules/@modern-js/codesmith-api-json/dist/esm-node/utils/index.js
|
|
64002
63361
|
async function editJson(generatorCore, resource, getNewJsonValue) {
|
|
64003
63362
|
const originJsonValue = await resource.value();
|
|
64004
63363
|
const newJsonString = await getNewJsonValue(originJsonValue.content);
|
|
@@ -64011,7 +63370,7 @@ async function editJson(generatorCore, resource, getNewJsonValue) {
|
|
|
64011
63370
|
return newJsonString;
|
|
64012
63371
|
}
|
|
64013
63372
|
|
|
64014
|
-
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-json@2.4.
|
|
63373
|
+
// ../../../../node_modules/.pnpm/@modern-js+codesmith-api-json@2.4.1/node_modules/@modern-js/codesmith-api-json/dist/esm-node/index.js
|
|
64015
63374
|
var JsonAPI = class {
|
|
64016
63375
|
async get(resource) {
|
|
64017
63376
|
const originJsonValue = await resource.value();
|
|
@@ -64055,29 +63414,700 @@ var JsonAPI = class {
|
|
|
64055
63414
|
}
|
|
64056
63415
|
};
|
|
64057
63416
|
|
|
64058
|
-
//
|
|
64059
|
-
var
|
|
64060
|
-
|
|
63417
|
+
// ../../../cli/plugin-i18n/dist/esm-node/index.js
|
|
63418
|
+
var import_lodash7 = require("@modern-js/utils/lodash");
|
|
63419
|
+
|
|
63420
|
+
// ../../../cli/plugin-i18n/dist/esm-node/utils/index.js
|
|
63421
|
+
var import_lodash6 = require("@modern-js/utils/lodash");
|
|
63422
|
+
function getObjKeyMap2(obj, prefix = "") {
|
|
63423
|
+
const result = {};
|
|
63424
|
+
Object.keys(obj).forEach((key) => {
|
|
63425
|
+
if ((0, import_lodash6.isString)(obj[key])) {
|
|
63426
|
+
result[key] = prefix ? `${prefix}.${key}` : key;
|
|
63427
|
+
} else if ((0, import_lodash6.isObject)(obj[key])) {
|
|
63428
|
+
result[key] = getObjKeyMap2(obj[key], prefix ? `${prefix}.${key}` : key);
|
|
63429
|
+
}
|
|
63430
|
+
});
|
|
63431
|
+
return result;
|
|
63432
|
+
}
|
|
63433
|
+
|
|
63434
|
+
// ../../../cli/plugin-i18n/dist/esm-node/index.js
|
|
63435
|
+
var I18n2 = class {
|
|
63436
|
+
format(msg, vars) {
|
|
63437
|
+
return msg.replace(/\{(\w+)\}/g, (_match, capture) => Object.prototype.hasOwnProperty.call(vars, capture) ? vars[capture] : capture);
|
|
63438
|
+
}
|
|
63439
|
+
getMessage(lang, key, vars, fallbackText) {
|
|
63440
|
+
const languages = Object.keys(this.languageMap);
|
|
63441
|
+
const resultLang = languages.find((l) => l === lang);
|
|
63442
|
+
if (!resultLang && languages.length === 0) {
|
|
63443
|
+
return fallbackText || key;
|
|
63444
|
+
}
|
|
63445
|
+
const model = this.languageMap[resultLang || "en"];
|
|
63446
|
+
if (!model) {
|
|
63447
|
+
return fallbackText || key;
|
|
63448
|
+
}
|
|
63449
|
+
const message = (0, import_lodash7.get)(model, key);
|
|
63450
|
+
const value = message || fallbackText || key;
|
|
63451
|
+
if (typeof value === "string") {
|
|
63452
|
+
return this.format(value, vars || {});
|
|
63453
|
+
}
|
|
63454
|
+
throw new Error("key is not a string");
|
|
63455
|
+
}
|
|
63456
|
+
init(language, languageMap) {
|
|
63457
|
+
this.language = language || "en";
|
|
63458
|
+
if (languageMap) {
|
|
63459
|
+
this.languageMap = languageMap;
|
|
63460
|
+
}
|
|
63461
|
+
return getObjKeyMap2(this.languageMap[this.language]);
|
|
63462
|
+
}
|
|
63463
|
+
changeLanguage(config) {
|
|
63464
|
+
this.language = config.locale || "en";
|
|
63465
|
+
}
|
|
63466
|
+
t(key, vars, fallbackText) {
|
|
63467
|
+
return this.getMessage(this.language, key, vars, fallbackText);
|
|
63468
|
+
}
|
|
63469
|
+
lang(lang) {
|
|
63470
|
+
return {
|
|
63471
|
+
t: (key, vars, fallbackText) => this.getMessage(lang, key, vars, fallbackText)
|
|
63472
|
+
};
|
|
63473
|
+
}
|
|
63474
|
+
constructor() {
|
|
63475
|
+
this.language = "en";
|
|
63476
|
+
this.languageMap = {};
|
|
63477
|
+
}
|
|
63478
|
+
};
|
|
63479
|
+
|
|
63480
|
+
// ../../generator-common/dist/esm-node/locale/en.js
|
|
63481
|
+
var EN_LOCALE2 = {
|
|
63482
|
+
solution: {
|
|
63483
|
+
self: "Please select the type of project you want to create:",
|
|
63484
|
+
mwa: "Web App",
|
|
63485
|
+
module: "Npm Module",
|
|
63486
|
+
custom: "Custom Solution",
|
|
63487
|
+
default: "Default"
|
|
63488
|
+
},
|
|
63489
|
+
scenes: {
|
|
63490
|
+
self: "Please select the project scenario:"
|
|
63491
|
+
},
|
|
63492
|
+
sub_solution: {
|
|
63493
|
+
self: "Please select the type of project you want to create:",
|
|
63494
|
+
mwa: "Web App",
|
|
63495
|
+
module: "Npm Module"
|
|
63496
|
+
},
|
|
63497
|
+
action: {
|
|
63498
|
+
self: "Please select the operation you want:",
|
|
63499
|
+
function: {
|
|
63500
|
+
self: "Enable Features",
|
|
63501
|
+
question: "Please select the feature name:",
|
|
63502
|
+
tailwindcss: "Enable Tailwind CSS",
|
|
63503
|
+
bff: "Enable BFF",
|
|
63504
|
+
micro_frontend: "Enable Micro Frontend",
|
|
63505
|
+
i18n: "Enable Internationalization (i18n)",
|
|
63506
|
+
storybookV7: "Enable Storybook V7",
|
|
63507
|
+
runtime_api: "Enable Runtime API",
|
|
63508
|
+
ssg: "Enable SSG",
|
|
63509
|
+
polyfill: "Enable UA-based Polyfill Feature",
|
|
63510
|
+
proxy: "Enable Global Proxy",
|
|
63511
|
+
swc: "Enable SWC Compile",
|
|
63512
|
+
module_doc: "Enable Module Doc"
|
|
63513
|
+
},
|
|
63514
|
+
element: {
|
|
63515
|
+
self: "Create Element",
|
|
63516
|
+
question: "Please select the type of element to create:",
|
|
63517
|
+
entry: 'New "entry"',
|
|
63518
|
+
server: 'New "Custom Web Server" source code directory'
|
|
63519
|
+
},
|
|
63520
|
+
refactor: {
|
|
63521
|
+
self: "Automatic Refactor",
|
|
63522
|
+
question: "Please select the type of refactoring:",
|
|
63523
|
+
react_router_5: "Use React Router v5"
|
|
63524
|
+
}
|
|
63525
|
+
},
|
|
63526
|
+
boolean: {
|
|
63527
|
+
yes: "Yes",
|
|
63528
|
+
no: "No"
|
|
63529
|
+
},
|
|
63530
|
+
language: {
|
|
63531
|
+
self: "Please select the programming language:"
|
|
63532
|
+
},
|
|
63533
|
+
packageManager: {
|
|
63534
|
+
self: "Please select the package manager:"
|
|
63535
|
+
},
|
|
63536
|
+
entry: {
|
|
63537
|
+
name: "Please fill in the entry name:",
|
|
63538
|
+
no_empty: "The entry name cannot be empty!",
|
|
63539
|
+
no_pages: 'The entry name cannot be "pages"!'
|
|
63540
|
+
},
|
|
63541
|
+
packageName: {
|
|
63542
|
+
self: "Please fill in the project name:",
|
|
63543
|
+
sub_name: "Please fill in the sub-project name:",
|
|
63544
|
+
no_empty: "The package name cannot be empty!"
|
|
63545
|
+
},
|
|
63546
|
+
packagePath: {
|
|
63547
|
+
self: "Please fill in the sub-project directory name:",
|
|
63548
|
+
no_empty: "The package path cannot be empty!",
|
|
63549
|
+
format: "Only lowercase letters, numbers and delimiters (-), and underscore (_), and directory delimiters (/) can be used in package path."
|
|
63550
|
+
},
|
|
63551
|
+
framework: {
|
|
63552
|
+
self: "Please select the framework:",
|
|
63553
|
+
egg: "Egg",
|
|
63554
|
+
express: "Express",
|
|
63555
|
+
koa: "Koa",
|
|
63556
|
+
nest: "Nest"
|
|
63557
|
+
},
|
|
63558
|
+
bff: {
|
|
63559
|
+
bffType: {
|
|
63560
|
+
self: "Please select the BFF type:",
|
|
63561
|
+
func: "Function",
|
|
63562
|
+
framework: "Framework"
|
|
63563
|
+
}
|
|
63564
|
+
},
|
|
63565
|
+
buildTools: {
|
|
63566
|
+
self: "Please select the bundler:",
|
|
63567
|
+
webpack: "webpack",
|
|
63568
|
+
rspack: "Rspack (experimental)"
|
|
63569
|
+
}
|
|
63570
|
+
};
|
|
63571
|
+
|
|
63572
|
+
// ../../generator-common/dist/esm-node/locale/zh.js
|
|
63573
|
+
var ZH_LOCALE2 = {
|
|
63574
|
+
solution: {
|
|
63575
|
+
self: "请选择你想创建的工程类型",
|
|
63576
|
+
mwa: "Web 应用",
|
|
63577
|
+
module: "Npm 模块",
|
|
63578
|
+
custom: "自定义",
|
|
63579
|
+
default: "默认"
|
|
63580
|
+
},
|
|
63581
|
+
scenes: {
|
|
63582
|
+
self: "请选择项目场景"
|
|
63583
|
+
},
|
|
63584
|
+
sub_solution: {
|
|
63585
|
+
self: "请选择你想创建的工程类型",
|
|
63586
|
+
mwa: "Web 应用",
|
|
63587
|
+
module: "Npm 模块"
|
|
63588
|
+
},
|
|
63589
|
+
action: {
|
|
63590
|
+
self: "请选择你想要的操作",
|
|
63591
|
+
function: {
|
|
63592
|
+
self: "启用可选功能",
|
|
63593
|
+
question: "请选择功能名称",
|
|
63594
|
+
tailwindcss: "启用「Tailwind CSS」 支持",
|
|
63595
|
+
bff: "启用「BFF」功能",
|
|
63596
|
+
micro_frontend: "启用「微前端」模式",
|
|
63597
|
+
i18n: "启用「国际化(i18n)」功能",
|
|
63598
|
+
storybookV7: "启用「Storybook」V7",
|
|
63599
|
+
runtime_api: "启用「Runtime API」",
|
|
63600
|
+
ssg: "启用「SSG」功能",
|
|
63601
|
+
polyfill: "启用「基于 UA 的 Polyfill」功能",
|
|
63602
|
+
proxy: "启用「全局代理」",
|
|
63603
|
+
swc: "启用「SWC 编译」",
|
|
63604
|
+
module_doc: "启动「模块文档」功能"
|
|
63605
|
+
},
|
|
63606
|
+
element: {
|
|
63607
|
+
self: "创建工程元素",
|
|
63608
|
+
question: "请选择创建元素类型",
|
|
63609
|
+
entry: "新建「应用入口」",
|
|
63610
|
+
server: "新建「自定义 Web Server」源码目录"
|
|
63611
|
+
},
|
|
63612
|
+
refactor: {
|
|
63613
|
+
self: "自动重构",
|
|
63614
|
+
question: "请选择重构类型",
|
|
63615
|
+
react_router_5: "使用 React Router v5"
|
|
63616
|
+
}
|
|
63617
|
+
},
|
|
63618
|
+
boolean: {
|
|
63619
|
+
yes: "是",
|
|
63620
|
+
no: "否"
|
|
63621
|
+
},
|
|
63622
|
+
language: {
|
|
63623
|
+
self: "请选择开发语言"
|
|
63624
|
+
},
|
|
63625
|
+
packageManager: {
|
|
63626
|
+
self: "请选择包管理工具"
|
|
63627
|
+
},
|
|
63628
|
+
entry: {
|
|
63629
|
+
name: "请填写入口名称",
|
|
63630
|
+
no_empty: "入口名称不能为空!",
|
|
63631
|
+
no_pages: '入口名称不支持 "pages"!'
|
|
63632
|
+
},
|
|
63633
|
+
packageName: {
|
|
63634
|
+
self: "请填写项目名称",
|
|
63635
|
+
sub_name: "请填写子项目名称",
|
|
63636
|
+
no_empty: "项目名称不能为空!"
|
|
63637
|
+
},
|
|
63638
|
+
packagePath: {
|
|
63639
|
+
self: "请填写子项目目录名称",
|
|
63640
|
+
no_empty: "目录名称不能为空!",
|
|
63641
|
+
format: "目录名称只能使用小写字母、数字和分隔线(-)、下划线(_)和目录分隔符(/)"
|
|
63642
|
+
},
|
|
63643
|
+
framework: {
|
|
63644
|
+
self: "请选择运行时框架",
|
|
63645
|
+
egg: "Egg",
|
|
63646
|
+
express: "Express",
|
|
63647
|
+
koa: "Koa",
|
|
63648
|
+
nest: "Nest"
|
|
63649
|
+
},
|
|
63650
|
+
bff: {
|
|
63651
|
+
bffType: {
|
|
63652
|
+
self: "请选择 BFF 类型",
|
|
63653
|
+
func: "函数模式",
|
|
63654
|
+
framework: "框架模式"
|
|
63655
|
+
}
|
|
63656
|
+
},
|
|
63657
|
+
buildTools: {
|
|
63658
|
+
self: "请选择构建工具",
|
|
63659
|
+
webpack: "webpack",
|
|
63660
|
+
rspack: "Rspack (实验性)"
|
|
63661
|
+
}
|
|
63662
|
+
};
|
|
63663
|
+
|
|
63664
|
+
// ../../generator-common/dist/esm-node/locale/index.js
|
|
63665
|
+
var i18n2 = new I18n2();
|
|
63666
|
+
var localeKeys2 = i18n2.init("en", {
|
|
63667
|
+
zh: ZH_LOCALE2,
|
|
63668
|
+
en: EN_LOCALE2
|
|
63669
|
+
});
|
|
63670
|
+
|
|
63671
|
+
// ../../generator-common/dist/esm-node/common/solution.js
|
|
63672
|
+
var Solution;
|
|
63673
|
+
(function(Solution2) {
|
|
63674
|
+
Solution2["MWA"] = "mwa";
|
|
63675
|
+
Solution2["Module"] = "module";
|
|
63676
|
+
})(Solution || (Solution = {}));
|
|
63677
|
+
var SolutionToolsMap = {
|
|
63678
|
+
["mwa"]: "@modern-js/app-tools",
|
|
63679
|
+
["module"]: "@modern-js/module-tools"
|
|
64061
63680
|
};
|
|
64062
63681
|
|
|
63682
|
+
// ../../generator-common/dist/esm-node/common/language.js
|
|
63683
|
+
var Language;
|
|
63684
|
+
(function(Language2) {
|
|
63685
|
+
Language2["TS"] = "ts";
|
|
63686
|
+
Language2["JS"] = "js";
|
|
63687
|
+
})(Language || (Language = {}));
|
|
63688
|
+
|
|
63689
|
+
// ../../generator-common/dist/esm-node/mwa/common.js
|
|
63690
|
+
var Framework;
|
|
63691
|
+
(function(Framework2) {
|
|
63692
|
+
Framework2["Express"] = "express";
|
|
63693
|
+
Framework2["Koa"] = "koa";
|
|
63694
|
+
})(Framework || (Framework = {}));
|
|
63695
|
+
var BuildTools;
|
|
63696
|
+
(function(BuildTools2) {
|
|
63697
|
+
BuildTools2["Webpack"] = "webpack";
|
|
63698
|
+
BuildTools2["Rspack"] = "rspack";
|
|
63699
|
+
})(BuildTools || (BuildTools = {}));
|
|
63700
|
+
var getFrameworkSchema = (_extra = {}) => {
|
|
63701
|
+
return {
|
|
63702
|
+
type: "string",
|
|
63703
|
+
title: i18n2.t(localeKeys2.framework.self),
|
|
63704
|
+
enum: Object.values(Framework).map((framework) => ({
|
|
63705
|
+
value: framework,
|
|
63706
|
+
label: i18n2.t(localeKeys2.framework[framework])
|
|
63707
|
+
}))
|
|
63708
|
+
};
|
|
63709
|
+
};
|
|
63710
|
+
var FrameworkAppendTypeContent = {
|
|
63711
|
+
["express"]: `/// <reference types='@modern-js/plugin-express/types' />`,
|
|
63712
|
+
["koa"]: `/// <reference types='@modern-js/plugin-koa/types' />`
|
|
63713
|
+
};
|
|
63714
|
+
|
|
63715
|
+
// ../../generator-common/dist/esm-node/mwa/bff.js
|
|
63716
|
+
var BFFType;
|
|
63717
|
+
(function(BFFType2) {
|
|
63718
|
+
BFFType2["Func"] = "func";
|
|
63719
|
+
BFFType2["Framework"] = "framework";
|
|
63720
|
+
})(BFFType || (BFFType = {}));
|
|
63721
|
+
var getBFFTypeSchema = (_extra = {}) => {
|
|
63722
|
+
return {
|
|
63723
|
+
type: "string",
|
|
63724
|
+
title: i18n2.t(localeKeys2.bff.bffType.self),
|
|
63725
|
+
enum: Object.values(BFFType).map((bffType) => ({
|
|
63726
|
+
value: bffType,
|
|
63727
|
+
label: i18n2.t(localeKeys2.bff.bffType[bffType])
|
|
63728
|
+
}))
|
|
63729
|
+
};
|
|
63730
|
+
};
|
|
63731
|
+
var getBFFchemaProperties = (extra) => {
|
|
63732
|
+
return {
|
|
63733
|
+
bffType: getBFFTypeSchema(extra),
|
|
63734
|
+
framework: getFrameworkSchema(extra)
|
|
63735
|
+
};
|
|
63736
|
+
};
|
|
63737
|
+
var getBFFSchema = (extra = {}) => {
|
|
63738
|
+
return {
|
|
63739
|
+
type: "object",
|
|
63740
|
+
properties: getBFFchemaProperties(extra)
|
|
63741
|
+
};
|
|
63742
|
+
};
|
|
63743
|
+
var MWADefaultBffConfig = {
|
|
63744
|
+
bffType: "func",
|
|
63745
|
+
frameWork: Framework.Express
|
|
63746
|
+
};
|
|
63747
|
+
|
|
63748
|
+
// ../../generator-common/dist/esm-node/newAction/common/index.js
|
|
63749
|
+
var ActionType;
|
|
63750
|
+
(function(ActionType2) {
|
|
63751
|
+
ActionType2["Function"] = "function";
|
|
63752
|
+
ActionType2["Element"] = "element";
|
|
63753
|
+
ActionType2["Refactor"] = "refactor";
|
|
63754
|
+
})(ActionType || (ActionType = {}));
|
|
63755
|
+
var ActionElement;
|
|
63756
|
+
(function(ActionElement2) {
|
|
63757
|
+
ActionElement2["Entry"] = "entry";
|
|
63758
|
+
ActionElement2["Server"] = "server";
|
|
63759
|
+
})(ActionElement || (ActionElement = {}));
|
|
63760
|
+
var ActionFunction;
|
|
63761
|
+
(function(ActionFunction2) {
|
|
63762
|
+
ActionFunction2["TailwindCSS"] = "tailwindcss";
|
|
63763
|
+
ActionFunction2["BFF"] = "bff";
|
|
63764
|
+
ActionFunction2["MicroFrontend"] = "micro_frontend";
|
|
63765
|
+
ActionFunction2["I18n"] = "i18n";
|
|
63766
|
+
ActionFunction2["StorybookV7"] = "storybookV7";
|
|
63767
|
+
ActionFunction2["RuntimeApi"] = "runtimeApi";
|
|
63768
|
+
ActionFunction2["SSG"] = "ssg";
|
|
63769
|
+
ActionFunction2["Polyfill"] = "polyfill";
|
|
63770
|
+
ActionFunction2["Proxy"] = "proxy";
|
|
63771
|
+
ActionFunction2["SWC"] = "swc";
|
|
63772
|
+
ActionFunction2["ModuleDoc"] = "module_doc";
|
|
63773
|
+
})(ActionFunction || (ActionFunction = {}));
|
|
63774
|
+
var ActionRefactor;
|
|
63775
|
+
(function(ActionRefactor2) {
|
|
63776
|
+
ActionRefactor2["ReactRouter5"] = "react_router_5";
|
|
63777
|
+
})(ActionRefactor || (ActionRefactor = {}));
|
|
63778
|
+
|
|
63779
|
+
// ../../generator-common/dist/esm-node/newAction/mwa/index.js
|
|
63780
|
+
var MWAActionTypes = [
|
|
63781
|
+
ActionType.Element,
|
|
63782
|
+
ActionType.Function,
|
|
63783
|
+
ActionType.Refactor
|
|
63784
|
+
];
|
|
63785
|
+
var MWAActionFunctions = [
|
|
63786
|
+
ActionFunction.TailwindCSS,
|
|
63787
|
+
ActionFunction.BFF,
|
|
63788
|
+
ActionFunction.SSG,
|
|
63789
|
+
ActionFunction.SWC,
|
|
63790
|
+
ActionFunction.MicroFrontend,
|
|
63791
|
+
ActionFunction.Polyfill,
|
|
63792
|
+
ActionFunction.Proxy,
|
|
63793
|
+
ActionFunction.StorybookV7
|
|
63794
|
+
];
|
|
63795
|
+
var MWAActionElements = [
|
|
63796
|
+
ActionElement.Entry,
|
|
63797
|
+
ActionElement.Server
|
|
63798
|
+
];
|
|
63799
|
+
var MWAActionReactors = [
|
|
63800
|
+
ActionRefactor.ReactRouter5
|
|
63801
|
+
];
|
|
63802
|
+
var MWAActionTypesMap = {
|
|
63803
|
+
[ActionType.Element]: MWAActionElements,
|
|
63804
|
+
[ActionType.Function]: MWAActionFunctions,
|
|
63805
|
+
[ActionType.Refactor]: MWAActionReactors
|
|
63806
|
+
};
|
|
63807
|
+
var MWAActionFunctionsDevDependencies = {
|
|
63808
|
+
[ActionFunction.SSG]: "@modern-js/plugin-ssg",
|
|
63809
|
+
[ActionFunction.StorybookV7]: "@modern-js/storybook",
|
|
63810
|
+
[ActionFunction.Proxy]: "@modern-js/plugin-proxy",
|
|
63811
|
+
[ActionFunction.TailwindCSS]: "tailwindcss",
|
|
63812
|
+
[ActionFunction.SWC]: "@modern-js/plugin-swc"
|
|
63813
|
+
};
|
|
63814
|
+
var MWAActionFunctionsDependencies = {
|
|
63815
|
+
[ActionFunction.BFF]: "@modern-js/plugin-bff",
|
|
63816
|
+
[ActionFunction.MicroFrontend]: "@modern-js/plugin-garfish",
|
|
63817
|
+
[ActionFunction.TailwindCSS]: "@modern-js/plugin-tailwindcss",
|
|
63818
|
+
[ActionFunction.Polyfill]: "@modern-js/plugin-polyfill"
|
|
63819
|
+
};
|
|
63820
|
+
var MWAActionFunctionsAppendTypeContent = {
|
|
63821
|
+
[ActionFunction.MicroFrontend]: `/// <reference types='@modern-js/plugin-garfish/types' />`
|
|
63822
|
+
};
|
|
63823
|
+
var MWAActionRefactorDependencies = {
|
|
63824
|
+
[ActionRefactor.ReactRouter5]: "@modern-js/plugin-router-v5"
|
|
63825
|
+
};
|
|
63826
|
+
var MWAActionReactorAppendTypeContent = {
|
|
63827
|
+
[ActionRefactor.ReactRouter5]: `/// <reference types='@modern-js/plugin-router-v5/types' />`
|
|
63828
|
+
};
|
|
63829
|
+
var MWANewActionGenerators = {
|
|
63830
|
+
[ActionType.Element]: {
|
|
63831
|
+
[ActionElement.Entry]: "@modern-js/entry-generator",
|
|
63832
|
+
[ActionElement.Server]: "@modern-js/server-generator"
|
|
63833
|
+
},
|
|
63834
|
+
[ActionType.Function]: {
|
|
63835
|
+
[ActionFunction.TailwindCSS]: "@modern-js/tailwindcss-generator",
|
|
63836
|
+
[ActionFunction.BFF]: "@modern-js/bff-generator",
|
|
63837
|
+
[ActionFunction.MicroFrontend]: "@modern-js/dependence-generator",
|
|
63838
|
+
[ActionFunction.StorybookV7]: "@modern-js/storybook-next-generator",
|
|
63839
|
+
[ActionFunction.SSG]: "@modern-js/ssg-generator",
|
|
63840
|
+
[ActionFunction.Polyfill]: "@modern-js/dependence-generator",
|
|
63841
|
+
[ActionFunction.Proxy]: "@modern-js/dependence-generator",
|
|
63842
|
+
[ActionFunction.SWC]: "@modern-js/dependence-generator"
|
|
63843
|
+
},
|
|
63844
|
+
[ActionType.Refactor]: {
|
|
63845
|
+
[ActionRefactor.ReactRouter5]: "@modern-js/router-v5-generator"
|
|
63846
|
+
}
|
|
63847
|
+
};
|
|
63848
|
+
var MWANewActionPluginName = {
|
|
63849
|
+
[ActionType.Element]: {
|
|
63850
|
+
[ActionElement.Server]: "serverPlugin"
|
|
63851
|
+
},
|
|
63852
|
+
[ActionType.Function]: {
|
|
63853
|
+
[ActionFunction.TailwindCSS]: "tailwindcssPlugin",
|
|
63854
|
+
[ActionFunction.BFF]: "bffPlugin",
|
|
63855
|
+
[ActionFunction.MicroFrontend]: "garfishPlugin",
|
|
63856
|
+
[ActionFunction.SSG]: "ssgPlugin",
|
|
63857
|
+
[ActionFunction.Polyfill]: "polyfillPlugin",
|
|
63858
|
+
[ActionFunction.Proxy]: "proxyPlugin",
|
|
63859
|
+
[ActionFunction.SWC]: "swcPlugin"
|
|
63860
|
+
},
|
|
63861
|
+
[ActionType.Refactor]: {
|
|
63862
|
+
[ActionRefactor.ReactRouter5]: "routerPlugin"
|
|
63863
|
+
}
|
|
63864
|
+
};
|
|
63865
|
+
var MWANewActionPluginDependence = {
|
|
63866
|
+
[ActionType.Element]: {
|
|
63867
|
+
[ActionElement.Server]: "@modern-js/plugin-server"
|
|
63868
|
+
},
|
|
63869
|
+
[ActionType.Function]: {
|
|
63870
|
+
[ActionFunction.TailwindCSS]: "@modern-js/plugin-tailwindcss",
|
|
63871
|
+
[ActionFunction.BFF]: "@modern-js/plugin-bff",
|
|
63872
|
+
[ActionFunction.MicroFrontend]: "@modern-js/plugin-garfish",
|
|
63873
|
+
[ActionFunction.SSG]: "@modern-js/plugin-ssg",
|
|
63874
|
+
[ActionFunction.Polyfill]: "@modern-js/plugin-polyfill",
|
|
63875
|
+
[ActionFunction.Proxy]: "@modern-js/plugin-proxy",
|
|
63876
|
+
[ActionFunction.SWC]: "@modern-js/plugin-swc"
|
|
63877
|
+
},
|
|
63878
|
+
[ActionType.Refactor]: {
|
|
63879
|
+
[ActionRefactor.ReactRouter5]: "@modern-js/plugin-router-v5"
|
|
63880
|
+
}
|
|
63881
|
+
};
|
|
63882
|
+
var BFFPluginName = {
|
|
63883
|
+
[Framework.Express]: "expressPlugin",
|
|
63884
|
+
[Framework.Koa]: "koaPlugin"
|
|
63885
|
+
};
|
|
63886
|
+
var BFFPluginDependence = {
|
|
63887
|
+
[Framework.Express]: "@modern-js/plugin-express",
|
|
63888
|
+
[Framework.Koa]: "@modern-js/plugin-koa"
|
|
63889
|
+
};
|
|
63890
|
+
|
|
63891
|
+
// ../../generator-utils/dist/esm/index.js
|
|
63892
|
+
var import_path5 = __toESM(require("path"));
|
|
63893
|
+
var import_utils18 = require("@modern-js/utils");
|
|
63894
|
+
|
|
63895
|
+
// ../../generator-utils/dist/esm/utils/fsExist.js
|
|
63896
|
+
var import_utils16 = require("@modern-js/utils");
|
|
63897
|
+
async function fileExist(filePath) {
|
|
63898
|
+
try {
|
|
63899
|
+
const stat = await import_utils16.fs.stat(filePath);
|
|
63900
|
+
if (stat.isFile()) {
|
|
63901
|
+
return true;
|
|
63902
|
+
}
|
|
63903
|
+
return false;
|
|
63904
|
+
} catch (e) {
|
|
63905
|
+
return false;
|
|
63906
|
+
}
|
|
63907
|
+
}
|
|
63908
|
+
|
|
63909
|
+
// ../../generator-utils/dist/esm/utils/package.js
|
|
63910
|
+
var import_utils17 = require("@modern-js/utils");
|
|
63911
|
+
async function isPackageExist(packageName, registry2) {
|
|
63912
|
+
if (await (0, import_utils17.canUseNpm)()) {
|
|
63913
|
+
try {
|
|
63914
|
+
const args = [
|
|
63915
|
+
"view",
|
|
63916
|
+
packageName,
|
|
63917
|
+
"version"
|
|
63918
|
+
];
|
|
63919
|
+
if (registry2) {
|
|
63920
|
+
args.push(`--registry=${registry2}`);
|
|
63921
|
+
}
|
|
63922
|
+
const result = await (0, import_utils17.execa)("npm", args);
|
|
63923
|
+
return (0, import_utils17.stripAnsi)(result.stdout);
|
|
63924
|
+
} catch (e) {
|
|
63925
|
+
return false;
|
|
63926
|
+
}
|
|
63927
|
+
}
|
|
63928
|
+
throw new Error("not found npm, please install npm before");
|
|
63929
|
+
}
|
|
63930
|
+
async function isPackageDeprecated(packageName, registry2) {
|
|
63931
|
+
if (await (0, import_utils17.canUseNpm)()) {
|
|
63932
|
+
const args = [
|
|
63933
|
+
"view",
|
|
63934
|
+
packageName,
|
|
63935
|
+
"deprecated"
|
|
63936
|
+
];
|
|
63937
|
+
if (registry2) {
|
|
63938
|
+
args.push(`--registry=${registry2}`);
|
|
63939
|
+
}
|
|
63940
|
+
const result = await (0, import_utils17.execa)("npm", args);
|
|
63941
|
+
return (0, import_utils17.stripAnsi)(result.stdout);
|
|
63942
|
+
}
|
|
63943
|
+
throw new Error("not found npm, please install npm before");
|
|
63944
|
+
}
|
|
63945
|
+
function semverDecrease(version) {
|
|
63946
|
+
const versionObj = import_utils17.semver.parse(version, {
|
|
63947
|
+
loose: true
|
|
63948
|
+
});
|
|
63949
|
+
if (!versionObj) {
|
|
63950
|
+
throw new Error(`Version ${version} is not valid semver`);
|
|
63951
|
+
}
|
|
63952
|
+
versionObj.build = [];
|
|
63953
|
+
versionObj.prerelease = [];
|
|
63954
|
+
versionObj.patch--;
|
|
63955
|
+
const result = versionObj.format();
|
|
63956
|
+
if (!import_utils17.semver.valid(result)) {
|
|
63957
|
+
import_utils17.logger.debug(`Version ${result} is not valid semver`);
|
|
63958
|
+
return version;
|
|
63959
|
+
}
|
|
63960
|
+
return result;
|
|
63961
|
+
}
|
|
63962
|
+
async function getAvailableVersion(packageName, currentVersion, registry2) {
|
|
63963
|
+
let times = 5;
|
|
63964
|
+
let version = currentVersion;
|
|
63965
|
+
while (times) {
|
|
63966
|
+
if (!await isPackageExist(`${packageName}@${version}`, registry2) || await isPackageDeprecated(`${packageName}@${version}`, registry2)) {
|
|
63967
|
+
version = import_utils17.semver.inc(version, "patch");
|
|
63968
|
+
times--;
|
|
63969
|
+
continue;
|
|
63970
|
+
}
|
|
63971
|
+
return version;
|
|
63972
|
+
}
|
|
63973
|
+
times = 5;
|
|
63974
|
+
while (times) {
|
|
63975
|
+
version = semverDecrease(version);
|
|
63976
|
+
if (!await isPackageExist(`${packageName}@${version}`, registry2) || await isPackageDeprecated(`${packageName}@${version}`, registry2)) {
|
|
63977
|
+
times--;
|
|
63978
|
+
continue;
|
|
63979
|
+
}
|
|
63980
|
+
return version;
|
|
63981
|
+
}
|
|
63982
|
+
return currentVersion;
|
|
63983
|
+
}
|
|
63984
|
+
|
|
63985
|
+
// ../../generator-utils/dist/esm/utils/stripAnsi.js
|
|
63986
|
+
function ansiRegex2({ onlyFirst = false } = {}) {
|
|
63987
|
+
const pattern = [
|
|
63988
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
63989
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
63990
|
+
].join("|");
|
|
63991
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
63992
|
+
}
|
|
63993
|
+
function stripAnsi3(string) {
|
|
63994
|
+
if (typeof string !== "string") {
|
|
63995
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
63996
|
+
}
|
|
63997
|
+
return string.replace(ansiRegex2(), "");
|
|
63998
|
+
}
|
|
63999
|
+
|
|
64000
|
+
// ../../generator-utils/dist/esm/index.js
|
|
64001
|
+
var import_utils19 = require("@modern-js/utils");
|
|
64002
|
+
async function getPackageVersion(packageName, registry2) {
|
|
64003
|
+
const spinner = (0, import_utils18.ora)({
|
|
64004
|
+
text: "Load Generator...",
|
|
64005
|
+
spinner: "runner"
|
|
64006
|
+
}).start();
|
|
64007
|
+
if (await (0, import_utils18.canUsePnpm)()) {
|
|
64008
|
+
const args = [
|
|
64009
|
+
"info",
|
|
64010
|
+
packageName,
|
|
64011
|
+
"version"
|
|
64012
|
+
];
|
|
64013
|
+
if (registry2) {
|
|
64014
|
+
args.push(`--registry=${registry2}`);
|
|
64015
|
+
}
|
|
64016
|
+
const result = await (0, import_utils18.execa)("pnpm", args);
|
|
64017
|
+
spinner.stop();
|
|
64018
|
+
return stripAnsi3(result.stdout);
|
|
64019
|
+
}
|
|
64020
|
+
if (await (0, import_utils18.canUseNpm)()) {
|
|
64021
|
+
const args = [
|
|
64022
|
+
"view",
|
|
64023
|
+
packageName,
|
|
64024
|
+
"version"
|
|
64025
|
+
];
|
|
64026
|
+
if (registry2) {
|
|
64027
|
+
args.push(`--registry=${registry2}`);
|
|
64028
|
+
}
|
|
64029
|
+
const result = await (0, import_utils18.execa)("npm", args);
|
|
64030
|
+
spinner.stop();
|
|
64031
|
+
return stripAnsi3(result.stdout);
|
|
64032
|
+
}
|
|
64033
|
+
spinner.stop();
|
|
64034
|
+
throw new Error("not found npm, please install npm before");
|
|
64035
|
+
}
|
|
64036
|
+
async function getModernPluginVersion(solution, packageName, options = {
|
|
64037
|
+
distTag: "latest"
|
|
64038
|
+
}) {
|
|
64039
|
+
const { cwd = process.cwd(), registry: registry2, distTag } = options;
|
|
64040
|
+
const getLatetPluginVersion = async (tag) => {
|
|
64041
|
+
const version = await getPackageVersion(`${packageName}@${tag || distTag || "latest"}`, registry2);
|
|
64042
|
+
return version;
|
|
64043
|
+
};
|
|
64044
|
+
if (!packageName.startsWith("@modern-js") || packageName.includes("electron") || packageName.includes("codesmith") || packageName.includes("easy-form") || packageName.startsWith("@modern-js-reduck")) {
|
|
64045
|
+
return getLatetPluginVersion("latest");
|
|
64046
|
+
}
|
|
64047
|
+
let pkgPath = import_path5.default.join(require.resolve(SolutionToolsMap[solution], {
|
|
64048
|
+
paths: [
|
|
64049
|
+
cwd
|
|
64050
|
+
]
|
|
64051
|
+
}), "../../..", "package.json");
|
|
64052
|
+
if (solution === Solution.Module) {
|
|
64053
|
+
pkgPath = import_path5.default.join(require.resolve(SolutionToolsMap[solution], {
|
|
64054
|
+
paths: [
|
|
64055
|
+
cwd
|
|
64056
|
+
]
|
|
64057
|
+
}), "../..", "package.json");
|
|
64058
|
+
}
|
|
64059
|
+
if (import_utils18.fs.existsSync(pkgPath)) {
|
|
64060
|
+
const pkgInfo = import_utils18.fs.readJSONSync(pkgPath);
|
|
64061
|
+
const modernVersion = pkgInfo.version;
|
|
64062
|
+
if (typeof modernVersion !== "string") {
|
|
64063
|
+
return getLatetPluginVersion();
|
|
64064
|
+
}
|
|
64065
|
+
const version = await getAvailableVersion(packageName, modernVersion, registry2);
|
|
64066
|
+
if (!await isPackageExist(`${packageName}@${version}`)) {
|
|
64067
|
+
return getLatetPluginVersion();
|
|
64068
|
+
}
|
|
64069
|
+
return version;
|
|
64070
|
+
}
|
|
64071
|
+
return getLatetPluginVersion();
|
|
64072
|
+
}
|
|
64073
|
+
function isTsProject(appDir) {
|
|
64074
|
+
return import_utils18.fs.existsSync(import_path5.default.join(appDir, "tsconfig.json"));
|
|
64075
|
+
}
|
|
64076
|
+
async function getModernConfigFile(appDir) {
|
|
64077
|
+
let exist = await fileExist(import_path5.default.join(appDir, "modern.config.ts"));
|
|
64078
|
+
if (exist) {
|
|
64079
|
+
return "modern.config.ts";
|
|
64080
|
+
}
|
|
64081
|
+
exist = await fileExist(import_path5.default.join(appDir, "modern.config.js"));
|
|
64082
|
+
if (exist) {
|
|
64083
|
+
return "modern.config.js";
|
|
64084
|
+
}
|
|
64085
|
+
return isTsProject(appDir) ? "modern.config.ts" : "modern.config.js";
|
|
64086
|
+
}
|
|
64087
|
+
|
|
64063
64088
|
// src/locale/en.ts
|
|
64064
64089
|
var EN_LOCALE3 = {
|
|
64065
64090
|
success: `Plugin dependency installed successfully! Please add the following code to`
|
|
64066
64091
|
};
|
|
64067
64092
|
|
|
64093
|
+
// src/locale/zh.ts
|
|
64094
|
+
var ZH_LOCALE3 = {
|
|
64095
|
+
success: `安装插件依赖成功!请添加如下代码至`
|
|
64096
|
+
};
|
|
64097
|
+
|
|
64068
64098
|
// src/locale/index.ts
|
|
64069
|
-
var i18n3 = new
|
|
64099
|
+
var i18n3 = new I18n2();
|
|
64070
64100
|
var localeKeys3 = i18n3.init("en", { zh: ZH_LOCALE3, en: EN_LOCALE3 });
|
|
64071
64101
|
|
|
64072
64102
|
// src/index.ts
|
|
64073
64103
|
function isEmptyApiDir(apiDir) {
|
|
64074
|
-
const files =
|
|
64104
|
+
const files = import_utils19.fs.readdirSync(apiDir);
|
|
64075
64105
|
if (files.length === 0) {
|
|
64076
64106
|
return true;
|
|
64077
64107
|
}
|
|
64078
64108
|
return files.every((file) => {
|
|
64079
|
-
if (
|
|
64080
|
-
const childFiles =
|
|
64109
|
+
if (import_utils19.fs.statSync(import_path6.default.join(apiDir, file)).isDirectory()) {
|
|
64110
|
+
const childFiles = import_utils19.fs.readdirSync(import_path6.default.join(apiDir, file));
|
|
64081
64111
|
return childFiles.length === 0;
|
|
64082
64112
|
}
|
|
64083
64113
|
return false;
|
|
@@ -64088,8 +64118,8 @@ var handleTemplateFile = async (context, generator, appApi) => {
|
|
|
64088
64118
|
const ans = await appApi.getInputBySchemaFunc(getBFFSchema, context.config);
|
|
64089
64119
|
const appDir = context.materials.default.basePath;
|
|
64090
64120
|
const apiDir = import_path6.default.join(appDir, "api");
|
|
64091
|
-
if (
|
|
64092
|
-
const files =
|
|
64121
|
+
if (import_utils19.fs.existsSync(apiDir) && !isEmptyApiDir(apiDir)) {
|
|
64122
|
+
const files = import_utils19.fs.readdirSync(apiDir);
|
|
64093
64123
|
if (files.length > 0) {
|
|
64094
64124
|
generator.logger.warn("'api' is already exist");
|
|
64095
64125
|
throw Error("'api' is already exist");
|
|
@@ -64138,7 +64168,7 @@ var handleTemplateFile = async (context, generator, appApi) => {
|
|
|
64138
64168
|
}
|
|
64139
64169
|
);
|
|
64140
64170
|
if (language === Language.TS) {
|
|
64141
|
-
const tsconfigJSON = (0,
|
|
64171
|
+
const tsconfigJSON = (0, import_utils19.readTsConfigByFile)(import_path6.default.join(appDir, "tsconfig.json"));
|
|
64142
64172
|
if (!(tsconfigJSON.include || []).includes("api")) {
|
|
64143
64173
|
await jsonAPI.update(
|
|
64144
64174
|
context.materials.default.get(import_path6.default.join(appDir, "tsconfig.json")),
|
|
@@ -64216,15 +64246,15 @@ var handleTemplateFile = async (context, generator, appApi) => {
|
|
|
64216
64246
|
const appendTypeContent = FrameworkAppendTypeContent[framework];
|
|
64217
64247
|
if (appendTypeContent && language === Language.TS) {
|
|
64218
64248
|
const typePath = import_path6.default.join(appDir, "src", "modern-app-env.d.ts");
|
|
64219
|
-
if (
|
|
64220
|
-
const npmrc =
|
|
64249
|
+
if (import_utils19.fs.existsSync(typePath)) {
|
|
64250
|
+
const npmrc = import_utils19.fs.readFileSync(typePath, "utf-8");
|
|
64221
64251
|
if (!npmrc.includes(appendTypeContent)) {
|
|
64222
|
-
|
|
64252
|
+
import_utils19.fs.writeFileSync(typePath, `${npmrc}${appendTypeContent}
|
|
64223
64253
|
`, "utf-8");
|
|
64224
64254
|
}
|
|
64225
64255
|
} else {
|
|
64226
|
-
|
|
64227
|
-
|
|
64256
|
+
import_utils19.fs.ensureFileSync(typePath);
|
|
64257
|
+
import_utils19.fs.writeFileSync(typePath, appendTypeContent, "utf-8");
|
|
64228
64258
|
}
|
|
64229
64259
|
}
|
|
64230
64260
|
};
|
|
@@ -64233,7 +64263,7 @@ var src_default = async (context, generator) => {
|
|
|
64233
64263
|
const { locale } = context.config;
|
|
64234
64264
|
i18n3.changeLanguage({ locale });
|
|
64235
64265
|
appApi.i18n.changeLanguage({ locale });
|
|
64236
|
-
|
|
64266
|
+
i18n2.changeLanguage({ locale });
|
|
64237
64267
|
if (!await appApi.checkEnvironment()) {
|
|
64238
64268
|
process.exit(1);
|
|
64239
64269
|
}
|
|
@@ -64262,30 +64292,30 @@ var src_default = async (context, generator) => {
|
|
|
64262
64292
|
shouldUsePluginNameExport
|
|
64263
64293
|
} = context.config;
|
|
64264
64294
|
console.info(
|
|
64265
|
-
|
|
64295
|
+
import_utils19.chalk.green(`
|
|
64266
64296
|
[INFO]`),
|
|
64267
64297
|
`${i18n3.t(localeKeys3.success)}`,
|
|
64268
|
-
|
|
64298
|
+
import_utils19.chalk.yellow.bold(`${configFile}`),
|
|
64269
64299
|
":",
|
|
64270
64300
|
"\n"
|
|
64271
64301
|
);
|
|
64272
64302
|
if (shouldUsePluginNameExport) {
|
|
64273
64303
|
console.info(
|
|
64274
|
-
|
|
64304
|
+
import_utils19.chalk.yellow.bold(
|
|
64275
64305
|
`import { ${pluginName} } from '${pluginDependence}';`
|
|
64276
64306
|
)
|
|
64277
64307
|
);
|
|
64278
64308
|
console.info(
|
|
64279
|
-
|
|
64309
|
+
import_utils19.chalk.yellow.bold(
|
|
64280
64310
|
`import { ${bffPluginName} } from '${bffPluginDependence}';`
|
|
64281
64311
|
)
|
|
64282
64312
|
);
|
|
64283
64313
|
} else {
|
|
64284
64314
|
console.info(
|
|
64285
|
-
|
|
64315
|
+
import_utils19.chalk.yellow.bold(`import ${pluginName} from '${pluginDependence}';`)
|
|
64286
64316
|
);
|
|
64287
64317
|
console.info(
|
|
64288
|
-
|
|
64318
|
+
import_utils19.chalk.yellow.bold(
|
|
64289
64319
|
`import ${bffPluginName} from '${bffPluginDependence}';`
|
|
64290
64320
|
)
|
|
64291
64321
|
);
|
|
@@ -64294,14 +64324,14 @@ var src_default = async (context, generator) => {
|
|
|
64294
64324
|
console.info(`
|
|
64295
64325
|
export default defineConfig({
|
|
64296
64326
|
...,
|
|
64297
|
-
plugins: [..., ${
|
|
64327
|
+
plugins: [..., ${import_utils19.chalk.yellow.bold(`${pluginName}(), ${bffPluginName}()`)}],
|
|
64298
64328
|
});
|
|
64299
64329
|
`);
|
|
64300
64330
|
} else {
|
|
64301
64331
|
console.info(`
|
|
64302
64332
|
module.exports = {
|
|
64303
64333
|
...,
|
|
64304
|
-
plugins: [..., ${
|
|
64334
|
+
plugins: [..., ${import_utils19.chalk.yellow.bold(`${pluginName}(), ${bffPluginName}()`)}],
|
|
64305
64335
|
};
|
|
64306
64336
|
`);
|
|
64307
64337
|
}
|