@xylabs/ts-scripts-common 7.5.0 → 7.5.2
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/actions/index.mjs +197 -110
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/packman/convert.mjs +187 -100
- package/dist/actions/packman/convert.mjs.map +1 -1
- package/dist/actions/packman/convertToPnpm.mjs +114 -38
- package/dist/actions/packman/convertToPnpm.mjs.map +1 -1
- package/dist/actions/packman/convertToYarn.mjs +104 -38
- package/dist/actions/packman/convertToYarn.mjs.map +1 -1
- package/dist/actions/packman/index.mjs +187 -100
- package/dist/actions/packman/index.mjs.map +1 -1
- package/dist/actions/packman/swapTsScriptsDependency.mjs +57 -0
- package/dist/actions/packman/swapTsScriptsDependency.mjs.map +1 -0
- package/dist/bin/xy.mjs +214 -127
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +216 -129
- package/dist/index.mjs.map +1 -1
- package/dist/xy/common/index.mjs +187 -100
- package/dist/xy/common/index.mjs.map +1 -1
- package/dist/xy/common/packmanCommand.mjs +187 -100
- package/dist/xy/common/packmanCommand.mjs.map +1 -1
- package/dist/xy/index.mjs +214 -127
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +214 -127
- package/dist/xy/xy.mjs.map +1 -1
- package/package.json +2 -2
package/dist/actions/index.mjs
CHANGED
|
@@ -3488,24 +3488,24 @@ function packageLintMonorepo(fix2 = false) {
|
|
|
3488
3488
|
|
|
3489
3489
|
// src/actions/packman/convert.ts
|
|
3490
3490
|
import {
|
|
3491
|
-
existsSync as
|
|
3491
|
+
existsSync as existsSync14,
|
|
3492
3492
|
readdirSync as readdirSync7,
|
|
3493
|
-
readFileSync as
|
|
3493
|
+
readFileSync as readFileSync14,
|
|
3494
3494
|
statSync as statSync3
|
|
3495
3495
|
} from "fs";
|
|
3496
|
-
import
|
|
3497
|
-
import
|
|
3496
|
+
import PATH14 from "path";
|
|
3497
|
+
import chalk47 from "chalk";
|
|
3498
3498
|
|
|
3499
3499
|
// src/actions/packman/convertToPnpm.ts
|
|
3500
3500
|
import {
|
|
3501
|
-
existsSync as
|
|
3501
|
+
existsSync as existsSync12,
|
|
3502
3502
|
mkdirSync as mkdirSync5,
|
|
3503
|
-
readFileSync as
|
|
3503
|
+
readFileSync as readFileSync12,
|
|
3504
3504
|
rmSync as rmSync3,
|
|
3505
|
-
writeFileSync as
|
|
3505
|
+
writeFileSync as writeFileSync9
|
|
3506
3506
|
} from "fs";
|
|
3507
|
-
import
|
|
3508
|
-
import
|
|
3507
|
+
import PATH12 from "path";
|
|
3508
|
+
import chalk45 from "chalk";
|
|
3509
3509
|
|
|
3510
3510
|
// src/actions/packman/rewriteScripts.ts
|
|
3511
3511
|
function rewriteYarnToPnpm(script) {
|
|
@@ -3555,6 +3555,60 @@ function rewriteScriptsInPackageJson(pkg, direction) {
|
|
|
3555
3555
|
return { ...pkg, scripts: rewritten };
|
|
3556
3556
|
}
|
|
3557
3557
|
|
|
3558
|
+
// src/actions/packman/swapTsScriptsDependency.ts
|
|
3559
|
+
import {
|
|
3560
|
+
existsSync as existsSync11,
|
|
3561
|
+
readFileSync as readFileSync11,
|
|
3562
|
+
writeFileSync as writeFileSync8
|
|
3563
|
+
} from "fs";
|
|
3564
|
+
import PATH11 from "path";
|
|
3565
|
+
import chalk44 from "chalk";
|
|
3566
|
+
var SWAP_MAP = {
|
|
3567
|
+
"yarn-to-pnpm": [
|
|
3568
|
+
["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"]
|
|
3569
|
+
],
|
|
3570
|
+
"pnpm-to-yarn": [
|
|
3571
|
+
["@xylabs/ts-scripts-pnpm", "@xylabs/ts-scripts-yarn3"]
|
|
3572
|
+
]
|
|
3573
|
+
};
|
|
3574
|
+
function swapInPackageJson(pkgPath, direction) {
|
|
3575
|
+
if (!existsSync11(pkgPath)) return false;
|
|
3576
|
+
const raw = readFileSync11(pkgPath, "utf8");
|
|
3577
|
+
const pkg = JSON.parse(raw);
|
|
3578
|
+
let changed = false;
|
|
3579
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
3580
|
+
const deps = pkg[depField];
|
|
3581
|
+
if (!deps) continue;
|
|
3582
|
+
for (const [from, to] of SWAP_MAP[direction]) {
|
|
3583
|
+
if (deps[from]) {
|
|
3584
|
+
deps[to] = deps[from];
|
|
3585
|
+
delete deps[from];
|
|
3586
|
+
changed = true;
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
if (changed) {
|
|
3591
|
+
writeFileSync8(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
3592
|
+
}
|
|
3593
|
+
return changed;
|
|
3594
|
+
}
|
|
3595
|
+
function swapTsScriptsDependency(cwd5, workspacePackageJsonPaths, direction) {
|
|
3596
|
+
let count = 0;
|
|
3597
|
+
if (swapInPackageJson(PATH11.join(cwd5, "package.json"), direction)) {
|
|
3598
|
+
count++;
|
|
3599
|
+
}
|
|
3600
|
+
for (const pkgPath of workspacePackageJsonPaths) {
|
|
3601
|
+
const fullPath = PATH11.resolve(cwd5, pkgPath, "package.json");
|
|
3602
|
+
if (swapInPackageJson(fullPath, direction)) {
|
|
3603
|
+
count++;
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
if (count > 0) {
|
|
3607
|
+
const target = direction === "yarn-to-pnpm" ? "@xylabs/ts-scripts-pnpm" : "@xylabs/ts-scripts-yarn3";
|
|
3608
|
+
console.log(chalk44.green(` Swapped ts-scripts dependency to ${target} in ${count} package(s)`));
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
|
|
3558
3612
|
// src/actions/packman/convertToPnpm.ts
|
|
3559
3613
|
var PNPM_VERSION = "10.12.1";
|
|
3560
3614
|
function createPnpmWorkspaceYaml(cwd5, workspacePatterns) {
|
|
@@ -3562,24 +3616,45 @@ function createPnpmWorkspaceYaml(cwd5, workspacePatterns) {
|
|
|
3562
3616
|
for (const pattern of workspacePatterns) {
|
|
3563
3617
|
lines.push(` - '${pattern}'`);
|
|
3564
3618
|
}
|
|
3565
|
-
|
|
3566
|
-
console.log(
|
|
3619
|
+
writeFileSync9(PATH12.join(cwd5, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
|
|
3620
|
+
console.log(chalk45.green(" Created pnpm-workspace.yaml"));
|
|
3621
|
+
}
|
|
3622
|
+
function readPnpmWorkspacePatterns(cwd5) {
|
|
3623
|
+
const wsPath = PATH12.join(cwd5, "pnpm-workspace.yaml");
|
|
3624
|
+
if (!existsSync12(wsPath)) return [];
|
|
3625
|
+
const content = readFileSync12(wsPath, "utf8");
|
|
3626
|
+
const patterns = [];
|
|
3627
|
+
const lines = content.split("\n");
|
|
3628
|
+
let inPackages = false;
|
|
3629
|
+
for (const line of lines) {
|
|
3630
|
+
if (line.trim() === "packages:") {
|
|
3631
|
+
inPackages = true;
|
|
3632
|
+
continue;
|
|
3633
|
+
}
|
|
3634
|
+
if (inPackages && /^\s+-\s+/.test(line)) {
|
|
3635
|
+
const pattern = line.replace(/^\s+-\s+/, "").replaceAll(/['"]/g, "").trim();
|
|
3636
|
+
if (pattern) patterns.push(pattern);
|
|
3637
|
+
} else if (inPackages && !/^\s/.test(line) && line.trim()) {
|
|
3638
|
+
inPackages = false;
|
|
3639
|
+
}
|
|
3640
|
+
}
|
|
3641
|
+
return patterns;
|
|
3567
3642
|
}
|
|
3568
3643
|
function updateRootPackageJson(cwd5) {
|
|
3569
|
-
const pkgPath =
|
|
3570
|
-
const pkg = JSON.parse(
|
|
3571
|
-
const workspacePatterns = pkg.workspaces ??
|
|
3644
|
+
const pkgPath = PATH12.join(cwd5, "package.json");
|
|
3645
|
+
const pkg = JSON.parse(readFileSync12(pkgPath, "utf8"));
|
|
3646
|
+
const workspacePatterns = pkg.workspaces ?? readPnpmWorkspacePatterns(cwd5);
|
|
3572
3647
|
delete pkg.workspaces;
|
|
3573
3648
|
pkg.packageManager = `pnpm@${PNPM_VERSION}`;
|
|
3574
3649
|
const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
|
|
3575
|
-
|
|
3576
|
-
console.log(
|
|
3650
|
+
writeFileSync9(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
3651
|
+
console.log(chalk45.green(" Updated root package.json"));
|
|
3577
3652
|
return workspacePatterns;
|
|
3578
3653
|
}
|
|
3579
3654
|
function updateGitignore(cwd5) {
|
|
3580
|
-
const gitignorePath =
|
|
3581
|
-
if (!
|
|
3582
|
-
let content =
|
|
3655
|
+
const gitignorePath = PATH12.join(cwd5, ".gitignore");
|
|
3656
|
+
if (!existsSync12(gitignorePath)) return;
|
|
3657
|
+
let content = readFileSync12(gitignorePath, "utf8");
|
|
3583
3658
|
const yarnLines = [
|
|
3584
3659
|
".pnp.*",
|
|
3585
3660
|
".pnp",
|
|
@@ -3594,63 +3669,64 @@ function updateGitignore(cwd5) {
|
|
|
3594
3669
|
content = content.replaceAll(new RegExp(String.raw`^${line.replaceAll(".", String.raw`\.`).replaceAll("*", String.raw`\*`).replaceAll("!", String.raw`\!`)}\s*$`, "gm"), "");
|
|
3595
3670
|
}
|
|
3596
3671
|
content = content.replaceAll(/\n{3,}/g, "\n\n");
|
|
3597
|
-
|
|
3598
|
-
console.log(
|
|
3672
|
+
writeFileSync9(gitignorePath, content, "utf8");
|
|
3673
|
+
console.log(chalk45.green(" Updated .gitignore"));
|
|
3599
3674
|
}
|
|
3600
3675
|
function deleteYarnArtifacts(cwd5) {
|
|
3601
|
-
const yarnLock =
|
|
3602
|
-
const yarnrc =
|
|
3603
|
-
const yarnDir =
|
|
3604
|
-
if (
|
|
3676
|
+
const yarnLock = PATH12.join(cwd5, "yarn.lock");
|
|
3677
|
+
const yarnrc = PATH12.join(cwd5, ".yarnrc.yml");
|
|
3678
|
+
const yarnDir = PATH12.join(cwd5, ".yarn");
|
|
3679
|
+
if (existsSync12(yarnLock)) {
|
|
3605
3680
|
rmSync3(yarnLock);
|
|
3606
|
-
console.log(
|
|
3681
|
+
console.log(chalk45.gray(" Deleted yarn.lock"));
|
|
3607
3682
|
}
|
|
3608
|
-
if (
|
|
3683
|
+
if (existsSync12(yarnrc)) {
|
|
3609
3684
|
rmSync3(yarnrc);
|
|
3610
|
-
console.log(
|
|
3685
|
+
console.log(chalk45.gray(" Deleted .yarnrc.yml"));
|
|
3611
3686
|
}
|
|
3612
|
-
if (
|
|
3687
|
+
if (existsSync12(yarnDir)) {
|
|
3613
3688
|
rmSync3(yarnDir, { force: true, recursive: true });
|
|
3614
|
-
console.log(
|
|
3689
|
+
console.log(chalk45.gray(" Deleted .yarn/"));
|
|
3615
3690
|
}
|
|
3616
3691
|
}
|
|
3617
3692
|
function createNpmrc(cwd5) {
|
|
3618
|
-
const npmrcPath =
|
|
3619
|
-
if (
|
|
3620
|
-
mkdirSync5(
|
|
3621
|
-
|
|
3622
|
-
console.log(
|
|
3693
|
+
const npmrcPath = PATH12.join(cwd5, ".npmrc");
|
|
3694
|
+
if (existsSync12(npmrcPath)) return;
|
|
3695
|
+
mkdirSync5(PATH12.dirname(npmrcPath), { recursive: true });
|
|
3696
|
+
writeFileSync9(npmrcPath, "", "utf8");
|
|
3697
|
+
console.log(chalk45.green(" Created .npmrc"));
|
|
3623
3698
|
}
|
|
3624
3699
|
function convertToPnpm(cwd5, workspacePackageJsonPaths) {
|
|
3625
|
-
console.log(
|
|
3700
|
+
console.log(chalk45.blue("\nConverting to pnpm...\n"));
|
|
3626
3701
|
const workspacePatterns = updateRootPackageJson(cwd5);
|
|
3627
3702
|
createPnpmWorkspaceYaml(cwd5, workspacePatterns);
|
|
3628
3703
|
for (const pkgPath of workspacePackageJsonPaths) {
|
|
3629
|
-
const fullPath =
|
|
3630
|
-
if (!
|
|
3631
|
-
const pkg = JSON.parse(
|
|
3704
|
+
const fullPath = PATH12.resolve(cwd5, pkgPath, "package.json");
|
|
3705
|
+
if (!existsSync12(fullPath)) continue;
|
|
3706
|
+
const pkg = JSON.parse(readFileSync12(fullPath, "utf8"));
|
|
3632
3707
|
const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
|
|
3633
3708
|
if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
|
|
3634
|
-
|
|
3709
|
+
writeFileSync9(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
3635
3710
|
}
|
|
3636
3711
|
}
|
|
3637
|
-
console.log(
|
|
3712
|
+
console.log(chalk45.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
|
|
3638
3713
|
updateGitignore(cwd5);
|
|
3639
3714
|
createNpmrc(cwd5);
|
|
3715
|
+
swapTsScriptsDependency(cwd5, workspacePackageJsonPaths, "yarn-to-pnpm");
|
|
3640
3716
|
deleteYarnArtifacts(cwd5);
|
|
3641
|
-
console.log(
|
|
3717
|
+
console.log(chalk45.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
|
|
3642
3718
|
return 0;
|
|
3643
3719
|
}
|
|
3644
3720
|
|
|
3645
3721
|
// src/actions/packman/convertToYarn.ts
|
|
3646
3722
|
import {
|
|
3647
|
-
existsSync as
|
|
3648
|
-
readFileSync as
|
|
3723
|
+
existsSync as existsSync13,
|
|
3724
|
+
readFileSync as readFileSync13,
|
|
3649
3725
|
rmSync as rmSync4,
|
|
3650
|
-
writeFileSync as
|
|
3726
|
+
writeFileSync as writeFileSync10
|
|
3651
3727
|
} from "fs";
|
|
3652
|
-
import
|
|
3653
|
-
import
|
|
3728
|
+
import PATH13 from "path";
|
|
3729
|
+
import chalk46 from "chalk";
|
|
3654
3730
|
var YARN_VERSION = "4.13.0";
|
|
3655
3731
|
var YARNRC_TEMPLATE = `compressionLevel: mixed
|
|
3656
3732
|
|
|
@@ -3671,10 +3747,10 @@ var YARN_GITIGNORE_ENTRIES = `
|
|
|
3671
3747
|
!.yarn/sdks
|
|
3672
3748
|
!.yarn/versions
|
|
3673
3749
|
`;
|
|
3674
|
-
function
|
|
3675
|
-
const wsPath =
|
|
3676
|
-
if (!
|
|
3677
|
-
const content =
|
|
3750
|
+
function readPnpmWorkspacePatterns2(cwd5) {
|
|
3751
|
+
const wsPath = PATH13.join(cwd5, "pnpm-workspace.yaml");
|
|
3752
|
+
if (!existsSync13(wsPath)) return [];
|
|
3753
|
+
const content = readFileSync13(wsPath, "utf8");
|
|
3678
3754
|
const patterns = [];
|
|
3679
3755
|
const lines = content.split("\n");
|
|
3680
3756
|
let inPackages = false;
|
|
@@ -3693,91 +3769,103 @@ function readPnpmWorkspacePatterns(cwd5) {
|
|
|
3693
3769
|
return patterns;
|
|
3694
3770
|
}
|
|
3695
3771
|
function updateRootPackageJson2(cwd5, workspacePatterns) {
|
|
3696
|
-
const pkgPath =
|
|
3697
|
-
const pkg = JSON.parse(
|
|
3772
|
+
const pkgPath = PATH13.join(cwd5, "package.json");
|
|
3773
|
+
const pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
|
|
3698
3774
|
pkg.workspaces = workspacePatterns;
|
|
3699
3775
|
pkg.packageManager = `yarn@${YARN_VERSION}`;
|
|
3700
3776
|
const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
|
|
3701
|
-
|
|
3702
|
-
console.log(
|
|
3777
|
+
writeFileSync10(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
3778
|
+
console.log(chalk46.green(" Updated root package.json"));
|
|
3703
3779
|
}
|
|
3704
3780
|
function updateGitignore2(cwd5) {
|
|
3705
|
-
const gitignorePath =
|
|
3706
|
-
let content =
|
|
3781
|
+
const gitignorePath = PATH13.join(cwd5, ".gitignore");
|
|
3782
|
+
let content = existsSync13(gitignorePath) ? readFileSync13(gitignorePath, "utf8") : "";
|
|
3707
3783
|
if (!content.includes(".yarn/*")) {
|
|
3708
3784
|
content = content.trimEnd() + "\n" + YARN_GITIGNORE_ENTRIES;
|
|
3709
3785
|
}
|
|
3710
|
-
|
|
3711
|
-
console.log(
|
|
3786
|
+
writeFileSync10(gitignorePath, content, "utf8");
|
|
3787
|
+
console.log(chalk46.green(" Updated .gitignore"));
|
|
3712
3788
|
}
|
|
3713
3789
|
function deletePnpmArtifacts(cwd5) {
|
|
3714
|
-
const lockfile =
|
|
3715
|
-
const workspaceYaml =
|
|
3716
|
-
const npmrc =
|
|
3717
|
-
if (
|
|
3790
|
+
const lockfile = PATH13.join(cwd5, "pnpm-lock.yaml");
|
|
3791
|
+
const workspaceYaml = PATH13.join(cwd5, "pnpm-workspace.yaml");
|
|
3792
|
+
const npmrc = PATH13.join(cwd5, ".npmrc");
|
|
3793
|
+
if (existsSync13(lockfile)) {
|
|
3718
3794
|
rmSync4(lockfile);
|
|
3719
|
-
console.log(
|
|
3795
|
+
console.log(chalk46.gray(" Deleted pnpm-lock.yaml"));
|
|
3720
3796
|
}
|
|
3721
|
-
if (
|
|
3797
|
+
if (existsSync13(workspaceYaml)) {
|
|
3722
3798
|
rmSync4(workspaceYaml);
|
|
3723
|
-
console.log(
|
|
3799
|
+
console.log(chalk46.gray(" Deleted pnpm-workspace.yaml"));
|
|
3724
3800
|
}
|
|
3725
|
-
if (
|
|
3726
|
-
const content =
|
|
3801
|
+
if (existsSync13(npmrc)) {
|
|
3802
|
+
const content = readFileSync13(npmrc, "utf8");
|
|
3727
3803
|
if (content.trim() === "" || content.includes("shamefully-hoist") || content.includes("node-linker")) {
|
|
3728
3804
|
rmSync4(npmrc);
|
|
3729
|
-
console.log(
|
|
3805
|
+
console.log(chalk46.gray(" Deleted .npmrc"));
|
|
3730
3806
|
}
|
|
3731
3807
|
}
|
|
3732
3808
|
}
|
|
3733
3809
|
function createYarnrc(cwd5) {
|
|
3734
|
-
const yarnrcPath =
|
|
3735
|
-
if (
|
|
3736
|
-
|
|
3737
|
-
console.log(
|
|
3810
|
+
const yarnrcPath = PATH13.join(cwd5, ".yarnrc.yml");
|
|
3811
|
+
if (existsSync13(yarnrcPath)) return;
|
|
3812
|
+
writeFileSync10(yarnrcPath, YARNRC_TEMPLATE, "utf8");
|
|
3813
|
+
console.log(chalk46.green(" Created .yarnrc.yml"));
|
|
3814
|
+
}
|
|
3815
|
+
function readWorkspacePatternsFromPackageJson(cwd5) {
|
|
3816
|
+
const pkgPath = PATH13.join(cwd5, "package.json");
|
|
3817
|
+
if (!existsSync13(pkgPath)) return [];
|
|
3818
|
+
const pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
|
|
3819
|
+
return pkg.workspaces ?? [];
|
|
3738
3820
|
}
|
|
3739
3821
|
function convertToYarn(cwd5, workspacePackageJsonPaths) {
|
|
3740
|
-
console.log(
|
|
3741
|
-
const workspacePatterns =
|
|
3822
|
+
console.log(chalk46.blue("\nConverting to yarn...\n"));
|
|
3823
|
+
const workspacePatterns = readPnpmWorkspacePatterns2(cwd5);
|
|
3742
3824
|
if (workspacePatterns.length === 0) {
|
|
3743
|
-
|
|
3825
|
+
const fromPkg = readWorkspacePatternsFromPackageJson(cwd5);
|
|
3826
|
+
if (fromPkg.length > 0) {
|
|
3827
|
+
workspacePatterns.push(...fromPkg);
|
|
3828
|
+
} else {
|
|
3829
|
+
console.warn(chalk46.yellow(" No workspace patterns found"));
|
|
3830
|
+
}
|
|
3744
3831
|
}
|
|
3745
3832
|
updateRootPackageJson2(cwd5, workspacePatterns);
|
|
3746
3833
|
for (const pkgPath of workspacePackageJsonPaths) {
|
|
3747
|
-
const fullPath =
|
|
3748
|
-
if (!
|
|
3749
|
-
const pkg = JSON.parse(
|
|
3834
|
+
const fullPath = PATH13.resolve(cwd5, pkgPath, "package.json");
|
|
3835
|
+
if (!existsSync13(fullPath)) continue;
|
|
3836
|
+
const pkg = JSON.parse(readFileSync13(fullPath, "utf8"));
|
|
3750
3837
|
const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
|
|
3751
3838
|
if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
|
|
3752
|
-
|
|
3839
|
+
writeFileSync10(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
3753
3840
|
}
|
|
3754
3841
|
}
|
|
3755
|
-
console.log(
|
|
3842
|
+
console.log(chalk46.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
|
|
3756
3843
|
updateGitignore2(cwd5);
|
|
3757
3844
|
createYarnrc(cwd5);
|
|
3845
|
+
swapTsScriptsDependency(cwd5, workspacePackageJsonPaths, "pnpm-to-yarn");
|
|
3758
3846
|
deletePnpmArtifacts(cwd5);
|
|
3759
|
-
console.log(
|
|
3847
|
+
console.log(chalk46.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
|
|
3760
3848
|
return 0;
|
|
3761
3849
|
}
|
|
3762
3850
|
|
|
3763
3851
|
// src/actions/packman/convert.ts
|
|
3764
3852
|
function detectCurrentPM(cwd5) {
|
|
3765
|
-
if (
|
|
3853
|
+
if (existsSync14(PATH14.join(cwd5, "pnpm-lock.yaml")) || existsSync14(PATH14.join(cwd5, "pnpm-workspace.yaml"))) {
|
|
3766
3854
|
return "pnpm";
|
|
3767
3855
|
}
|
|
3768
|
-
if (
|
|
3856
|
+
if (existsSync14(PATH14.join(cwd5, "yarn.lock")) || existsSync14(PATH14.join(cwd5, ".yarnrc.yml"))) {
|
|
3769
3857
|
return "yarn";
|
|
3770
3858
|
}
|
|
3771
3859
|
return "unknown";
|
|
3772
3860
|
}
|
|
3773
3861
|
function findWorkspacePackagePaths(cwd5) {
|
|
3774
|
-
const pkgPath =
|
|
3775
|
-
const pkg = JSON.parse(
|
|
3862
|
+
const pkgPath = PATH14.join(cwd5, "package.json");
|
|
3863
|
+
const pkg = JSON.parse(readFileSync14(pkgPath, "utf8"));
|
|
3776
3864
|
let patterns = pkg.workspaces ?? [];
|
|
3777
3865
|
if (patterns.length === 0) {
|
|
3778
|
-
const wsPath =
|
|
3779
|
-
if (
|
|
3780
|
-
const content =
|
|
3866
|
+
const wsPath = PATH14.join(cwd5, "pnpm-workspace.yaml");
|
|
3867
|
+
if (existsSync14(wsPath)) {
|
|
3868
|
+
const content = readFileSync14(wsPath, "utf8");
|
|
3781
3869
|
const lines = content.split("\n");
|
|
3782
3870
|
let inPackages = false;
|
|
3783
3871
|
for (const line of lines) {
|
|
@@ -3807,15 +3895,15 @@ function resolveWorkspaceGlob(cwd5, pattern) {
|
|
|
3807
3895
|
}
|
|
3808
3896
|
function walkGlob(basePath, parts, currentPath) {
|
|
3809
3897
|
if (parts.length === 0) {
|
|
3810
|
-
const fullPath =
|
|
3811
|
-
if (
|
|
3898
|
+
const fullPath = PATH14.join(basePath, currentPath);
|
|
3899
|
+
if (existsSync14(PATH14.join(fullPath, "package.json"))) {
|
|
3812
3900
|
return [currentPath];
|
|
3813
3901
|
}
|
|
3814
3902
|
return [];
|
|
3815
3903
|
}
|
|
3816
3904
|
const [part, ...rest] = parts;
|
|
3817
|
-
const dirPath =
|
|
3818
|
-
if (!
|
|
3905
|
+
const dirPath = PATH14.join(basePath, currentPath);
|
|
3906
|
+
if (!existsSync14(dirPath) || !statSync3(dirPath).isDirectory()) {
|
|
3819
3907
|
return [];
|
|
3820
3908
|
}
|
|
3821
3909
|
if (part === "*" || part === "**") {
|
|
@@ -3843,26 +3931,25 @@ function walkGlob(basePath, parts, currentPath) {
|
|
|
3843
3931
|
function convert({ target, verbose }) {
|
|
3844
3932
|
const validTargets = ["pnpm", "yarn"];
|
|
3845
3933
|
if (!validTargets.includes(target)) {
|
|
3846
|
-
console.error(
|
|
3934
|
+
console.error(chalk47.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
|
|
3847
3935
|
return 1;
|
|
3848
3936
|
}
|
|
3849
3937
|
const cwd5 = process.cwd();
|
|
3850
3938
|
const currentPM = detectCurrentPM(cwd5);
|
|
3851
3939
|
if (verbose) {
|
|
3852
|
-
console.log(
|
|
3853
|
-
console.log(
|
|
3940
|
+
console.log(chalk47.gray(`Current package manager: ${currentPM}`));
|
|
3941
|
+
console.log(chalk47.gray(`Target package manager: ${target}`));
|
|
3854
3942
|
}
|
|
3855
3943
|
if (currentPM === target) {
|
|
3856
|
-
console.
|
|
3857
|
-
return 1;
|
|
3944
|
+
console.log(chalk47.yellow(`Already using ${target}. Re-applying conversion to fix any incomplete steps...`));
|
|
3858
3945
|
}
|
|
3859
3946
|
if (currentPM === "unknown") {
|
|
3860
|
-
console.error(
|
|
3947
|
+
console.error(chalk47.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
|
|
3861
3948
|
return 1;
|
|
3862
3949
|
}
|
|
3863
3950
|
const workspacePaths = findWorkspacePackagePaths(cwd5);
|
|
3864
3951
|
if (verbose) {
|
|
3865
|
-
console.log(
|
|
3952
|
+
console.log(chalk47.gray(`Found ${workspacePaths.length} workspace packages`));
|
|
3866
3953
|
}
|
|
3867
3954
|
if (target === "pnpm") {
|
|
3868
3955
|
return convertToPnpm(cwd5, workspacePaths);
|
|
@@ -3920,7 +4007,7 @@ var rebuild = ({ target }) => {
|
|
|
3920
4007
|
};
|
|
3921
4008
|
|
|
3922
4009
|
// src/actions/recompile.ts
|
|
3923
|
-
import
|
|
4010
|
+
import chalk48 from "chalk";
|
|
3924
4011
|
var recompile = async ({
|
|
3925
4012
|
verbose,
|
|
3926
4013
|
target,
|
|
@@ -3955,7 +4042,7 @@ var recompileAll = async ({
|
|
|
3955
4042
|
const start = Date.now();
|
|
3956
4043
|
const targetOptions = target ? ["-t", target] : [];
|
|
3957
4044
|
if (jobs) {
|
|
3958
|
-
console.log(
|
|
4045
|
+
console.log(chalk48.blue(`Jobs set to [${jobs}]`));
|
|
3959
4046
|
}
|
|
3960
4047
|
const foreachOptions = {
|
|
3961
4048
|
incremental,
|
|
@@ -3968,25 +4055,25 @@ var recompileAll = async ({
|
|
|
3968
4055
|
pm.foreachWorkspace("package-compile", targetOptions, foreachOptions)
|
|
3969
4056
|
]);
|
|
3970
4057
|
console.log(
|
|
3971
|
-
`${
|
|
4058
|
+
`${chalk48.gray("Recompiled in")} [${chalk48.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk48.gray("seconds")}`
|
|
3972
4059
|
);
|
|
3973
4060
|
return result;
|
|
3974
4061
|
};
|
|
3975
4062
|
|
|
3976
4063
|
// src/actions/relint.ts
|
|
3977
|
-
import
|
|
4064
|
+
import chalk49 from "chalk";
|
|
3978
4065
|
var relintPackage = ({
|
|
3979
4066
|
pkg,
|
|
3980
4067
|
fix: fix2,
|
|
3981
4068
|
verbose
|
|
3982
4069
|
}) => {
|
|
3983
|
-
console.log(
|
|
4070
|
+
console.log(chalk49.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
3984
4071
|
const start = Date.now();
|
|
3985
4072
|
const pm = getPackageManager();
|
|
3986
4073
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
3987
4074
|
pm.runInWorkspace(pkg, fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint")
|
|
3988
4075
|
]);
|
|
3989
|
-
console.log(
|
|
4076
|
+
console.log(chalk49.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk49.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk49.gray("seconds")}`));
|
|
3990
4077
|
return result;
|
|
3991
4078
|
};
|
|
3992
4079
|
var relint = ({
|
|
@@ -4006,13 +4093,13 @@ var relint = ({
|
|
|
4006
4093
|
});
|
|
4007
4094
|
};
|
|
4008
4095
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
4009
|
-
console.log(
|
|
4096
|
+
console.log(chalk49.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
4010
4097
|
const start = Date.now();
|
|
4011
4098
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
4012
4099
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
4013
4100
|
["eslint", fixOptions]
|
|
4014
4101
|
]);
|
|
4015
|
-
console.log(
|
|
4102
|
+
console.log(chalk49.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk49.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk49.gray("seconds")}`));
|
|
4016
4103
|
return result;
|
|
4017
4104
|
};
|
|
4018
4105
|
|
|
@@ -4038,10 +4125,10 @@ var sonar = () => {
|
|
|
4038
4125
|
};
|
|
4039
4126
|
|
|
4040
4127
|
// src/actions/statics.ts
|
|
4041
|
-
import
|
|
4128
|
+
import chalk50 from "chalk";
|
|
4042
4129
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
4043
4130
|
var statics = () => {
|
|
4044
|
-
console.log(
|
|
4131
|
+
console.log(chalk50.green("Check Required Static Dependencies"));
|
|
4045
4132
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
4046
4133
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
4047
4134
|
};
|