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