@xylabs/ts-scripts-common 7.5.1 → 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/index.mjs
CHANGED
|
@@ -3601,24 +3601,24 @@ function packageLintMonorepo(fix2 = false) {
|
|
|
3601
3601
|
|
|
3602
3602
|
// src/actions/packman/convert.ts
|
|
3603
3603
|
import {
|
|
3604
|
-
existsSync as
|
|
3604
|
+
existsSync as existsSync15,
|
|
3605
3605
|
readdirSync as readdirSync7,
|
|
3606
|
-
readFileSync as
|
|
3606
|
+
readFileSync as readFileSync17,
|
|
3607
3607
|
statSync as statSync3
|
|
3608
3608
|
} from "fs";
|
|
3609
|
-
import
|
|
3610
|
-
import
|
|
3609
|
+
import PATH15 from "path";
|
|
3610
|
+
import chalk49 from "chalk";
|
|
3611
3611
|
|
|
3612
3612
|
// src/actions/packman/convertToPnpm.ts
|
|
3613
3613
|
import {
|
|
3614
|
-
existsSync as
|
|
3614
|
+
existsSync as existsSync13,
|
|
3615
3615
|
mkdirSync as mkdirSync5,
|
|
3616
|
-
readFileSync as
|
|
3616
|
+
readFileSync as readFileSync15,
|
|
3617
3617
|
rmSync as rmSync3,
|
|
3618
|
-
writeFileSync as
|
|
3618
|
+
writeFileSync as writeFileSync9
|
|
3619
3619
|
} from "fs";
|
|
3620
|
-
import
|
|
3621
|
-
import
|
|
3620
|
+
import PATH13 from "path";
|
|
3621
|
+
import chalk47 from "chalk";
|
|
3622
3622
|
|
|
3623
3623
|
// src/actions/packman/rewriteScripts.ts
|
|
3624
3624
|
function rewriteYarnToPnpm(script) {
|
|
@@ -3668,6 +3668,60 @@ function rewriteScriptsInPackageJson(pkg, direction) {
|
|
|
3668
3668
|
return { ...pkg, scripts: rewritten };
|
|
3669
3669
|
}
|
|
3670
3670
|
|
|
3671
|
+
// src/actions/packman/swapTsScriptsDependency.ts
|
|
3672
|
+
import {
|
|
3673
|
+
existsSync as existsSync12,
|
|
3674
|
+
readFileSync as readFileSync14,
|
|
3675
|
+
writeFileSync as writeFileSync8
|
|
3676
|
+
} from "fs";
|
|
3677
|
+
import PATH12 from "path";
|
|
3678
|
+
import chalk46 from "chalk";
|
|
3679
|
+
var SWAP_MAP = {
|
|
3680
|
+
"yarn-to-pnpm": [
|
|
3681
|
+
["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"]
|
|
3682
|
+
],
|
|
3683
|
+
"pnpm-to-yarn": [
|
|
3684
|
+
["@xylabs/ts-scripts-pnpm", "@xylabs/ts-scripts-yarn3"]
|
|
3685
|
+
]
|
|
3686
|
+
};
|
|
3687
|
+
function swapInPackageJson(pkgPath, direction) {
|
|
3688
|
+
if (!existsSync12(pkgPath)) return false;
|
|
3689
|
+
const raw = readFileSync14(pkgPath, "utf8");
|
|
3690
|
+
const pkg = JSON.parse(raw);
|
|
3691
|
+
let changed = false;
|
|
3692
|
+
for (const depField of ["dependencies", "devDependencies"]) {
|
|
3693
|
+
const deps = pkg[depField];
|
|
3694
|
+
if (!deps) continue;
|
|
3695
|
+
for (const [from, to] of SWAP_MAP[direction]) {
|
|
3696
|
+
if (deps[from]) {
|
|
3697
|
+
deps[to] = deps[from];
|
|
3698
|
+
delete deps[from];
|
|
3699
|
+
changed = true;
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
if (changed) {
|
|
3704
|
+
writeFileSync8(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
3705
|
+
}
|
|
3706
|
+
return changed;
|
|
3707
|
+
}
|
|
3708
|
+
function swapTsScriptsDependency(cwd5, workspacePackageJsonPaths, direction) {
|
|
3709
|
+
let count = 0;
|
|
3710
|
+
if (swapInPackageJson(PATH12.join(cwd5, "package.json"), direction)) {
|
|
3711
|
+
count++;
|
|
3712
|
+
}
|
|
3713
|
+
for (const pkgPath of workspacePackageJsonPaths) {
|
|
3714
|
+
const fullPath = PATH12.resolve(cwd5, pkgPath, "package.json");
|
|
3715
|
+
if (swapInPackageJson(fullPath, direction)) {
|
|
3716
|
+
count++;
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
if (count > 0) {
|
|
3720
|
+
const target = direction === "yarn-to-pnpm" ? "@xylabs/ts-scripts-pnpm" : "@xylabs/ts-scripts-yarn3";
|
|
3721
|
+
console.log(chalk46.green(` Swapped ts-scripts dependency to ${target} in ${count} package(s)`));
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
|
|
3671
3725
|
// src/actions/packman/convertToPnpm.ts
|
|
3672
3726
|
var PNPM_VERSION = "10.12.1";
|
|
3673
3727
|
function createPnpmWorkspaceYaml(cwd5, workspacePatterns) {
|
|
@@ -3675,24 +3729,45 @@ function createPnpmWorkspaceYaml(cwd5, workspacePatterns) {
|
|
|
3675
3729
|
for (const pattern of workspacePatterns) {
|
|
3676
3730
|
lines.push(` - '${pattern}'`);
|
|
3677
3731
|
}
|
|
3678
|
-
|
|
3679
|
-
console.log(
|
|
3732
|
+
writeFileSync9(PATH13.join(cwd5, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
|
|
3733
|
+
console.log(chalk47.green(" Created pnpm-workspace.yaml"));
|
|
3734
|
+
}
|
|
3735
|
+
function readPnpmWorkspacePatterns(cwd5) {
|
|
3736
|
+
const wsPath = PATH13.join(cwd5, "pnpm-workspace.yaml");
|
|
3737
|
+
if (!existsSync13(wsPath)) return [];
|
|
3738
|
+
const content = readFileSync15(wsPath, "utf8");
|
|
3739
|
+
const patterns = [];
|
|
3740
|
+
const lines = content.split("\n");
|
|
3741
|
+
let inPackages = false;
|
|
3742
|
+
for (const line of lines) {
|
|
3743
|
+
if (line.trim() === "packages:") {
|
|
3744
|
+
inPackages = true;
|
|
3745
|
+
continue;
|
|
3746
|
+
}
|
|
3747
|
+
if (inPackages && /^\s+-\s+/.test(line)) {
|
|
3748
|
+
const pattern = line.replace(/^\s+-\s+/, "").replaceAll(/['"]/g, "").trim();
|
|
3749
|
+
if (pattern) patterns.push(pattern);
|
|
3750
|
+
} else if (inPackages && !/^\s/.test(line) && line.trim()) {
|
|
3751
|
+
inPackages = false;
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
return patterns;
|
|
3680
3755
|
}
|
|
3681
3756
|
function updateRootPackageJson(cwd5) {
|
|
3682
|
-
const pkgPath =
|
|
3683
|
-
const pkg = JSON.parse(
|
|
3684
|
-
const workspacePatterns = pkg.workspaces ??
|
|
3757
|
+
const pkgPath = PATH13.join(cwd5, "package.json");
|
|
3758
|
+
const pkg = JSON.parse(readFileSync15(pkgPath, "utf8"));
|
|
3759
|
+
const workspacePatterns = pkg.workspaces ?? readPnpmWorkspacePatterns(cwd5);
|
|
3685
3760
|
delete pkg.workspaces;
|
|
3686
3761
|
pkg.packageManager = `pnpm@${PNPM_VERSION}`;
|
|
3687
3762
|
const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
|
|
3688
|
-
|
|
3689
|
-
console.log(
|
|
3763
|
+
writeFileSync9(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
3764
|
+
console.log(chalk47.green(" Updated root package.json"));
|
|
3690
3765
|
return workspacePatterns;
|
|
3691
3766
|
}
|
|
3692
3767
|
function updateGitignore(cwd5) {
|
|
3693
|
-
const gitignorePath =
|
|
3694
|
-
if (!
|
|
3695
|
-
let content =
|
|
3768
|
+
const gitignorePath = PATH13.join(cwd5, ".gitignore");
|
|
3769
|
+
if (!existsSync13(gitignorePath)) return;
|
|
3770
|
+
let content = readFileSync15(gitignorePath, "utf8");
|
|
3696
3771
|
const yarnLines = [
|
|
3697
3772
|
".pnp.*",
|
|
3698
3773
|
".pnp",
|
|
@@ -3707,63 +3782,64 @@ function updateGitignore(cwd5) {
|
|
|
3707
3782
|
content = content.replaceAll(new RegExp(String.raw`^${line.replaceAll(".", String.raw`\.`).replaceAll("*", String.raw`\*`).replaceAll("!", String.raw`\!`)}\s*$`, "gm"), "");
|
|
3708
3783
|
}
|
|
3709
3784
|
content = content.replaceAll(/\n{3,}/g, "\n\n");
|
|
3710
|
-
|
|
3711
|
-
console.log(
|
|
3785
|
+
writeFileSync9(gitignorePath, content, "utf8");
|
|
3786
|
+
console.log(chalk47.green(" Updated .gitignore"));
|
|
3712
3787
|
}
|
|
3713
3788
|
function deleteYarnArtifacts(cwd5) {
|
|
3714
|
-
const yarnLock =
|
|
3715
|
-
const yarnrc =
|
|
3716
|
-
const yarnDir =
|
|
3717
|
-
if (
|
|
3789
|
+
const yarnLock = PATH13.join(cwd5, "yarn.lock");
|
|
3790
|
+
const yarnrc = PATH13.join(cwd5, ".yarnrc.yml");
|
|
3791
|
+
const yarnDir = PATH13.join(cwd5, ".yarn");
|
|
3792
|
+
if (existsSync13(yarnLock)) {
|
|
3718
3793
|
rmSync3(yarnLock);
|
|
3719
|
-
console.log(
|
|
3794
|
+
console.log(chalk47.gray(" Deleted yarn.lock"));
|
|
3720
3795
|
}
|
|
3721
|
-
if (
|
|
3796
|
+
if (existsSync13(yarnrc)) {
|
|
3722
3797
|
rmSync3(yarnrc);
|
|
3723
|
-
console.log(
|
|
3798
|
+
console.log(chalk47.gray(" Deleted .yarnrc.yml"));
|
|
3724
3799
|
}
|
|
3725
|
-
if (
|
|
3800
|
+
if (existsSync13(yarnDir)) {
|
|
3726
3801
|
rmSync3(yarnDir, { force: true, recursive: true });
|
|
3727
|
-
console.log(
|
|
3802
|
+
console.log(chalk47.gray(" Deleted .yarn/"));
|
|
3728
3803
|
}
|
|
3729
3804
|
}
|
|
3730
3805
|
function createNpmrc(cwd5) {
|
|
3731
|
-
const npmrcPath =
|
|
3732
|
-
if (
|
|
3733
|
-
mkdirSync5(
|
|
3734
|
-
|
|
3735
|
-
console.log(
|
|
3806
|
+
const npmrcPath = PATH13.join(cwd5, ".npmrc");
|
|
3807
|
+
if (existsSync13(npmrcPath)) return;
|
|
3808
|
+
mkdirSync5(PATH13.dirname(npmrcPath), { recursive: true });
|
|
3809
|
+
writeFileSync9(npmrcPath, "", "utf8");
|
|
3810
|
+
console.log(chalk47.green(" Created .npmrc"));
|
|
3736
3811
|
}
|
|
3737
3812
|
function convertToPnpm(cwd5, workspacePackageJsonPaths) {
|
|
3738
|
-
console.log(
|
|
3813
|
+
console.log(chalk47.blue("\nConverting to pnpm...\n"));
|
|
3739
3814
|
const workspacePatterns = updateRootPackageJson(cwd5);
|
|
3740
3815
|
createPnpmWorkspaceYaml(cwd5, workspacePatterns);
|
|
3741
3816
|
for (const pkgPath of workspacePackageJsonPaths) {
|
|
3742
|
-
const fullPath =
|
|
3743
|
-
if (!
|
|
3744
|
-
const pkg = JSON.parse(
|
|
3817
|
+
const fullPath = PATH13.resolve(cwd5, pkgPath, "package.json");
|
|
3818
|
+
if (!existsSync13(fullPath)) continue;
|
|
3819
|
+
const pkg = JSON.parse(readFileSync15(fullPath, "utf8"));
|
|
3745
3820
|
const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
|
|
3746
3821
|
if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
|
|
3747
|
-
|
|
3822
|
+
writeFileSync9(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
3748
3823
|
}
|
|
3749
3824
|
}
|
|
3750
|
-
console.log(
|
|
3825
|
+
console.log(chalk47.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
|
|
3751
3826
|
updateGitignore(cwd5);
|
|
3752
3827
|
createNpmrc(cwd5);
|
|
3828
|
+
swapTsScriptsDependency(cwd5, workspacePackageJsonPaths, "yarn-to-pnpm");
|
|
3753
3829
|
deleteYarnArtifacts(cwd5);
|
|
3754
|
-
console.log(
|
|
3830
|
+
console.log(chalk47.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
|
|
3755
3831
|
return 0;
|
|
3756
3832
|
}
|
|
3757
3833
|
|
|
3758
3834
|
// src/actions/packman/convertToYarn.ts
|
|
3759
3835
|
import {
|
|
3760
|
-
existsSync as
|
|
3761
|
-
readFileSync as
|
|
3836
|
+
existsSync as existsSync14,
|
|
3837
|
+
readFileSync as readFileSync16,
|
|
3762
3838
|
rmSync as rmSync4,
|
|
3763
|
-
writeFileSync as
|
|
3839
|
+
writeFileSync as writeFileSync10
|
|
3764
3840
|
} from "fs";
|
|
3765
|
-
import
|
|
3766
|
-
import
|
|
3841
|
+
import PATH14 from "path";
|
|
3842
|
+
import chalk48 from "chalk";
|
|
3767
3843
|
var YARN_VERSION = "4.13.0";
|
|
3768
3844
|
var YARNRC_TEMPLATE = `compressionLevel: mixed
|
|
3769
3845
|
|
|
@@ -3784,10 +3860,10 @@ var YARN_GITIGNORE_ENTRIES = `
|
|
|
3784
3860
|
!.yarn/sdks
|
|
3785
3861
|
!.yarn/versions
|
|
3786
3862
|
`;
|
|
3787
|
-
function
|
|
3788
|
-
const wsPath =
|
|
3789
|
-
if (!
|
|
3790
|
-
const content =
|
|
3863
|
+
function readPnpmWorkspacePatterns2(cwd5) {
|
|
3864
|
+
const wsPath = PATH14.join(cwd5, "pnpm-workspace.yaml");
|
|
3865
|
+
if (!existsSync14(wsPath)) return [];
|
|
3866
|
+
const content = readFileSync16(wsPath, "utf8");
|
|
3791
3867
|
const patterns = [];
|
|
3792
3868
|
const lines = content.split("\n");
|
|
3793
3869
|
let inPackages = false;
|
|
@@ -3806,91 +3882,103 @@ function readPnpmWorkspacePatterns(cwd5) {
|
|
|
3806
3882
|
return patterns;
|
|
3807
3883
|
}
|
|
3808
3884
|
function updateRootPackageJson2(cwd5, workspacePatterns) {
|
|
3809
|
-
const pkgPath =
|
|
3810
|
-
const pkg = JSON.parse(
|
|
3885
|
+
const pkgPath = PATH14.join(cwd5, "package.json");
|
|
3886
|
+
const pkg = JSON.parse(readFileSync16(pkgPath, "utf8"));
|
|
3811
3887
|
pkg.workspaces = workspacePatterns;
|
|
3812
3888
|
pkg.packageManager = `yarn@${YARN_VERSION}`;
|
|
3813
3889
|
const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
|
|
3814
|
-
|
|
3815
|
-
console.log(
|
|
3890
|
+
writeFileSync10(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
3891
|
+
console.log(chalk48.green(" Updated root package.json"));
|
|
3816
3892
|
}
|
|
3817
3893
|
function updateGitignore2(cwd5) {
|
|
3818
|
-
const gitignorePath =
|
|
3819
|
-
let content =
|
|
3894
|
+
const gitignorePath = PATH14.join(cwd5, ".gitignore");
|
|
3895
|
+
let content = existsSync14(gitignorePath) ? readFileSync16(gitignorePath, "utf8") : "";
|
|
3820
3896
|
if (!content.includes(".yarn/*")) {
|
|
3821
3897
|
content = content.trimEnd() + "\n" + YARN_GITIGNORE_ENTRIES;
|
|
3822
3898
|
}
|
|
3823
|
-
|
|
3824
|
-
console.log(
|
|
3899
|
+
writeFileSync10(gitignorePath, content, "utf8");
|
|
3900
|
+
console.log(chalk48.green(" Updated .gitignore"));
|
|
3825
3901
|
}
|
|
3826
3902
|
function deletePnpmArtifacts(cwd5) {
|
|
3827
|
-
const lockfile =
|
|
3828
|
-
const workspaceYaml =
|
|
3829
|
-
const npmrc =
|
|
3830
|
-
if (
|
|
3903
|
+
const lockfile = PATH14.join(cwd5, "pnpm-lock.yaml");
|
|
3904
|
+
const workspaceYaml = PATH14.join(cwd5, "pnpm-workspace.yaml");
|
|
3905
|
+
const npmrc = PATH14.join(cwd5, ".npmrc");
|
|
3906
|
+
if (existsSync14(lockfile)) {
|
|
3831
3907
|
rmSync4(lockfile);
|
|
3832
|
-
console.log(
|
|
3908
|
+
console.log(chalk48.gray(" Deleted pnpm-lock.yaml"));
|
|
3833
3909
|
}
|
|
3834
|
-
if (
|
|
3910
|
+
if (existsSync14(workspaceYaml)) {
|
|
3835
3911
|
rmSync4(workspaceYaml);
|
|
3836
|
-
console.log(
|
|
3912
|
+
console.log(chalk48.gray(" Deleted pnpm-workspace.yaml"));
|
|
3837
3913
|
}
|
|
3838
|
-
if (
|
|
3839
|
-
const content =
|
|
3914
|
+
if (existsSync14(npmrc)) {
|
|
3915
|
+
const content = readFileSync16(npmrc, "utf8");
|
|
3840
3916
|
if (content.trim() === "" || content.includes("shamefully-hoist") || content.includes("node-linker")) {
|
|
3841
3917
|
rmSync4(npmrc);
|
|
3842
|
-
console.log(
|
|
3918
|
+
console.log(chalk48.gray(" Deleted .npmrc"));
|
|
3843
3919
|
}
|
|
3844
3920
|
}
|
|
3845
3921
|
}
|
|
3846
3922
|
function createYarnrc(cwd5) {
|
|
3847
|
-
const yarnrcPath =
|
|
3848
|
-
if (
|
|
3849
|
-
|
|
3850
|
-
console.log(
|
|
3923
|
+
const yarnrcPath = PATH14.join(cwd5, ".yarnrc.yml");
|
|
3924
|
+
if (existsSync14(yarnrcPath)) return;
|
|
3925
|
+
writeFileSync10(yarnrcPath, YARNRC_TEMPLATE, "utf8");
|
|
3926
|
+
console.log(chalk48.green(" Created .yarnrc.yml"));
|
|
3927
|
+
}
|
|
3928
|
+
function readWorkspacePatternsFromPackageJson(cwd5) {
|
|
3929
|
+
const pkgPath = PATH14.join(cwd5, "package.json");
|
|
3930
|
+
if (!existsSync14(pkgPath)) return [];
|
|
3931
|
+
const pkg = JSON.parse(readFileSync16(pkgPath, "utf8"));
|
|
3932
|
+
return pkg.workspaces ?? [];
|
|
3851
3933
|
}
|
|
3852
3934
|
function convertToYarn(cwd5, workspacePackageJsonPaths) {
|
|
3853
|
-
console.log(
|
|
3854
|
-
const workspacePatterns =
|
|
3935
|
+
console.log(chalk48.blue("\nConverting to yarn...\n"));
|
|
3936
|
+
const workspacePatterns = readPnpmWorkspacePatterns2(cwd5);
|
|
3855
3937
|
if (workspacePatterns.length === 0) {
|
|
3856
|
-
|
|
3938
|
+
const fromPkg = readWorkspacePatternsFromPackageJson(cwd5);
|
|
3939
|
+
if (fromPkg.length > 0) {
|
|
3940
|
+
workspacePatterns.push(...fromPkg);
|
|
3941
|
+
} else {
|
|
3942
|
+
console.warn(chalk48.yellow(" No workspace patterns found"));
|
|
3943
|
+
}
|
|
3857
3944
|
}
|
|
3858
3945
|
updateRootPackageJson2(cwd5, workspacePatterns);
|
|
3859
3946
|
for (const pkgPath of workspacePackageJsonPaths) {
|
|
3860
|
-
const fullPath =
|
|
3861
|
-
if (!
|
|
3862
|
-
const pkg = JSON.parse(
|
|
3947
|
+
const fullPath = PATH14.resolve(cwd5, pkgPath, "package.json");
|
|
3948
|
+
if (!existsSync14(fullPath)) continue;
|
|
3949
|
+
const pkg = JSON.parse(readFileSync16(fullPath, "utf8"));
|
|
3863
3950
|
const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
|
|
3864
3951
|
if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
|
|
3865
|
-
|
|
3952
|
+
writeFileSync10(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
3866
3953
|
}
|
|
3867
3954
|
}
|
|
3868
|
-
console.log(
|
|
3955
|
+
console.log(chalk48.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
|
|
3869
3956
|
updateGitignore2(cwd5);
|
|
3870
3957
|
createYarnrc(cwd5);
|
|
3958
|
+
swapTsScriptsDependency(cwd5, workspacePackageJsonPaths, "pnpm-to-yarn");
|
|
3871
3959
|
deletePnpmArtifacts(cwd5);
|
|
3872
|
-
console.log(
|
|
3960
|
+
console.log(chalk48.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
|
|
3873
3961
|
return 0;
|
|
3874
3962
|
}
|
|
3875
3963
|
|
|
3876
3964
|
// src/actions/packman/convert.ts
|
|
3877
3965
|
function detectCurrentPM(cwd5) {
|
|
3878
|
-
if (
|
|
3966
|
+
if (existsSync15(PATH15.join(cwd5, "pnpm-lock.yaml")) || existsSync15(PATH15.join(cwd5, "pnpm-workspace.yaml"))) {
|
|
3879
3967
|
return "pnpm";
|
|
3880
3968
|
}
|
|
3881
|
-
if (
|
|
3969
|
+
if (existsSync15(PATH15.join(cwd5, "yarn.lock")) || existsSync15(PATH15.join(cwd5, ".yarnrc.yml"))) {
|
|
3882
3970
|
return "yarn";
|
|
3883
3971
|
}
|
|
3884
3972
|
return "unknown";
|
|
3885
3973
|
}
|
|
3886
3974
|
function findWorkspacePackagePaths(cwd5) {
|
|
3887
|
-
const pkgPath =
|
|
3888
|
-
const pkg = JSON.parse(
|
|
3975
|
+
const pkgPath = PATH15.join(cwd5, "package.json");
|
|
3976
|
+
const pkg = JSON.parse(readFileSync17(pkgPath, "utf8"));
|
|
3889
3977
|
let patterns = pkg.workspaces ?? [];
|
|
3890
3978
|
if (patterns.length === 0) {
|
|
3891
|
-
const wsPath =
|
|
3892
|
-
if (
|
|
3893
|
-
const content =
|
|
3979
|
+
const wsPath = PATH15.join(cwd5, "pnpm-workspace.yaml");
|
|
3980
|
+
if (existsSync15(wsPath)) {
|
|
3981
|
+
const content = readFileSync17(wsPath, "utf8");
|
|
3894
3982
|
const lines = content.split("\n");
|
|
3895
3983
|
let inPackages = false;
|
|
3896
3984
|
for (const line of lines) {
|
|
@@ -3920,15 +4008,15 @@ function resolveWorkspaceGlob(cwd5, pattern) {
|
|
|
3920
4008
|
}
|
|
3921
4009
|
function walkGlob(basePath, parts, currentPath) {
|
|
3922
4010
|
if (parts.length === 0) {
|
|
3923
|
-
const fullPath =
|
|
3924
|
-
if (
|
|
4011
|
+
const fullPath = PATH15.join(basePath, currentPath);
|
|
4012
|
+
if (existsSync15(PATH15.join(fullPath, "package.json"))) {
|
|
3925
4013
|
return [currentPath];
|
|
3926
4014
|
}
|
|
3927
4015
|
return [];
|
|
3928
4016
|
}
|
|
3929
4017
|
const [part, ...rest] = parts;
|
|
3930
|
-
const dirPath =
|
|
3931
|
-
if (!
|
|
4018
|
+
const dirPath = PATH15.join(basePath, currentPath);
|
|
4019
|
+
if (!existsSync15(dirPath) || !statSync3(dirPath).isDirectory()) {
|
|
3932
4020
|
return [];
|
|
3933
4021
|
}
|
|
3934
4022
|
if (part === "*" || part === "**") {
|
|
@@ -3956,26 +4044,25 @@ function walkGlob(basePath, parts, currentPath) {
|
|
|
3956
4044
|
function convert({ target, verbose }) {
|
|
3957
4045
|
const validTargets = ["pnpm", "yarn"];
|
|
3958
4046
|
if (!validTargets.includes(target)) {
|
|
3959
|
-
console.error(
|
|
4047
|
+
console.error(chalk49.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
|
|
3960
4048
|
return 1;
|
|
3961
4049
|
}
|
|
3962
4050
|
const cwd5 = process.cwd();
|
|
3963
4051
|
const currentPM = detectCurrentPM(cwd5);
|
|
3964
4052
|
if (verbose) {
|
|
3965
|
-
console.log(
|
|
3966
|
-
console.log(
|
|
4053
|
+
console.log(chalk49.gray(`Current package manager: ${currentPM}`));
|
|
4054
|
+
console.log(chalk49.gray(`Target package manager: ${target}`));
|
|
3967
4055
|
}
|
|
3968
4056
|
if (currentPM === target) {
|
|
3969
|
-
console.
|
|
3970
|
-
return 1;
|
|
4057
|
+
console.log(chalk49.yellow(`Already using ${target}. Re-applying conversion to fix any incomplete steps...`));
|
|
3971
4058
|
}
|
|
3972
4059
|
if (currentPM === "unknown") {
|
|
3973
|
-
console.error(
|
|
4060
|
+
console.error(chalk49.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
|
|
3974
4061
|
return 1;
|
|
3975
4062
|
}
|
|
3976
4063
|
const workspacePaths = findWorkspacePackagePaths(cwd5);
|
|
3977
4064
|
if (verbose) {
|
|
3978
|
-
console.log(
|
|
4065
|
+
console.log(chalk49.gray(`Found ${workspacePaths.length} workspace packages`));
|
|
3979
4066
|
}
|
|
3980
4067
|
if (target === "pnpm") {
|
|
3981
4068
|
return convertToPnpm(cwd5, workspacePaths);
|
|
@@ -4033,7 +4120,7 @@ var rebuild = ({ target }) => {
|
|
|
4033
4120
|
};
|
|
4034
4121
|
|
|
4035
4122
|
// src/actions/recompile.ts
|
|
4036
|
-
import
|
|
4123
|
+
import chalk50 from "chalk";
|
|
4037
4124
|
var recompile = async ({
|
|
4038
4125
|
verbose,
|
|
4039
4126
|
target,
|
|
@@ -4068,7 +4155,7 @@ var recompileAll = async ({
|
|
|
4068
4155
|
const start = Date.now();
|
|
4069
4156
|
const targetOptions = target ? ["-t", target] : [];
|
|
4070
4157
|
if (jobs) {
|
|
4071
|
-
console.log(
|
|
4158
|
+
console.log(chalk50.blue(`Jobs set to [${jobs}]`));
|
|
4072
4159
|
}
|
|
4073
4160
|
const foreachOptions = {
|
|
4074
4161
|
incremental,
|
|
@@ -4081,25 +4168,25 @@ var recompileAll = async ({
|
|
|
4081
4168
|
pm.foreachWorkspace("package-compile", targetOptions, foreachOptions)
|
|
4082
4169
|
]);
|
|
4083
4170
|
console.log(
|
|
4084
|
-
`${
|
|
4171
|
+
`${chalk50.gray("Recompiled in")} [${chalk50.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk50.gray("seconds")}`
|
|
4085
4172
|
);
|
|
4086
4173
|
return result;
|
|
4087
4174
|
};
|
|
4088
4175
|
|
|
4089
4176
|
// src/actions/relint.ts
|
|
4090
|
-
import
|
|
4177
|
+
import chalk51 from "chalk";
|
|
4091
4178
|
var relintPackage = ({
|
|
4092
4179
|
pkg,
|
|
4093
4180
|
fix: fix2,
|
|
4094
4181
|
verbose
|
|
4095
4182
|
}) => {
|
|
4096
|
-
console.log(
|
|
4183
|
+
console.log(chalk51.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
4097
4184
|
const start = Date.now();
|
|
4098
4185
|
const pm = getPackageManager();
|
|
4099
4186
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
4100
4187
|
pm.runInWorkspace(pkg, fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint")
|
|
4101
4188
|
]);
|
|
4102
|
-
console.log(
|
|
4189
|
+
console.log(chalk51.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk51.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk51.gray("seconds")}`));
|
|
4103
4190
|
return result;
|
|
4104
4191
|
};
|
|
4105
4192
|
var relint = ({
|
|
@@ -4119,13 +4206,13 @@ var relint = ({
|
|
|
4119
4206
|
});
|
|
4120
4207
|
};
|
|
4121
4208
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
4122
|
-
console.log(
|
|
4209
|
+
console.log(chalk51.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
4123
4210
|
const start = Date.now();
|
|
4124
4211
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
4125
4212
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
4126
4213
|
["eslint", fixOptions]
|
|
4127
4214
|
]);
|
|
4128
|
-
console.log(
|
|
4215
|
+
console.log(chalk51.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk51.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk51.gray("seconds")}`));
|
|
4129
4216
|
return result;
|
|
4130
4217
|
};
|
|
4131
4218
|
|
|
@@ -4151,10 +4238,10 @@ var sonar = () => {
|
|
|
4151
4238
|
};
|
|
4152
4239
|
|
|
4153
4240
|
// src/actions/statics.ts
|
|
4154
|
-
import
|
|
4241
|
+
import chalk52 from "chalk";
|
|
4155
4242
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
4156
4243
|
var statics = () => {
|
|
4157
|
-
console.log(
|
|
4244
|
+
console.log(chalk52.green("Check Required Static Dependencies"));
|
|
4158
4245
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
4159
4246
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
4160
4247
|
};
|
|
@@ -4586,7 +4673,7 @@ var xyCommonCommands = (args) => {
|
|
|
4586
4673
|
};
|
|
4587
4674
|
|
|
4588
4675
|
// src/xy/lint/cycleCommand.ts
|
|
4589
|
-
import
|
|
4676
|
+
import chalk53 from "chalk";
|
|
4590
4677
|
var cycleCommand = {
|
|
4591
4678
|
command: "cycle [package]",
|
|
4592
4679
|
describe: "Cycle - Check for dependency cycles",
|
|
@@ -4597,12 +4684,12 @@ var cycleCommand = {
|
|
|
4597
4684
|
const start = Date.now();
|
|
4598
4685
|
if (argv.verbose) console.log("Cycle");
|
|
4599
4686
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
4600
|
-
console.log(
|
|
4687
|
+
console.log(chalk53.blue(`Finished in ${Date.now() - start}ms`));
|
|
4601
4688
|
}
|
|
4602
4689
|
};
|
|
4603
4690
|
|
|
4604
4691
|
// src/xy/lint/deplintCommand.ts
|
|
4605
|
-
import
|
|
4692
|
+
import chalk54 from "chalk";
|
|
4606
4693
|
var deplintCommand = {
|
|
4607
4694
|
command: "deplint [package]",
|
|
4608
4695
|
describe: "Deplint - Run Deplint",
|
|
@@ -4640,12 +4727,12 @@ var deplintCommand = {
|
|
|
4640
4727
|
peerDeps: !!argv.peerDeps,
|
|
4641
4728
|
verbose: !!argv.verbose
|
|
4642
4729
|
});
|
|
4643
|
-
console.log(
|
|
4730
|
+
console.log(chalk54.blue(`Finished in ${Date.now() - start}ms`));
|
|
4644
4731
|
}
|
|
4645
4732
|
};
|
|
4646
4733
|
|
|
4647
4734
|
// src/xy/lint/fixCommand.ts
|
|
4648
|
-
import
|
|
4735
|
+
import chalk55 from "chalk";
|
|
4649
4736
|
var fixCommand = {
|
|
4650
4737
|
command: "fix [package]",
|
|
4651
4738
|
describe: "Fix - Run Eslint w/fix",
|
|
@@ -4656,12 +4743,12 @@ var fixCommand = {
|
|
|
4656
4743
|
const start = Date.now();
|
|
4657
4744
|
if (argv.verbose) console.log("Fix");
|
|
4658
4745
|
process.exitCode = fix();
|
|
4659
|
-
console.log(
|
|
4746
|
+
console.log(chalk55.blue(`Finished in ${Date.now() - start}ms`));
|
|
4660
4747
|
}
|
|
4661
4748
|
};
|
|
4662
4749
|
|
|
4663
4750
|
// src/xy/lint/knipCommand.ts
|
|
4664
|
-
import
|
|
4751
|
+
import chalk56 from "chalk";
|
|
4665
4752
|
var knipCommand = {
|
|
4666
4753
|
command: "knip",
|
|
4667
4754
|
describe: "Knip - Run Knip",
|
|
@@ -4672,12 +4759,12 @@ var knipCommand = {
|
|
|
4672
4759
|
if (argv.verbose) console.log("Knip");
|
|
4673
4760
|
const start = Date.now();
|
|
4674
4761
|
process.exitCode = knip();
|
|
4675
|
-
console.log(
|
|
4762
|
+
console.log(chalk56.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
4676
4763
|
}
|
|
4677
4764
|
};
|
|
4678
4765
|
|
|
4679
4766
|
// src/xy/lint/lintCommand.ts
|
|
4680
|
-
import
|
|
4767
|
+
import chalk57 from "chalk";
|
|
4681
4768
|
var lintCommand = {
|
|
4682
4769
|
command: "lint [package]",
|
|
4683
4770
|
describe: "Lint - Run Eslint",
|
|
@@ -4706,7 +4793,7 @@ var lintCommand = {
|
|
|
4706
4793
|
cache: argv.cache,
|
|
4707
4794
|
verbose: !!argv.verbose
|
|
4708
4795
|
});
|
|
4709
|
-
console.log(
|
|
4796
|
+
console.log(chalk57.blue(`Finished in ${Date.now() - start}ms`));
|
|
4710
4797
|
}
|
|
4711
4798
|
};
|
|
4712
4799
|
|
|
@@ -4748,7 +4835,7 @@ var packageLintCommand = {
|
|
|
4748
4835
|
};
|
|
4749
4836
|
|
|
4750
4837
|
// src/xy/lint/publintCommand.ts
|
|
4751
|
-
import
|
|
4838
|
+
import chalk58 from "chalk";
|
|
4752
4839
|
var publintCommand = {
|
|
4753
4840
|
command: "publint [package]",
|
|
4754
4841
|
describe: "Publint - Run Publint",
|
|
@@ -4759,12 +4846,12 @@ var publintCommand = {
|
|
|
4759
4846
|
if (argv.verbose) console.log("Publint");
|
|
4760
4847
|
const start = Date.now();
|
|
4761
4848
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
4762
|
-
console.log(
|
|
4849
|
+
console.log(chalk58.blue(`Finished in ${Date.now() - start}ms`));
|
|
4763
4850
|
}
|
|
4764
4851
|
};
|
|
4765
4852
|
|
|
4766
4853
|
// src/xy/lint/relintCommand.ts
|
|
4767
|
-
import
|
|
4854
|
+
import chalk59 from "chalk";
|
|
4768
4855
|
var relintCommand = {
|
|
4769
4856
|
command: "relint [package]",
|
|
4770
4857
|
describe: "Relint - Clean & Lint",
|
|
@@ -4775,12 +4862,12 @@ var relintCommand = {
|
|
|
4775
4862
|
if (argv.verbose) console.log("Relinting");
|
|
4776
4863
|
const start = Date.now();
|
|
4777
4864
|
process.exitCode = relint();
|
|
4778
|
-
console.log(
|
|
4865
|
+
console.log(chalk59.blue(`Finished in ${Date.now() - start}ms`));
|
|
4779
4866
|
}
|
|
4780
4867
|
};
|
|
4781
4868
|
|
|
4782
4869
|
// src/xy/lint/sonarCommand.ts
|
|
4783
|
-
import
|
|
4870
|
+
import chalk60 from "chalk";
|
|
4784
4871
|
var sonarCommand = {
|
|
4785
4872
|
command: "sonar",
|
|
4786
4873
|
describe: "Sonar - Run Sonar Check",
|
|
@@ -4791,7 +4878,7 @@ var sonarCommand = {
|
|
|
4791
4878
|
const start = Date.now();
|
|
4792
4879
|
if (argv.verbose) console.log("Sonar Check");
|
|
4793
4880
|
process.exitCode = sonar();
|
|
4794
|
-
console.log(
|
|
4881
|
+
console.log(chalk60.blue(`Finished in ${Date.now() - start}ms`));
|
|
4795
4882
|
}
|
|
4796
4883
|
};
|
|
4797
4884
|
|
|
@@ -4801,7 +4888,7 @@ var xyLintCommands = (args) => {
|
|
|
4801
4888
|
};
|
|
4802
4889
|
|
|
4803
4890
|
// src/xy/xy.ts
|
|
4804
|
-
import
|
|
4891
|
+
import chalk61 from "chalk";
|
|
4805
4892
|
|
|
4806
4893
|
// src/xy/xyParseOptions.ts
|
|
4807
4894
|
import yargs from "yargs";
|
|
@@ -4844,8 +4931,8 @@ var xyBase = async (plugins) => {
|
|
|
4844
4931
|
let args = xyBuildCommands(xyCommonCommands(xyLintCommands(options)));
|
|
4845
4932
|
if (plugins) args = plugins(args);
|
|
4846
4933
|
return await args.demandCommand(1).command("*", "", () => {
|
|
4847
|
-
console.error(
|
|
4848
|
-
console.log(
|
|
4934
|
+
console.error(chalk61.yellow(`Command not found [${chalk61.magenta(process.argv[2])}]`));
|
|
4935
|
+
console.log(chalk61.gray("Try 'xy --help' for list of commands"));
|
|
4849
4936
|
}).version().help().argv;
|
|
4850
4937
|
};
|
|
4851
4938
|
export {
|