@icebreakers/monorepo 0.7.11 → 1.0.1
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 +13 -13
- package/dist/{chunk-MUNJQQ7U.js → chunk-OIMX7CDP.js} +102 -76
- package/dist/cli.cjs +96 -64
- package/dist/cli.js +16 -8
- package/dist/index.cjs +84 -60
- package/dist/index.js +1 -1
- package/package.json +4 -6
- package/templates/vue-ui/eslint.config.js +9 -0
- package/templates/vue-ui/index.html +13 -0
- package/templates/vue-ui/lib/HelloWorld.vue +19 -0
- package/templates/vue-ui/lib/index.ts +3 -0
- package/templates/vue-ui/package.json +57 -0
- package/templates/vue-ui/src/App.vue +9 -0
- package/templates/vue-ui/src/main.ts +5 -0
- package/templates/vue-ui/src/style.css +0 -0
- package/templates/vue-ui/src/vite-env.d.ts +1 -0
- package/templates/vue-ui/test/index.test.ts +13 -0
- package/templates/vue-ui/tsconfig.app.json +29 -0
- package/templates/vue-ui/tsconfig.json +14 -0
- package/templates/vue-ui/tsconfig.node.json +25 -0
- package/templates/vue-ui/tsconfig.test.json +40 -0
- package/templates/vue-ui/vite.config.ts +36 -0
- package/templates/vue-ui/vite.shared.config.ts +16 -0
- package/templates/vue-ui/vitest.config.ts +10 -0
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.11.0",
|
|
7
7
|
"author": "ice breaker <1324318532@qq.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -33,38 +33,38 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@changesets/changelog-github": "^0.5.1",
|
|
36
|
-
"@changesets/cli": "^2.29.
|
|
36
|
+
"@changesets/cli": "^2.29.4",
|
|
37
37
|
"@commitlint/cli": "^19.8.0",
|
|
38
38
|
"@commitlint/config-conventional": "^19.8.0",
|
|
39
39
|
"@commitlint/prompt-cli": "^19.8.0",
|
|
40
40
|
"@commitlint/types": "^19.8.0",
|
|
41
|
-
"@icebreakers/eslint-config": "^1.1.
|
|
41
|
+
"@icebreakers/eslint-config": "^1.1.5",
|
|
42
42
|
"@icebreakers/monorepo": "workspace:*",
|
|
43
|
-
"@icebreakers/stylelint-config": "^1.0.
|
|
43
|
+
"@icebreakers/stylelint-config": "^1.0.1",
|
|
44
44
|
"@types/fs-extra": "^11.0.4",
|
|
45
|
-
"@types/node": "^22.15.
|
|
46
|
-
"@vitest/coverage-v8": "~3.1.
|
|
45
|
+
"@types/node": "^22.15.18",
|
|
46
|
+
"@vitest/coverage-v8": "~3.1.4",
|
|
47
47
|
"ci-info": "^4.2.0",
|
|
48
48
|
"cross-env": "^7.0.3",
|
|
49
49
|
"defu": "^6.1.4",
|
|
50
|
-
"es-toolkit": "^1.
|
|
51
|
-
"eslint": "^9.
|
|
50
|
+
"es-toolkit": "^1.38.0",
|
|
51
|
+
"eslint": "^9.27.0",
|
|
52
52
|
"execa": "^9.5.2",
|
|
53
53
|
"fs-extra": "^11.3.0",
|
|
54
54
|
"husky": "^9.1.6",
|
|
55
|
-
"lint-staged": "^
|
|
55
|
+
"lint-staged": "^16.0.0",
|
|
56
56
|
"only-allow": "^1.2.1",
|
|
57
57
|
"pathe": "^2.0.3",
|
|
58
58
|
"pkg-types": "^2.1.0",
|
|
59
59
|
"rimraf": "^6.0.1",
|
|
60
60
|
"tslib": "^2.8.0",
|
|
61
|
-
"tsup": "^8.
|
|
62
|
-
"tsx": "^4.19.
|
|
61
|
+
"tsup": "^8.5.0",
|
|
62
|
+
"tsx": "^4.19.4",
|
|
63
63
|
"turbo": "^2.5.2",
|
|
64
64
|
"typescript": "^5.8.2",
|
|
65
65
|
"unbuild": "^3.5.0",
|
|
66
|
-
"vitest": "~3.1.
|
|
67
|
-
"yaml": "^2.
|
|
66
|
+
"vitest": "~3.1.4",
|
|
67
|
+
"yaml": "^2.8.0"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public",
|
|
@@ -27,9 +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.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.8_@types+node@22.15.23__jiti@2.4.2_postcss@8.5_b914d2c7671fefba2a17179d863c3344/node_modules/tsup/assets/esm_shims.js
|
|
31
|
+
import path from "path";
|
|
32
|
+
import { fileURLToPath } from "url";
|
|
31
33
|
var init_esm_shims = __esm({
|
|
32
|
-
"../../node_modules/.pnpm/tsup@8.
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.8_@types+node@22.15.23__jiti@2.4.2_postcss@8.5_b914d2c7671fefba2a17179d863c3344/node_modules/tsup/assets/esm_shims.js"() {
|
|
33
35
|
"use strict";
|
|
34
36
|
}
|
|
35
37
|
});
|
|
@@ -181,9 +183,9 @@ var require_set_value = __commonJS({
|
|
|
181
183
|
}
|
|
182
184
|
return obj;
|
|
183
185
|
};
|
|
184
|
-
var setValue = (target,
|
|
185
|
-
if (!
|
|
186
|
-
const keys = split2(
|
|
186
|
+
var setValue = (target, path11, value, options) => {
|
|
187
|
+
if (!path11 || !isObject2(target)) return target;
|
|
188
|
+
const keys = split2(path11, options);
|
|
187
189
|
let obj = target;
|
|
188
190
|
for (let i = 0; i < keys.length; i++) {
|
|
189
191
|
const key = keys[i];
|
|
@@ -217,7 +219,7 @@ var require_set_value = __commonJS({
|
|
|
217
219
|
init_esm_shims();
|
|
218
220
|
import { parse, stringify } from "comment-json";
|
|
219
221
|
import fs from "fs-extra";
|
|
220
|
-
import
|
|
222
|
+
import path2 from "pathe";
|
|
221
223
|
|
|
222
224
|
// src/monorepo/mirror/sources.ts
|
|
223
225
|
init_esm_shims();
|
|
@@ -265,7 +267,7 @@ function setMirror(obj) {
|
|
|
265
267
|
|
|
266
268
|
// src/monorepo/binaryMirror.ts
|
|
267
269
|
async function setVscodeBinaryMirror(cwd) {
|
|
268
|
-
const targetJsonPath =
|
|
270
|
+
const targetJsonPath = path2.resolve(cwd, ".vscode/settings.json");
|
|
269
271
|
await fs.ensureFile(targetJsonPath);
|
|
270
272
|
const json = parse(await fs.readFile(targetJsonPath, "utf8"), void 0, false);
|
|
271
273
|
json && typeof json === "object" && setMirror(json);
|
|
@@ -277,17 +279,19 @@ async function setVscodeBinaryMirror(cwd) {
|
|
|
277
279
|
init_esm_shims();
|
|
278
280
|
var import_set_value2 = __toESM(require_set_value(), 1);
|
|
279
281
|
import fs2 from "fs-extra";
|
|
280
|
-
import
|
|
281
|
-
var
|
|
282
|
+
import path3 from "pathe";
|
|
283
|
+
var cleanDirs = [
|
|
282
284
|
"packages/monorepo",
|
|
283
|
-
"packages/
|
|
285
|
+
"packages/bar",
|
|
286
|
+
"packages/ui",
|
|
287
|
+
// 'packages/foo',
|
|
284
288
|
// 'apps/cli',
|
|
285
289
|
// 'apps/website',
|
|
286
290
|
"apps"
|
|
287
291
|
];
|
|
288
292
|
async function cleanProjects(cwd) {
|
|
289
|
-
for (const dir of
|
|
290
|
-
return
|
|
293
|
+
for (const dir of cleanDirs.map((x) => {
|
|
294
|
+
return path3.resolve(cwd, x);
|
|
291
295
|
})) {
|
|
292
296
|
await fs2.remove(dir);
|
|
293
297
|
}
|
|
@@ -313,11 +317,11 @@ var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
|
|
|
313
317
|
}
|
|
314
318
|
return segs[0] + joinChar + segs[1];
|
|
315
319
|
}, "join");
|
|
316
|
-
var split = /* @__PURE__ */ __name((
|
|
320
|
+
var split = /* @__PURE__ */ __name((path11, splitChar, options) => {
|
|
317
321
|
if (typeof options.split === "function") {
|
|
318
|
-
return options.split(
|
|
322
|
+
return options.split(path11);
|
|
319
323
|
}
|
|
320
|
-
return
|
|
324
|
+
return path11.split(splitChar);
|
|
321
325
|
}, "split");
|
|
322
326
|
var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
323
327
|
if (typeof options?.isValid === "function") {
|
|
@@ -328,27 +332,27 @@ var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
|
328
332
|
var isValidObject = /* @__PURE__ */ __name((v) => {
|
|
329
333
|
return isObject(v) || typeof v === "function";
|
|
330
334
|
}, "isValidObject");
|
|
331
|
-
var getValue = /* @__PURE__ */ __name((target,
|
|
335
|
+
var getValue = /* @__PURE__ */ __name((target, path11, options = {}) => {
|
|
332
336
|
if (!isObject(options)) {
|
|
333
337
|
options = { default: options };
|
|
334
338
|
}
|
|
335
339
|
if (!isValidObject(target)) {
|
|
336
340
|
return typeof options.default !== "undefined" ? options.default : target;
|
|
337
341
|
}
|
|
338
|
-
if (typeof
|
|
339
|
-
|
|
342
|
+
if (typeof path11 === "number") {
|
|
343
|
+
path11 = String(path11);
|
|
340
344
|
}
|
|
341
|
-
const pathIsArray = Array.isArray(
|
|
342
|
-
const pathIsString = typeof
|
|
345
|
+
const pathIsArray = Array.isArray(path11);
|
|
346
|
+
const pathIsString = typeof path11 === "string";
|
|
343
347
|
const splitChar = options.separator || ".";
|
|
344
348
|
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
345
349
|
if (!pathIsString && !pathIsArray) {
|
|
346
350
|
return target;
|
|
347
351
|
}
|
|
348
|
-
if (target[
|
|
349
|
-
return isValid(
|
|
352
|
+
if (target[path11] !== void 0) {
|
|
353
|
+
return isValid(path11, target, options) ? target[path11] : options.default;
|
|
350
354
|
}
|
|
351
|
-
const segs = pathIsArray ?
|
|
355
|
+
const segs = pathIsArray ? path11 : split(path11, splitChar, options);
|
|
352
356
|
const len = segs.length;
|
|
353
357
|
let idx = 0;
|
|
354
358
|
do {
|
|
@@ -512,9 +516,9 @@ var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
|
512
516
|
});
|
|
513
517
|
|
|
514
518
|
// src/monorepo/workspace.ts
|
|
515
|
-
import
|
|
519
|
+
import path4 from "pathe";
|
|
516
520
|
async function getWorkspacePackages(cwd, options) {
|
|
517
|
-
const posixCwd =
|
|
521
|
+
const posixCwd = path4.normalize(cwd);
|
|
518
522
|
const { ignoreRootPackage, ignorePrivatePackage, patterns } = defu(options, {
|
|
519
523
|
ignoreRootPackage: true,
|
|
520
524
|
ignorePrivatePackage: true
|
|
@@ -528,7 +532,7 @@ async function getWorkspacePackages(cwd, options) {
|
|
|
528
532
|
}
|
|
529
533
|
return true;
|
|
530
534
|
}).map((project) => {
|
|
531
|
-
const pkgJsonPath =
|
|
535
|
+
const pkgJsonPath = path4.resolve(project.rootDir, "package.json");
|
|
532
536
|
return {
|
|
533
537
|
...project,
|
|
534
538
|
pkgJsonPath
|
|
@@ -536,7 +540,7 @@ async function getWorkspacePackages(cwd, options) {
|
|
|
536
540
|
});
|
|
537
541
|
if (ignoreRootPackage) {
|
|
538
542
|
pkgs = pkgs.filter((x) => {
|
|
539
|
-
return
|
|
543
|
+
return path4.normalize(
|
|
540
544
|
x.rootDir
|
|
541
545
|
) !== posixCwd;
|
|
542
546
|
});
|
|
@@ -549,11 +553,11 @@ init_esm_shims();
|
|
|
549
553
|
|
|
550
554
|
// src/monorepo/context.ts
|
|
551
555
|
init_esm_shims();
|
|
552
|
-
import
|
|
556
|
+
import path5 from "pathe";
|
|
553
557
|
import "@pnpm/types";
|
|
554
558
|
async function createContext(cwd) {
|
|
555
559
|
const git = new GitClient();
|
|
556
|
-
const workspaceFilepath =
|
|
560
|
+
const workspaceFilepath = path5.resolve(cwd, "pnpm-workspace.yaml");
|
|
557
561
|
const projects = await getWorkspacePackages(cwd);
|
|
558
562
|
const gitUrl = await git.getGitUrl();
|
|
559
563
|
const gitUser = await git.getUser();
|
|
@@ -567,18 +571,39 @@ async function createContext(cwd) {
|
|
|
567
571
|
};
|
|
568
572
|
}
|
|
569
573
|
|
|
570
|
-
// src/monorepo/
|
|
574
|
+
// src/monorepo/setChangeset.ts
|
|
571
575
|
init_esm_shims();
|
|
572
576
|
var import_set_value3 = __toESM(require_set_value(), 1);
|
|
573
577
|
import fs3 from "fs-extra";
|
|
574
|
-
import
|
|
578
|
+
import path6 from "pathe";
|
|
579
|
+
async function setChangeset_default(ctx) {
|
|
580
|
+
const { gitUrl, workspaceFilepath } = ctx;
|
|
581
|
+
if (gitUrl && await fs3.exists(workspaceFilepath)) {
|
|
582
|
+
const changesetConfigPath = path6.resolve(path6.dirname(workspaceFilepath), ".changeset/config.json");
|
|
583
|
+
if (await fs3.exists(changesetConfigPath)) {
|
|
584
|
+
const changesetConfig = await fs3.readJson(
|
|
585
|
+
changesetConfigPath
|
|
586
|
+
);
|
|
587
|
+
if (gitUrl.full_name) {
|
|
588
|
+
(0, import_set_value3.default)(changesetConfig, "changelog.1.repo", gitUrl.full_name);
|
|
589
|
+
await fs3.outputJson(changesetConfigPath, changesetConfig, { spaces: 2 });
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// src/monorepo/setPkgJson.ts
|
|
596
|
+
init_esm_shims();
|
|
597
|
+
var import_set_value4 = __toESM(require_set_value(), 1);
|
|
598
|
+
import fs4 from "fs-extra";
|
|
599
|
+
import path7 from "pathe";
|
|
575
600
|
async function setPkgJson_default(ctx) {
|
|
576
601
|
const { gitUrl, gitUser, projects, cwd, workspaceFilepath } = ctx;
|
|
577
|
-
if (gitUrl && await
|
|
602
|
+
if (gitUrl && await fs4.exists(workspaceFilepath)) {
|
|
578
603
|
for (const project of projects) {
|
|
579
604
|
const pkgJson = project.manifest;
|
|
580
|
-
const directory =
|
|
581
|
-
(0,
|
|
605
|
+
const directory = path7.relative(cwd, project.rootDir);
|
|
606
|
+
(0, import_set_value4.default)(pkgJson, "bugs.url", `https://github.com/${gitUrl.full_name}/issues`);
|
|
582
607
|
const repository = {
|
|
583
608
|
type: "git",
|
|
584
609
|
url: `git+https://github.com/${gitUrl.full_name}.git`
|
|
@@ -586,11 +611,11 @@ async function setPkgJson_default(ctx) {
|
|
|
586
611
|
if (directory) {
|
|
587
612
|
repository.directory = directory;
|
|
588
613
|
}
|
|
589
|
-
(0,
|
|
614
|
+
(0, import_set_value4.default)(pkgJson, "repository", repository);
|
|
590
615
|
if (gitUser) {
|
|
591
|
-
(0,
|
|
616
|
+
(0, import_set_value4.default)(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
|
|
592
617
|
}
|
|
593
|
-
await
|
|
618
|
+
await fs4.writeJSON(project.pkgJsonPath, pkgJson, {
|
|
594
619
|
spaces: 2
|
|
595
620
|
});
|
|
596
621
|
}
|
|
@@ -599,8 +624,8 @@ async function setPkgJson_default(ctx) {
|
|
|
599
624
|
|
|
600
625
|
// src/monorepo/setReadme.ts
|
|
601
626
|
init_esm_shims();
|
|
602
|
-
import
|
|
603
|
-
import
|
|
627
|
+
import fs5 from "fs-extra";
|
|
628
|
+
import path8 from "pathe";
|
|
604
629
|
async function getRows(ctx) {
|
|
605
630
|
const { projects, git, cwd } = ctx;
|
|
606
631
|
const gitUrl = await git.getGitUrl();
|
|
@@ -612,7 +637,7 @@ async function getRows(ctx) {
|
|
|
612
637
|
}
|
|
613
638
|
rows.push("## Projects\n");
|
|
614
639
|
for (const project of projects) {
|
|
615
|
-
const p =
|
|
640
|
+
const p = path8.relative(cwd, project.rootDirRealPath);
|
|
616
641
|
if (p) {
|
|
617
642
|
const description = project.manifest.description ? `- ${project.manifest.description}` : "";
|
|
618
643
|
rows.push(`- [${project.manifest.name}](${p}) ${description}`);
|
|
@@ -640,23 +665,24 @@ async function getRows(ctx) {
|
|
|
640
665
|
}
|
|
641
666
|
async function setReadme_default(ctx) {
|
|
642
667
|
const rows = await getRows(ctx);
|
|
643
|
-
await
|
|
668
|
+
await fs5.writeFile(path8.resolve(ctx.cwd, "README.md"), `${rows.join("\n")}
|
|
644
669
|
`);
|
|
645
670
|
}
|
|
646
671
|
|
|
647
672
|
// src/monorepo/init.ts
|
|
648
673
|
async function init(cwd) {
|
|
649
674
|
const ctx = await createContext(cwd);
|
|
675
|
+
await setChangeset_default(ctx);
|
|
650
676
|
await setPkgJson_default(ctx);
|
|
651
677
|
await setReadme_default(ctx);
|
|
652
678
|
}
|
|
653
679
|
|
|
654
680
|
// src/monorepo/sync.ts
|
|
655
681
|
init_esm_shims();
|
|
656
|
-
import os from "
|
|
682
|
+
import os from "os";
|
|
657
683
|
import { execa } from "execa";
|
|
658
684
|
import PQueue from "p-queue";
|
|
659
|
-
import
|
|
685
|
+
import path9 from "pathe";
|
|
660
686
|
import pc from "picocolors";
|
|
661
687
|
|
|
662
688
|
// src/logger.ts
|
|
@@ -668,15 +694,15 @@ var logger = createConsola();
|
|
|
668
694
|
async function syncNpmMirror(cwd, options) {
|
|
669
695
|
const packages = await getWorkspacePackages(cwd, options);
|
|
670
696
|
logger.info(`[\u5F53\u524D\u5DE5\u4F5C\u533ARepo]:
|
|
671
|
-
${packages.map((x) => `- ${pc.green(x.manifest.name)} : ${
|
|
697
|
+
${packages.map((x) => `- ${pc.green(x.manifest.name)} : ${path9.relative(cwd, x.rootDir)}`).join("\n")}
|
|
672
698
|
`);
|
|
673
|
-
const
|
|
699
|
+
const set6 = new Set(packages.map((x) => x.manifest.name));
|
|
674
700
|
logger.info(`[\u5373\u5C06\u540C\u6B65\u7684\u5305]:
|
|
675
|
-
${Array.from(
|
|
701
|
+
${Array.from(set6).map((x) => `- ${pc.green(x)}`).join("\n")}
|
|
676
702
|
`);
|
|
677
703
|
const concurrency = Math.max(os.cpus().length, 1);
|
|
678
704
|
const queue2 = new PQueue({ concurrency });
|
|
679
|
-
for (const pkgName of
|
|
705
|
+
for (const pkgName of set6) {
|
|
680
706
|
if (pkgName) {
|
|
681
707
|
await queue2.add(async () => {
|
|
682
708
|
return execa({
|
|
@@ -692,7 +718,7 @@ init_esm_shims();
|
|
|
692
718
|
|
|
693
719
|
// src/utils/md5.ts
|
|
694
720
|
init_esm_shims();
|
|
695
|
-
import crypto from "
|
|
721
|
+
import crypto from "crypto";
|
|
696
722
|
function getFileHash(data) {
|
|
697
723
|
const hashSum = crypto.createHash("md5");
|
|
698
724
|
hashSum.update(data);
|
|
@@ -725,15 +751,15 @@ function isMatch(str, arr) {
|
|
|
725
751
|
|
|
726
752
|
// src/upgrade.ts
|
|
727
753
|
init_esm_shims();
|
|
728
|
-
import process from "
|
|
729
|
-
import { fileURLToPath } from "
|
|
754
|
+
import process from "process";
|
|
755
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
730
756
|
import checkbox from "@inquirer/checkbox";
|
|
731
757
|
import confirm from "@inquirer/confirm";
|
|
732
|
-
import
|
|
733
|
-
var
|
|
758
|
+
import fs6 from "fs-extra";
|
|
759
|
+
var import_set_value5 = __toESM(require_set_value(), 1);
|
|
734
760
|
import klaw from "klaw";
|
|
735
761
|
import PQueue2 from "p-queue";
|
|
736
|
-
import
|
|
762
|
+
import path10 from "pathe";
|
|
737
763
|
import pc2 from "picocolors";
|
|
738
764
|
|
|
739
765
|
// src/constants.ts
|
|
@@ -741,7 +767,7 @@ init_esm_shims();
|
|
|
741
767
|
|
|
742
768
|
// package.json
|
|
743
769
|
var name = "@icebreakers/monorepo";
|
|
744
|
-
var version = "0.
|
|
770
|
+
var version = "1.0.1";
|
|
745
771
|
|
|
746
772
|
// src/scripts.ts
|
|
747
773
|
init_esm_shims();
|
|
@@ -791,9 +817,9 @@ function getAssetTargets(raw) {
|
|
|
791
817
|
|
|
792
818
|
// src/upgrade.ts
|
|
793
819
|
var queue = new PQueue2({ concurrency: 1 });
|
|
794
|
-
var __filename2 =
|
|
795
|
-
var __dirname2 =
|
|
796
|
-
var assetsDir =
|
|
820
|
+
var __filename2 = fileURLToPath2(import.meta.url);
|
|
821
|
+
var __dirname2 = path10.dirname(__filename2);
|
|
822
|
+
var assetsDir = path10.join(__dirname2, "../assets");
|
|
797
823
|
function isWorkspace(version2) {
|
|
798
824
|
if (typeof version2 === "string") {
|
|
799
825
|
return version2.startsWith("workspace:");
|
|
@@ -806,21 +832,21 @@ function setPkgJson(sourcePkgJson, targetPkgJson) {
|
|
|
806
832
|
const devDeps = index_default(sourcePkgJson, "devDependencies", { default: {} });
|
|
807
833
|
const targetDeps = index_default(targetPkgJson, "dependencies", { default: {} });
|
|
808
834
|
const targetDevDeps = index_default(targetPkgJson, "devDependencies", { default: {} });
|
|
809
|
-
(0,
|
|
835
|
+
(0, import_set_value5.default)(targetPkgJson, "packageManager", packageManager);
|
|
810
836
|
Object.entries(deps).forEach((x) => {
|
|
811
837
|
if (!isWorkspace(targetDeps[x[0]])) {
|
|
812
|
-
(0,
|
|
838
|
+
(0, import_set_value5.default)(targetPkgJson, `dependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
|
|
813
839
|
}
|
|
814
840
|
});
|
|
815
841
|
Object.entries(devDeps).forEach((x) => {
|
|
816
842
|
if (x[0] === name) {
|
|
817
|
-
(0,
|
|
843
|
+
(0, import_set_value5.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, `^${version}`, { preservePaths: false });
|
|
818
844
|
} else if (!isWorkspace(targetDevDeps[x[0]])) {
|
|
819
|
-
(0,
|
|
845
|
+
(0, import_set_value5.default)(targetPkgJson, `devDependencies.${x[0].replaceAll(".", "\\.")}`, x[1], { preservePaths: false });
|
|
820
846
|
}
|
|
821
847
|
});
|
|
822
848
|
for (const [k, v] of scriptsEntries) {
|
|
823
|
-
(0,
|
|
849
|
+
(0, import_set_value5.default)(targetPkgJson, `scripts.${k}`, v);
|
|
824
850
|
}
|
|
825
851
|
}
|
|
826
852
|
function confirmOverwrite(filename) {
|
|
@@ -831,7 +857,7 @@ async function upgradeMonorepo(opts) {
|
|
|
831
857
|
cwd: process.cwd(),
|
|
832
858
|
outDir: ""
|
|
833
859
|
});
|
|
834
|
-
const absOutDir =
|
|
860
|
+
const absOutDir = path10.isAbsolute(outDir) ? outDir : path10.join(cwd, outDir);
|
|
835
861
|
const gitClient = new GitClient({
|
|
836
862
|
baseDir: cwd
|
|
837
863
|
});
|
|
@@ -853,20 +879,20 @@ async function upgradeMonorepo(opts) {
|
|
|
853
879
|
});
|
|
854
880
|
for await (const file of klaw(assetsDir, {
|
|
855
881
|
filter(p) {
|
|
856
|
-
const str =
|
|
882
|
+
const str = path10.relative(assetsDir, p);
|
|
857
883
|
return isMatch(str, regexpArr);
|
|
858
884
|
}
|
|
859
885
|
})) {
|
|
860
886
|
await queue.add(async () => {
|
|
861
887
|
if (file.stats.isFile()) {
|
|
862
|
-
const relPath =
|
|
863
|
-
const targetPath =
|
|
864
|
-
const targetIsExisted = await
|
|
888
|
+
const relPath = path10.relative(assetsDir, file.path);
|
|
889
|
+
const targetPath = path10.resolve(absOutDir, relPath);
|
|
890
|
+
const targetIsExisted = await fs6.exists(targetPath);
|
|
865
891
|
async function overwriteOrCopy(target) {
|
|
866
892
|
let isOverwrite = true;
|
|
867
893
|
if (targetIsExisted) {
|
|
868
|
-
const src = await
|
|
869
|
-
const dest = target ?? await
|
|
894
|
+
const src = await fs6.readFile(file.path);
|
|
895
|
+
const dest = target ?? await fs6.readFile(targetPath);
|
|
870
896
|
if (await isFileChanged(src, dest)) {
|
|
871
897
|
isOverwrite = await confirmOverwrite(relPath);
|
|
872
898
|
}
|
|
@@ -876,25 +902,25 @@ async function upgradeMonorepo(opts) {
|
|
|
876
902
|
if (relPath === "package.json") {
|
|
877
903
|
const sourcePath = file.path;
|
|
878
904
|
if (targetIsExisted) {
|
|
879
|
-
const sourcePkgJson = await
|
|
880
|
-
const targetPkgJson = await
|
|
905
|
+
const sourcePkgJson = await fs6.readJson(sourcePath);
|
|
906
|
+
const targetPkgJson = await fs6.readJson(targetPath);
|
|
881
907
|
setPkgJson(sourcePkgJson, targetPkgJson);
|
|
882
908
|
const data = JSON.stringify(targetPkgJson, void 0, 2);
|
|
883
|
-
await
|
|
909
|
+
await fs6.outputFile(targetPath, `${data}
|
|
884
910
|
`, "utf8");
|
|
885
911
|
logger.success(targetPath);
|
|
886
912
|
}
|
|
887
913
|
} else if (relPath === ".changeset/config.json" && repoName) {
|
|
888
|
-
const changesetJson = await
|
|
889
|
-
(0,
|
|
914
|
+
const changesetJson = await fs6.readJson(file.path);
|
|
915
|
+
(0, import_set_value5.default)(changesetJson, "changelog.1.repo", repoName);
|
|
890
916
|
const data = JSON.stringify(changesetJson, void 0, 2);
|
|
891
917
|
if (await overwriteOrCopy(data)) {
|
|
892
|
-
await
|
|
918
|
+
await fs6.outputFile(targetPath, `${data}
|
|
893
919
|
`, "utf8");
|
|
894
920
|
logger.success(targetPath);
|
|
895
921
|
}
|
|
896
922
|
} else if (await overwriteOrCopy()) {
|
|
897
|
-
await
|
|
923
|
+
await fs6.copy(
|
|
898
924
|
file.path,
|
|
899
925
|
targetPath
|
|
900
926
|
);
|