@xylabs/ts-scripts-common 7.5.2 → 7.5.4

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.
Files changed (49) hide show
  1. package/dist/actions/deplint/checkPackage/checkPackage.mjs +52 -5
  2. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
  3. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +17 -2
  4. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
  5. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +15 -1
  6. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
  7. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +15 -1
  8. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
  9. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +41 -1
  10. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -1
  11. package/dist/actions/deplint/checkPackage/index.mjs +52 -5
  12. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
  13. package/dist/actions/deplint/deplint.mjs +43 -5
  14. package/dist/actions/deplint/deplint.mjs.map +1 -1
  15. package/dist/actions/deplint/implicitDevDependencies.mjs +25 -0
  16. package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -1
  17. package/dist/actions/deplint/index.mjs +43 -5
  18. package/dist/actions/deplint/index.mjs.map +1 -1
  19. package/dist/actions/deplint/tsScriptsAliases.mjs +20 -0
  20. package/dist/actions/deplint/tsScriptsAliases.mjs.map +1 -0
  21. package/dist/actions/index.mjs +195 -98
  22. package/dist/actions/index.mjs.map +1 -1
  23. package/dist/actions/packman/convert.mjs +142 -83
  24. package/dist/actions/packman/convert.mjs.map +1 -1
  25. package/dist/actions/packman/convertToPnpm.mjs +94 -36
  26. package/dist/actions/packman/convertToPnpm.mjs.map +1 -1
  27. package/dist/actions/packman/convertToYarn.mjs +95 -37
  28. package/dist/actions/packman/convertToYarn.mjs.map +1 -1
  29. package/dist/actions/packman/index.mjs +142 -83
  30. package/dist/actions/packman/index.mjs.map +1 -1
  31. package/dist/actions/packman/rewriteSourceImports.mjs +60 -0
  32. package/dist/actions/packman/rewriteSourceImports.mjs.map +1 -0
  33. package/dist/bin/xy.mjs +212 -115
  34. package/dist/bin/xy.mjs.map +1 -1
  35. package/dist/index.mjs +214 -117
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/xy/common/index.mjs +142 -83
  38. package/dist/xy/common/index.mjs.map +1 -1
  39. package/dist/xy/common/packmanCommand.mjs +142 -83
  40. package/dist/xy/common/packmanCommand.mjs.map +1 -1
  41. package/dist/xy/index.mjs +212 -115
  42. package/dist/xy/index.mjs.map +1 -1
  43. package/dist/xy/lint/deplintCommand.mjs +43 -5
  44. package/dist/xy/lint/deplintCommand.mjs.map +1 -1
  45. package/dist/xy/lint/index.mjs +43 -5
  46. package/dist/xy/lint/index.mjs.map +1 -1
  47. package/dist/xy/xy.mjs +212 -115
  48. package/dist/xy/xy.mjs.map +1 -1
  49. package/package.json +2 -2
@@ -1501,6 +1501,24 @@ function getExternalImportsFromFiles({
1501
1501
  // src/actions/deplint/checkPackage/getUnlistedDependencies.ts
1502
1502
  import { builtinModules } from "module";
1503
1503
  import chalk19 from "chalk";
1504
+
1505
+ // src/actions/deplint/tsScriptsAliases.ts
1506
+ var VARIANT_MAP = {
1507
+ "@xylabs/ts-scripts-yarn3": "@xylabs/ts-scripts-pnpm",
1508
+ "@xylabs/ts-scripts-pnpm": "@xylabs/ts-scripts-yarn3",
1509
+ "@xylabs/ts-scripts-react-yarn3": "@xylabs/ts-scripts-react-pnpm",
1510
+ "@xylabs/ts-scripts-react-pnpm": "@xylabs/ts-scripts-react-yarn3"
1511
+ };
1512
+ function isSatisfiedByTsScriptsVariant(imp, allDeps) {
1513
+ const variant = VARIANT_MAP[imp];
1514
+ return variant !== void 0 && allDeps.includes(variant);
1515
+ }
1516
+ function isUsedViaTsScriptsVariant(dep, imports) {
1517
+ const variant = VARIANT_MAP[dep];
1518
+ return variant !== void 0 && imports.includes(variant);
1519
+ }
1520
+
1521
+ // src/actions/deplint/checkPackage/getUnlistedDependencies.ts
1504
1522
  function isRuntimeImportListed(imp, name, dependencies, peerDependencies) {
1505
1523
  return dependencies.includes(imp) || imp === name || peerDependencies.includes(imp) || builtinModules.includes(imp);
1506
1524
  }
@@ -1523,14 +1541,15 @@ function getUnlistedDependencies({ name, location }, {
1523
1541
  distImportPaths
1524
1542
  }) {
1525
1543
  let unlistedDependencies = 0;
1544
+ const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
1526
1545
  for (const imp of externalDistImports) {
1527
- if (!isRuntimeImportListed(imp, name, dependencies, peerDependencies)) {
1546
+ if (!isRuntimeImportListed(imp, name, dependencies, peerDependencies) && !isSatisfiedByTsScriptsVariant(imp, allDeps)) {
1528
1547
  unlistedDependencies++;
1529
1548
  logMissing(name, imp, distImportPaths);
1530
1549
  }
1531
1550
  }
1532
1551
  for (const imp of externalDistTypeImports) {
1533
- if (!isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies)) {
1552
+ if (!isTypeImportListed(imp, name, dependencies, devDependencies, peerDependencies) && !isSatisfiedByTsScriptsVariant(imp, allDeps)) {
1534
1553
  unlistedDependencies++;
1535
1554
  logMissing(name, imp, distImportPaths);
1536
1555
  }
@@ -1557,7 +1576,7 @@ function getUnlistedDevDependencies({ name, location }, {
1557
1576
  }) {
1558
1577
  let unlistedDevDependencies = 0;
1559
1578
  for (const imp of externalAllImports) {
1560
- if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp)) {
1579
+ if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp) && !isSatisfiedByTsScriptsVariant(imp, [...dependencies, ...devDependencies, ...peerDependencies])) {
1561
1580
  unlistedDevDependencies++;
1562
1581
  console.log(`[${chalk20.blue(name)}] Missing devDependency in package.json: ${chalk20.red(imp)}`);
1563
1582
  if (allImportPaths[imp]) {
@@ -1583,7 +1602,7 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
1583
1602
  let unusedDependencies = 0;
1584
1603
  for (const dep of dependencies) {
1585
1604
  if (exclude?.has(dep)) continue;
1586
- if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
1605
+ if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, "")) && !isUsedViaTsScriptsVariant(dep, [...externalDistImports, ...externalDistTypeImports])) {
1587
1606
  unusedDependencies++;
1588
1607
  if (externalAllImports.includes(dep)) {
1589
1608
  console.log(`[${chalk21.blue(name)}] dependency should be devDependency in package.json: ${chalk21.red(dep)}`);
@@ -1813,6 +1832,8 @@ function hasImportPlugin({ location, allDependencies }) {
1813
1832
  return false;
1814
1833
  }
1815
1834
  var hasVitest = ({ allDependencies }) => allDependencies.includes("vitest");
1835
+ var isYarnRepo = () => detectPackageManager() === "yarn";
1836
+ var isPnpmRepo = () => detectPackageManager() === "pnpm";
1816
1837
  var rules = [
1817
1838
  {
1818
1839
  package: "typescript",
@@ -1829,6 +1850,22 @@ var rules = [
1829
1850
  {
1830
1851
  package: "@vitest/coverage-v8",
1831
1852
  isNeeded: hasVitest
1853
+ },
1854
+ {
1855
+ package: "@xylabs/ts-scripts-yarn3",
1856
+ isNeeded: isYarnRepo
1857
+ },
1858
+ {
1859
+ package: "@xylabs/ts-scripts-react-yarn3",
1860
+ isNeeded: isYarnRepo
1861
+ },
1862
+ {
1863
+ package: "@xylabs/ts-scripts-pnpm",
1864
+ isNeeded: isPnpmRepo
1865
+ },
1866
+ {
1867
+ package: "@xylabs/ts-scripts-react-pnpm",
1868
+ isNeeded: isPnpmRepo
1832
1869
  }
1833
1870
  ];
1834
1871
  function getImplicitDevDependencies(context) {
@@ -1862,7 +1899,8 @@ function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs,
1862
1899
  const baseName = dep.replace(/^@types\//, "");
1863
1900
  return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
1864
1901
  }
1865
- return allImports.has(dep);
1902
+ if (allImports.has(dep)) return true;
1903
+ return isUsedViaTsScriptsVariant(dep, [...allImports]);
1866
1904
  }
1867
1905
  function getUnusedDevDependencies({ name, location }, {
1868
1906
  devDependencies,
@@ -3488,24 +3526,24 @@ function packageLintMonorepo(fix2 = false) {
3488
3526
 
3489
3527
  // src/actions/packman/convert.ts
3490
3528
  import {
3491
- existsSync as existsSync14,
3529
+ existsSync as existsSync15,
3492
3530
  readdirSync as readdirSync7,
3493
- readFileSync as readFileSync14,
3531
+ readFileSync as readFileSync15,
3494
3532
  statSync as statSync3
3495
3533
  } from "fs";
3496
3534
  import PATH14 from "path";
3497
- import chalk47 from "chalk";
3535
+ import chalk48 from "chalk";
3498
3536
 
3499
3537
  // src/actions/packman/convertToPnpm.ts
3500
3538
  import {
3501
- existsSync as existsSync12,
3539
+ existsSync as existsSync13,
3502
3540
  mkdirSync as mkdirSync5,
3503
- readFileSync as readFileSync12,
3541
+ readFileSync as readFileSync13,
3504
3542
  rmSync as rmSync3,
3505
- writeFileSync as writeFileSync9
3543
+ writeFileSync as writeFileSync10
3506
3544
  } from "fs";
3507
3545
  import PATH12 from "path";
3508
- import chalk45 from "chalk";
3546
+ import chalk46 from "chalk";
3509
3547
 
3510
3548
  // src/actions/packman/rewriteScripts.ts
3511
3549
  function rewriteYarnToPnpm(script) {
@@ -3555,14 +3593,71 @@ function rewriteScriptsInPackageJson(pkg, direction) {
3555
3593
  return { ...pkg, scripts: rewritten };
3556
3594
  }
3557
3595
 
3558
- // src/actions/packman/swapTsScriptsDependency.ts
3596
+ // src/actions/packman/rewriteSourceImports.ts
3559
3597
  import {
3560
3598
  existsSync as existsSync11,
3561
3599
  readFileSync as readFileSync11,
3562
3600
  writeFileSync as writeFileSync8
3563
3601
  } from "fs";
3564
- import PATH11 from "path";
3565
3602
  import chalk44 from "chalk";
3603
+ import { globSync as globSync3 } from "glob";
3604
+ var IMPORT_SWAP_MAP = {
3605
+ "yarn-to-pnpm": [
3606
+ ["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"],
3607
+ ["@xylabs/ts-scripts-react-yarn3", "@xylabs/ts-scripts-react-pnpm"]
3608
+ ],
3609
+ "pnpm-to-yarn": [
3610
+ ["@xylabs/ts-scripts-pnpm", "@xylabs/ts-scripts-yarn3"],
3611
+ ["@xylabs/ts-scripts-react-pnpm", "@xylabs/ts-scripts-react-yarn3"]
3612
+ ]
3613
+ };
3614
+ var SOURCE_GLOBS = [
3615
+ "**/*.ts",
3616
+ "**/*.tsx",
3617
+ "**/*.mts",
3618
+ "**/*.cts",
3619
+ "**/*.js",
3620
+ "**/*.mjs"
3621
+ ];
3622
+ var IGNORE_PATTERNS = [
3623
+ "**/node_modules/**",
3624
+ "**/dist/**",
3625
+ "**/build/**",
3626
+ "**/.yarn/**"
3627
+ ];
3628
+ function rewriteSourceImports(cwd5, direction) {
3629
+ const swaps = IMPORT_SWAP_MAP[direction];
3630
+ const files = globSync3(SOURCE_GLOBS, {
3631
+ cwd: cwd5,
3632
+ absolute: true,
3633
+ ignore: IGNORE_PATTERNS
3634
+ });
3635
+ let count = 0;
3636
+ for (const file of files) {
3637
+ if (!existsSync11(file)) continue;
3638
+ const original = readFileSync11(file, "utf8");
3639
+ let content = original;
3640
+ for (const [from, to] of swaps) {
3641
+ content = content.replaceAll(from, to);
3642
+ }
3643
+ if (content !== original) {
3644
+ writeFileSync8(file, content, "utf8");
3645
+ count++;
3646
+ }
3647
+ }
3648
+ if (count > 0) {
3649
+ console.log(chalk44.green(` Rewrote ts-scripts imports in ${count} source file(s)`));
3650
+ }
3651
+ }
3652
+
3653
+ // src/actions/packman/swapTsScriptsDependency.ts
3654
+ import {
3655
+ existsSync as existsSync12,
3656
+ readFileSync as readFileSync12,
3657
+ writeFileSync as writeFileSync9
3658
+ } from "fs";
3659
+ import PATH11 from "path";
3660
+ import chalk45 from "chalk";
3566
3661
  var SWAP_MAP = {
3567
3662
  "yarn-to-pnpm": [
3568
3663
  ["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"]
@@ -3572,8 +3667,8 @@ var SWAP_MAP = {
3572
3667
  ]
3573
3668
  };
3574
3669
  function swapInPackageJson(pkgPath, direction) {
3575
- if (!existsSync11(pkgPath)) return false;
3576
- const raw = readFileSync11(pkgPath, "utf8");
3670
+ if (!existsSync12(pkgPath)) return false;
3671
+ const raw = readFileSync12(pkgPath, "utf8");
3577
3672
  const pkg = JSON.parse(raw);
3578
3673
  let changed = false;
3579
3674
  for (const depField of ["dependencies", "devDependencies"]) {
@@ -3588,7 +3683,7 @@ function swapInPackageJson(pkgPath, direction) {
3588
3683
  }
3589
3684
  }
3590
3685
  if (changed) {
3591
- writeFileSync8(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
3686
+ writeFileSync9(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
3592
3687
  }
3593
3688
  return changed;
3594
3689
  }
@@ -3605,7 +3700,7 @@ function swapTsScriptsDependency(cwd5, workspacePackageJsonPaths, direction) {
3605
3700
  }
3606
3701
  if (count > 0) {
3607
3702
  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)`));
3703
+ console.log(chalk45.green(` Swapped ts-scripts dependency to ${target} in ${count} package(s)`));
3609
3704
  }
3610
3705
  }
3611
3706
 
@@ -3616,13 +3711,13 @@ function createPnpmWorkspaceYaml(cwd5, workspacePatterns) {
3616
3711
  for (const pattern of workspacePatterns) {
3617
3712
  lines.push(` - '${pattern}'`);
3618
3713
  }
3619
- writeFileSync9(PATH12.join(cwd5, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
3620
- console.log(chalk45.green(" Created pnpm-workspace.yaml"));
3714
+ writeFileSync10(PATH12.join(cwd5, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
3715
+ console.log(chalk46.green(" Created pnpm-workspace.yaml"));
3621
3716
  }
3622
3717
  function readPnpmWorkspacePatterns(cwd5) {
3623
3718
  const wsPath = PATH12.join(cwd5, "pnpm-workspace.yaml");
3624
- if (!existsSync12(wsPath)) return [];
3625
- const content = readFileSync12(wsPath, "utf8");
3719
+ if (!existsSync13(wsPath)) return [];
3720
+ const content = readFileSync13(wsPath, "utf8");
3626
3721
  const patterns = [];
3627
3722
  const lines = content.split("\n");
3628
3723
  let inPackages = false;
@@ -3642,19 +3737,19 @@ function readPnpmWorkspacePatterns(cwd5) {
3642
3737
  }
3643
3738
  function updateRootPackageJson(cwd5) {
3644
3739
  const pkgPath = PATH12.join(cwd5, "package.json");
3645
- const pkg = JSON.parse(readFileSync12(pkgPath, "utf8"));
3740
+ const pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
3646
3741
  const workspacePatterns = pkg.workspaces ?? readPnpmWorkspacePatterns(cwd5);
3647
3742
  delete pkg.workspaces;
3648
3743
  pkg.packageManager = `pnpm@${PNPM_VERSION}`;
3649
3744
  const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
3650
- writeFileSync9(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
3651
- console.log(chalk45.green(" Updated root package.json"));
3745
+ writeFileSync10(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
3746
+ console.log(chalk46.green(" Updated root package.json"));
3652
3747
  return workspacePatterns;
3653
3748
  }
3654
3749
  function updateGitignore(cwd5) {
3655
3750
  const gitignorePath = PATH12.join(cwd5, ".gitignore");
3656
- if (!existsSync12(gitignorePath)) return;
3657
- let content = readFileSync12(gitignorePath, "utf8");
3751
+ if (!existsSync13(gitignorePath)) return;
3752
+ let content = readFileSync13(gitignorePath, "utf8");
3658
3753
  const yarnLines = [
3659
3754
  ".pnp.*",
3660
3755
  ".pnp",
@@ -3669,64 +3764,65 @@ function updateGitignore(cwd5) {
3669
3764
  content = content.replaceAll(new RegExp(String.raw`^${line.replaceAll(".", String.raw`\.`).replaceAll("*", String.raw`\*`).replaceAll("!", String.raw`\!`)}\s*$`, "gm"), "");
3670
3765
  }
3671
3766
  content = content.replaceAll(/\n{3,}/g, "\n\n");
3672
- writeFileSync9(gitignorePath, content, "utf8");
3673
- console.log(chalk45.green(" Updated .gitignore"));
3767
+ writeFileSync10(gitignorePath, content, "utf8");
3768
+ console.log(chalk46.green(" Updated .gitignore"));
3674
3769
  }
3675
3770
  function deleteYarnArtifacts(cwd5) {
3676
3771
  const yarnLock = PATH12.join(cwd5, "yarn.lock");
3677
3772
  const yarnrc = PATH12.join(cwd5, ".yarnrc.yml");
3678
3773
  const yarnDir = PATH12.join(cwd5, ".yarn");
3679
- if (existsSync12(yarnLock)) {
3774
+ if (existsSync13(yarnLock)) {
3680
3775
  rmSync3(yarnLock);
3681
- console.log(chalk45.gray(" Deleted yarn.lock"));
3776
+ console.log(chalk46.gray(" Deleted yarn.lock"));
3682
3777
  }
3683
- if (existsSync12(yarnrc)) {
3778
+ if (existsSync13(yarnrc)) {
3684
3779
  rmSync3(yarnrc);
3685
- console.log(chalk45.gray(" Deleted .yarnrc.yml"));
3780
+ console.log(chalk46.gray(" Deleted .yarnrc.yml"));
3686
3781
  }
3687
- if (existsSync12(yarnDir)) {
3782
+ if (existsSync13(yarnDir)) {
3688
3783
  rmSync3(yarnDir, { force: true, recursive: true });
3689
- console.log(chalk45.gray(" Deleted .yarn/"));
3784
+ console.log(chalk46.gray(" Deleted .yarn/"));
3690
3785
  }
3691
3786
  }
3692
3787
  function createNpmrc(cwd5) {
3693
3788
  const npmrcPath = PATH12.join(cwd5, ".npmrc");
3694
- if (existsSync12(npmrcPath)) return;
3789
+ if (existsSync13(npmrcPath)) return;
3695
3790
  mkdirSync5(PATH12.dirname(npmrcPath), { recursive: true });
3696
- writeFileSync9(npmrcPath, "", "utf8");
3697
- console.log(chalk45.green(" Created .npmrc"));
3791
+ writeFileSync10(npmrcPath, "", "utf8");
3792
+ console.log(chalk46.green(" Created .npmrc"));
3698
3793
  }
3699
3794
  function convertToPnpm(cwd5, workspacePackageJsonPaths) {
3700
- console.log(chalk45.blue("\nConverting to pnpm...\n"));
3795
+ console.log(chalk46.blue("\nConverting to pnpm...\n"));
3701
3796
  const workspacePatterns = updateRootPackageJson(cwd5);
3702
3797
  createPnpmWorkspaceYaml(cwd5, workspacePatterns);
3703
3798
  for (const pkgPath of workspacePackageJsonPaths) {
3704
3799
  const fullPath = PATH12.resolve(cwd5, pkgPath, "package.json");
3705
- if (!existsSync12(fullPath)) continue;
3706
- const pkg = JSON.parse(readFileSync12(fullPath, "utf8"));
3800
+ if (!existsSync13(fullPath)) continue;
3801
+ const pkg = JSON.parse(readFileSync13(fullPath, "utf8"));
3707
3802
  const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
3708
3803
  if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
3709
- writeFileSync9(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
3804
+ writeFileSync10(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
3710
3805
  }
3711
3806
  }
3712
- console.log(chalk45.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
3807
+ console.log(chalk46.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
3713
3808
  updateGitignore(cwd5);
3714
3809
  createNpmrc(cwd5);
3715
3810
  swapTsScriptsDependency(cwd5, workspacePackageJsonPaths, "yarn-to-pnpm");
3811
+ rewriteSourceImports(cwd5, "yarn-to-pnpm");
3716
3812
  deleteYarnArtifacts(cwd5);
3717
- console.log(chalk45.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
3813
+ console.log(chalk46.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
3718
3814
  return 0;
3719
3815
  }
3720
3816
 
3721
3817
  // src/actions/packman/convertToYarn.ts
3722
3818
  import {
3723
- existsSync as existsSync13,
3724
- readFileSync as readFileSync13,
3819
+ existsSync as existsSync14,
3820
+ readFileSync as readFileSync14,
3725
3821
  rmSync as rmSync4,
3726
- writeFileSync as writeFileSync10
3822
+ writeFileSync as writeFileSync11
3727
3823
  } from "fs";
3728
3824
  import PATH13 from "path";
3729
- import chalk46 from "chalk";
3825
+ import chalk47 from "chalk";
3730
3826
  var YARN_VERSION = "4.13.0";
3731
3827
  var YARNRC_TEMPLATE = `compressionLevel: mixed
3732
3828
 
@@ -3749,8 +3845,8 @@ var YARN_GITIGNORE_ENTRIES = `
3749
3845
  `;
3750
3846
  function readPnpmWorkspacePatterns2(cwd5) {
3751
3847
  const wsPath = PATH13.join(cwd5, "pnpm-workspace.yaml");
3752
- if (!existsSync13(wsPath)) return [];
3753
- const content = readFileSync13(wsPath, "utf8");
3848
+ if (!existsSync14(wsPath)) return [];
3849
+ const content = readFileSync14(wsPath, "utf8");
3754
3850
  const patterns = [];
3755
3851
  const lines = content.split("\n");
3756
3852
  let inPackages = false;
@@ -3770,102 +3866,103 @@ function readPnpmWorkspacePatterns2(cwd5) {
3770
3866
  }
3771
3867
  function updateRootPackageJson2(cwd5, workspacePatterns) {
3772
3868
  const pkgPath = PATH13.join(cwd5, "package.json");
3773
- const pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
3869
+ const pkg = JSON.parse(readFileSync14(pkgPath, "utf8"));
3774
3870
  pkg.workspaces = workspacePatterns;
3775
3871
  pkg.packageManager = `yarn@${YARN_VERSION}`;
3776
3872
  const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
3777
- writeFileSync10(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
3778
- console.log(chalk46.green(" Updated root package.json"));
3873
+ writeFileSync11(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
3874
+ console.log(chalk47.green(" Updated root package.json"));
3779
3875
  }
3780
3876
  function updateGitignore2(cwd5) {
3781
3877
  const gitignorePath = PATH13.join(cwd5, ".gitignore");
3782
- let content = existsSync13(gitignorePath) ? readFileSync13(gitignorePath, "utf8") : "";
3878
+ let content = existsSync14(gitignorePath) ? readFileSync14(gitignorePath, "utf8") : "";
3783
3879
  if (!content.includes(".yarn/*")) {
3784
3880
  content = content.trimEnd() + "\n" + YARN_GITIGNORE_ENTRIES;
3785
3881
  }
3786
- writeFileSync10(gitignorePath, content, "utf8");
3787
- console.log(chalk46.green(" Updated .gitignore"));
3882
+ writeFileSync11(gitignorePath, content, "utf8");
3883
+ console.log(chalk47.green(" Updated .gitignore"));
3788
3884
  }
3789
3885
  function deletePnpmArtifacts(cwd5) {
3790
3886
  const lockfile = PATH13.join(cwd5, "pnpm-lock.yaml");
3791
3887
  const workspaceYaml = PATH13.join(cwd5, "pnpm-workspace.yaml");
3792
3888
  const npmrc = PATH13.join(cwd5, ".npmrc");
3793
- if (existsSync13(lockfile)) {
3889
+ if (existsSync14(lockfile)) {
3794
3890
  rmSync4(lockfile);
3795
- console.log(chalk46.gray(" Deleted pnpm-lock.yaml"));
3891
+ console.log(chalk47.gray(" Deleted pnpm-lock.yaml"));
3796
3892
  }
3797
- if (existsSync13(workspaceYaml)) {
3893
+ if (existsSync14(workspaceYaml)) {
3798
3894
  rmSync4(workspaceYaml);
3799
- console.log(chalk46.gray(" Deleted pnpm-workspace.yaml"));
3895
+ console.log(chalk47.gray(" Deleted pnpm-workspace.yaml"));
3800
3896
  }
3801
- if (existsSync13(npmrc)) {
3802
- const content = readFileSync13(npmrc, "utf8");
3897
+ if (existsSync14(npmrc)) {
3898
+ const content = readFileSync14(npmrc, "utf8");
3803
3899
  if (content.trim() === "" || content.includes("shamefully-hoist") || content.includes("node-linker")) {
3804
3900
  rmSync4(npmrc);
3805
- console.log(chalk46.gray(" Deleted .npmrc"));
3901
+ console.log(chalk47.gray(" Deleted .npmrc"));
3806
3902
  }
3807
3903
  }
3808
3904
  }
3809
3905
  function createYarnrc(cwd5) {
3810
3906
  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"));
3907
+ if (existsSync14(yarnrcPath)) return;
3908
+ writeFileSync11(yarnrcPath, YARNRC_TEMPLATE, "utf8");
3909
+ console.log(chalk47.green(" Created .yarnrc.yml"));
3814
3910
  }
3815
3911
  function readWorkspacePatternsFromPackageJson(cwd5) {
3816
3912
  const pkgPath = PATH13.join(cwd5, "package.json");
3817
- if (!existsSync13(pkgPath)) return [];
3818
- const pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
3913
+ if (!existsSync14(pkgPath)) return [];
3914
+ const pkg = JSON.parse(readFileSync14(pkgPath, "utf8"));
3819
3915
  return pkg.workspaces ?? [];
3820
3916
  }
3821
3917
  function convertToYarn(cwd5, workspacePackageJsonPaths) {
3822
- console.log(chalk46.blue("\nConverting to yarn...\n"));
3918
+ console.log(chalk47.blue("\nConverting to yarn...\n"));
3823
3919
  const workspacePatterns = readPnpmWorkspacePatterns2(cwd5);
3824
3920
  if (workspacePatterns.length === 0) {
3825
3921
  const fromPkg = readWorkspacePatternsFromPackageJson(cwd5);
3826
3922
  if (fromPkg.length > 0) {
3827
3923
  workspacePatterns.push(...fromPkg);
3828
3924
  } else {
3829
- console.warn(chalk46.yellow(" No workspace patterns found"));
3925
+ console.warn(chalk47.yellow(" No workspace patterns found"));
3830
3926
  }
3831
3927
  }
3832
3928
  updateRootPackageJson2(cwd5, workspacePatterns);
3833
3929
  for (const pkgPath of workspacePackageJsonPaths) {
3834
3930
  const fullPath = PATH13.resolve(cwd5, pkgPath, "package.json");
3835
- if (!existsSync13(fullPath)) continue;
3836
- const pkg = JSON.parse(readFileSync13(fullPath, "utf8"));
3931
+ if (!existsSync14(fullPath)) continue;
3932
+ const pkg = JSON.parse(readFileSync14(fullPath, "utf8"));
3837
3933
  const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
3838
3934
  if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
3839
- writeFileSync10(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
3935
+ writeFileSync11(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
3840
3936
  }
3841
3937
  }
3842
- console.log(chalk46.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
3938
+ console.log(chalk47.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
3843
3939
  updateGitignore2(cwd5);
3844
3940
  createYarnrc(cwd5);
3845
3941
  swapTsScriptsDependency(cwd5, workspacePackageJsonPaths, "pnpm-to-yarn");
3942
+ rewriteSourceImports(cwd5, "pnpm-to-yarn");
3846
3943
  deletePnpmArtifacts(cwd5);
3847
- console.log(chalk46.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
3944
+ console.log(chalk47.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
3848
3945
  return 0;
3849
3946
  }
3850
3947
 
3851
3948
  // src/actions/packman/convert.ts
3852
3949
  function detectCurrentPM(cwd5) {
3853
- if (existsSync14(PATH14.join(cwd5, "pnpm-lock.yaml")) || existsSync14(PATH14.join(cwd5, "pnpm-workspace.yaml"))) {
3950
+ if (existsSync15(PATH14.join(cwd5, "pnpm-lock.yaml")) || existsSync15(PATH14.join(cwd5, "pnpm-workspace.yaml"))) {
3854
3951
  return "pnpm";
3855
3952
  }
3856
- if (existsSync14(PATH14.join(cwd5, "yarn.lock")) || existsSync14(PATH14.join(cwd5, ".yarnrc.yml"))) {
3953
+ if (existsSync15(PATH14.join(cwd5, "yarn.lock")) || existsSync15(PATH14.join(cwd5, ".yarnrc.yml"))) {
3857
3954
  return "yarn";
3858
3955
  }
3859
3956
  return "unknown";
3860
3957
  }
3861
3958
  function findWorkspacePackagePaths(cwd5) {
3862
3959
  const pkgPath = PATH14.join(cwd5, "package.json");
3863
- const pkg = JSON.parse(readFileSync14(pkgPath, "utf8"));
3960
+ const pkg = JSON.parse(readFileSync15(pkgPath, "utf8"));
3864
3961
  let patterns = pkg.workspaces ?? [];
3865
3962
  if (patterns.length === 0) {
3866
3963
  const wsPath = PATH14.join(cwd5, "pnpm-workspace.yaml");
3867
- if (existsSync14(wsPath)) {
3868
- const content = readFileSync14(wsPath, "utf8");
3964
+ if (existsSync15(wsPath)) {
3965
+ const content = readFileSync15(wsPath, "utf8");
3869
3966
  const lines = content.split("\n");
3870
3967
  let inPackages = false;
3871
3968
  for (const line of lines) {
@@ -3896,14 +3993,14 @@ function resolveWorkspaceGlob(cwd5, pattern) {
3896
3993
  function walkGlob(basePath, parts, currentPath) {
3897
3994
  if (parts.length === 0) {
3898
3995
  const fullPath = PATH14.join(basePath, currentPath);
3899
- if (existsSync14(PATH14.join(fullPath, "package.json"))) {
3996
+ if (existsSync15(PATH14.join(fullPath, "package.json"))) {
3900
3997
  return [currentPath];
3901
3998
  }
3902
3999
  return [];
3903
4000
  }
3904
4001
  const [part, ...rest] = parts;
3905
4002
  const dirPath = PATH14.join(basePath, currentPath);
3906
- if (!existsSync14(dirPath) || !statSync3(dirPath).isDirectory()) {
4003
+ if (!existsSync15(dirPath) || !statSync3(dirPath).isDirectory()) {
3907
4004
  return [];
3908
4005
  }
3909
4006
  if (part === "*" || part === "**") {
@@ -3931,25 +4028,25 @@ function walkGlob(basePath, parts, currentPath) {
3931
4028
  function convert({ target, verbose }) {
3932
4029
  const validTargets = ["pnpm", "yarn"];
3933
4030
  if (!validTargets.includes(target)) {
3934
- console.error(chalk47.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
4031
+ console.error(chalk48.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
3935
4032
  return 1;
3936
4033
  }
3937
4034
  const cwd5 = process.cwd();
3938
4035
  const currentPM = detectCurrentPM(cwd5);
3939
4036
  if (verbose) {
3940
- console.log(chalk47.gray(`Current package manager: ${currentPM}`));
3941
- console.log(chalk47.gray(`Target package manager: ${target}`));
4037
+ console.log(chalk48.gray(`Current package manager: ${currentPM}`));
4038
+ console.log(chalk48.gray(`Target package manager: ${target}`));
3942
4039
  }
3943
4040
  if (currentPM === target) {
3944
- console.log(chalk47.yellow(`Already using ${target}. Re-applying conversion to fix any incomplete steps...`));
4041
+ console.log(chalk48.yellow(`Already using ${target}. Re-applying conversion to fix any incomplete steps...`));
3945
4042
  }
3946
4043
  if (currentPM === "unknown") {
3947
- console.error(chalk47.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
4044
+ console.error(chalk48.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
3948
4045
  return 1;
3949
4046
  }
3950
4047
  const workspacePaths = findWorkspacePackagePaths(cwd5);
3951
4048
  if (verbose) {
3952
- console.log(chalk47.gray(`Found ${workspacePaths.length} workspace packages`));
4049
+ console.log(chalk48.gray(`Found ${workspacePaths.length} workspace packages`));
3953
4050
  }
3954
4051
  if (target === "pnpm") {
3955
4052
  return convertToPnpm(cwd5, workspacePaths);
@@ -4007,7 +4104,7 @@ var rebuild = ({ target }) => {
4007
4104
  };
4008
4105
 
4009
4106
  // src/actions/recompile.ts
4010
- import chalk48 from "chalk";
4107
+ import chalk49 from "chalk";
4011
4108
  var recompile = async ({
4012
4109
  verbose,
4013
4110
  target,
@@ -4042,7 +4139,7 @@ var recompileAll = async ({
4042
4139
  const start = Date.now();
4043
4140
  const targetOptions = target ? ["-t", target] : [];
4044
4141
  if (jobs) {
4045
- console.log(chalk48.blue(`Jobs set to [${jobs}]`));
4142
+ console.log(chalk49.blue(`Jobs set to [${jobs}]`));
4046
4143
  }
4047
4144
  const foreachOptions = {
4048
4145
  incremental,
@@ -4055,25 +4152,25 @@ var recompileAll = async ({
4055
4152
  pm.foreachWorkspace("package-compile", targetOptions, foreachOptions)
4056
4153
  ]);
4057
4154
  console.log(
4058
- `${chalk48.gray("Recompiled in")} [${chalk48.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk48.gray("seconds")}`
4155
+ `${chalk49.gray("Recompiled in")} [${chalk49.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk49.gray("seconds")}`
4059
4156
  );
4060
4157
  return result;
4061
4158
  };
4062
4159
 
4063
4160
  // src/actions/relint.ts
4064
- import chalk49 from "chalk";
4161
+ import chalk50 from "chalk";
4065
4162
  var relintPackage = ({
4066
4163
  pkg,
4067
4164
  fix: fix2,
4068
4165
  verbose
4069
4166
  }) => {
4070
- console.log(chalk49.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
4167
+ console.log(chalk50.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
4071
4168
  const start = Date.now();
4072
4169
  const pm = getPackageManager();
4073
4170
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
4074
4171
  pm.runInWorkspace(pkg, fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint")
4075
4172
  ]);
4076
- console.log(chalk49.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk49.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk49.gray("seconds")}`));
4173
+ console.log(chalk50.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk50.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk50.gray("seconds")}`));
4077
4174
  return result;
4078
4175
  };
4079
4176
  var relint = ({
@@ -4093,13 +4190,13 @@ var relint = ({
4093
4190
  });
4094
4191
  };
4095
4192
  var relintAllPackages = ({ fix: fix2 = false } = {}) => {
4096
- console.log(chalk49.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
4193
+ console.log(chalk50.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
4097
4194
  const start = Date.now();
4098
4195
  const fixOptions = fix2 ? ["--fix"] : [];
4099
4196
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
4100
4197
  ["eslint", fixOptions]
4101
4198
  ]);
4102
- console.log(chalk49.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk49.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk49.gray("seconds")}`));
4199
+ console.log(chalk50.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk50.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk50.gray("seconds")}`));
4103
4200
  return result;
4104
4201
  };
4105
4202
 
@@ -4125,10 +4222,10 @@ var sonar = () => {
4125
4222
  };
4126
4223
 
4127
4224
  // src/actions/statics.ts
4128
- import chalk50 from "chalk";
4225
+ import chalk51 from "chalk";
4129
4226
  var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
4130
4227
  var statics = () => {
4131
- console.log(chalk50.green("Check Required Static Dependencies"));
4228
+ console.log(chalk51.green("Check Required Static Dependencies"));
4132
4229
  const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
4133
4230
  return detectDuplicateDependencies(statics2, DefaultDependencies);
4134
4231
  };