@icebreakers/monorepo 0.6.21 → 0.6.24
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/assets/.github/workflows/ci.yml +3 -0
- package/assets/package.json +20 -32
- package/assets/vitest.config.ts +19 -0
- package/dist/{chunk-54PKU7G6.js → chunk-YMAPO4ZI.js} +115 -116
- package/dist/cli.cjs +136 -130
- package/dist/cli.js +18 -11
- package/dist/index.cjs +117 -118
- package/dist/index.js +1 -1
- package/package.json +20 -10
- package/templates/foo/build.config.ts +25 -0
- package/templates/foo/package.json +45 -0
- package/templates/foo/src/index.ts +7 -0
- package/templates/foo/test/index.test.ts +7 -0
- package/templates/foo/tsconfig.json +15 -0
- package/templates/foo/vitest.config.ts +15 -0
- package/assets/vitest.workspace.ts +0 -8
package/dist/cli.cjs
CHANGED
|
@@ -28,10 +28,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
mod
|
|
29
29
|
));
|
|
30
30
|
|
|
31
|
-
// ../../node_modules/.pnpm/tsup@8.3.
|
|
31
|
+
// ../../node_modules/.pnpm/tsup@8.3.6_jiti@2.4.2_postcss@8.5.0_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
|
|
32
32
|
var getImportMetaUrl, importMetaUrl;
|
|
33
33
|
var init_cjs_shims = __esm({
|
|
34
|
-
"../../node_modules/.pnpm/tsup@8.3.
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.3.6_jiti@2.4.2_postcss@8.5.0_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
35
35
|
"use strict";
|
|
36
36
|
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
37
37
|
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
@@ -57,7 +57,7 @@ var require_isobject = __commonJS({
|
|
|
57
57
|
"../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports2, module2) {
|
|
58
58
|
"use strict";
|
|
59
59
|
init_cjs_shims();
|
|
60
|
-
module2.exports = function
|
|
60
|
+
module2.exports = function isObject2(val) {
|
|
61
61
|
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
@@ -68,9 +68,9 @@ var require_is_plain_object = __commonJS({
|
|
|
68
68
|
"../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports2, module2) {
|
|
69
69
|
"use strict";
|
|
70
70
|
init_cjs_shims();
|
|
71
|
-
var
|
|
71
|
+
var isObject2 = require_isobject();
|
|
72
72
|
function isObjectObject(o) {
|
|
73
|
-
return
|
|
73
|
+
return isObject2(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
74
74
|
}
|
|
75
75
|
module2.exports = function isPlainObject2(o) {
|
|
76
76
|
var ctor, prot;
|
|
@@ -95,7 +95,7 @@ var require_set_value = __commonJS({
|
|
|
95
95
|
var { deleteProperty } = Reflect;
|
|
96
96
|
var isPrimitive = require_is_primitive();
|
|
97
97
|
var isPlainObject2 = require_is_plain_object();
|
|
98
|
-
var
|
|
98
|
+
var isObject2 = (value) => {
|
|
99
99
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
100
100
|
};
|
|
101
101
|
var isUnsafeKey = (key) => {
|
|
@@ -163,7 +163,7 @@ var require_set_value = __commonJS({
|
|
|
163
163
|
}
|
|
164
164
|
return parts;
|
|
165
165
|
};
|
|
166
|
-
var
|
|
166
|
+
var split2 = (input, options) => {
|
|
167
167
|
if (options && typeof options.split === "function") return options.split(input);
|
|
168
168
|
if (typeof input === "symbol") return [input];
|
|
169
169
|
if (Array.isArray(input)) return input;
|
|
@@ -186,8 +186,8 @@ var require_set_value = __commonJS({
|
|
|
186
186
|
return obj;
|
|
187
187
|
};
|
|
188
188
|
var setValue = (target, path10, value, options) => {
|
|
189
|
-
if (!path10 || !
|
|
190
|
-
const keys =
|
|
189
|
+
if (!path10 || !isObject2(target)) return target;
|
|
190
|
+
const keys = split2(path10, options);
|
|
191
191
|
let obj = target;
|
|
192
192
|
for (let i = 0; i < keys.length; i++) {
|
|
193
193
|
const key = keys[i];
|
|
@@ -201,14 +201,14 @@ var require_set_value = __commonJS({
|
|
|
201
201
|
obj = obj[key] = [];
|
|
202
202
|
continue;
|
|
203
203
|
}
|
|
204
|
-
if (!
|
|
204
|
+
if (!isObject2(obj[key])) {
|
|
205
205
|
obj[key] = {};
|
|
206
206
|
}
|
|
207
207
|
obj = obj[key];
|
|
208
208
|
}
|
|
209
209
|
return target;
|
|
210
210
|
};
|
|
211
|
-
setValue.split =
|
|
211
|
+
setValue.split = split2;
|
|
212
212
|
setValue.cache = /* @__PURE__ */ new Map();
|
|
213
213
|
setValue.clear = () => {
|
|
214
214
|
setValue.cache = /* @__PURE__ */ new Map();
|
|
@@ -217,96 +217,6 @@ var require_set_value = __commonJS({
|
|
|
217
217
|
}
|
|
218
218
|
});
|
|
219
219
|
|
|
220
|
-
// ../../node_modules/.pnpm/get-value@3.0.1/node_modules/get-value/index.js
|
|
221
|
-
var require_get_value = __commonJS({
|
|
222
|
-
"../../node_modules/.pnpm/get-value@3.0.1/node_modules/get-value/index.js"(exports2, module2) {
|
|
223
|
-
"use strict";
|
|
224
|
-
init_cjs_shims();
|
|
225
|
-
var isObject = require_isobject();
|
|
226
|
-
module2.exports = function(target, path10, options) {
|
|
227
|
-
if (!isObject(options)) {
|
|
228
|
-
options = { default: options };
|
|
229
|
-
}
|
|
230
|
-
if (!isValidObject(target)) {
|
|
231
|
-
return typeof options.default !== "undefined" ? options.default : target;
|
|
232
|
-
}
|
|
233
|
-
if (typeof path10 === "number") {
|
|
234
|
-
path10 = String(path10);
|
|
235
|
-
}
|
|
236
|
-
const isArray = Array.isArray(path10);
|
|
237
|
-
const isString = typeof path10 === "string";
|
|
238
|
-
const splitChar = options.separator || ".";
|
|
239
|
-
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
240
|
-
if (!isString && !isArray) {
|
|
241
|
-
return target;
|
|
242
|
-
}
|
|
243
|
-
if (isString && path10 in target) {
|
|
244
|
-
return isValid(path10, target, options) ? target[path10] : options.default;
|
|
245
|
-
}
|
|
246
|
-
let segs = isArray ? path10 : split(path10, splitChar, options);
|
|
247
|
-
let len = segs.length;
|
|
248
|
-
let idx = 0;
|
|
249
|
-
do {
|
|
250
|
-
let prop = segs[idx];
|
|
251
|
-
if (typeof prop === "number") {
|
|
252
|
-
prop = String(prop);
|
|
253
|
-
}
|
|
254
|
-
while (prop && prop.slice(-1) === "\\") {
|
|
255
|
-
prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
|
|
256
|
-
}
|
|
257
|
-
if (prop in target) {
|
|
258
|
-
if (!isValid(prop, target, options)) {
|
|
259
|
-
return options.default;
|
|
260
|
-
}
|
|
261
|
-
target = target[prop];
|
|
262
|
-
} else {
|
|
263
|
-
let hasProp = false;
|
|
264
|
-
let n = idx + 1;
|
|
265
|
-
while (n < len) {
|
|
266
|
-
prop = join([prop, segs[n++]], joinChar, options);
|
|
267
|
-
if (hasProp = prop in target) {
|
|
268
|
-
if (!isValid(prop, target, options)) {
|
|
269
|
-
return options.default;
|
|
270
|
-
}
|
|
271
|
-
target = target[prop];
|
|
272
|
-
idx = n - 1;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
if (!hasProp) {
|
|
277
|
-
return options.default;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
} while (++idx < len && isValidObject(target));
|
|
281
|
-
if (idx === len) {
|
|
282
|
-
return target;
|
|
283
|
-
}
|
|
284
|
-
return options.default;
|
|
285
|
-
};
|
|
286
|
-
function join(segs, joinChar, options) {
|
|
287
|
-
if (typeof options.join === "function") {
|
|
288
|
-
return options.join(segs);
|
|
289
|
-
}
|
|
290
|
-
return segs[0] + joinChar + segs[1];
|
|
291
|
-
}
|
|
292
|
-
function split(path10, splitChar, options) {
|
|
293
|
-
if (typeof options.split === "function") {
|
|
294
|
-
return options.split(path10);
|
|
295
|
-
}
|
|
296
|
-
return path10.split(splitChar);
|
|
297
|
-
}
|
|
298
|
-
function isValid(key, target, options) {
|
|
299
|
-
if (typeof options.isValid === "function") {
|
|
300
|
-
return options.isValid(key, target);
|
|
301
|
-
}
|
|
302
|
-
return true;
|
|
303
|
-
}
|
|
304
|
-
function isValidObject(val) {
|
|
305
|
-
return isObject(val) || Array.isArray(val) || typeof val === "function";
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
|
|
310
220
|
// src/cli.ts
|
|
311
221
|
init_cjs_shims();
|
|
312
222
|
|
|
@@ -320,7 +230,7 @@ init_cjs_shims();
|
|
|
320
230
|
|
|
321
231
|
// package.json
|
|
322
232
|
var name = "@icebreakers/monorepo";
|
|
323
|
-
var version = "0.6.
|
|
233
|
+
var version = "0.6.24";
|
|
324
234
|
|
|
325
235
|
// src/create.ts
|
|
326
236
|
init_cjs_shims();
|
|
@@ -399,6 +309,7 @@ var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
|
399
309
|
// src/create.ts
|
|
400
310
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
401
311
|
var import_pathe = __toESM(require("pathe"), 1);
|
|
312
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
402
313
|
var import_set_value = __toESM(require_set_value(), 1);
|
|
403
314
|
|
|
404
315
|
// src/logger.ts
|
|
@@ -410,29 +321,33 @@ var logger = (0, import_consola.createConsola)();
|
|
|
410
321
|
var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
|
|
411
322
|
var __dirname = import_pathe.default.dirname(__filename2);
|
|
412
323
|
var templatesDir = import_pathe.default.join(__dirname, "../templates");
|
|
324
|
+
var defaultTemplate = "tsup";
|
|
325
|
+
var fromMap = {
|
|
326
|
+
tsup: "bar",
|
|
327
|
+
unbuild: "foo"
|
|
328
|
+
};
|
|
413
329
|
async function createNewProject(options) {
|
|
414
|
-
const
|
|
415
|
-
const { name: name2, renameJson, cwd: cwd2 } = defu(options, {
|
|
330
|
+
const { name: targetName, renameJson, cwd: cwd2, type } = defu(options, {
|
|
416
331
|
cwd: import_node_process.default.cwd(),
|
|
417
|
-
name: defaultTemplate,
|
|
332
|
+
name: fromMap[defaultTemplate],
|
|
418
333
|
renameJson: false
|
|
419
334
|
});
|
|
420
|
-
const
|
|
421
|
-
const from = import_pathe.default.join(templatesDir,
|
|
422
|
-
const to = import_pathe.default.join(cwd2,
|
|
335
|
+
const bundlerName = type ?? defaultTemplate;
|
|
336
|
+
const from = import_pathe.default.join(templatesDir, fromMap[bundlerName]);
|
|
337
|
+
const to = import_pathe.default.join(cwd2, targetName);
|
|
423
338
|
const filelist = await import_fs_extra.default.readdir(from);
|
|
424
339
|
for (const filename of filelist) {
|
|
425
340
|
if (filename === "package.json") {
|
|
426
341
|
const sourceJsonPath = import_pathe.default.resolve(from, filename);
|
|
427
342
|
const sourceJson = await import_fs_extra.default.readJson(sourceJsonPath);
|
|
428
343
|
(0, import_set_value.default)(sourceJson, "version", "0.0.0");
|
|
429
|
-
(0, import_set_value.default)(sourceJson, "name", import_pathe.default.basename(
|
|
344
|
+
(0, import_set_value.default)(sourceJson, "name", import_pathe.default.basename(targetName));
|
|
430
345
|
await import_fs_extra.default.outputJson(import_pathe.default.resolve(to, renameJson ? "package.mock.json" : filename), sourceJson, { spaces: 2 });
|
|
431
346
|
} else {
|
|
432
347
|
await import_fs_extra.default.copy(import_pathe.default.resolve(from, filename), import_pathe.default.resolve(to, filename));
|
|
433
348
|
}
|
|
434
349
|
}
|
|
435
|
-
logger.success(`${
|
|
350
|
+
logger.success(`${import_picocolors.default.bgGreenBright(import_picocolors.default.white(`[${bundlerName}]`))} ${targetName} \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01`);
|
|
436
351
|
}
|
|
437
352
|
|
|
438
353
|
// src/monorepo/index.ts
|
|
@@ -526,7 +441,96 @@ async function cleanProjects(cwd2) {
|
|
|
526
441
|
|
|
527
442
|
// src/monorepo/git.ts
|
|
528
443
|
init_cjs_shims();
|
|
529
|
-
|
|
444
|
+
|
|
445
|
+
// ../../node_modules/.pnpm/get-value@4.0.1/node_modules/get-value/dist/index.mjs
|
|
446
|
+
init_cjs_shims();
|
|
447
|
+
var __defProp2 = Object.defineProperty;
|
|
448
|
+
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
|
|
449
|
+
var isObject = /* @__PURE__ */ __name((v) => v !== null && typeof v === "object", "isObject");
|
|
450
|
+
var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
|
|
451
|
+
if (typeof options.join === "function") {
|
|
452
|
+
return options.join(segs);
|
|
453
|
+
}
|
|
454
|
+
return segs[0] + joinChar + segs[1];
|
|
455
|
+
}, "join");
|
|
456
|
+
var split = /* @__PURE__ */ __name((path10, splitChar, options) => {
|
|
457
|
+
if (typeof options.split === "function") {
|
|
458
|
+
return options.split(path10);
|
|
459
|
+
}
|
|
460
|
+
return path10.split(splitChar);
|
|
461
|
+
}, "split");
|
|
462
|
+
var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
463
|
+
if (typeof options?.isValid === "function") {
|
|
464
|
+
return options.isValid(key, target);
|
|
465
|
+
}
|
|
466
|
+
return true;
|
|
467
|
+
}, "isValid");
|
|
468
|
+
var isValidObject = /* @__PURE__ */ __name((v) => {
|
|
469
|
+
return isObject(v) || typeof v === "function";
|
|
470
|
+
}, "isValidObject");
|
|
471
|
+
var getValue = /* @__PURE__ */ __name((target, path10, options = {}) => {
|
|
472
|
+
if (!isObject(options)) {
|
|
473
|
+
options = { default: options };
|
|
474
|
+
}
|
|
475
|
+
if (!isValidObject(target)) {
|
|
476
|
+
return typeof options.default !== "undefined" ? options.default : target;
|
|
477
|
+
}
|
|
478
|
+
if (typeof path10 === "number") {
|
|
479
|
+
path10 = String(path10);
|
|
480
|
+
}
|
|
481
|
+
const pathIsArray = Array.isArray(path10);
|
|
482
|
+
const pathIsString = typeof path10 === "string";
|
|
483
|
+
const splitChar = options.separator || ".";
|
|
484
|
+
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
485
|
+
if (!pathIsString && !pathIsArray) {
|
|
486
|
+
return target;
|
|
487
|
+
}
|
|
488
|
+
if (target[path10] !== void 0) {
|
|
489
|
+
return isValid(path10, target, options) ? target[path10] : options.default;
|
|
490
|
+
}
|
|
491
|
+
const segs = pathIsArray ? path10 : split(path10, splitChar, options);
|
|
492
|
+
const len = segs.length;
|
|
493
|
+
let idx = 0;
|
|
494
|
+
do {
|
|
495
|
+
let prop = segs[idx];
|
|
496
|
+
if (typeof prop !== "string") {
|
|
497
|
+
prop = String(prop);
|
|
498
|
+
}
|
|
499
|
+
while (prop && prop.slice(-1) === "\\") {
|
|
500
|
+
prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
|
|
501
|
+
}
|
|
502
|
+
if (target[prop] !== void 0) {
|
|
503
|
+
if (!isValid(prop, target, options)) {
|
|
504
|
+
return options.default;
|
|
505
|
+
}
|
|
506
|
+
target = target[prop];
|
|
507
|
+
} else {
|
|
508
|
+
let hasProp = false;
|
|
509
|
+
let n = idx + 1;
|
|
510
|
+
while (n < len) {
|
|
511
|
+
prop = join([prop, segs[n++]], joinChar, options);
|
|
512
|
+
if (hasProp = target[prop] !== void 0) {
|
|
513
|
+
if (!isValid(prop, target, options)) {
|
|
514
|
+
return options.default;
|
|
515
|
+
}
|
|
516
|
+
target = target[prop];
|
|
517
|
+
idx = n - 1;
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
if (!hasProp) {
|
|
522
|
+
return options.default;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
} while (++idx < len && isValidObject(target));
|
|
526
|
+
if (idx === len) {
|
|
527
|
+
return target;
|
|
528
|
+
}
|
|
529
|
+
return options.default;
|
|
530
|
+
}, "getValue");
|
|
531
|
+
var index_default = getValue;
|
|
532
|
+
|
|
533
|
+
// src/monorepo/git.ts
|
|
530
534
|
var import_git_url_parse = __toESM(require("git-url-parse"), 1);
|
|
531
535
|
var import_simple_git = require("simple-git");
|
|
532
536
|
var GitClient = class {
|
|
@@ -552,7 +556,7 @@ var GitClient = class {
|
|
|
552
556
|
}
|
|
553
557
|
async getGitUrl() {
|
|
554
558
|
const config = await this.getConfig();
|
|
555
|
-
const x = (
|
|
559
|
+
const x = index_default(config, "remote.origin.url");
|
|
556
560
|
if (x) {
|
|
557
561
|
return (0, import_git_url_parse.default)(x);
|
|
558
562
|
}
|
|
@@ -565,8 +569,8 @@ var GitClient = class {
|
|
|
565
569
|
}
|
|
566
570
|
async getUser() {
|
|
567
571
|
const config = await this.getConfig();
|
|
568
|
-
const name2 = (
|
|
569
|
-
const email = (
|
|
572
|
+
const name2 = index_default(config, "user.name");
|
|
573
|
+
const email = index_default(config, "user.email");
|
|
570
574
|
return {
|
|
571
575
|
name: name2,
|
|
572
576
|
email
|
|
@@ -722,15 +726,15 @@ var import_node_os = __toESM(require("os"), 1);
|
|
|
722
726
|
var import_execa = require("execa");
|
|
723
727
|
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
724
728
|
var import_pathe8 = __toESM(require("pathe"), 1);
|
|
725
|
-
var
|
|
729
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
726
730
|
async function syncNpmMirror(cwd2) {
|
|
727
731
|
const packages = await getWorkspacePackages(cwd2);
|
|
728
732
|
logger.info(`[\u5F53\u524D\u5DE5\u4F5C\u533ARepo]:
|
|
729
|
-
${packages.map((x) => `- ${
|
|
733
|
+
${packages.map((x) => `- ${import_picocolors2.default.green(x.manifest.name)} : ${import_pathe8.default.relative(cwd2, x.rootDir)}`).join("\n")}
|
|
730
734
|
`);
|
|
731
735
|
const set6 = new Set(packages.map((x) => x.manifest.name));
|
|
732
736
|
logger.info(`[\u5373\u5C06\u540C\u6B65\u7684\u5305]:
|
|
733
|
-
${Array.from(set6).map((x) => `- ${
|
|
737
|
+
${Array.from(set6).map((x) => `- ${import_picocolors2.default.green(x)}`).join("\n")}
|
|
734
738
|
`);
|
|
735
739
|
const concurrency = Math.max(import_node_os.default.cpus().length, 1);
|
|
736
740
|
const queue2 = new import_p_queue.default({ concurrency });
|
|
@@ -752,11 +756,10 @@ var import_node_url2 = require("url");
|
|
|
752
756
|
var import_checkbox = __toESM(require("@inquirer/checkbox"), 1);
|
|
753
757
|
var import_confirm = __toESM(require("@inquirer/confirm"), 1);
|
|
754
758
|
var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
755
|
-
var import_get_value2 = __toESM(require_get_value(), 1);
|
|
756
759
|
var import_klaw = __toESM(require("klaw"), 1);
|
|
757
760
|
var import_p_queue2 = __toESM(require("p-queue"), 1);
|
|
758
761
|
var import_pathe9 = __toESM(require("pathe"), 1);
|
|
759
|
-
var
|
|
762
|
+
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
760
763
|
var import_set_value5 = __toESM(require_set_value(), 1);
|
|
761
764
|
|
|
762
765
|
// src/scripts.ts
|
|
@@ -792,7 +795,8 @@ function getAssetTargets(raw) {
|
|
|
792
795
|
// turbo
|
|
793
796
|
"turbo.json",
|
|
794
797
|
// vitest
|
|
795
|
-
"vitest.
|
|
798
|
+
"vitest.config.ts",
|
|
799
|
+
// 'vitest.workspace.ts',
|
|
796
800
|
// #region docker
|
|
797
801
|
"Dockerfile",
|
|
798
802
|
".dockerignore"
|
|
@@ -849,11 +853,11 @@ function isWorkspace(version2) {
|
|
|
849
853
|
return false;
|
|
850
854
|
}
|
|
851
855
|
function setPkgJson(sourcePkgJson, targetPkgJson) {
|
|
852
|
-
const packageManager = (
|
|
853
|
-
const deps = (
|
|
854
|
-
const devDeps = (
|
|
855
|
-
const targetDeps = (
|
|
856
|
-
const targetDevDeps = (
|
|
856
|
+
const packageManager = index_default(sourcePkgJson, "packageManager", { default: "" });
|
|
857
|
+
const deps = index_default(sourcePkgJson, "dependencies", { default: {} });
|
|
858
|
+
const devDeps = index_default(sourcePkgJson, "devDependencies", { default: {} });
|
|
859
|
+
const targetDeps = index_default(targetPkgJson, "dependencies", { default: {} });
|
|
860
|
+
const targetDevDeps = index_default(targetPkgJson, "devDependencies", { default: {} });
|
|
857
861
|
(0, import_set_value5.default)(targetPkgJson, "packageManager", packageManager);
|
|
858
862
|
Object.entries(deps).forEach((x) => {
|
|
859
863
|
if (!isWorkspace(targetDeps[x[0]])) {
|
|
@@ -872,7 +876,7 @@ function setPkgJson(sourcePkgJson, targetPkgJson) {
|
|
|
872
876
|
}
|
|
873
877
|
}
|
|
874
878
|
function confirmOverwrite(filename) {
|
|
875
|
-
return (0, import_confirm.default)({ message: `${
|
|
879
|
+
return (0, import_confirm.default)({ message: `${import_picocolors3.default.greenBright(filename)} \u6587\u4EF6\u5185\u5BB9\u53D1\u751F\u6539\u53D8,\u662F\u5426\u8986\u76D6?`, default: false });
|
|
876
880
|
}
|
|
877
881
|
async function upgradeMonorepo(opts) {
|
|
878
882
|
const { outDir, raw, interactive, cwd: cwd2 } = defu(opts, {
|
|
@@ -977,10 +981,12 @@ import_commander.program.command("mirror").description("\u8BBE\u7F6E VscodeBinar
|
|
|
977
981
|
await setVscodeBinaryMirror(cwd);
|
|
978
982
|
logger.success("set vscode binary mirror finished!");
|
|
979
983
|
});
|
|
980
|
-
import_commander.program.command("new").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B50\u5305").alias("create").argument("[name]").action(async (name2) => {
|
|
984
|
+
import_commander.program.command("new").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B50\u5305").alias("create").argument("[name]").option("--tsup").option("--unbuild").action(async (name2, options) => {
|
|
985
|
+
const type = options.tsup ? "tsup" : options.unbuild ? "unbuild" : void 0;
|
|
981
986
|
await createNewProject({
|
|
982
987
|
name: name2,
|
|
983
|
-
cwd
|
|
988
|
+
cwd,
|
|
989
|
+
type
|
|
984
990
|
});
|
|
985
991
|
logger.success("create a package");
|
|
986
992
|
});
|
|
@@ -1022,11 +1028,11 @@ set-value/index.js:
|
|
|
1022
1028
|
* Released under the MIT License.
|
|
1023
1029
|
*)
|
|
1024
1030
|
|
|
1025
|
-
get-value/index.
|
|
1031
|
+
get-value/dist/index.mjs:
|
|
1026
1032
|
(*!
|
|
1027
1033
|
* get-value <https://github.com/jonschlinkert/get-value>
|
|
1028
1034
|
*
|
|
1029
|
-
* Copyright (c) 2014-
|
|
1035
|
+
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
1030
1036
|
* Released under the MIT License.
|
|
1031
1037
|
*)
|
|
1032
1038
|
*/
|
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
syncNpmMirror,
|
|
12
12
|
upgradeMonorepo,
|
|
13
13
|
version
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-YMAPO4ZI.js";
|
|
15
15
|
|
|
16
16
|
// src/cli.ts
|
|
17
17
|
init_esm_shims();
|
|
@@ -28,32 +28,37 @@ import { fileURLToPath } from "node:url";
|
|
|
28
28
|
var import_set_value = __toESM(require_set_value(), 1);
|
|
29
29
|
import fs from "fs-extra";
|
|
30
30
|
import path from "pathe";
|
|
31
|
+
import pc from "picocolors";
|
|
31
32
|
var __filename = fileURLToPath(import.meta.url);
|
|
32
33
|
var __dirname = path.dirname(__filename);
|
|
33
34
|
var templatesDir = path.join(__dirname, "../templates");
|
|
35
|
+
var defaultTemplate = "tsup";
|
|
36
|
+
var fromMap = {
|
|
37
|
+
tsup: "bar",
|
|
38
|
+
unbuild: "foo"
|
|
39
|
+
};
|
|
34
40
|
async function createNewProject(options) {
|
|
35
|
-
const
|
|
36
|
-
const { name: name2, renameJson, cwd: cwd2 } = defu(options, {
|
|
41
|
+
const { name: targetName, renameJson, cwd: cwd2, type } = defu(options, {
|
|
37
42
|
cwd: process.cwd(),
|
|
38
|
-
name: defaultTemplate,
|
|
43
|
+
name: fromMap[defaultTemplate],
|
|
39
44
|
renameJson: false
|
|
40
45
|
});
|
|
41
|
-
const
|
|
42
|
-
const from = path.join(templatesDir,
|
|
43
|
-
const to = path.join(cwd2,
|
|
46
|
+
const bundlerName = type ?? defaultTemplate;
|
|
47
|
+
const from = path.join(templatesDir, fromMap[bundlerName]);
|
|
48
|
+
const to = path.join(cwd2, targetName);
|
|
44
49
|
const filelist = await fs.readdir(from);
|
|
45
50
|
for (const filename of filelist) {
|
|
46
51
|
if (filename === "package.json") {
|
|
47
52
|
const sourceJsonPath = path.resolve(from, filename);
|
|
48
53
|
const sourceJson = await fs.readJson(sourceJsonPath);
|
|
49
54
|
(0, import_set_value.default)(sourceJson, "version", "0.0.0");
|
|
50
|
-
(0, import_set_value.default)(sourceJson, "name", path.basename(
|
|
55
|
+
(0, import_set_value.default)(sourceJson, "name", path.basename(targetName));
|
|
51
56
|
await fs.outputJson(path.resolve(to, renameJson ? "package.mock.json" : filename), sourceJson, { spaces: 2 });
|
|
52
57
|
} else {
|
|
53
58
|
await fs.copy(path.resolve(from, filename), path.resolve(to, filename));
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
|
-
logger.success(`${
|
|
61
|
+
logger.success(`${pc.bgGreenBright(pc.white(`[${bundlerName}]`))} ${targetName} \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01`);
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
// src/program.ts
|
|
@@ -79,10 +84,12 @@ program.command("mirror").description("\u8BBE\u7F6E VscodeBinaryMirror").action(
|
|
|
79
84
|
await setVscodeBinaryMirror(cwd);
|
|
80
85
|
logger.success("set vscode binary mirror finished!");
|
|
81
86
|
});
|
|
82
|
-
program.command("new").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B50\u5305").alias("create").argument("[name]").action(async (name2) => {
|
|
87
|
+
program.command("new").description("\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u5B50\u5305").alias("create").argument("[name]").option("--tsup").option("--unbuild").action(async (name2, options) => {
|
|
88
|
+
const type = options.tsup ? "tsup" : options.unbuild ? "unbuild" : void 0;
|
|
83
89
|
await createNewProject({
|
|
84
90
|
name: name2,
|
|
85
|
-
cwd
|
|
91
|
+
cwd,
|
|
92
|
+
type
|
|
86
93
|
});
|
|
87
94
|
logger.success("create a package");
|
|
88
95
|
});
|