create-rsbuild 0.0.0-next-20240528072128 → 0.0.0-next-20240723074951
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 +644 -89
- package/package.json +6 -3
- package/template-biome/biome.json +25 -0
- package/template-biome/package.json +12 -0
- package/template-eslint/common-js/eslint.config.mjs +8 -0
- package/template-eslint/common-js/package.json +13 -0
- package/template-eslint/common-ts/eslint.config.mjs +10 -0
- package/template-eslint/common-ts/package.json +14 -0
- package/template-eslint/react-js/eslint.config.mjs +29 -0
- package/template-eslint/react-js/package.json +16 -0
- package/template-eslint/react-ts/eslint.config.mjs +31 -0
- package/template-eslint/react-ts/package.json +17 -0
- package/template-eslint/svelte-js/eslint.config.mjs +20 -0
- package/template-eslint/svelte-js/package.json +14 -0
- package/template-eslint/svelte-ts/eslint.config.mjs +28 -0
- package/template-eslint/svelte-ts/package.json +16 -0
- package/template-eslint/vue-js/eslint.config.mjs +10 -0
- package/template-eslint/vue-js/package.json +14 -0
- package/template-eslint/vue-ts/eslint.config.mjs +12 -0
- package/template-eslint/vue-ts/package.json +15 -0
- package/template-lit-js/package.json +4 -2
- package/template-lit-ts/package.json +4 -2
- package/template-lit-ts/tsconfig.json +3 -1
- package/template-preact-js/package.json +1 -1
- package/template-preact-ts/package.json +2 -2
- package/template-preact-ts/src/index.tsx +4 -1
- package/template-preact-ts/tsconfig.json +2 -0
- package/template-prettier/.prettierignore +4 -0
- package/template-prettier/.prettierrc +3 -0
- package/template-prettier/package.json +11 -0
- package/template-react-ts/package.json +2 -2
- package/template-react-ts/src/index.tsx +9 -6
- package/template-react-ts/tsconfig.json +3 -1
- package/template-solid-js/package.json +1 -1
- package/template-solid-js/rsbuild.config.mjs +0 -1
- package/template-solid-ts/package.json +2 -2
- package/template-solid-ts/rsbuild.config.ts +0 -1
- package/template-solid-ts/src/index.tsx +4 -1
- package/template-solid-ts/tsconfig.json +3 -1
- package/template-svelte-js/package.json +1 -1
- package/template-svelte-js/src/index.js +0 -3
- package/template-svelte-ts/package.json +5 -3
- package/template-svelte-ts/src/index.ts +0 -3
- package/template-svelte-ts/tsconfig.json +6 -1
- package/template-vanilla-ts/package.json +1 -1
- package/template-vanilla-ts/tsconfig.json +3 -1
- package/template-vue2-ts/package.json +1 -1
- package/template-vue2-ts/tsconfig.json +3 -1
- package/template-vue3-ts/package.json +1 -1
- package/template-vue3-ts/tsconfig.json +3 -1
- package/dist/index.d.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -38,12 +38,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
mod
|
|
39
39
|
));
|
|
40
40
|
|
|
41
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.
|
|
41
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.56.0_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js
|
|
42
42
|
import { fileURLToPath } from "url";
|
|
43
43
|
import path from "path";
|
|
44
44
|
var getFilename, getDirname, __dirname;
|
|
45
45
|
var init_esm = __esm({
|
|
46
|
-
"../../node_modules/.pnpm/@modern-js+module-tools@2.
|
|
46
|
+
"../../node_modules/.pnpm/@modern-js+module-tools@2.56.0_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js"() {
|
|
47
47
|
"use strict";
|
|
48
48
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
49
49
|
getDirname = () => path.dirname(getFilename());
|
|
@@ -113,57 +113,392 @@ var require_src = __commonJS({
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
// ../../node_modules/.pnpm/picocolors@1.0.
|
|
116
|
+
// ../../node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
|
|
117
117
|
var require_picocolors = __commonJS({
|
|
118
|
-
"../../node_modules/.pnpm/picocolors@1.0.
|
|
118
|
+
"../../node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
119
119
|
"use strict";
|
|
120
120
|
init_esm();
|
|
121
|
-
var
|
|
122
|
-
var
|
|
121
|
+
var argv = process.argv || [];
|
|
122
|
+
var env2 = process.env;
|
|
123
|
+
var isColorSupported = !("NO_COLOR" in env2 || argv.includes("--no-color")) && ("FORCE_COLOR" in env2 || argv.includes("--color") || process.platform === "win32" || __require != null && __require("tty").isatty(1) && env2.TERM !== "dumb" || "CI" in env2);
|
|
123
124
|
var formatter2 = (open, close, replace = open) => (input) => {
|
|
124
125
|
let string = "" + input;
|
|
125
126
|
let index = string.indexOf(close, open.length);
|
|
126
127
|
return ~index ? open + replaceClose2(string, close, replace, index) + close : open + string + close;
|
|
127
128
|
};
|
|
128
129
|
var replaceClose2 = (string, close, replace, index) => {
|
|
129
|
-
let
|
|
130
|
-
let
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
let result = "";
|
|
131
|
+
let cursor = 0;
|
|
132
|
+
do {
|
|
133
|
+
result += string.substring(cursor, index) + replace;
|
|
134
|
+
cursor = index + close.length;
|
|
135
|
+
index = string.indexOf(close, cursor);
|
|
136
|
+
} while (~index);
|
|
137
|
+
return result + string.substring(cursor);
|
|
138
|
+
};
|
|
139
|
+
var createColors = (enabled = isColorSupported) => {
|
|
140
|
+
let init = enabled ? formatter2 : () => String;
|
|
141
|
+
return {
|
|
142
|
+
isColorSupported: enabled,
|
|
143
|
+
reset: init("\x1B[0m", "\x1B[0m"),
|
|
144
|
+
bold: init("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
145
|
+
dim: init("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
146
|
+
italic: init("\x1B[3m", "\x1B[23m"),
|
|
147
|
+
underline: init("\x1B[4m", "\x1B[24m"),
|
|
148
|
+
inverse: init("\x1B[7m", "\x1B[27m"),
|
|
149
|
+
hidden: init("\x1B[8m", "\x1B[28m"),
|
|
150
|
+
strikethrough: init("\x1B[9m", "\x1B[29m"),
|
|
151
|
+
black: init("\x1B[30m", "\x1B[39m"),
|
|
152
|
+
red: init("\x1B[31m", "\x1B[39m"),
|
|
153
|
+
green: init("\x1B[32m", "\x1B[39m"),
|
|
154
|
+
yellow: init("\x1B[33m", "\x1B[39m"),
|
|
155
|
+
blue: init("\x1B[34m", "\x1B[39m"),
|
|
156
|
+
magenta: init("\x1B[35m", "\x1B[39m"),
|
|
157
|
+
cyan: init("\x1B[36m", "\x1B[39m"),
|
|
158
|
+
white: init("\x1B[37m", "\x1B[39m"),
|
|
159
|
+
gray: init("\x1B[90m", "\x1B[39m"),
|
|
160
|
+
bgBlack: init("\x1B[40m", "\x1B[49m"),
|
|
161
|
+
bgRed: init("\x1B[41m", "\x1B[49m"),
|
|
162
|
+
bgGreen: init("\x1B[42m", "\x1B[49m"),
|
|
163
|
+
bgYellow: init("\x1B[43m", "\x1B[49m"),
|
|
164
|
+
bgBlue: init("\x1B[44m", "\x1B[49m"),
|
|
165
|
+
bgMagenta: init("\x1B[45m", "\x1B[49m"),
|
|
166
|
+
bgCyan: init("\x1B[46m", "\x1B[49m"),
|
|
167
|
+
bgWhite: init("\x1B[47m", "\x1B[49m")
|
|
168
|
+
};
|
|
133
169
|
};
|
|
134
|
-
var createColors = (enabled = isColorSupported) => ({
|
|
135
|
-
isColorSupported: enabled,
|
|
136
|
-
reset: enabled ? (s) => `\x1B[0m${s}\x1B[0m` : String,
|
|
137
|
-
bold: enabled ? formatter2("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
|
|
138
|
-
dim: enabled ? formatter2("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
|
|
139
|
-
italic: enabled ? formatter2("\x1B[3m", "\x1B[23m") : String,
|
|
140
|
-
underline: enabled ? formatter2("\x1B[4m", "\x1B[24m") : String,
|
|
141
|
-
inverse: enabled ? formatter2("\x1B[7m", "\x1B[27m") : String,
|
|
142
|
-
hidden: enabled ? formatter2("\x1B[8m", "\x1B[28m") : String,
|
|
143
|
-
strikethrough: enabled ? formatter2("\x1B[9m", "\x1B[29m") : String,
|
|
144
|
-
black: enabled ? formatter2("\x1B[30m", "\x1B[39m") : String,
|
|
145
|
-
red: enabled ? formatter2("\x1B[31m", "\x1B[39m") : String,
|
|
146
|
-
green: enabled ? formatter2("\x1B[32m", "\x1B[39m") : String,
|
|
147
|
-
yellow: enabled ? formatter2("\x1B[33m", "\x1B[39m") : String,
|
|
148
|
-
blue: enabled ? formatter2("\x1B[34m", "\x1B[39m") : String,
|
|
149
|
-
magenta: enabled ? formatter2("\x1B[35m", "\x1B[39m") : String,
|
|
150
|
-
cyan: enabled ? formatter2("\x1B[36m", "\x1B[39m") : String,
|
|
151
|
-
white: enabled ? formatter2("\x1B[37m", "\x1B[39m") : String,
|
|
152
|
-
gray: enabled ? formatter2("\x1B[90m", "\x1B[39m") : String,
|
|
153
|
-
bgBlack: enabled ? formatter2("\x1B[40m", "\x1B[49m") : String,
|
|
154
|
-
bgRed: enabled ? formatter2("\x1B[41m", "\x1B[49m") : String,
|
|
155
|
-
bgGreen: enabled ? formatter2("\x1B[42m", "\x1B[49m") : String,
|
|
156
|
-
bgYellow: enabled ? formatter2("\x1B[43m", "\x1B[49m") : String,
|
|
157
|
-
bgBlue: enabled ? formatter2("\x1B[44m", "\x1B[49m") : String,
|
|
158
|
-
bgMagenta: enabled ? formatter2("\x1B[45m", "\x1B[49m") : String,
|
|
159
|
-
bgCyan: enabled ? formatter2("\x1B[46m", "\x1B[49m") : String,
|
|
160
|
-
bgWhite: enabled ? formatter2("\x1B[47m", "\x1B[49m") : String
|
|
161
|
-
});
|
|
162
170
|
module.exports = createColors();
|
|
163
171
|
module.exports.createColors = createColors;
|
|
164
172
|
}
|
|
165
173
|
});
|
|
166
174
|
|
|
175
|
+
// ../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js
|
|
176
|
+
var require_cjs = __commonJS({
|
|
177
|
+
"../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"(exports, module) {
|
|
178
|
+
"use strict";
|
|
179
|
+
init_esm();
|
|
180
|
+
var isMergeableObject = function isMergeableObject2(value) {
|
|
181
|
+
return isNonNullObject(value) && !isSpecial(value);
|
|
182
|
+
};
|
|
183
|
+
function isNonNullObject(value) {
|
|
184
|
+
return !!value && typeof value === "object";
|
|
185
|
+
}
|
|
186
|
+
function isSpecial(value) {
|
|
187
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
188
|
+
return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
|
|
189
|
+
}
|
|
190
|
+
var canUseSymbol = typeof Symbol === "function" && Symbol.for;
|
|
191
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
|
|
192
|
+
function isReactElement(value) {
|
|
193
|
+
return value.$$typeof === REACT_ELEMENT_TYPE;
|
|
194
|
+
}
|
|
195
|
+
function emptyTarget(val) {
|
|
196
|
+
return Array.isArray(val) ? [] : {};
|
|
197
|
+
}
|
|
198
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
199
|
+
return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value;
|
|
200
|
+
}
|
|
201
|
+
function defaultArrayMerge(target, source, options) {
|
|
202
|
+
return target.concat(source).map(function(element) {
|
|
203
|
+
return cloneUnlessOtherwiseSpecified(element, options);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function getMergeFunction(key, options) {
|
|
207
|
+
if (!options.customMerge) {
|
|
208
|
+
return deepmerge2;
|
|
209
|
+
}
|
|
210
|
+
var customMerge = options.customMerge(key);
|
|
211
|
+
return typeof customMerge === "function" ? customMerge : deepmerge2;
|
|
212
|
+
}
|
|
213
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
214
|
+
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
215
|
+
return Object.propertyIsEnumerable.call(target, symbol);
|
|
216
|
+
}) : [];
|
|
217
|
+
}
|
|
218
|
+
function getKeys(target) {
|
|
219
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
|
|
220
|
+
}
|
|
221
|
+
function propertyIsOnObject(object, property) {
|
|
222
|
+
try {
|
|
223
|
+
return property in object;
|
|
224
|
+
} catch (_3) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function propertyIsUnsafe(target, key) {
|
|
229
|
+
return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
|
|
230
|
+
}
|
|
231
|
+
function mergeObject(target, source, options) {
|
|
232
|
+
var destination = {};
|
|
233
|
+
if (options.isMergeableObject(target)) {
|
|
234
|
+
getKeys(target).forEach(function(key) {
|
|
235
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
getKeys(source).forEach(function(key) {
|
|
239
|
+
if (propertyIsUnsafe(target, key)) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
243
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
244
|
+
} else {
|
|
245
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
return destination;
|
|
249
|
+
}
|
|
250
|
+
function deepmerge2(target, source, options) {
|
|
251
|
+
options = options || {};
|
|
252
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
253
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
254
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
255
|
+
var sourceIsArray = Array.isArray(source);
|
|
256
|
+
var targetIsArray = Array.isArray(target);
|
|
257
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
258
|
+
if (!sourceAndTargetTypesMatch) {
|
|
259
|
+
return cloneUnlessOtherwiseSpecified(source, options);
|
|
260
|
+
} else if (sourceIsArray) {
|
|
261
|
+
return options.arrayMerge(target, source, options);
|
|
262
|
+
} else {
|
|
263
|
+
return mergeObject(target, source, options);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
deepmerge2.all = function deepmergeAll(array, options) {
|
|
267
|
+
if (!Array.isArray(array)) {
|
|
268
|
+
throw new Error("first argument should be an array");
|
|
269
|
+
}
|
|
270
|
+
return array.reduce(function(prev, next) {
|
|
271
|
+
return deepmerge2(prev, next, options);
|
|
272
|
+
}, {});
|
|
273
|
+
};
|
|
274
|
+
var deepmerge_1 = deepmerge2;
|
|
275
|
+
module.exports = deepmerge_1;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// ../../node_modules/.pnpm/minimist@1.2.8/node_modules/minimist/index.js
|
|
280
|
+
var require_minimist = __commonJS({
|
|
281
|
+
"../../node_modules/.pnpm/minimist@1.2.8/node_modules/minimist/index.js"(exports, module) {
|
|
282
|
+
"use strict";
|
|
283
|
+
init_esm();
|
|
284
|
+
function hasKey(obj, keys) {
|
|
285
|
+
var o2 = obj;
|
|
286
|
+
keys.slice(0, -1).forEach(function(key2) {
|
|
287
|
+
o2 = o2[key2] || {};
|
|
288
|
+
});
|
|
289
|
+
var key = keys[keys.length - 1];
|
|
290
|
+
return key in o2;
|
|
291
|
+
}
|
|
292
|
+
function isNumber(x3) {
|
|
293
|
+
if (typeof x3 === "number") {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
if (/^0x[0-9a-f]+$/i.test(x3)) {
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x3);
|
|
300
|
+
}
|
|
301
|
+
function isConstructorOrProto(obj, key) {
|
|
302
|
+
return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
|
|
303
|
+
}
|
|
304
|
+
module.exports = function(args, opts) {
|
|
305
|
+
if (!opts) {
|
|
306
|
+
opts = {};
|
|
307
|
+
}
|
|
308
|
+
var flags = {
|
|
309
|
+
bools: {},
|
|
310
|
+
strings: {},
|
|
311
|
+
unknownFn: null
|
|
312
|
+
};
|
|
313
|
+
if (typeof opts.unknown === "function") {
|
|
314
|
+
flags.unknownFn = opts.unknown;
|
|
315
|
+
}
|
|
316
|
+
if (typeof opts.boolean === "boolean" && opts.boolean) {
|
|
317
|
+
flags.allBools = true;
|
|
318
|
+
} else {
|
|
319
|
+
[].concat(opts.boolean).filter(Boolean).forEach(function(key2) {
|
|
320
|
+
flags.bools[key2] = true;
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
var aliases = {};
|
|
324
|
+
function aliasIsBoolean(key2) {
|
|
325
|
+
return aliases[key2].some(function(x3) {
|
|
326
|
+
return flags.bools[x3];
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
Object.keys(opts.alias || {}).forEach(function(key2) {
|
|
330
|
+
aliases[key2] = [].concat(opts.alias[key2]);
|
|
331
|
+
aliases[key2].forEach(function(x3) {
|
|
332
|
+
aliases[x3] = [key2].concat(aliases[key2].filter(function(y3) {
|
|
333
|
+
return x3 !== y3;
|
|
334
|
+
}));
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
[].concat(opts.string).filter(Boolean).forEach(function(key2) {
|
|
338
|
+
flags.strings[key2] = true;
|
|
339
|
+
if (aliases[key2]) {
|
|
340
|
+
[].concat(aliases[key2]).forEach(function(k2) {
|
|
341
|
+
flags.strings[k2] = true;
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
var defaults = opts.default || {};
|
|
346
|
+
var argv = { _: [] };
|
|
347
|
+
function argDefined(key2, arg2) {
|
|
348
|
+
return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
|
|
349
|
+
}
|
|
350
|
+
function setKey(obj, keys, value2) {
|
|
351
|
+
var o2 = obj;
|
|
352
|
+
for (var i2 = 0; i2 < keys.length - 1; i2++) {
|
|
353
|
+
var key2 = keys[i2];
|
|
354
|
+
if (isConstructorOrProto(o2, key2)) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (o2[key2] === void 0) {
|
|
358
|
+
o2[key2] = {};
|
|
359
|
+
}
|
|
360
|
+
if (o2[key2] === Object.prototype || o2[key2] === Number.prototype || o2[key2] === String.prototype) {
|
|
361
|
+
o2[key2] = {};
|
|
362
|
+
}
|
|
363
|
+
if (o2[key2] === Array.prototype) {
|
|
364
|
+
o2[key2] = [];
|
|
365
|
+
}
|
|
366
|
+
o2 = o2[key2];
|
|
367
|
+
}
|
|
368
|
+
var lastKey = keys[keys.length - 1];
|
|
369
|
+
if (isConstructorOrProto(o2, lastKey)) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (o2 === Object.prototype || o2 === Number.prototype || o2 === String.prototype) {
|
|
373
|
+
o2 = {};
|
|
374
|
+
}
|
|
375
|
+
if (o2 === Array.prototype) {
|
|
376
|
+
o2 = [];
|
|
377
|
+
}
|
|
378
|
+
if (o2[lastKey] === void 0 || flags.bools[lastKey] || typeof o2[lastKey] === "boolean") {
|
|
379
|
+
o2[lastKey] = value2;
|
|
380
|
+
} else if (Array.isArray(o2[lastKey])) {
|
|
381
|
+
o2[lastKey].push(value2);
|
|
382
|
+
} else {
|
|
383
|
+
o2[lastKey] = [o2[lastKey], value2];
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
function setArg(key2, val, arg2) {
|
|
387
|
+
if (arg2 && flags.unknownFn && !argDefined(key2, arg2)) {
|
|
388
|
+
if (flags.unknownFn(arg2) === false) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
|
|
393
|
+
setKey(argv, key2.split("."), value2);
|
|
394
|
+
(aliases[key2] || []).forEach(function(x3) {
|
|
395
|
+
setKey(argv, x3.split("."), value2);
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
Object.keys(flags.bools).forEach(function(key2) {
|
|
399
|
+
setArg(key2, defaults[key2] === void 0 ? false : defaults[key2]);
|
|
400
|
+
});
|
|
401
|
+
var notFlags = [];
|
|
402
|
+
if (args.indexOf("--") !== -1) {
|
|
403
|
+
notFlags = args.slice(args.indexOf("--") + 1);
|
|
404
|
+
args = args.slice(0, args.indexOf("--"));
|
|
405
|
+
}
|
|
406
|
+
for (var i = 0; i < args.length; i++) {
|
|
407
|
+
var arg = args[i];
|
|
408
|
+
var key;
|
|
409
|
+
var next;
|
|
410
|
+
if (/^--.+=/.test(arg)) {
|
|
411
|
+
var m2 = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
|
412
|
+
key = m2[1];
|
|
413
|
+
var value = m2[2];
|
|
414
|
+
if (flags.bools[key]) {
|
|
415
|
+
value = value !== "false";
|
|
416
|
+
}
|
|
417
|
+
setArg(key, value, arg);
|
|
418
|
+
} else if (/^--no-.+/.test(arg)) {
|
|
419
|
+
key = arg.match(/^--no-(.+)/)[1];
|
|
420
|
+
setArg(key, false, arg);
|
|
421
|
+
} else if (/^--.+/.test(arg)) {
|
|
422
|
+
key = arg.match(/^--(.+)/)[1];
|
|
423
|
+
next = args[i + 1];
|
|
424
|
+
if (next !== void 0 && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
|
425
|
+
setArg(key, next, arg);
|
|
426
|
+
i += 1;
|
|
427
|
+
} else if (/^(true|false)$/.test(next)) {
|
|
428
|
+
setArg(key, next === "true", arg);
|
|
429
|
+
i += 1;
|
|
430
|
+
} else {
|
|
431
|
+
setArg(key, flags.strings[key] ? "" : true, arg);
|
|
432
|
+
}
|
|
433
|
+
} else if (/^-[^-]+/.test(arg)) {
|
|
434
|
+
var letters = arg.slice(1, -1).split("");
|
|
435
|
+
var broken = false;
|
|
436
|
+
for (var j2 = 0; j2 < letters.length; j2++) {
|
|
437
|
+
next = arg.slice(j2 + 2);
|
|
438
|
+
if (next === "-") {
|
|
439
|
+
setArg(letters[j2], next, arg);
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
if (/[A-Za-z]/.test(letters[j2]) && next[0] === "=") {
|
|
443
|
+
setArg(letters[j2], next.slice(1), arg);
|
|
444
|
+
broken = true;
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
if (/[A-Za-z]/.test(letters[j2]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
|
448
|
+
setArg(letters[j2], next, arg);
|
|
449
|
+
broken = true;
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
if (letters[j2 + 1] && letters[j2 + 1].match(/\W/)) {
|
|
453
|
+
setArg(letters[j2], arg.slice(j2 + 2), arg);
|
|
454
|
+
broken = true;
|
|
455
|
+
break;
|
|
456
|
+
} else {
|
|
457
|
+
setArg(letters[j2], flags.strings[letters[j2]] ? "" : true, arg);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
key = arg.slice(-1)[0];
|
|
461
|
+
if (!broken && key !== "-") {
|
|
462
|
+
if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
|
463
|
+
setArg(key, args[i + 1], arg);
|
|
464
|
+
i += 1;
|
|
465
|
+
} else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
|
|
466
|
+
setArg(key, args[i + 1] === "true", arg);
|
|
467
|
+
i += 1;
|
|
468
|
+
} else {
|
|
469
|
+
setArg(key, flags.strings[key] ? "" : true, arg);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
} else {
|
|
473
|
+
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
|
474
|
+
argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
|
|
475
|
+
}
|
|
476
|
+
if (opts.stopEarly) {
|
|
477
|
+
argv._.push.apply(argv._, args.slice(i + 1));
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
Object.keys(defaults).forEach(function(k2) {
|
|
483
|
+
if (!hasKey(argv, k2.split("."))) {
|
|
484
|
+
setKey(argv, k2.split("."), defaults[k2]);
|
|
485
|
+
(aliases[k2] || []).forEach(function(x3) {
|
|
486
|
+
setKey(argv, x3.split("."), defaults[k2]);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
if (opts["--"]) {
|
|
491
|
+
argv["--"] = notFlags.slice();
|
|
492
|
+
} else {
|
|
493
|
+
notFlags.forEach(function(k2) {
|
|
494
|
+
argv._.push(k2);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
return argv;
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
|
|
167
502
|
// src/index.ts
|
|
168
503
|
init_esm();
|
|
169
504
|
import fs from "fs";
|
|
@@ -484,6 +819,41 @@ var x = class {
|
|
|
484
819
|
}
|
|
485
820
|
}
|
|
486
821
|
};
|
|
822
|
+
var pD = Object.defineProperty;
|
|
823
|
+
var fD = (t, u, F) => u in t ? pD(t, u, { enumerable: true, configurable: true, writable: true, value: F }) : t[u] = F;
|
|
824
|
+
var K = (t, u, F) => (fD(t, typeof u != "symbol" ? u + "" : u, F), F);
|
|
825
|
+
var gD = class extends x {
|
|
826
|
+
constructor(u) {
|
|
827
|
+
super(u, false), K(this, "options"), K(this, "cursor", 0), this.options = u.options, this.value = [...u.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F }) => F === u.cursorAt), 0), this.on("key", (F) => {
|
|
828
|
+
F === "a" && this.toggleAll();
|
|
829
|
+
}), this.on("cursor", (F) => {
|
|
830
|
+
switch (F) {
|
|
831
|
+
case "left":
|
|
832
|
+
case "up":
|
|
833
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
834
|
+
break;
|
|
835
|
+
case "down":
|
|
836
|
+
case "right":
|
|
837
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
838
|
+
break;
|
|
839
|
+
case "space":
|
|
840
|
+
this.toggleValue();
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
get _value() {
|
|
846
|
+
return this.options[this.cursor].value;
|
|
847
|
+
}
|
|
848
|
+
toggleAll() {
|
|
849
|
+
const u = this.value.length === this.options.length;
|
|
850
|
+
this.value = u ? [] : this.options.map((F) => F.value);
|
|
851
|
+
}
|
|
852
|
+
toggleValue() {
|
|
853
|
+
const u = this.value.includes(this._value);
|
|
854
|
+
this.value = u ? this.value.filter((F) => F !== this._value) : [...this.value, this._value];
|
|
855
|
+
}
|
|
856
|
+
};
|
|
487
857
|
var bD = Object.defineProperty;
|
|
488
858
|
var wD = (t, u, F) => u in t ? bD(t, u, { enumerable: true, configurable: true, writable: true, value: F }) : t[u] = F;
|
|
489
859
|
var Z = (t, u, F) => (wD(t, typeof u != "symbol" ? u + "" : u, F), F);
|
|
@@ -545,7 +915,7 @@ var H = o("◆", "*");
|
|
|
545
915
|
var I2 = o("■", "x");
|
|
546
916
|
var x2 = o("▲", "x");
|
|
547
917
|
var S2 = o("◇", "o");
|
|
548
|
-
var
|
|
918
|
+
var K2 = o("┌", "T");
|
|
549
919
|
var a2 = o("│", "|");
|
|
550
920
|
var d2 = o("└", "—");
|
|
551
921
|
var b2 = o("●", ">");
|
|
@@ -624,6 +994,50 @@ ${import_picocolors2.default.cyan(d2)}
|
|
|
624
994
|
}
|
|
625
995
|
} }).prompt();
|
|
626
996
|
};
|
|
997
|
+
var ae = (r2) => {
|
|
998
|
+
const n = (i, t) => {
|
|
999
|
+
const s = i.label ?? String(i.value);
|
|
1000
|
+
return t === "active" ? `${import_picocolors2.default.cyan(C)} ${s} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}` : t === "selected" ? `${import_picocolors2.default.green(w2)} ${import_picocolors2.default.dim(s)}` : t === "cancelled" ? `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}` : t === "active-selected" ? `${import_picocolors2.default.green(w2)} ${s} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}` : t === "submitted" ? `${import_picocolors2.default.dim(s)}` : `${import_picocolors2.default.dim(M2)} ${import_picocolors2.default.dim(s)}`;
|
|
1001
|
+
};
|
|
1002
|
+
return new gD({ options: r2.options, initialValues: r2.initialValues, required: r2.required ?? true, cursorAt: r2.cursorAt, validate(i) {
|
|
1003
|
+
if (this.required && i.length === 0)
|
|
1004
|
+
return `Please select at least one option.
|
|
1005
|
+
${import_picocolors2.default.reset(import_picocolors2.default.dim(`Press ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" space ")))} to select, ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" enter ")))} to submit`))}`;
|
|
1006
|
+
}, render() {
|
|
1007
|
+
let i = `${import_picocolors2.default.gray(a2)}
|
|
1008
|
+
${y2(this.state)} ${r2.message}
|
|
1009
|
+
`;
|
|
1010
|
+
switch (this.state) {
|
|
1011
|
+
case "submit":
|
|
1012
|
+
return `${i}${import_picocolors2.default.gray(a2)} ${this.options.filter(({ value: t }) => this.value.includes(t)).map((t) => n(t, "submitted")).join(import_picocolors2.default.dim(", ")) || import_picocolors2.default.dim("none")}`;
|
|
1013
|
+
case "cancel": {
|
|
1014
|
+
const t = this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "cancelled")).join(import_picocolors2.default.dim(", "));
|
|
1015
|
+
return `${i}${import_picocolors2.default.gray(a2)} ${t.trim() ? `${t}
|
|
1016
|
+
${import_picocolors2.default.gray(a2)}` : ""}`;
|
|
1017
|
+
}
|
|
1018
|
+
case "error": {
|
|
1019
|
+
const t = this.error.split(`
|
|
1020
|
+
`).map((s, c2) => c2 === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(s)}` : ` ${s}`).join(`
|
|
1021
|
+
`);
|
|
1022
|
+
return i + import_picocolors2.default.yellow(a2) + " " + this.options.map((s, c2) => {
|
|
1023
|
+
const l2 = this.value.includes(s.value), u = c2 === this.cursor;
|
|
1024
|
+
return u && l2 ? n(s, "active-selected") : l2 ? n(s, "selected") : n(s, u ? "active" : "inactive");
|
|
1025
|
+
}).join(`
|
|
1026
|
+
${import_picocolors2.default.yellow(a2)} `) + `
|
|
1027
|
+
` + t + `
|
|
1028
|
+
`;
|
|
1029
|
+
}
|
|
1030
|
+
default:
|
|
1031
|
+
return `${i}${import_picocolors2.default.cyan(a2)} ${this.options.map((t, s) => {
|
|
1032
|
+
const c2 = this.value.includes(t.value), l2 = s === this.cursor;
|
|
1033
|
+
return l2 && c2 ? n(t, "active-selected") : c2 ? n(t, "selected") : n(t, l2 ? "active" : "inactive");
|
|
1034
|
+
}).join(`
|
|
1035
|
+
${import_picocolors2.default.cyan(a2)} `)}
|
|
1036
|
+
${import_picocolors2.default.cyan(d2)}
|
|
1037
|
+
`;
|
|
1038
|
+
}
|
|
1039
|
+
} }).prompt();
|
|
1040
|
+
};
|
|
627
1041
|
var R2 = (r2) => r2.replace(me(), "");
|
|
628
1042
|
var le = (r2 = "", n = "") => {
|
|
629
1043
|
const i = `
|
|
@@ -653,6 +1067,10 @@ function me() {
|
|
|
653
1067
|
return new RegExp(r2, "g");
|
|
654
1068
|
}
|
|
655
1069
|
|
|
1070
|
+
// src/index.ts
|
|
1071
|
+
var import_deepmerge = __toESM(require_cjs());
|
|
1072
|
+
var import_minimist = __toESM(require_minimist());
|
|
1073
|
+
|
|
656
1074
|
// ../../node_modules/.pnpm/rslog@1.2.2/node_modules/rslog/dist/index.mjs
|
|
657
1075
|
init_esm();
|
|
658
1076
|
import process2 from "process";
|
|
@@ -944,9 +1362,14 @@ function checkCancel(value) {
|
|
|
944
1362
|
if (hD(value)) {
|
|
945
1363
|
cancelAndExit();
|
|
946
1364
|
}
|
|
1365
|
+
return value;
|
|
947
1366
|
}
|
|
948
|
-
function
|
|
949
|
-
|
|
1367
|
+
function formatProjectName(input) {
|
|
1368
|
+
const formatted = input.trim().replace(/\/+$/g, "");
|
|
1369
|
+
return {
|
|
1370
|
+
packageName: formatted.startsWith("@") ? formatted : path2.basename(formatted),
|
|
1371
|
+
targetDir: formatted
|
|
1372
|
+
};
|
|
950
1373
|
}
|
|
951
1374
|
function pkgFromUserAgent(userAgent) {
|
|
952
1375
|
if (!userAgent)
|
|
@@ -962,66 +1385,159 @@ function isEmptyDir(path3) {
|
|
|
962
1385
|
const files = fs.readdirSync(path3);
|
|
963
1386
|
return files.length === 0 || files.length === 1 && files[0] === ".git";
|
|
964
1387
|
}
|
|
1388
|
+
function logHelpMessage() {
|
|
1389
|
+
logger.log(`
|
|
1390
|
+
Usage: create-rsbuild [options]
|
|
1391
|
+
|
|
1392
|
+
Options:
|
|
1393
|
+
|
|
1394
|
+
-h, --help display help for command
|
|
1395
|
+
-d, --dir create project in specified directory
|
|
1396
|
+
-t, --template specify the template to use
|
|
1397
|
+
--tools select additional tools (biome, eslint, prettier)
|
|
1398
|
+
--override override files in target directory
|
|
1399
|
+
|
|
1400
|
+
Templates:
|
|
1401
|
+
|
|
1402
|
+
react react-ts
|
|
1403
|
+
vue3 vue3-ts
|
|
1404
|
+
vue2 vue2-ts
|
|
1405
|
+
lit lit-ts
|
|
1406
|
+
preact preact-ts
|
|
1407
|
+
svelte svelte-ts
|
|
1408
|
+
solid solid-ts
|
|
1409
|
+
vanilla vanilla-ts
|
|
1410
|
+
`);
|
|
1411
|
+
}
|
|
1412
|
+
var frameworkAlias = {
|
|
1413
|
+
vue: "vue3",
|
|
1414
|
+
"solid-js": "solid"
|
|
1415
|
+
};
|
|
1416
|
+
async function getTemplate({ template }) {
|
|
1417
|
+
if (typeof template === "string") {
|
|
1418
|
+
const pair = template.split("-");
|
|
1419
|
+
const language2 = pair[1] ?? "js";
|
|
1420
|
+
const framework2 = pair[0];
|
|
1421
|
+
return {
|
|
1422
|
+
framework: frameworkAlias[framework2] ?? framework2,
|
|
1423
|
+
language: language2
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
const framework = checkCancel(
|
|
1427
|
+
await ie({
|
|
1428
|
+
message: "Select framework",
|
|
1429
|
+
options: [
|
|
1430
|
+
{ value: "react", label: "React" },
|
|
1431
|
+
{ value: "vue3", label: "Vue 3" },
|
|
1432
|
+
{ value: "vue2", label: "Vue 2" },
|
|
1433
|
+
{ value: "lit", label: "Lit" },
|
|
1434
|
+
{ value: "preact", label: "Preact" },
|
|
1435
|
+
{ value: "svelte", label: "Svelte" },
|
|
1436
|
+
{ value: "solid", label: "Solid" },
|
|
1437
|
+
{ value: "vanilla", label: "Vanilla" }
|
|
1438
|
+
]
|
|
1439
|
+
})
|
|
1440
|
+
);
|
|
1441
|
+
const language = checkCancel(
|
|
1442
|
+
await ie({
|
|
1443
|
+
message: "Select language",
|
|
1444
|
+
options: [
|
|
1445
|
+
{ value: "ts", label: "TypeScript" },
|
|
1446
|
+
{ value: "js", label: "JavaScript" }
|
|
1447
|
+
]
|
|
1448
|
+
})
|
|
1449
|
+
);
|
|
1450
|
+
return {
|
|
1451
|
+
framework,
|
|
1452
|
+
language
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
async function getTools({ tools, dir, template }) {
|
|
1456
|
+
if (tools) {
|
|
1457
|
+
return Array.isArray(tools) ? tools : [tools];
|
|
1458
|
+
}
|
|
1459
|
+
if (dir && template) {
|
|
1460
|
+
return [];
|
|
1461
|
+
}
|
|
1462
|
+
return checkCancel(
|
|
1463
|
+
await ae({
|
|
1464
|
+
message: "Select additional tools (press enter to continue)",
|
|
1465
|
+
options: [
|
|
1466
|
+
{ value: "biome", label: "Add Biome for code linting and formatting" },
|
|
1467
|
+
{ value: "eslint", label: "Add ESLint for code linting" },
|
|
1468
|
+
{ value: "prettier", label: "Add Prettier for code formatting" }
|
|
1469
|
+
],
|
|
1470
|
+
required: false
|
|
1471
|
+
})
|
|
1472
|
+
);
|
|
1473
|
+
}
|
|
965
1474
|
async function main() {
|
|
1475
|
+
const argv = (0, import_minimist.default)(process.argv.slice(2), {
|
|
1476
|
+
alias: { h: "help", d: "dir", t: "template" }
|
|
1477
|
+
});
|
|
966
1478
|
console.log("");
|
|
967
1479
|
logger.greet("◆ Create Rsbuild Project");
|
|
1480
|
+
if (argv.help) {
|
|
1481
|
+
logHelpMessage();
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
968
1484
|
const cwd = process.cwd();
|
|
969
1485
|
const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
|
|
970
1486
|
const pkgManager = pkgInfo ? pkgInfo.name : "npm";
|
|
971
1487
|
const packageRoot = path2.resolve(__dirname, "..");
|
|
972
1488
|
const packageJsonPath = path2.join(packageRoot, "package.json");
|
|
973
1489
|
const { version } = __require(packageJsonPath);
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1490
|
+
const projectName = argv.dir ?? checkCancel(
|
|
1491
|
+
await te({
|
|
1492
|
+
message: "Project name or path",
|
|
1493
|
+
placeholder: "rsbuild-project",
|
|
1494
|
+
defaultValue: "rsbuild-project",
|
|
1495
|
+
validate(value) {
|
|
1496
|
+
if (value.length === 0) {
|
|
1497
|
+
return "Project name is required";
|
|
1498
|
+
}
|
|
980
1499
|
}
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1500
|
+
})
|
|
1501
|
+
);
|
|
1502
|
+
const { targetDir, packageName } = formatProjectName(projectName);
|
|
1503
|
+
const distFolder = path2.isAbsolute(targetDir) ? targetDir : path2.join(cwd, targetDir);
|
|
1504
|
+
if (!argv.override && fs.existsSync(distFolder) && !isEmptyDir(distFolder)) {
|
|
1505
|
+
const option = checkCancel(
|
|
1506
|
+
await ie({
|
|
1507
|
+
message: `"${targetDir}" is not empty, please choose:`,
|
|
1508
|
+
options: [
|
|
1509
|
+
{ value: "yes", label: "Continue and override files" },
|
|
1510
|
+
{ value: "no", label: "Cancel operation" }
|
|
1511
|
+
]
|
|
1512
|
+
})
|
|
1513
|
+
);
|
|
995
1514
|
if (option === "no") {
|
|
996
1515
|
cancelAndExit();
|
|
997
1516
|
}
|
|
998
1517
|
}
|
|
999
|
-
const framework = await
|
|
1000
|
-
|
|
1001
|
-
options: [
|
|
1002
|
-
{ value: "react", label: "React" },
|
|
1003
|
-
{ value: "vue3", label: "Vue 3" },
|
|
1004
|
-
{ value: "vue2", label: "Vue 2" },
|
|
1005
|
-
{ value: "lit", label: "Lit" },
|
|
1006
|
-
{ value: "preact", label: "Preact" },
|
|
1007
|
-
{ value: "svelte", label: "Svelte" },
|
|
1008
|
-
{ value: "solid", label: "Solid" },
|
|
1009
|
-
{ value: "vanilla", label: "Vanilla" }
|
|
1010
|
-
]
|
|
1011
|
-
});
|
|
1012
|
-
checkCancel(framework);
|
|
1013
|
-
const language = await ie({
|
|
1014
|
-
message: "Select language",
|
|
1015
|
-
options: [
|
|
1016
|
-
{ value: "ts", label: "TypeScript" },
|
|
1017
|
-
{ value: "js", label: "JavaScript" }
|
|
1018
|
-
]
|
|
1019
|
-
});
|
|
1020
|
-
checkCancel(language);
|
|
1518
|
+
const { framework, language } = await getTemplate(argv);
|
|
1519
|
+
const tools = await getTools(argv);
|
|
1021
1520
|
const srcFolder = path2.join(packageRoot, `template-${framework}-${language}`);
|
|
1022
1521
|
const commonFolder = path2.join(packageRoot, "template-common");
|
|
1522
|
+
if (!fs.existsSync(srcFolder)) {
|
|
1523
|
+
throw new Error(
|
|
1524
|
+
`Invalid input: template "${framework}-${language}" not found. `
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1023
1527
|
copyFolder(commonFolder, distFolder, version);
|
|
1024
|
-
copyFolder(srcFolder, distFolder, version,
|
|
1528
|
+
copyFolder(srcFolder, distFolder, version, packageName);
|
|
1529
|
+
for (const tool of tools) {
|
|
1530
|
+
const toolFolder = path2.join(packageRoot, `template-${tool}`);
|
|
1531
|
+
if (tool === "eslint") {
|
|
1532
|
+
let subFolder = path2.join(toolFolder, `${framework}-${language}`);
|
|
1533
|
+
if (!fs.existsSync(subFolder)) {
|
|
1534
|
+
subFolder = path2.join(toolFolder, `common-${language}`);
|
|
1535
|
+
}
|
|
1536
|
+
copyFolder(subFolder, distFolder, version);
|
|
1537
|
+
} else {
|
|
1538
|
+
copyFolder(toolFolder, distFolder, version);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1025
1541
|
const nextSteps = [
|
|
1026
1542
|
`cd ${targetDir}`,
|
|
1027
1543
|
`${pkgManager} i`,
|
|
@@ -1030,6 +1546,33 @@ async function main() {
|
|
|
1030
1546
|
le(nextSteps.join("\n"), "Next steps");
|
|
1031
1547
|
$e("Done.");
|
|
1032
1548
|
}
|
|
1549
|
+
function sortObjectKeys(obj) {
|
|
1550
|
+
const sortedKeys = Object.keys(obj).sort();
|
|
1551
|
+
const sortedObj = {};
|
|
1552
|
+
for (const key of sortedKeys) {
|
|
1553
|
+
sortedObj[key] = obj[key];
|
|
1554
|
+
}
|
|
1555
|
+
return sortedObj;
|
|
1556
|
+
}
|
|
1557
|
+
function mergePackageJson(targetPackage, extraPackage) {
|
|
1558
|
+
if (!fs.existsSync(targetPackage)) {
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
const targetJson = JSON.parse(fs.readFileSync(targetPackage, "utf-8"));
|
|
1562
|
+
const extraJson = JSON.parse(fs.readFileSync(extraPackage, "utf-8"));
|
|
1563
|
+
const mergedJson = (0, import_deepmerge.default)(targetJson, extraJson);
|
|
1564
|
+
mergedJson.name = targetJson.name || extraJson.name;
|
|
1565
|
+
for (const key of ["scripts", "dependencies", "devDependencies"]) {
|
|
1566
|
+
if (!(key in mergedJson)) {
|
|
1567
|
+
continue;
|
|
1568
|
+
}
|
|
1569
|
+
mergedJson[key] = sortObjectKeys(
|
|
1570
|
+
mergedJson[key]
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1573
|
+
fs.writeFileSync(targetPackage, `${JSON.stringify(mergedJson, null, 2)}
|
|
1574
|
+
`);
|
|
1575
|
+
}
|
|
1033
1576
|
function copyFolder(src, dist, version, name) {
|
|
1034
1577
|
const renameFiles = {
|
|
1035
1578
|
gitignore: ".gitignore"
|
|
@@ -1045,20 +1588,32 @@ function copyFolder(src, dist, version, name) {
|
|
|
1045
1588
|
const stat = fs.statSync(srcFile);
|
|
1046
1589
|
if (stat.isDirectory()) {
|
|
1047
1590
|
copyFolder(srcFile, distFile, version);
|
|
1048
|
-
} else {
|
|
1049
|
-
|
|
1050
|
-
if (
|
|
1591
|
+
} else if (file === "package.json") {
|
|
1592
|
+
const targetPackage = path2.resolve(dist, "package.json");
|
|
1593
|
+
if (fs.existsSync(targetPackage)) {
|
|
1594
|
+
mergePackageJson(targetPackage, srcFile);
|
|
1595
|
+
} else {
|
|
1596
|
+
fs.copyFileSync(srcFile, distFile);
|
|
1051
1597
|
updatePackageJson(distFile, version, name);
|
|
1052
1598
|
}
|
|
1599
|
+
} else {
|
|
1600
|
+
fs.copyFileSync(srcFile, distFile);
|
|
1053
1601
|
}
|
|
1054
1602
|
}
|
|
1055
1603
|
}
|
|
1604
|
+
var isStableVersion = (version) => {
|
|
1605
|
+
return ["alpha", "beta", "rc", "canary", "nightly"].every(
|
|
1606
|
+
(tag) => !version.includes(tag)
|
|
1607
|
+
);
|
|
1608
|
+
};
|
|
1056
1609
|
var updatePackageJson = (pkgJsonPath, version, name) => {
|
|
1057
1610
|
let content = fs.readFileSync(pkgJsonPath, "utf-8");
|
|
1058
|
-
|
|
1611
|
+
const targetVersion = isStableVersion(version) ? `^${version}` : version;
|
|
1612
|
+
content = content.replace(/workspace:\*/g, targetVersion);
|
|
1059
1613
|
const pkg = JSON.parse(content);
|
|
1060
|
-
if (name)
|
|
1614
|
+
if (name && name !== ".") {
|
|
1061
1615
|
pkg.name = name;
|
|
1616
|
+
}
|
|
1062
1617
|
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2));
|
|
1063
1618
|
};
|
|
1064
1619
|
main();
|