@xylabs/ts-scripts-common 7.5.1 → 7.5.3

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 (43) hide show
  1. package/dist/actions/deplint/checkPackage/checkPackage.mjs +27 -0
  2. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
  3. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +27 -0
  4. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -1
  5. package/dist/actions/deplint/checkPackage/index.mjs +27 -0
  6. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
  7. package/dist/actions/deplint/deplint.mjs +18 -0
  8. package/dist/actions/deplint/deplint.mjs.map +1 -1
  9. package/dist/actions/deplint/implicitDevDependencies.mjs +25 -0
  10. package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -1
  11. package/dist/actions/deplint/index.mjs +18 -0
  12. package/dist/actions/deplint/index.mjs.map +1 -1
  13. package/dist/actions/index.mjs +270 -110
  14. package/dist/actions/index.mjs.map +1 -1
  15. package/dist/actions/packman/convert.mjs +242 -100
  16. package/dist/actions/packman/convert.mjs.map +1 -1
  17. package/dist/actions/packman/convertToPnpm.mjs +168 -38
  18. package/dist/actions/packman/convertToPnpm.mjs.map +1 -1
  19. package/dist/actions/packman/convertToYarn.mjs +158 -38
  20. package/dist/actions/packman/convertToYarn.mjs.map +1 -1
  21. package/dist/actions/packman/index.mjs +242 -100
  22. package/dist/actions/packman/index.mjs.map +1 -1
  23. package/dist/actions/packman/rewriteSourceImports.mjs +56 -0
  24. package/dist/actions/packman/rewriteSourceImports.mjs.map +1 -0
  25. package/dist/actions/packman/swapTsScriptsDependency.mjs +57 -0
  26. package/dist/actions/packman/swapTsScriptsDependency.mjs.map +1 -0
  27. package/dist/bin/xy.mjs +287 -127
  28. package/dist/bin/xy.mjs.map +1 -1
  29. package/dist/index.mjs +289 -129
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/xy/common/index.mjs +242 -100
  32. package/dist/xy/common/index.mjs.map +1 -1
  33. package/dist/xy/common/packmanCommand.mjs +242 -100
  34. package/dist/xy/common/packmanCommand.mjs.map +1 -1
  35. package/dist/xy/index.mjs +287 -127
  36. package/dist/xy/index.mjs.map +1 -1
  37. package/dist/xy/lint/deplintCommand.mjs +18 -0
  38. package/dist/xy/lint/deplintCommand.mjs.map +1 -1
  39. package/dist/xy/lint/index.mjs +18 -0
  40. package/dist/xy/lint/index.mjs.map +1 -1
  41. package/dist/xy/xy.mjs +287 -127
  42. package/dist/xy/xy.mjs.map +1 -1
  43. package/package.json +2 -2
package/dist/xy/index.mjs CHANGED
@@ -1696,6 +1696,8 @@ function hasImportPlugin({ location, allDependencies }) {
1696
1696
  return false;
1697
1697
  }
1698
1698
  var hasVitest = ({ allDependencies }) => allDependencies.includes("vitest");
1699
+ var isYarnRepo = () => detectPackageManager() === "yarn";
1700
+ var isPnpmRepo = () => detectPackageManager() === "pnpm";
1699
1701
  var rules = [
1700
1702
  {
1701
1703
  package: "typescript",
@@ -1712,6 +1714,22 @@ var rules = [
1712
1714
  {
1713
1715
  package: "@vitest/coverage-v8",
1714
1716
  isNeeded: hasVitest
1717
+ },
1718
+ {
1719
+ package: "@xylabs/ts-scripts-yarn3",
1720
+ isNeeded: isYarnRepo
1721
+ },
1722
+ {
1723
+ package: "@xylabs/ts-scripts-react-yarn3",
1724
+ isNeeded: isYarnRepo
1725
+ },
1726
+ {
1727
+ package: "@xylabs/ts-scripts-pnpm",
1728
+ isNeeded: isPnpmRepo
1729
+ },
1730
+ {
1731
+ package: "@xylabs/ts-scripts-react-pnpm",
1732
+ isNeeded: isPnpmRepo
1715
1733
  }
1716
1734
  ];
1717
1735
  function getImplicitDevDependencies(context) {
@@ -2583,24 +2601,24 @@ function packageLintMonorepo(fix2 = false) {
2583
2601
 
2584
2602
  // src/actions/packman/convert.ts
2585
2603
  import {
2586
- existsSync as existsSync12,
2604
+ existsSync as existsSync14,
2587
2605
  readdirSync as readdirSync6,
2588
- readFileSync as readFileSync13,
2606
+ readFileSync as readFileSync15,
2589
2607
  statSync as statSync3
2590
2608
  } from "fs";
2591
- import PATH14 from "path";
2592
- import chalk33 from "chalk";
2609
+ import PATH15 from "path";
2610
+ import chalk35 from "chalk";
2593
2611
 
2594
2612
  // src/actions/packman/convertToPnpm.ts
2595
2613
  import {
2596
- existsSync as existsSync10,
2614
+ existsSync as existsSync12,
2597
2615
  mkdirSync as mkdirSync5,
2598
- readFileSync as readFileSync11,
2616
+ readFileSync as readFileSync13,
2599
2617
  rmSync as rmSync3,
2600
- writeFileSync as writeFileSync8
2618
+ writeFileSync as writeFileSync10
2601
2619
  } from "fs";
2602
- import PATH12 from "path";
2603
- import chalk31 from "chalk";
2620
+ import PATH13 from "path";
2621
+ import chalk33 from "chalk";
2604
2622
 
2605
2623
  // src/actions/packman/rewriteScripts.ts
2606
2624
  function rewriteYarnToPnpm(script) {
@@ -2650,6 +2668,113 @@ function rewriteScriptsInPackageJson(pkg, direction) {
2650
2668
  return { ...pkg, scripts: rewritten };
2651
2669
  }
2652
2670
 
2671
+ // src/actions/packman/rewriteSourceImports.ts
2672
+ import { existsSync as existsSync10, readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "fs";
2673
+ import chalk31 from "chalk";
2674
+ import { globSync as globSync3 } from "glob";
2675
+ var IMPORT_SWAP_MAP = {
2676
+ "yarn-to-pnpm": [
2677
+ ["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"],
2678
+ ["@xylabs/ts-scripts-react-yarn3", "@xylabs/ts-scripts-react-pnpm"]
2679
+ ],
2680
+ "pnpm-to-yarn": [
2681
+ ["@xylabs/ts-scripts-pnpm", "@xylabs/ts-scripts-yarn3"],
2682
+ ["@xylabs/ts-scripts-react-pnpm", "@xylabs/ts-scripts-react-yarn3"]
2683
+ ]
2684
+ };
2685
+ var SOURCE_GLOBS = [
2686
+ "**/*.ts",
2687
+ "**/*.tsx",
2688
+ "**/*.mts",
2689
+ "**/*.cts",
2690
+ "**/*.js",
2691
+ "**/*.mjs"
2692
+ ];
2693
+ var IGNORE_PATTERNS = [
2694
+ "**/node_modules/**",
2695
+ "**/dist/**",
2696
+ "**/build/**",
2697
+ "**/.yarn/**"
2698
+ ];
2699
+ function rewriteSourceImports(cwd, direction) {
2700
+ const swaps = IMPORT_SWAP_MAP[direction];
2701
+ const files = globSync3(SOURCE_GLOBS, {
2702
+ cwd,
2703
+ absolute: true,
2704
+ ignore: IGNORE_PATTERNS
2705
+ });
2706
+ let count = 0;
2707
+ for (const file of files) {
2708
+ if (!existsSync10(file)) continue;
2709
+ const original = readFileSync11(file, "utf8");
2710
+ let content = original;
2711
+ for (const [from, to] of swaps) {
2712
+ content = content.replaceAll(from, to);
2713
+ }
2714
+ if (content !== original) {
2715
+ writeFileSync8(file, content, "utf8");
2716
+ count++;
2717
+ }
2718
+ }
2719
+ if (count > 0) {
2720
+ console.log(chalk31.green(` Rewrote ts-scripts imports in ${count} source file(s)`));
2721
+ }
2722
+ }
2723
+
2724
+ // src/actions/packman/swapTsScriptsDependency.ts
2725
+ import {
2726
+ existsSync as existsSync11,
2727
+ readFileSync as readFileSync12,
2728
+ writeFileSync as writeFileSync9
2729
+ } from "fs";
2730
+ import PATH12 from "path";
2731
+ import chalk32 from "chalk";
2732
+ var SWAP_MAP = {
2733
+ "yarn-to-pnpm": [
2734
+ ["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"]
2735
+ ],
2736
+ "pnpm-to-yarn": [
2737
+ ["@xylabs/ts-scripts-pnpm", "@xylabs/ts-scripts-yarn3"]
2738
+ ]
2739
+ };
2740
+ function swapInPackageJson(pkgPath, direction) {
2741
+ if (!existsSync11(pkgPath)) return false;
2742
+ const raw = readFileSync12(pkgPath, "utf8");
2743
+ const pkg = JSON.parse(raw);
2744
+ let changed = false;
2745
+ for (const depField of ["dependencies", "devDependencies"]) {
2746
+ const deps = pkg[depField];
2747
+ if (!deps) continue;
2748
+ for (const [from, to] of SWAP_MAP[direction]) {
2749
+ if (deps[from]) {
2750
+ deps[to] = deps[from];
2751
+ delete deps[from];
2752
+ changed = true;
2753
+ }
2754
+ }
2755
+ }
2756
+ if (changed) {
2757
+ writeFileSync9(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
2758
+ }
2759
+ return changed;
2760
+ }
2761
+ function swapTsScriptsDependency(cwd, workspacePackageJsonPaths, direction) {
2762
+ let count = 0;
2763
+ if (swapInPackageJson(PATH12.join(cwd, "package.json"), direction)) {
2764
+ count++;
2765
+ }
2766
+ for (const pkgPath of workspacePackageJsonPaths) {
2767
+ const fullPath = PATH12.resolve(cwd, pkgPath, "package.json");
2768
+ if (swapInPackageJson(fullPath, direction)) {
2769
+ count++;
2770
+ }
2771
+ }
2772
+ if (count > 0) {
2773
+ const target = direction === "yarn-to-pnpm" ? "@xylabs/ts-scripts-pnpm" : "@xylabs/ts-scripts-yarn3";
2774
+ console.log(chalk32.green(` Swapped ts-scripts dependency to ${target} in ${count} package(s)`));
2775
+ }
2776
+ }
2777
+
2653
2778
  // src/actions/packman/convertToPnpm.ts
2654
2779
  var PNPM_VERSION = "10.12.1";
2655
2780
  function createPnpmWorkspaceYaml(cwd, workspacePatterns) {
@@ -2657,24 +2782,45 @@ function createPnpmWorkspaceYaml(cwd, workspacePatterns) {
2657
2782
  for (const pattern of workspacePatterns) {
2658
2783
  lines.push(` - '${pattern}'`);
2659
2784
  }
2660
- writeFileSync8(PATH12.join(cwd, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
2661
- console.log(chalk31.green(" Created pnpm-workspace.yaml"));
2785
+ writeFileSync10(PATH13.join(cwd, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
2786
+ console.log(chalk33.green(" Created pnpm-workspace.yaml"));
2787
+ }
2788
+ function readPnpmWorkspacePatterns(cwd) {
2789
+ const wsPath = PATH13.join(cwd, "pnpm-workspace.yaml");
2790
+ if (!existsSync12(wsPath)) return [];
2791
+ const content = readFileSync13(wsPath, "utf8");
2792
+ const patterns = [];
2793
+ const lines = content.split("\n");
2794
+ let inPackages = false;
2795
+ for (const line of lines) {
2796
+ if (line.trim() === "packages:") {
2797
+ inPackages = true;
2798
+ continue;
2799
+ }
2800
+ if (inPackages && /^\s+-\s+/.test(line)) {
2801
+ const pattern = line.replace(/^\s+-\s+/, "").replaceAll(/['"]/g, "").trim();
2802
+ if (pattern) patterns.push(pattern);
2803
+ } else if (inPackages && !/^\s/.test(line) && line.trim()) {
2804
+ inPackages = false;
2805
+ }
2806
+ }
2807
+ return patterns;
2662
2808
  }
2663
2809
  function updateRootPackageJson(cwd) {
2664
- const pkgPath = PATH12.join(cwd, "package.json");
2665
- const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
2666
- const workspacePatterns = pkg.workspaces ?? [];
2810
+ const pkgPath = PATH13.join(cwd, "package.json");
2811
+ const pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
2812
+ const workspacePatterns = pkg.workspaces ?? readPnpmWorkspacePatterns(cwd);
2667
2813
  delete pkg.workspaces;
2668
2814
  pkg.packageManager = `pnpm@${PNPM_VERSION}`;
2669
2815
  const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
2670
- writeFileSync8(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
2671
- console.log(chalk31.green(" Updated root package.json"));
2816
+ writeFileSync10(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
2817
+ console.log(chalk33.green(" Updated root package.json"));
2672
2818
  return workspacePatterns;
2673
2819
  }
2674
2820
  function updateGitignore(cwd) {
2675
- const gitignorePath = PATH12.join(cwd, ".gitignore");
2676
- if (!existsSync10(gitignorePath)) return;
2677
- let content = readFileSync11(gitignorePath, "utf8");
2821
+ const gitignorePath = PATH13.join(cwd, ".gitignore");
2822
+ if (!existsSync12(gitignorePath)) return;
2823
+ let content = readFileSync13(gitignorePath, "utf8");
2678
2824
  const yarnLines = [
2679
2825
  ".pnp.*",
2680
2826
  ".pnp",
@@ -2689,63 +2835,65 @@ function updateGitignore(cwd) {
2689
2835
  content = content.replaceAll(new RegExp(String.raw`^${line.replaceAll(".", String.raw`\.`).replaceAll("*", String.raw`\*`).replaceAll("!", String.raw`\!`)}\s*$`, "gm"), "");
2690
2836
  }
2691
2837
  content = content.replaceAll(/\n{3,}/g, "\n\n");
2692
- writeFileSync8(gitignorePath, content, "utf8");
2693
- console.log(chalk31.green(" Updated .gitignore"));
2838
+ writeFileSync10(gitignorePath, content, "utf8");
2839
+ console.log(chalk33.green(" Updated .gitignore"));
2694
2840
  }
2695
2841
  function deleteYarnArtifacts(cwd) {
2696
- const yarnLock = PATH12.join(cwd, "yarn.lock");
2697
- const yarnrc = PATH12.join(cwd, ".yarnrc.yml");
2698
- const yarnDir = PATH12.join(cwd, ".yarn");
2699
- if (existsSync10(yarnLock)) {
2842
+ const yarnLock = PATH13.join(cwd, "yarn.lock");
2843
+ const yarnrc = PATH13.join(cwd, ".yarnrc.yml");
2844
+ const yarnDir = PATH13.join(cwd, ".yarn");
2845
+ if (existsSync12(yarnLock)) {
2700
2846
  rmSync3(yarnLock);
2701
- console.log(chalk31.gray(" Deleted yarn.lock"));
2847
+ console.log(chalk33.gray(" Deleted yarn.lock"));
2702
2848
  }
2703
- if (existsSync10(yarnrc)) {
2849
+ if (existsSync12(yarnrc)) {
2704
2850
  rmSync3(yarnrc);
2705
- console.log(chalk31.gray(" Deleted .yarnrc.yml"));
2851
+ console.log(chalk33.gray(" Deleted .yarnrc.yml"));
2706
2852
  }
2707
- if (existsSync10(yarnDir)) {
2853
+ if (existsSync12(yarnDir)) {
2708
2854
  rmSync3(yarnDir, { force: true, recursive: true });
2709
- console.log(chalk31.gray(" Deleted .yarn/"));
2855
+ console.log(chalk33.gray(" Deleted .yarn/"));
2710
2856
  }
2711
2857
  }
2712
2858
  function createNpmrc(cwd) {
2713
- const npmrcPath = PATH12.join(cwd, ".npmrc");
2714
- if (existsSync10(npmrcPath)) return;
2715
- mkdirSync5(PATH12.dirname(npmrcPath), { recursive: true });
2716
- writeFileSync8(npmrcPath, "", "utf8");
2717
- console.log(chalk31.green(" Created .npmrc"));
2859
+ const npmrcPath = PATH13.join(cwd, ".npmrc");
2860
+ if (existsSync12(npmrcPath)) return;
2861
+ mkdirSync5(PATH13.dirname(npmrcPath), { recursive: true });
2862
+ writeFileSync10(npmrcPath, "", "utf8");
2863
+ console.log(chalk33.green(" Created .npmrc"));
2718
2864
  }
2719
2865
  function convertToPnpm(cwd, workspacePackageJsonPaths) {
2720
- console.log(chalk31.blue("\nConverting to pnpm...\n"));
2866
+ console.log(chalk33.blue("\nConverting to pnpm...\n"));
2721
2867
  const workspacePatterns = updateRootPackageJson(cwd);
2722
2868
  createPnpmWorkspaceYaml(cwd, workspacePatterns);
2723
2869
  for (const pkgPath of workspacePackageJsonPaths) {
2724
- const fullPath = PATH12.resolve(cwd, pkgPath, "package.json");
2725
- if (!existsSync10(fullPath)) continue;
2726
- const pkg = JSON.parse(readFileSync11(fullPath, "utf8"));
2870
+ const fullPath = PATH13.resolve(cwd, pkgPath, "package.json");
2871
+ if (!existsSync12(fullPath)) continue;
2872
+ const pkg = JSON.parse(readFileSync13(fullPath, "utf8"));
2727
2873
  const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
2728
2874
  if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
2729
- writeFileSync8(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
2875
+ writeFileSync10(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
2730
2876
  }
2731
2877
  }
2732
- console.log(chalk31.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
2878
+ console.log(chalk33.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
2733
2879
  updateGitignore(cwd);
2734
2880
  createNpmrc(cwd);
2881
+ swapTsScriptsDependency(cwd, workspacePackageJsonPaths, "yarn-to-pnpm");
2882
+ rewriteSourceImports(cwd, "yarn-to-pnpm");
2735
2883
  deleteYarnArtifacts(cwd);
2736
- console.log(chalk31.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
2884
+ console.log(chalk33.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
2737
2885
  return 0;
2738
2886
  }
2739
2887
 
2740
2888
  // src/actions/packman/convertToYarn.ts
2741
2889
  import {
2742
- existsSync as existsSync11,
2743
- readFileSync as readFileSync12,
2890
+ existsSync as existsSync13,
2891
+ readFileSync as readFileSync14,
2744
2892
  rmSync as rmSync4,
2745
- writeFileSync as writeFileSync9
2893
+ writeFileSync as writeFileSync11
2746
2894
  } from "fs";
2747
- import PATH13 from "path";
2748
- import chalk32 from "chalk";
2895
+ import PATH14 from "path";
2896
+ import chalk34 from "chalk";
2749
2897
  var YARN_VERSION = "4.13.0";
2750
2898
  var YARNRC_TEMPLATE = `compressionLevel: mixed
2751
2899
 
@@ -2766,10 +2914,10 @@ var YARN_GITIGNORE_ENTRIES = `
2766
2914
  !.yarn/sdks
2767
2915
  !.yarn/versions
2768
2916
  `;
2769
- function readPnpmWorkspacePatterns(cwd) {
2770
- const wsPath = PATH13.join(cwd, "pnpm-workspace.yaml");
2771
- if (!existsSync11(wsPath)) return [];
2772
- const content = readFileSync12(wsPath, "utf8");
2917
+ function readPnpmWorkspacePatterns2(cwd) {
2918
+ const wsPath = PATH14.join(cwd, "pnpm-workspace.yaml");
2919
+ if (!existsSync13(wsPath)) return [];
2920
+ const content = readFileSync14(wsPath, "utf8");
2773
2921
  const patterns = [];
2774
2922
  const lines = content.split("\n");
2775
2923
  let inPackages = false;
@@ -2788,91 +2936,104 @@ function readPnpmWorkspacePatterns(cwd) {
2788
2936
  return patterns;
2789
2937
  }
2790
2938
  function updateRootPackageJson2(cwd, workspacePatterns) {
2791
- const pkgPath = PATH13.join(cwd, "package.json");
2792
- const pkg = JSON.parse(readFileSync12(pkgPath, "utf8"));
2939
+ const pkgPath = PATH14.join(cwd, "package.json");
2940
+ const pkg = JSON.parse(readFileSync14(pkgPath, "utf8"));
2793
2941
  pkg.workspaces = workspacePatterns;
2794
2942
  pkg.packageManager = `yarn@${YARN_VERSION}`;
2795
2943
  const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
2796
- writeFileSync9(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
2797
- console.log(chalk32.green(" Updated root package.json"));
2944
+ writeFileSync11(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
2945
+ console.log(chalk34.green(" Updated root package.json"));
2798
2946
  }
2799
2947
  function updateGitignore2(cwd) {
2800
- const gitignorePath = PATH13.join(cwd, ".gitignore");
2801
- let content = existsSync11(gitignorePath) ? readFileSync12(gitignorePath, "utf8") : "";
2948
+ const gitignorePath = PATH14.join(cwd, ".gitignore");
2949
+ let content = existsSync13(gitignorePath) ? readFileSync14(gitignorePath, "utf8") : "";
2802
2950
  if (!content.includes(".yarn/*")) {
2803
2951
  content = content.trimEnd() + "\n" + YARN_GITIGNORE_ENTRIES;
2804
2952
  }
2805
- writeFileSync9(gitignorePath, content, "utf8");
2806
- console.log(chalk32.green(" Updated .gitignore"));
2953
+ writeFileSync11(gitignorePath, content, "utf8");
2954
+ console.log(chalk34.green(" Updated .gitignore"));
2807
2955
  }
2808
2956
  function deletePnpmArtifacts(cwd) {
2809
- const lockfile = PATH13.join(cwd, "pnpm-lock.yaml");
2810
- const workspaceYaml = PATH13.join(cwd, "pnpm-workspace.yaml");
2811
- const npmrc = PATH13.join(cwd, ".npmrc");
2812
- if (existsSync11(lockfile)) {
2957
+ const lockfile = PATH14.join(cwd, "pnpm-lock.yaml");
2958
+ const workspaceYaml = PATH14.join(cwd, "pnpm-workspace.yaml");
2959
+ const npmrc = PATH14.join(cwd, ".npmrc");
2960
+ if (existsSync13(lockfile)) {
2813
2961
  rmSync4(lockfile);
2814
- console.log(chalk32.gray(" Deleted pnpm-lock.yaml"));
2962
+ console.log(chalk34.gray(" Deleted pnpm-lock.yaml"));
2815
2963
  }
2816
- if (existsSync11(workspaceYaml)) {
2964
+ if (existsSync13(workspaceYaml)) {
2817
2965
  rmSync4(workspaceYaml);
2818
- console.log(chalk32.gray(" Deleted pnpm-workspace.yaml"));
2966
+ console.log(chalk34.gray(" Deleted pnpm-workspace.yaml"));
2819
2967
  }
2820
- if (existsSync11(npmrc)) {
2821
- const content = readFileSync12(npmrc, "utf8");
2968
+ if (existsSync13(npmrc)) {
2969
+ const content = readFileSync14(npmrc, "utf8");
2822
2970
  if (content.trim() === "" || content.includes("shamefully-hoist") || content.includes("node-linker")) {
2823
2971
  rmSync4(npmrc);
2824
- console.log(chalk32.gray(" Deleted .npmrc"));
2972
+ console.log(chalk34.gray(" Deleted .npmrc"));
2825
2973
  }
2826
2974
  }
2827
2975
  }
2828
2976
  function createYarnrc(cwd) {
2829
- const yarnrcPath = PATH13.join(cwd, ".yarnrc.yml");
2830
- if (existsSync11(yarnrcPath)) return;
2831
- writeFileSync9(yarnrcPath, YARNRC_TEMPLATE, "utf8");
2832
- console.log(chalk32.green(" Created .yarnrc.yml"));
2977
+ const yarnrcPath = PATH14.join(cwd, ".yarnrc.yml");
2978
+ if (existsSync13(yarnrcPath)) return;
2979
+ writeFileSync11(yarnrcPath, YARNRC_TEMPLATE, "utf8");
2980
+ console.log(chalk34.green(" Created .yarnrc.yml"));
2981
+ }
2982
+ function readWorkspacePatternsFromPackageJson(cwd) {
2983
+ const pkgPath = PATH14.join(cwd, "package.json");
2984
+ if (!existsSync13(pkgPath)) return [];
2985
+ const pkg = JSON.parse(readFileSync14(pkgPath, "utf8"));
2986
+ return pkg.workspaces ?? [];
2833
2987
  }
2834
2988
  function convertToYarn(cwd, workspacePackageJsonPaths) {
2835
- console.log(chalk32.blue("\nConverting to yarn...\n"));
2836
- const workspacePatterns = readPnpmWorkspacePatterns(cwd);
2989
+ console.log(chalk34.blue("\nConverting to yarn...\n"));
2990
+ const workspacePatterns = readPnpmWorkspacePatterns2(cwd);
2837
2991
  if (workspacePatterns.length === 0) {
2838
- console.warn(chalk32.yellow(" No workspace patterns found in pnpm-workspace.yaml"));
2992
+ const fromPkg = readWorkspacePatternsFromPackageJson(cwd);
2993
+ if (fromPkg.length > 0) {
2994
+ workspacePatterns.push(...fromPkg);
2995
+ } else {
2996
+ console.warn(chalk34.yellow(" No workspace patterns found"));
2997
+ }
2839
2998
  }
2840
2999
  updateRootPackageJson2(cwd, workspacePatterns);
2841
3000
  for (const pkgPath of workspacePackageJsonPaths) {
2842
- const fullPath = PATH13.resolve(cwd, pkgPath, "package.json");
2843
- if (!existsSync11(fullPath)) continue;
2844
- const pkg = JSON.parse(readFileSync12(fullPath, "utf8"));
3001
+ const fullPath = PATH14.resolve(cwd, pkgPath, "package.json");
3002
+ if (!existsSync13(fullPath)) continue;
3003
+ const pkg = JSON.parse(readFileSync14(fullPath, "utf8"));
2845
3004
  const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
2846
3005
  if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
2847
- writeFileSync9(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
3006
+ writeFileSync11(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
2848
3007
  }
2849
3008
  }
2850
- console.log(chalk32.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
3009
+ console.log(chalk34.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
2851
3010
  updateGitignore2(cwd);
2852
3011
  createYarnrc(cwd);
3012
+ swapTsScriptsDependency(cwd, workspacePackageJsonPaths, "pnpm-to-yarn");
3013
+ rewriteSourceImports(cwd, "pnpm-to-yarn");
2853
3014
  deletePnpmArtifacts(cwd);
2854
- console.log(chalk32.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
3015
+ console.log(chalk34.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
2855
3016
  return 0;
2856
3017
  }
2857
3018
 
2858
3019
  // src/actions/packman/convert.ts
2859
3020
  function detectCurrentPM(cwd) {
2860
- if (existsSync12(PATH14.join(cwd, "pnpm-lock.yaml")) || existsSync12(PATH14.join(cwd, "pnpm-workspace.yaml"))) {
3021
+ if (existsSync14(PATH15.join(cwd, "pnpm-lock.yaml")) || existsSync14(PATH15.join(cwd, "pnpm-workspace.yaml"))) {
2861
3022
  return "pnpm";
2862
3023
  }
2863
- if (existsSync12(PATH14.join(cwd, "yarn.lock")) || existsSync12(PATH14.join(cwd, ".yarnrc.yml"))) {
3024
+ if (existsSync14(PATH15.join(cwd, "yarn.lock")) || existsSync14(PATH15.join(cwd, ".yarnrc.yml"))) {
2864
3025
  return "yarn";
2865
3026
  }
2866
3027
  return "unknown";
2867
3028
  }
2868
3029
  function findWorkspacePackagePaths(cwd) {
2869
- const pkgPath = PATH14.join(cwd, "package.json");
2870
- const pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
3030
+ const pkgPath = PATH15.join(cwd, "package.json");
3031
+ const pkg = JSON.parse(readFileSync15(pkgPath, "utf8"));
2871
3032
  let patterns = pkg.workspaces ?? [];
2872
3033
  if (patterns.length === 0) {
2873
- const wsPath = PATH14.join(cwd, "pnpm-workspace.yaml");
2874
- if (existsSync12(wsPath)) {
2875
- const content = readFileSync13(wsPath, "utf8");
3034
+ const wsPath = PATH15.join(cwd, "pnpm-workspace.yaml");
3035
+ if (existsSync14(wsPath)) {
3036
+ const content = readFileSync15(wsPath, "utf8");
2876
3037
  const lines = content.split("\n");
2877
3038
  let inPackages = false;
2878
3039
  for (const line of lines) {
@@ -2902,15 +3063,15 @@ function resolveWorkspaceGlob(cwd, pattern) {
2902
3063
  }
2903
3064
  function walkGlob(basePath, parts, currentPath) {
2904
3065
  if (parts.length === 0) {
2905
- const fullPath = PATH14.join(basePath, currentPath);
2906
- if (existsSync12(PATH14.join(fullPath, "package.json"))) {
3066
+ const fullPath = PATH15.join(basePath, currentPath);
3067
+ if (existsSync14(PATH15.join(fullPath, "package.json"))) {
2907
3068
  return [currentPath];
2908
3069
  }
2909
3070
  return [];
2910
3071
  }
2911
3072
  const [part, ...rest] = parts;
2912
- const dirPath = PATH14.join(basePath, currentPath);
2913
- if (!existsSync12(dirPath) || !statSync3(dirPath).isDirectory()) {
3073
+ const dirPath = PATH15.join(basePath, currentPath);
3074
+ if (!existsSync14(dirPath) || !statSync3(dirPath).isDirectory()) {
2914
3075
  return [];
2915
3076
  }
2916
3077
  if (part === "*" || part === "**") {
@@ -2938,26 +3099,25 @@ function walkGlob(basePath, parts, currentPath) {
2938
3099
  function convert({ target, verbose }) {
2939
3100
  const validTargets = ["pnpm", "yarn"];
2940
3101
  if (!validTargets.includes(target)) {
2941
- console.error(chalk33.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
3102
+ console.error(chalk35.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
2942
3103
  return 1;
2943
3104
  }
2944
3105
  const cwd = process.cwd();
2945
3106
  const currentPM = detectCurrentPM(cwd);
2946
3107
  if (verbose) {
2947
- console.log(chalk33.gray(`Current package manager: ${currentPM}`));
2948
- console.log(chalk33.gray(`Target package manager: ${target}`));
3108
+ console.log(chalk35.gray(`Current package manager: ${currentPM}`));
3109
+ console.log(chalk35.gray(`Target package manager: ${target}`));
2949
3110
  }
2950
3111
  if (currentPM === target) {
2951
- console.error(chalk33.red(`Already using ${target}. No conversion needed.`));
2952
- return 1;
3112
+ console.log(chalk35.yellow(`Already using ${target}. Re-applying conversion to fix any incomplete steps...`));
2953
3113
  }
2954
3114
  if (currentPM === "unknown") {
2955
- console.error(chalk33.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
3115
+ console.error(chalk35.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
2956
3116
  return 1;
2957
3117
  }
2958
3118
  const workspacePaths = findWorkspacePackagePaths(cwd);
2959
3119
  if (verbose) {
2960
- console.log(chalk33.gray(`Found ${workspacePaths.length} workspace packages`));
3120
+ console.log(chalk35.gray(`Found ${workspacePaths.length} workspace packages`));
2961
3121
  }
2962
3122
  if (target === "pnpm") {
2963
3123
  return convertToPnpm(cwd, workspacePaths);
@@ -3015,7 +3175,7 @@ var rebuild = ({ target }) => {
3015
3175
  };
3016
3176
 
3017
3177
  // src/actions/recompile.ts
3018
- import chalk34 from "chalk";
3178
+ import chalk36 from "chalk";
3019
3179
  var recompile = async ({
3020
3180
  verbose,
3021
3181
  target,
@@ -3050,7 +3210,7 @@ var recompileAll = async ({
3050
3210
  const start = Date.now();
3051
3211
  const targetOptions = target ? ["-t", target] : [];
3052
3212
  if (jobs) {
3053
- console.log(chalk34.blue(`Jobs set to [${jobs}]`));
3213
+ console.log(chalk36.blue(`Jobs set to [${jobs}]`));
3054
3214
  }
3055
3215
  const foreachOptions = {
3056
3216
  incremental,
@@ -3063,25 +3223,25 @@ var recompileAll = async ({
3063
3223
  pm.foreachWorkspace("package-compile", targetOptions, foreachOptions)
3064
3224
  ]);
3065
3225
  console.log(
3066
- `${chalk34.gray("Recompiled in")} [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`
3226
+ `${chalk36.gray("Recompiled in")} [${chalk36.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk36.gray("seconds")}`
3067
3227
  );
3068
3228
  return result;
3069
3229
  };
3070
3230
 
3071
3231
  // src/actions/relint.ts
3072
- import chalk35 from "chalk";
3232
+ import chalk37 from "chalk";
3073
3233
  var relintPackage = ({
3074
3234
  pkg,
3075
3235
  fix: fix2,
3076
3236
  verbose
3077
3237
  }) => {
3078
- console.log(chalk35.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
3238
+ console.log(chalk37.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
3079
3239
  const start = Date.now();
3080
3240
  const pm = getPackageManager();
3081
3241
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
3082
3242
  pm.runInWorkspace(pkg, fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint")
3083
3243
  ]);
3084
- console.log(chalk35.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
3244
+ console.log(chalk37.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk37.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk37.gray("seconds")}`));
3085
3245
  return result;
3086
3246
  };
3087
3247
  var relint = ({
@@ -3101,13 +3261,13 @@ var relint = ({
3101
3261
  });
3102
3262
  };
3103
3263
  var relintAllPackages = ({ fix: fix2 = false } = {}) => {
3104
- console.log(chalk35.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
3264
+ console.log(chalk37.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
3105
3265
  const start = Date.now();
3106
3266
  const fixOptions = fix2 ? ["--fix"] : [];
3107
3267
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
3108
3268
  ["eslint", fixOptions]
3109
3269
  ]);
3110
- console.log(chalk35.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
3270
+ console.log(chalk37.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk37.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk37.gray("seconds")}`));
3111
3271
  return result;
3112
3272
  };
3113
3273
 
@@ -3551,7 +3711,7 @@ var xyCommonCommands = (args) => {
3551
3711
  };
3552
3712
 
3553
3713
  // src/xy/lint/cycleCommand.ts
3554
- import chalk36 from "chalk";
3714
+ import chalk38 from "chalk";
3555
3715
  var cycleCommand = {
3556
3716
  command: "cycle [package]",
3557
3717
  describe: "Cycle - Check for dependency cycles",
@@ -3562,12 +3722,12 @@ var cycleCommand = {
3562
3722
  const start = Date.now();
3563
3723
  if (argv.verbose) console.log("Cycle");
3564
3724
  process.exitCode = await cycle({ pkg: argv.package });
3565
- console.log(chalk36.blue(`Finished in ${Date.now() - start}ms`));
3725
+ console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
3566
3726
  }
3567
3727
  };
3568
3728
 
3569
3729
  // src/xy/lint/deplintCommand.ts
3570
- import chalk37 from "chalk";
3730
+ import chalk39 from "chalk";
3571
3731
  var deplintCommand = {
3572
3732
  command: "deplint [package]",
3573
3733
  describe: "Deplint - Run Deplint",
@@ -3605,12 +3765,12 @@ var deplintCommand = {
3605
3765
  peerDeps: !!argv.peerDeps,
3606
3766
  verbose: !!argv.verbose
3607
3767
  });
3608
- console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
3768
+ console.log(chalk39.blue(`Finished in ${Date.now() - start}ms`));
3609
3769
  }
3610
3770
  };
3611
3771
 
3612
3772
  // src/xy/lint/fixCommand.ts
3613
- import chalk38 from "chalk";
3773
+ import chalk40 from "chalk";
3614
3774
  var fixCommand = {
3615
3775
  command: "fix [package]",
3616
3776
  describe: "Fix - Run Eslint w/fix",
@@ -3621,12 +3781,12 @@ var fixCommand = {
3621
3781
  const start = Date.now();
3622
3782
  if (argv.verbose) console.log("Fix");
3623
3783
  process.exitCode = fix();
3624
- console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
3784
+ console.log(chalk40.blue(`Finished in ${Date.now() - start}ms`));
3625
3785
  }
3626
3786
  };
3627
3787
 
3628
3788
  // src/xy/lint/knipCommand.ts
3629
- import chalk39 from "chalk";
3789
+ import chalk41 from "chalk";
3630
3790
  var knipCommand = {
3631
3791
  command: "knip",
3632
3792
  describe: "Knip - Run Knip",
@@ -3637,12 +3797,12 @@ var knipCommand = {
3637
3797
  if (argv.verbose) console.log("Knip");
3638
3798
  const start = Date.now();
3639
3799
  process.exitCode = knip();
3640
- console.log(chalk39.blue(`Knip finished in ${Date.now() - start}ms`));
3800
+ console.log(chalk41.blue(`Knip finished in ${Date.now() - start}ms`));
3641
3801
  }
3642
3802
  };
3643
3803
 
3644
3804
  // src/xy/lint/lintCommand.ts
3645
- import chalk40 from "chalk";
3805
+ import chalk42 from "chalk";
3646
3806
  var lintCommand = {
3647
3807
  command: "lint [package]",
3648
3808
  describe: "Lint - Run Eslint",
@@ -3671,7 +3831,7 @@ var lintCommand = {
3671
3831
  cache: argv.cache,
3672
3832
  verbose: !!argv.verbose
3673
3833
  });
3674
- console.log(chalk40.blue(`Finished in ${Date.now() - start}ms`));
3834
+ console.log(chalk42.blue(`Finished in ${Date.now() - start}ms`));
3675
3835
  }
3676
3836
  };
3677
3837
 
@@ -3713,7 +3873,7 @@ var packageLintCommand = {
3713
3873
  };
3714
3874
 
3715
3875
  // src/xy/lint/publintCommand.ts
3716
- import chalk41 from "chalk";
3876
+ import chalk43 from "chalk";
3717
3877
  var publintCommand = {
3718
3878
  command: "publint [package]",
3719
3879
  describe: "Publint - Run Publint",
@@ -3724,12 +3884,12 @@ var publintCommand = {
3724
3884
  if (argv.verbose) console.log("Publint");
3725
3885
  const start = Date.now();
3726
3886
  process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
3727
- console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
3887
+ console.log(chalk43.blue(`Finished in ${Date.now() - start}ms`));
3728
3888
  }
3729
3889
  };
3730
3890
 
3731
3891
  // src/xy/lint/relintCommand.ts
3732
- import chalk42 from "chalk";
3892
+ import chalk44 from "chalk";
3733
3893
  var relintCommand = {
3734
3894
  command: "relint [package]",
3735
3895
  describe: "Relint - Clean & Lint",
@@ -3740,12 +3900,12 @@ var relintCommand = {
3740
3900
  if (argv.verbose) console.log("Relinting");
3741
3901
  const start = Date.now();
3742
3902
  process.exitCode = relint();
3743
- console.log(chalk42.blue(`Finished in ${Date.now() - start}ms`));
3903
+ console.log(chalk44.blue(`Finished in ${Date.now() - start}ms`));
3744
3904
  }
3745
3905
  };
3746
3906
 
3747
3907
  // src/xy/lint/sonarCommand.ts
3748
- import chalk43 from "chalk";
3908
+ import chalk45 from "chalk";
3749
3909
  var sonarCommand = {
3750
3910
  command: "sonar",
3751
3911
  describe: "Sonar - Run Sonar Check",
@@ -3756,7 +3916,7 @@ var sonarCommand = {
3756
3916
  const start = Date.now();
3757
3917
  if (argv.verbose) console.log("Sonar Check");
3758
3918
  process.exitCode = sonar();
3759
- console.log(chalk43.blue(`Finished in ${Date.now() - start}ms`));
3919
+ console.log(chalk45.blue(`Finished in ${Date.now() - start}ms`));
3760
3920
  }
3761
3921
  };
3762
3922
 
@@ -3766,7 +3926,7 @@ var xyLintCommands = (args) => {
3766
3926
  };
3767
3927
 
3768
3928
  // src/xy/xy.ts
3769
- import chalk44 from "chalk";
3929
+ import chalk46 from "chalk";
3770
3930
 
3771
3931
  // src/xy/xyParseOptions.ts
3772
3932
  import yargs from "yargs";
@@ -3809,8 +3969,8 @@ var xyBase = async (plugins) => {
3809
3969
  let args = xyBuildCommands(xyCommonCommands(xyLintCommands(options)));
3810
3970
  if (plugins) args = plugins(args);
3811
3971
  return await args.demandCommand(1).command("*", "", () => {
3812
- console.error(chalk44.yellow(`Command not found [${chalk44.magenta(process.argv[2])}]`));
3813
- console.log(chalk44.gray("Try 'xy --help' for list of commands"));
3972
+ console.error(chalk46.yellow(`Command not found [${chalk46.magenta(process.argv[2])}]`));
3973
+ console.log(chalk46.gray("Try 'xy --help' for list of commands"));
3814
3974
  }).version().help().argv;
3815
3975
  };
3816
3976
  export {