@icebreakers/monorepo 1.1.7 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/package.json +3 -3
- package/dist/{chunk-FLOYQDBY.js → chunk-EBATUF3S.js} +171 -107
- package/dist/cli.cjs +119 -115
- package/dist/cli.js +10 -71
- package/dist/index.cjs +158 -102
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +3 -3
- package/package.json +4 -2
- package/templates/tsup-template/package.json +0 -42
- package/templates/tsup-template/src/index.ts +0 -12
- package/templates/tsup-template/test/index.test.ts +0 -7
- package/templates/tsup-template/tsconfig.json +0 -15
- package/templates/tsup-template/tsup.config.ts +0 -18
- package/templates/tsup-template/vitest.config.ts +0 -15
- package/templates/unbuild-template/build.config.ts +0 -24
- package/templates/unbuild-template/package.json +0 -42
- package/templates/unbuild-template/src/index.ts +0 -9
- package/templates/unbuild-template/src/utils.ts +0 -3
- package/templates/unbuild-template/test/index.test.ts +0 -7
- package/templates/unbuild-template/tsconfig.json +0 -15
- package/templates/unbuild-template/vitest.config.ts +0 -15
- package/templates/vue-lib-template/eslint.config.js +0 -12
- package/templates/vue-lib-template/index.html +0 -13
- package/templates/vue-lib-template/lib/HelloWorld.vue +0 -21
- package/templates/vue-lib-template/lib/index.ts +0 -3
- package/templates/vue-lib-template/package.json +0 -61
- package/templates/vue-lib-template/src/App.vue +0 -9
- package/templates/vue-lib-template/src/main.ts +0 -8
- package/templates/vue-lib-template/src/pages/index.vue +0 -7
- package/templates/vue-lib-template/src/router/index.ts +0 -11
- package/templates/vue-lib-template/src/style.css +0 -1
- package/templates/vue-lib-template/src/vite-env.d.ts +0 -2
- package/templates/vue-lib-template/test/index.test.ts +0 -13
- package/templates/vue-lib-template/tsconfig.app.json +0 -30
- package/templates/vue-lib-template/tsconfig.json +0 -14
- package/templates/vue-lib-template/tsconfig.node.json +0 -25
- package/templates/vue-lib-template/tsconfig.test.json +0 -40
- package/templates/vue-lib-template/vite.config.ts +0 -47
- package/templates/vue-lib-template/vite.shared.config.ts +0 -13
- package/templates/vue-lib-template/vitest.config.ts +0 -13
package/assets/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"private": true,
|
|
6
|
-
"packageManager": "pnpm@10.
|
|
6
|
+
"packageManager": "pnpm@10.17.0",
|
|
7
7
|
"author": "ice breaker <1324318532@qq.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@icebreakers/monorepo": "workspace:*",
|
|
51
51
|
"@icebreakers/stylelint-config": "^1.1.4",
|
|
52
52
|
"@types/fs-extra": "^11.0.4",
|
|
53
|
-
"@types/node": "^24.5.
|
|
53
|
+
"@types/node": "^24.5.2",
|
|
54
54
|
"@vitest/coverage-v8": "~3.2.4",
|
|
55
55
|
"ci-info": "^4.3.0",
|
|
56
56
|
"cross-env": "^10.0.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"tsup": "^8.5.0",
|
|
70
70
|
"tsx": "^4.20.5",
|
|
71
71
|
"turbo": "^2.5.6",
|
|
72
|
-
"type-fest": "^5.0.
|
|
72
|
+
"type-fest": "^5.0.1",
|
|
73
73
|
"typescript": "^5.9.2",
|
|
74
74
|
"unbuild": "^3.6.1",
|
|
75
75
|
"vitest": "~3.2.4",
|
|
@@ -27,11 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.12_@types+node@24.5.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.12_@types+node@24.5.2__jiti@2.5.1_postcss@8.5._d1da7b371d2f426607ba6a1b179cf002/node_modules/tsup/assets/esm_shims.js
|
|
31
31
|
import path from "path";
|
|
32
32
|
import { fileURLToPath } from "url";
|
|
33
33
|
var init_esm_shims = __esm({
|
|
34
|
-
"../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.12_@types+node@24.5.
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.12_@types+node@24.5.2__jiti@2.5.1_postcss@8.5._d1da7b371d2f426607ba6a1b179cf002/node_modules/tsup/assets/esm_shims.js"() {
|
|
35
35
|
"use strict";
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -183,9 +183,9 @@ var require_set_value = __commonJS({
|
|
|
183
183
|
}
|
|
184
184
|
return obj;
|
|
185
185
|
};
|
|
186
|
-
var setValue = (target,
|
|
187
|
-
if (!
|
|
188
|
-
const keys = split2(
|
|
186
|
+
var setValue = (target, path13, value, options) => {
|
|
187
|
+
if (!path13 || !isObject2(target)) return target;
|
|
188
|
+
const keys = split2(path13, options);
|
|
189
189
|
let obj = target;
|
|
190
190
|
for (let i = 0; i < keys.length; i++) {
|
|
191
191
|
const key = keys[i];
|
|
@@ -360,6 +360,89 @@ async function cleanProjects(cwd) {
|
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
+
// src/monorepo/create.ts
|
|
364
|
+
init_esm_shims();
|
|
365
|
+
import process from "process";
|
|
366
|
+
var import_set_value2 = __toESM(require_set_value(), 1);
|
|
367
|
+
import fs2 from "fs-extra";
|
|
368
|
+
import path5 from "pathe";
|
|
369
|
+
import pc from "picocolors";
|
|
370
|
+
|
|
371
|
+
// src/constants.ts
|
|
372
|
+
init_esm_shims();
|
|
373
|
+
import path4 from "path";
|
|
374
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
375
|
+
|
|
376
|
+
// package.json
|
|
377
|
+
var name = "@icebreakers/monorepo";
|
|
378
|
+
var version = "1.2.0";
|
|
379
|
+
|
|
380
|
+
// src/constants.ts
|
|
381
|
+
var __filename2 = fileURLToPath2(import.meta.url);
|
|
382
|
+
var __dirname2 = path4.dirname(__filename2);
|
|
383
|
+
var templatesDir = path4.join(__dirname2, "../templates");
|
|
384
|
+
var assetsDir = path4.join(__dirname2, "../assets");
|
|
385
|
+
var rootDir = path4.join(__dirname2, "../../..");
|
|
386
|
+
|
|
387
|
+
// src/logger.ts
|
|
388
|
+
init_esm_shims();
|
|
389
|
+
import { createConsola } from "consola";
|
|
390
|
+
var logger = createConsola();
|
|
391
|
+
|
|
392
|
+
// src/monorepo/create.ts
|
|
393
|
+
var defaultTemplate = "unbuild";
|
|
394
|
+
var fromMap = {
|
|
395
|
+
"tsup": "packages/tsup-template",
|
|
396
|
+
"unbuild": "packages/unbuild-template",
|
|
397
|
+
"vue-lib": "packages/vue-lib-template",
|
|
398
|
+
"hono-server": "apps/server",
|
|
399
|
+
"vue-hono": "apps/client",
|
|
400
|
+
"vitepress": "apps/website",
|
|
401
|
+
"cli": "apps/cli"
|
|
402
|
+
};
|
|
403
|
+
var createChoices = [
|
|
404
|
+
{ name: "unbuild \u6253\u5305", value: "unbuild" },
|
|
405
|
+
{ name: "tsup \u6253\u5305", value: "tsup" },
|
|
406
|
+
{ name: "vue \u7EC4\u4EF6", value: "vue-lib" },
|
|
407
|
+
{ name: "vue hono \u5168\u6808", value: "vue-hono" },
|
|
408
|
+
{ name: "hono \u6A21\u677F", value: "hono-server" },
|
|
409
|
+
{ name: "vitepress \u6587\u6863", value: "vitepress" },
|
|
410
|
+
{ name: "cli \u6A21\u677F", value: "cli" }
|
|
411
|
+
];
|
|
412
|
+
async function createNewProject(options) {
|
|
413
|
+
const { name: targetName, renameJson, cwd, type } = defu(options, {
|
|
414
|
+
cwd: process.cwd(),
|
|
415
|
+
name: fromMap[defaultTemplate],
|
|
416
|
+
renameJson: false
|
|
417
|
+
});
|
|
418
|
+
const bundlerName = type ?? defaultTemplate;
|
|
419
|
+
const from = path5.join(templatesDir, fromMap[bundlerName]);
|
|
420
|
+
const to = path5.join(cwd, targetName);
|
|
421
|
+
const filelist = await fs2.readdir(from);
|
|
422
|
+
for (const filename of filelist) {
|
|
423
|
+
if (filename === "package.json") {
|
|
424
|
+
const sourceJsonPath = path5.resolve(from, filename);
|
|
425
|
+
const sourceJson = await fs2.readJson(sourceJsonPath);
|
|
426
|
+
(0, import_set_value2.default)(sourceJson, "version", "0.0.0");
|
|
427
|
+
(0, import_set_value2.default)(sourceJson, "name", path5.basename(targetName));
|
|
428
|
+
await fs2.outputJson(
|
|
429
|
+
path5.resolve(
|
|
430
|
+
to,
|
|
431
|
+
renameJson ? "package.mock.json" : filename
|
|
432
|
+
),
|
|
433
|
+
sourceJson,
|
|
434
|
+
{ spaces: 2 }
|
|
435
|
+
);
|
|
436
|
+
} else {
|
|
437
|
+
await fs2.copy(
|
|
438
|
+
path5.resolve(from, filename),
|
|
439
|
+
path5.resolve(to, filename)
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
logger.success(`${pc.bgGreenBright(pc.white(`[${bundlerName}]`))} ${targetName} \u9879\u76EE\u521B\u5EFA\u6210\u529F\uFF01`);
|
|
444
|
+
}
|
|
445
|
+
|
|
363
446
|
// src/monorepo/git/index.ts
|
|
364
447
|
init_esm_shims();
|
|
365
448
|
|
|
@@ -374,11 +457,11 @@ var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
|
|
|
374
457
|
}
|
|
375
458
|
return segs[0] + joinChar + segs[1];
|
|
376
459
|
}, "join");
|
|
377
|
-
var split = /* @__PURE__ */ __name((
|
|
460
|
+
var split = /* @__PURE__ */ __name((path13, splitChar, options) => {
|
|
378
461
|
if (typeof options.split === "function") {
|
|
379
|
-
return options.split(
|
|
462
|
+
return options.split(path13);
|
|
380
463
|
}
|
|
381
|
-
return
|
|
464
|
+
return path13.split(splitChar);
|
|
382
465
|
}, "split");
|
|
383
466
|
var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
384
467
|
if (typeof (options == null ? void 0 : options.isValid) === "function") {
|
|
@@ -389,27 +472,27 @@ var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
|
389
472
|
var isValidObject = /* @__PURE__ */ __name((v) => {
|
|
390
473
|
return isObject(v) || typeof v === "function";
|
|
391
474
|
}, "isValidObject");
|
|
392
|
-
var getValue = /* @__PURE__ */ __name((target,
|
|
475
|
+
var getValue = /* @__PURE__ */ __name((target, path13, options = {}) => {
|
|
393
476
|
if (!isObject(options)) {
|
|
394
477
|
options = { default: options };
|
|
395
478
|
}
|
|
396
479
|
if (!isValidObject(target)) {
|
|
397
480
|
return typeof options.default !== "undefined" ? options.default : target;
|
|
398
481
|
}
|
|
399
|
-
if (typeof
|
|
400
|
-
|
|
482
|
+
if (typeof path13 === "number") {
|
|
483
|
+
path13 = String(path13);
|
|
401
484
|
}
|
|
402
|
-
const pathIsArray = Array.isArray(
|
|
403
|
-
const pathIsString = typeof
|
|
485
|
+
const pathIsArray = Array.isArray(path13);
|
|
486
|
+
const pathIsString = typeof path13 === "string";
|
|
404
487
|
const splitChar = options.separator || ".";
|
|
405
488
|
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
406
489
|
if (!pathIsString && !pathIsArray) {
|
|
407
490
|
return target;
|
|
408
491
|
}
|
|
409
|
-
if (target[
|
|
410
|
-
return isValid(
|
|
492
|
+
if (target[path13] !== void 0) {
|
|
493
|
+
return isValid(path13, target, options) ? target[path13] : options.default;
|
|
411
494
|
}
|
|
412
|
-
const segs = pathIsArray ?
|
|
495
|
+
const segs = pathIsArray ? path13 : split(path13, splitChar, options);
|
|
413
496
|
const len = segs.length;
|
|
414
497
|
let idx = 0;
|
|
415
498
|
do {
|
|
@@ -504,12 +587,12 @@ init_esm_shims();
|
|
|
504
587
|
|
|
505
588
|
// src/monorepo/context/index.ts
|
|
506
589
|
init_esm_shims();
|
|
507
|
-
import
|
|
590
|
+
import path6 from "pathe";
|
|
508
591
|
import "@pnpm/types";
|
|
509
592
|
async function createContext(cwd) {
|
|
510
593
|
const git = new GitClient();
|
|
511
594
|
const { packages, workspaceDir } = await getWorkspaceData(cwd);
|
|
512
|
-
const workspaceFilepath =
|
|
595
|
+
const workspaceFilepath = path6.resolve(workspaceDir, "pnpm-workspace.yaml");
|
|
513
596
|
const gitUrl = await git.getGitUrl();
|
|
514
597
|
const gitUser = await git.getUser();
|
|
515
598
|
return {
|
|
@@ -525,20 +608,20 @@ async function createContext(cwd) {
|
|
|
525
608
|
|
|
526
609
|
// src/monorepo/init/setChangeset.ts
|
|
527
610
|
init_esm_shims();
|
|
528
|
-
var
|
|
529
|
-
import
|
|
530
|
-
import
|
|
611
|
+
var import_set_value3 = __toESM(require_set_value(), 1);
|
|
612
|
+
import fs3 from "fs-extra";
|
|
613
|
+
import path7 from "pathe";
|
|
531
614
|
async function setChangeset_default(ctx) {
|
|
532
615
|
const { gitUrl, workspaceFilepath } = ctx;
|
|
533
|
-
if (gitUrl && await
|
|
534
|
-
const changesetConfigPath =
|
|
535
|
-
if (await
|
|
536
|
-
const changesetConfig = await
|
|
616
|
+
if (gitUrl && await fs3.exists(workspaceFilepath)) {
|
|
617
|
+
const changesetConfigPath = path7.resolve(path7.dirname(workspaceFilepath), ".changeset/config.json");
|
|
618
|
+
if (await fs3.exists(changesetConfigPath)) {
|
|
619
|
+
const changesetConfig = await fs3.readJson(
|
|
537
620
|
changesetConfigPath
|
|
538
621
|
);
|
|
539
622
|
if (gitUrl.full_name) {
|
|
540
|
-
(0,
|
|
541
|
-
await
|
|
623
|
+
(0, import_set_value3.default)(changesetConfig, "changelog.1.repo", gitUrl.full_name);
|
|
624
|
+
await fs3.outputJson(changesetConfigPath, changesetConfig, { spaces: 2 });
|
|
542
625
|
}
|
|
543
626
|
}
|
|
544
627
|
}
|
|
@@ -546,16 +629,16 @@ async function setChangeset_default(ctx) {
|
|
|
546
629
|
|
|
547
630
|
// src/monorepo/init/setPkgJson.ts
|
|
548
631
|
init_esm_shims();
|
|
549
|
-
var
|
|
550
|
-
import
|
|
551
|
-
import
|
|
632
|
+
var import_set_value4 = __toESM(require_set_value(), 1);
|
|
633
|
+
import fs4 from "fs-extra";
|
|
634
|
+
import path8 from "pathe";
|
|
552
635
|
async function setPkgJson_default(ctx) {
|
|
553
636
|
const { gitUrl, gitUser, packages, cwd, workspaceFilepath } = ctx;
|
|
554
|
-
if (gitUrl && await
|
|
637
|
+
if (gitUrl && await fs4.exists(workspaceFilepath)) {
|
|
555
638
|
for (const pkg of packages) {
|
|
556
639
|
const pkgJson = pkg.manifest;
|
|
557
|
-
const directory =
|
|
558
|
-
(0,
|
|
640
|
+
const directory = path8.relative(cwd, pkg.rootDir);
|
|
641
|
+
(0, import_set_value4.default)(pkgJson, "bugs.url", `https://github.com/${gitUrl.full_name}/issues`);
|
|
559
642
|
const repository = {
|
|
560
643
|
type: "git",
|
|
561
644
|
url: `git+https://github.com/${gitUrl.full_name}.git`
|
|
@@ -563,11 +646,11 @@ async function setPkgJson_default(ctx) {
|
|
|
563
646
|
if (directory) {
|
|
564
647
|
repository.directory = directory;
|
|
565
648
|
}
|
|
566
|
-
(0,
|
|
649
|
+
(0, import_set_value4.default)(pkgJson, "repository", repository);
|
|
567
650
|
if (gitUser) {
|
|
568
|
-
(0,
|
|
651
|
+
(0, import_set_value4.default)(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
|
|
569
652
|
}
|
|
570
|
-
await
|
|
653
|
+
await fs4.writeJSON(pkg.pkgJsonPath, pkgJson, {
|
|
571
654
|
spaces: 2
|
|
572
655
|
});
|
|
573
656
|
}
|
|
@@ -576,8 +659,8 @@ async function setPkgJson_default(ctx) {
|
|
|
576
659
|
|
|
577
660
|
// src/monorepo/init/setReadme.ts
|
|
578
661
|
init_esm_shims();
|
|
579
|
-
import
|
|
580
|
-
import
|
|
662
|
+
import fs5 from "fs-extra";
|
|
663
|
+
import path9 from "pathe";
|
|
581
664
|
async function getRows(ctx) {
|
|
582
665
|
const { packages, git, cwd } = ctx;
|
|
583
666
|
const gitUrl = await git.getGitUrl();
|
|
@@ -589,7 +672,7 @@ async function getRows(ctx) {
|
|
|
589
672
|
}
|
|
590
673
|
rows.push("## Packages\n");
|
|
591
674
|
for (const pkg of packages) {
|
|
592
|
-
const p =
|
|
675
|
+
const p = path9.relative(cwd, pkg.rootDirRealPath);
|
|
593
676
|
if (p) {
|
|
594
677
|
const description = pkg.manifest.description ? `- ${pkg.manifest.description}` : "";
|
|
595
678
|
rows.push(`- [${pkg.manifest.name}](${p}) ${description}`);
|
|
@@ -617,7 +700,7 @@ async function getRows(ctx) {
|
|
|
617
700
|
}
|
|
618
701
|
async function setReadme_default(ctx) {
|
|
619
702
|
const rows = await getRows(ctx);
|
|
620
|
-
await
|
|
703
|
+
await fs5.writeFile(path9.resolve(ctx.cwd, "README.md"), `${rows.join("\n")}
|
|
621
704
|
`);
|
|
622
705
|
}
|
|
623
706
|
|
|
@@ -632,12 +715,12 @@ async function init(cwd) {
|
|
|
632
715
|
// src/monorepo/mirror/binaryMirror.ts
|
|
633
716
|
init_esm_shims();
|
|
634
717
|
import { parse, stringify } from "comment-json";
|
|
635
|
-
import
|
|
636
|
-
import
|
|
718
|
+
import fs6 from "fs-extra";
|
|
719
|
+
import path10 from "pathe";
|
|
637
720
|
|
|
638
721
|
// src/monorepo/mirror/utils.ts
|
|
639
722
|
init_esm_shims();
|
|
640
|
-
var
|
|
723
|
+
var import_set_value5 = __toESM(require_set_value(), 1);
|
|
641
724
|
|
|
642
725
|
// src/monorepo/mirror/sources.ts
|
|
643
726
|
init_esm_shims();
|
|
@@ -676,18 +759,18 @@ function setMirror(obj) {
|
|
|
676
759
|
const prefix = "terminal.integrated.env";
|
|
677
760
|
if (typeof obj === "object" && obj) {
|
|
678
761
|
for (const platform of platforms) {
|
|
679
|
-
(0,
|
|
762
|
+
(0, import_set_value5.default)(obj, [prefix, platform].join(".").replaceAll(".", "\\."), chinaMirrorsEnvs);
|
|
680
763
|
}
|
|
681
764
|
}
|
|
682
765
|
}
|
|
683
766
|
|
|
684
767
|
// src/monorepo/mirror/binaryMirror.ts
|
|
685
768
|
async function setVscodeBinaryMirror(cwd) {
|
|
686
|
-
const targetJsonPath =
|
|
687
|
-
await
|
|
688
|
-
const json = parse(await
|
|
769
|
+
const targetJsonPath = path10.resolve(cwd, ".vscode/settings.json");
|
|
770
|
+
await fs6.ensureFile(targetJsonPath);
|
|
771
|
+
const json = parse(await fs6.readFile(targetJsonPath, "utf8"), void 0, false);
|
|
689
772
|
json && typeof json === "object" && setMirror(json);
|
|
690
|
-
await
|
|
773
|
+
await fs6.writeFile(targetJsonPath, `${stringify(json, void 0, 2)}
|
|
691
774
|
`, "utf8");
|
|
692
775
|
}
|
|
693
776
|
|
|
@@ -696,27 +779,20 @@ init_esm_shims();
|
|
|
696
779
|
import os from "os";
|
|
697
780
|
import { execa } from "execa";
|
|
698
781
|
import PQueue from "p-queue";
|
|
699
|
-
import
|
|
700
|
-
import
|
|
701
|
-
|
|
702
|
-
// src/logger.ts
|
|
703
|
-
init_esm_shims();
|
|
704
|
-
import { createConsola } from "consola";
|
|
705
|
-
var logger = createConsola();
|
|
706
|
-
|
|
707
|
-
// src/monorepo/sync.ts
|
|
782
|
+
import path11 from "pathe";
|
|
783
|
+
import pc2 from "picocolors";
|
|
708
784
|
async function syncNpmMirror(cwd, options) {
|
|
709
785
|
const { packages, workspaceDir } = await getWorkspaceData(cwd, options);
|
|
710
786
|
logger.info(`[\u5F53\u524D\u5DE5\u4F5C\u533ARepo]:
|
|
711
|
-
${packages.map((x) => `- ${
|
|
787
|
+
${packages.map((x) => `- ${pc2.green(x.manifest.name)} : ${path11.relative(workspaceDir, x.rootDir)}`).join("\n")}
|
|
712
788
|
`);
|
|
713
|
-
const
|
|
789
|
+
const set7 = new Set(packages.map((x) => x.manifest.name));
|
|
714
790
|
logger.info(`[\u5373\u5C06\u540C\u6B65\u7684\u5305]:
|
|
715
|
-
${Array.from(
|
|
791
|
+
${Array.from(set7).map((x) => `- ${pc2.green(x)}`).join("\n")}
|
|
716
792
|
`);
|
|
717
793
|
const concurrency = Math.max(os.cpus().length, 1);
|
|
718
794
|
const queue2 = new PQueue({ concurrency });
|
|
719
|
-
for (const pkgName of
|
|
795
|
+
for (const pkgName of set7) {
|
|
720
796
|
if (pkgName) {
|
|
721
797
|
await queue2.add(async () => {
|
|
722
798
|
return execa({
|
|
@@ -727,9 +803,6 @@ ${Array.from(set6).map((x) => `- ${pc.green(x)}`).join("\n")}
|
|
|
727
803
|
}
|
|
728
804
|
}
|
|
729
805
|
|
|
730
|
-
// src/monorepo/index.ts
|
|
731
|
-
init_esm_shims();
|
|
732
|
-
|
|
733
806
|
// src/utils/md5.ts
|
|
734
807
|
init_esm_shims();
|
|
735
808
|
import crypto from "crypto";
|
|
@@ -763,25 +836,17 @@ function isMatch(str, arr) {
|
|
|
763
836
|
return false;
|
|
764
837
|
}
|
|
765
838
|
|
|
766
|
-
// src/upgrade.ts
|
|
839
|
+
// src/monorepo/upgrade.ts
|
|
767
840
|
init_esm_shims();
|
|
768
|
-
import
|
|
769
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
841
|
+
import process2 from "process";
|
|
770
842
|
import checkbox2 from "@inquirer/checkbox";
|
|
771
843
|
import confirm from "@inquirer/confirm";
|
|
772
|
-
import
|
|
773
|
-
var
|
|
844
|
+
import fs7 from "fs-extra";
|
|
845
|
+
var import_set_value6 = __toESM(require_set_value(), 1);
|
|
774
846
|
import klaw from "klaw";
|
|
775
847
|
import PQueue2 from "p-queue";
|
|
776
|
-
import
|
|
777
|
-
import
|
|
778
|
-
|
|
779
|
-
// src/constants.ts
|
|
780
|
-
init_esm_shims();
|
|
781
|
-
|
|
782
|
-
// package.json
|
|
783
|
-
var name = "@icebreakers/monorepo";
|
|
784
|
-
var version = "1.1.7";
|
|
848
|
+
import path12 from "pathe";
|
|
849
|
+
import pc3 from "picocolors";
|
|
785
850
|
|
|
786
851
|
// src/scripts.ts
|
|
787
852
|
init_esm_shims();
|
|
@@ -830,11 +895,8 @@ function getAssetTargets(raw) {
|
|
|
830
895
|
return list;
|
|
831
896
|
}
|
|
832
897
|
|
|
833
|
-
// src/upgrade.ts
|
|
898
|
+
// src/monorepo/upgrade.ts
|
|
834
899
|
var queue = new PQueue2({ concurrency: 1 });
|
|
835
|
-
var __filename2 = fileURLToPath2(import.meta.url);
|
|
836
|
-
var __dirname2 = path10.dirname(__filename2);
|
|
837
|
-
var assetsDir = path10.join(__dirname2, "../assets");
|
|
838
900
|
function isWorkspace(version2) {
|
|
839
901
|
if (typeof version2 === "string") {
|
|
840
902
|
return version2.startsWith("workspace:");
|
|
@@ -847,32 +909,32 @@ function setPkgJson(sourcePkgJson, targetPkgJson) {
|
|
|
847
909
|
const devDeps = index_default(sourcePkgJson, "devDependencies", { default: {} });
|
|
848
910
|
const targetDeps = index_default(targetPkgJson, "dependencies", { default: {} });
|
|
849
911
|
const targetDevDeps = index_default(targetPkgJson, "devDependencies", { default: {} });
|
|
850
|
-
(0,
|
|
912
|
+
(0, import_set_value6.default)(targetPkgJson, "packageManager", packageManager);
|
|
851
913
|
Object.entries(deps).forEach((x) => {
|
|
852
914
|
if (!isWorkspace(targetDeps[x[0]])) {
|
|
853
|
-
(0,
|
|
915
|
+
(0, import_set_value6.default)(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
|
|
854
916
|
}
|
|
855
917
|
});
|
|
856
918
|
Object.entries(devDeps).forEach((x) => {
|
|
857
919
|
if (x[0] === name) {
|
|
858
|
-
(0,
|
|
920
|
+
(0, import_set_value6.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, `^${version}`, { preservePaths: false });
|
|
859
921
|
} else if (!isWorkspace(targetDevDeps[x[0]])) {
|
|
860
|
-
(0,
|
|
922
|
+
(0, import_set_value6.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
|
|
861
923
|
}
|
|
862
924
|
});
|
|
863
925
|
for (const [k, v] of scriptsEntries) {
|
|
864
|
-
(0,
|
|
926
|
+
(0, import_set_value6.default)(targetPkgJson, `scripts.${k}`, v);
|
|
865
927
|
}
|
|
866
928
|
}
|
|
867
929
|
function confirmOverwrite(filename) {
|
|
868
|
-
return confirm({ message: `${
|
|
930
|
+
return confirm({ message: `${pc3.greenBright(filename)} \u6587\u4EF6\u5185\u5BB9\u53D1\u751F\u6539\u53D8,\u662F\u5426\u8986\u76D6?`, default: true });
|
|
869
931
|
}
|
|
870
932
|
async function upgradeMonorepo(opts) {
|
|
871
933
|
const { outDir, raw, interactive, cwd, skipOverwrite } = defu(opts, {
|
|
872
|
-
cwd:
|
|
934
|
+
cwd: process2.cwd(),
|
|
873
935
|
outDir: ""
|
|
874
936
|
});
|
|
875
|
-
const absOutDir =
|
|
937
|
+
const absOutDir = path12.isAbsolute(outDir) ? outDir : path12.join(cwd, outDir);
|
|
876
938
|
const gitClient = new GitClient({
|
|
877
939
|
baseDir: cwd
|
|
878
940
|
});
|
|
@@ -894,20 +956,20 @@ async function upgradeMonorepo(opts) {
|
|
|
894
956
|
});
|
|
895
957
|
for await (const file of klaw(assetsDir, {
|
|
896
958
|
filter(p) {
|
|
897
|
-
const str =
|
|
959
|
+
const str = path12.relative(assetsDir, p);
|
|
898
960
|
return isMatch(str, regexpArr);
|
|
899
961
|
}
|
|
900
962
|
})) {
|
|
901
963
|
await queue.add(async () => {
|
|
902
964
|
if (file.stats.isFile()) {
|
|
903
|
-
const relPath =
|
|
904
|
-
const targetPath =
|
|
905
|
-
const targetIsExisted = await
|
|
965
|
+
const relPath = path12.relative(assetsDir, file.path);
|
|
966
|
+
const targetPath = path12.resolve(absOutDir, relPath);
|
|
967
|
+
const targetIsExisted = await fs7.exists(targetPath);
|
|
906
968
|
async function overwriteOrCopy(target) {
|
|
907
969
|
let isOverwrite = true;
|
|
908
970
|
if (targetIsExisted) {
|
|
909
|
-
const src = await
|
|
910
|
-
const dest = target ?? await
|
|
971
|
+
const src = await fs7.readFile(file.path);
|
|
972
|
+
const dest = target ?? await fs7.readFile(targetPath);
|
|
911
973
|
if (await isFileChanged(src, dest)) {
|
|
912
974
|
isOverwrite = await confirmOverwrite(relPath);
|
|
913
975
|
}
|
|
@@ -919,25 +981,25 @@ async function upgradeMonorepo(opts) {
|
|
|
919
981
|
if (relPath === "package.json") {
|
|
920
982
|
const sourcePath = file.path;
|
|
921
983
|
if (targetIsExisted) {
|
|
922
|
-
const sourcePkgJson = await
|
|
923
|
-
const targetPkgJson = await
|
|
984
|
+
const sourcePkgJson = await fs7.readJson(sourcePath);
|
|
985
|
+
const targetPkgJson = await fs7.readJson(targetPath);
|
|
924
986
|
setPkgJson(sourcePkgJson, targetPkgJson);
|
|
925
987
|
const data = JSON.stringify(targetPkgJson, void 0, 2);
|
|
926
|
-
await
|
|
988
|
+
await fs7.outputFile(targetPath, `${data}
|
|
927
989
|
`, "utf8");
|
|
928
990
|
logger.success(targetPath);
|
|
929
991
|
}
|
|
930
992
|
} else if (relPath === ".changeset/config.json" && repoName) {
|
|
931
|
-
const changesetJson = await
|
|
932
|
-
(0,
|
|
993
|
+
const changesetJson = await fs7.readJson(file.path);
|
|
994
|
+
(0, import_set_value6.default)(changesetJson, "changelog.1.repo", repoName);
|
|
933
995
|
const data = JSON.stringify(changesetJson, void 0, 2);
|
|
934
996
|
if (await overwriteOrCopy(data)) {
|
|
935
|
-
await
|
|
997
|
+
await fs7.outputFile(targetPath, `${data}
|
|
936
998
|
`, "utf8");
|
|
937
999
|
logger.success(targetPath);
|
|
938
1000
|
}
|
|
939
1001
|
} else if (await overwriteOrCopy()) {
|
|
940
|
-
await
|
|
1002
|
+
await fs7.copy(
|
|
941
1003
|
file.path,
|
|
942
1004
|
targetPath
|
|
943
1005
|
);
|
|
@@ -948,17 +1010,20 @@ async function upgradeMonorepo(opts) {
|
|
|
948
1010
|
}
|
|
949
1011
|
}
|
|
950
1012
|
|
|
1013
|
+
// src/monorepo/index.ts
|
|
1014
|
+
init_esm_shims();
|
|
1015
|
+
|
|
951
1016
|
export {
|
|
952
|
-
__toESM,
|
|
953
1017
|
name,
|
|
954
1018
|
version,
|
|
955
1019
|
init_esm_shims,
|
|
956
|
-
defu,
|
|
957
|
-
require_set_value,
|
|
958
1020
|
logger,
|
|
959
1021
|
getWorkspacePackages,
|
|
960
1022
|
getWorkspaceData,
|
|
961
1023
|
cleanProjects,
|
|
1024
|
+
defaultTemplate,
|
|
1025
|
+
createChoices,
|
|
1026
|
+
createNewProject,
|
|
962
1027
|
GitClient,
|
|
963
1028
|
init,
|
|
964
1029
|
setVscodeBinaryMirror,
|
|
@@ -967,7 +1032,6 @@ export {
|
|
|
967
1032
|
isFileChanged,
|
|
968
1033
|
escapeStringRegexp,
|
|
969
1034
|
isMatch,
|
|
970
|
-
setPkgJson,
|
|
971
1035
|
upgradeMonorepo
|
|
972
1036
|
};
|
|
973
1037
|
/*! Bundled license information:
|