@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
@@ -1142,24 +1142,24 @@ var npmignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
1142
1142
 
1143
1143
  // src/actions/packman/convert.ts
1144
1144
  import {
1145
- existsSync as existsSync11,
1145
+ existsSync as existsSync13,
1146
1146
  readdirSync as readdirSync6,
1147
- readFileSync as readFileSync10,
1147
+ readFileSync as readFileSync12,
1148
1148
  statSync as statSync3
1149
1149
  } from "fs";
1150
- import PATH11 from "path";
1151
- import chalk19 from "chalk";
1150
+ import PATH12 from "path";
1151
+ import chalk21 from "chalk";
1152
1152
 
1153
1153
  // src/actions/packman/convertToPnpm.ts
1154
1154
  import {
1155
- existsSync as existsSync9,
1155
+ existsSync as existsSync11,
1156
1156
  mkdirSync as mkdirSync5,
1157
- readFileSync as readFileSync8,
1157
+ readFileSync as readFileSync10,
1158
1158
  rmSync as rmSync3,
1159
- writeFileSync as writeFileSync6
1159
+ writeFileSync as writeFileSync8
1160
1160
  } from "fs";
1161
- import PATH9 from "path";
1162
- import chalk17 from "chalk";
1161
+ import PATH10 from "path";
1162
+ import chalk19 from "chalk";
1163
1163
 
1164
1164
  // src/actions/packman/rewriteScripts.ts
1165
1165
  function rewriteYarnToPnpm(script) {
@@ -1209,6 +1209,113 @@ function rewriteScriptsInPackageJson(pkg, direction) {
1209
1209
  return { ...pkg, scripts: rewritten };
1210
1210
  }
1211
1211
 
1212
+ // src/actions/packman/rewriteSourceImports.ts
1213
+ import { existsSync as existsSync9, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
1214
+ import chalk17 from "chalk";
1215
+ import { globSync } from "glob";
1216
+ var IMPORT_SWAP_MAP = {
1217
+ "yarn-to-pnpm": [
1218
+ ["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"],
1219
+ ["@xylabs/ts-scripts-react-yarn3", "@xylabs/ts-scripts-react-pnpm"]
1220
+ ],
1221
+ "pnpm-to-yarn": [
1222
+ ["@xylabs/ts-scripts-pnpm", "@xylabs/ts-scripts-yarn3"],
1223
+ ["@xylabs/ts-scripts-react-pnpm", "@xylabs/ts-scripts-react-yarn3"]
1224
+ ]
1225
+ };
1226
+ var SOURCE_GLOBS = [
1227
+ "**/*.ts",
1228
+ "**/*.tsx",
1229
+ "**/*.mts",
1230
+ "**/*.cts",
1231
+ "**/*.js",
1232
+ "**/*.mjs"
1233
+ ];
1234
+ var IGNORE_PATTERNS = [
1235
+ "**/node_modules/**",
1236
+ "**/dist/**",
1237
+ "**/build/**",
1238
+ "**/.yarn/**"
1239
+ ];
1240
+ function rewriteSourceImports(cwd, direction) {
1241
+ const swaps = IMPORT_SWAP_MAP[direction];
1242
+ const files = globSync(SOURCE_GLOBS, {
1243
+ cwd,
1244
+ absolute: true,
1245
+ ignore: IGNORE_PATTERNS
1246
+ });
1247
+ let count = 0;
1248
+ for (const file of files) {
1249
+ if (!existsSync9(file)) continue;
1250
+ const original = readFileSync8(file, "utf8");
1251
+ let content = original;
1252
+ for (const [from, to] of swaps) {
1253
+ content = content.replaceAll(from, to);
1254
+ }
1255
+ if (content !== original) {
1256
+ writeFileSync6(file, content, "utf8");
1257
+ count++;
1258
+ }
1259
+ }
1260
+ if (count > 0) {
1261
+ console.log(chalk17.green(` Rewrote ts-scripts imports in ${count} source file(s)`));
1262
+ }
1263
+ }
1264
+
1265
+ // src/actions/packman/swapTsScriptsDependency.ts
1266
+ import {
1267
+ existsSync as existsSync10,
1268
+ readFileSync as readFileSync9,
1269
+ writeFileSync as writeFileSync7
1270
+ } from "fs";
1271
+ import PATH9 from "path";
1272
+ import chalk18 from "chalk";
1273
+ var SWAP_MAP = {
1274
+ "yarn-to-pnpm": [
1275
+ ["@xylabs/ts-scripts-yarn3", "@xylabs/ts-scripts-pnpm"]
1276
+ ],
1277
+ "pnpm-to-yarn": [
1278
+ ["@xylabs/ts-scripts-pnpm", "@xylabs/ts-scripts-yarn3"]
1279
+ ]
1280
+ };
1281
+ function swapInPackageJson(pkgPath, direction) {
1282
+ if (!existsSync10(pkgPath)) return false;
1283
+ const raw = readFileSync9(pkgPath, "utf8");
1284
+ const pkg = JSON.parse(raw);
1285
+ let changed = false;
1286
+ for (const depField of ["dependencies", "devDependencies"]) {
1287
+ const deps = pkg[depField];
1288
+ if (!deps) continue;
1289
+ for (const [from, to] of SWAP_MAP[direction]) {
1290
+ if (deps[from]) {
1291
+ deps[to] = deps[from];
1292
+ delete deps[from];
1293
+ changed = true;
1294
+ }
1295
+ }
1296
+ }
1297
+ if (changed) {
1298
+ writeFileSync7(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
1299
+ }
1300
+ return changed;
1301
+ }
1302
+ function swapTsScriptsDependency(cwd, workspacePackageJsonPaths, direction) {
1303
+ let count = 0;
1304
+ if (swapInPackageJson(PATH9.join(cwd, "package.json"), direction)) {
1305
+ count++;
1306
+ }
1307
+ for (const pkgPath of workspacePackageJsonPaths) {
1308
+ const fullPath = PATH9.resolve(cwd, pkgPath, "package.json");
1309
+ if (swapInPackageJson(fullPath, direction)) {
1310
+ count++;
1311
+ }
1312
+ }
1313
+ if (count > 0) {
1314
+ const target = direction === "yarn-to-pnpm" ? "@xylabs/ts-scripts-pnpm" : "@xylabs/ts-scripts-yarn3";
1315
+ console.log(chalk18.green(` Swapped ts-scripts dependency to ${target} in ${count} package(s)`));
1316
+ }
1317
+ }
1318
+
1212
1319
  // src/actions/packman/convertToPnpm.ts
1213
1320
  var PNPM_VERSION = "10.12.1";
1214
1321
  function createPnpmWorkspaceYaml(cwd, workspacePatterns) {
@@ -1216,24 +1323,45 @@ function createPnpmWorkspaceYaml(cwd, workspacePatterns) {
1216
1323
  for (const pattern of workspacePatterns) {
1217
1324
  lines.push(` - '${pattern}'`);
1218
1325
  }
1219
- writeFileSync6(PATH9.join(cwd, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
1220
- console.log(chalk17.green(" Created pnpm-workspace.yaml"));
1326
+ writeFileSync8(PATH10.join(cwd, "pnpm-workspace.yaml"), lines.join("\n") + "\n", "utf8");
1327
+ console.log(chalk19.green(" Created pnpm-workspace.yaml"));
1328
+ }
1329
+ function readPnpmWorkspacePatterns(cwd) {
1330
+ const wsPath = PATH10.join(cwd, "pnpm-workspace.yaml");
1331
+ if (!existsSync11(wsPath)) return [];
1332
+ const content = readFileSync10(wsPath, "utf8");
1333
+ const patterns = [];
1334
+ const lines = content.split("\n");
1335
+ let inPackages = false;
1336
+ for (const line of lines) {
1337
+ if (line.trim() === "packages:") {
1338
+ inPackages = true;
1339
+ continue;
1340
+ }
1341
+ if (inPackages && /^\s+-\s+/.test(line)) {
1342
+ const pattern = line.replace(/^\s+-\s+/, "").replaceAll(/['"]/g, "").trim();
1343
+ if (pattern) patterns.push(pattern);
1344
+ } else if (inPackages && !/^\s/.test(line) && line.trim()) {
1345
+ inPackages = false;
1346
+ }
1347
+ }
1348
+ return patterns;
1221
1349
  }
1222
1350
  function updateRootPackageJson(cwd) {
1223
- const pkgPath = PATH9.join(cwd, "package.json");
1224
- const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
1225
- const workspacePatterns = pkg.workspaces ?? [];
1351
+ const pkgPath = PATH10.join(cwd, "package.json");
1352
+ const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
1353
+ const workspacePatterns = pkg.workspaces ?? readPnpmWorkspacePatterns(cwd);
1226
1354
  delete pkg.workspaces;
1227
1355
  pkg.packageManager = `pnpm@${PNPM_VERSION}`;
1228
1356
  const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
1229
- writeFileSync6(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
1230
- console.log(chalk17.green(" Updated root package.json"));
1357
+ writeFileSync8(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
1358
+ console.log(chalk19.green(" Updated root package.json"));
1231
1359
  return workspacePatterns;
1232
1360
  }
1233
1361
  function updateGitignore(cwd) {
1234
- const gitignorePath = PATH9.join(cwd, ".gitignore");
1235
- if (!existsSync9(gitignorePath)) return;
1236
- let content = readFileSync8(gitignorePath, "utf8");
1362
+ const gitignorePath = PATH10.join(cwd, ".gitignore");
1363
+ if (!existsSync11(gitignorePath)) return;
1364
+ let content = readFileSync10(gitignorePath, "utf8");
1237
1365
  const yarnLines = [
1238
1366
  ".pnp.*",
1239
1367
  ".pnp",
@@ -1248,63 +1376,65 @@ function updateGitignore(cwd) {
1248
1376
  content = content.replaceAll(new RegExp(String.raw`^${line.replaceAll(".", String.raw`\.`).replaceAll("*", String.raw`\*`).replaceAll("!", String.raw`\!`)}\s*$`, "gm"), "");
1249
1377
  }
1250
1378
  content = content.replaceAll(/\n{3,}/g, "\n\n");
1251
- writeFileSync6(gitignorePath, content, "utf8");
1252
- console.log(chalk17.green(" Updated .gitignore"));
1379
+ writeFileSync8(gitignorePath, content, "utf8");
1380
+ console.log(chalk19.green(" Updated .gitignore"));
1253
1381
  }
1254
1382
  function deleteYarnArtifacts(cwd) {
1255
- const yarnLock = PATH9.join(cwd, "yarn.lock");
1256
- const yarnrc = PATH9.join(cwd, ".yarnrc.yml");
1257
- const yarnDir = PATH9.join(cwd, ".yarn");
1258
- if (existsSync9(yarnLock)) {
1383
+ const yarnLock = PATH10.join(cwd, "yarn.lock");
1384
+ const yarnrc = PATH10.join(cwd, ".yarnrc.yml");
1385
+ const yarnDir = PATH10.join(cwd, ".yarn");
1386
+ if (existsSync11(yarnLock)) {
1259
1387
  rmSync3(yarnLock);
1260
- console.log(chalk17.gray(" Deleted yarn.lock"));
1388
+ console.log(chalk19.gray(" Deleted yarn.lock"));
1261
1389
  }
1262
- if (existsSync9(yarnrc)) {
1390
+ if (existsSync11(yarnrc)) {
1263
1391
  rmSync3(yarnrc);
1264
- console.log(chalk17.gray(" Deleted .yarnrc.yml"));
1392
+ console.log(chalk19.gray(" Deleted .yarnrc.yml"));
1265
1393
  }
1266
- if (existsSync9(yarnDir)) {
1394
+ if (existsSync11(yarnDir)) {
1267
1395
  rmSync3(yarnDir, { force: true, recursive: true });
1268
- console.log(chalk17.gray(" Deleted .yarn/"));
1396
+ console.log(chalk19.gray(" Deleted .yarn/"));
1269
1397
  }
1270
1398
  }
1271
1399
  function createNpmrc(cwd) {
1272
- const npmrcPath = PATH9.join(cwd, ".npmrc");
1273
- if (existsSync9(npmrcPath)) return;
1274
- mkdirSync5(PATH9.dirname(npmrcPath), { recursive: true });
1275
- writeFileSync6(npmrcPath, "", "utf8");
1276
- console.log(chalk17.green(" Created .npmrc"));
1400
+ const npmrcPath = PATH10.join(cwd, ".npmrc");
1401
+ if (existsSync11(npmrcPath)) return;
1402
+ mkdirSync5(PATH10.dirname(npmrcPath), { recursive: true });
1403
+ writeFileSync8(npmrcPath, "", "utf8");
1404
+ console.log(chalk19.green(" Created .npmrc"));
1277
1405
  }
1278
1406
  function convertToPnpm(cwd, workspacePackageJsonPaths) {
1279
- console.log(chalk17.blue("\nConverting to pnpm...\n"));
1407
+ console.log(chalk19.blue("\nConverting to pnpm...\n"));
1280
1408
  const workspacePatterns = updateRootPackageJson(cwd);
1281
1409
  createPnpmWorkspaceYaml(cwd, workspacePatterns);
1282
1410
  for (const pkgPath of workspacePackageJsonPaths) {
1283
- const fullPath = PATH9.resolve(cwd, pkgPath, "package.json");
1284
- if (!existsSync9(fullPath)) continue;
1285
- const pkg = JSON.parse(readFileSync8(fullPath, "utf8"));
1411
+ const fullPath = PATH10.resolve(cwd, pkgPath, "package.json");
1412
+ if (!existsSync11(fullPath)) continue;
1413
+ const pkg = JSON.parse(readFileSync10(fullPath, "utf8"));
1286
1414
  const updated = rewriteScriptsInPackageJson(pkg, "yarn-to-pnpm");
1287
1415
  if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
1288
- writeFileSync6(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
1416
+ writeFileSync8(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
1289
1417
  }
1290
1418
  }
1291
- console.log(chalk17.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
1419
+ console.log(chalk19.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
1292
1420
  updateGitignore(cwd);
1293
1421
  createNpmrc(cwd);
1422
+ swapTsScriptsDependency(cwd, workspacePackageJsonPaths, "yarn-to-pnpm");
1423
+ rewriteSourceImports(cwd, "yarn-to-pnpm");
1294
1424
  deleteYarnArtifacts(cwd);
1295
- console.log(chalk17.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
1425
+ console.log(chalk19.blue("\nConversion complete. Run `pnpm install` to generate pnpm-lock.yaml.\n"));
1296
1426
  return 0;
1297
1427
  }
1298
1428
 
1299
1429
  // src/actions/packman/convertToYarn.ts
1300
1430
  import {
1301
- existsSync as existsSync10,
1302
- readFileSync as readFileSync9,
1431
+ existsSync as existsSync12,
1432
+ readFileSync as readFileSync11,
1303
1433
  rmSync as rmSync4,
1304
- writeFileSync as writeFileSync7
1434
+ writeFileSync as writeFileSync9
1305
1435
  } from "fs";
1306
- import PATH10 from "path";
1307
- import chalk18 from "chalk";
1436
+ import PATH11 from "path";
1437
+ import chalk20 from "chalk";
1308
1438
  var YARN_VERSION = "4.13.0";
1309
1439
  var YARNRC_TEMPLATE = `compressionLevel: mixed
1310
1440
 
@@ -1325,10 +1455,10 @@ var YARN_GITIGNORE_ENTRIES = `
1325
1455
  !.yarn/sdks
1326
1456
  !.yarn/versions
1327
1457
  `;
1328
- function readPnpmWorkspacePatterns(cwd) {
1329
- const wsPath = PATH10.join(cwd, "pnpm-workspace.yaml");
1330
- if (!existsSync10(wsPath)) return [];
1331
- const content = readFileSync9(wsPath, "utf8");
1458
+ function readPnpmWorkspacePatterns2(cwd) {
1459
+ const wsPath = PATH11.join(cwd, "pnpm-workspace.yaml");
1460
+ if (!existsSync12(wsPath)) return [];
1461
+ const content = readFileSync11(wsPath, "utf8");
1332
1462
  const patterns = [];
1333
1463
  const lines = content.split("\n");
1334
1464
  let inPackages = false;
@@ -1347,91 +1477,104 @@ function readPnpmWorkspacePatterns(cwd) {
1347
1477
  return patterns;
1348
1478
  }
1349
1479
  function updateRootPackageJson2(cwd, workspacePatterns) {
1350
- const pkgPath = PATH10.join(cwd, "package.json");
1351
- const pkg = JSON.parse(readFileSync9(pkgPath, "utf8"));
1480
+ const pkgPath = PATH11.join(cwd, "package.json");
1481
+ const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
1352
1482
  pkg.workspaces = workspacePatterns;
1353
1483
  pkg.packageManager = `yarn@${YARN_VERSION}`;
1354
1484
  const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
1355
- writeFileSync7(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
1356
- console.log(chalk18.green(" Updated root package.json"));
1485
+ writeFileSync9(pkgPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
1486
+ console.log(chalk20.green(" Updated root package.json"));
1357
1487
  }
1358
1488
  function updateGitignore2(cwd) {
1359
- const gitignorePath = PATH10.join(cwd, ".gitignore");
1360
- let content = existsSync10(gitignorePath) ? readFileSync9(gitignorePath, "utf8") : "";
1489
+ const gitignorePath = PATH11.join(cwd, ".gitignore");
1490
+ let content = existsSync12(gitignorePath) ? readFileSync11(gitignorePath, "utf8") : "";
1361
1491
  if (!content.includes(".yarn/*")) {
1362
1492
  content = content.trimEnd() + "\n" + YARN_GITIGNORE_ENTRIES;
1363
1493
  }
1364
- writeFileSync7(gitignorePath, content, "utf8");
1365
- console.log(chalk18.green(" Updated .gitignore"));
1494
+ writeFileSync9(gitignorePath, content, "utf8");
1495
+ console.log(chalk20.green(" Updated .gitignore"));
1366
1496
  }
1367
1497
  function deletePnpmArtifacts(cwd) {
1368
- const lockfile = PATH10.join(cwd, "pnpm-lock.yaml");
1369
- const workspaceYaml = PATH10.join(cwd, "pnpm-workspace.yaml");
1370
- const npmrc = PATH10.join(cwd, ".npmrc");
1371
- if (existsSync10(lockfile)) {
1498
+ const lockfile = PATH11.join(cwd, "pnpm-lock.yaml");
1499
+ const workspaceYaml = PATH11.join(cwd, "pnpm-workspace.yaml");
1500
+ const npmrc = PATH11.join(cwd, ".npmrc");
1501
+ if (existsSync12(lockfile)) {
1372
1502
  rmSync4(lockfile);
1373
- console.log(chalk18.gray(" Deleted pnpm-lock.yaml"));
1503
+ console.log(chalk20.gray(" Deleted pnpm-lock.yaml"));
1374
1504
  }
1375
- if (existsSync10(workspaceYaml)) {
1505
+ if (existsSync12(workspaceYaml)) {
1376
1506
  rmSync4(workspaceYaml);
1377
- console.log(chalk18.gray(" Deleted pnpm-workspace.yaml"));
1507
+ console.log(chalk20.gray(" Deleted pnpm-workspace.yaml"));
1378
1508
  }
1379
- if (existsSync10(npmrc)) {
1380
- const content = readFileSync9(npmrc, "utf8");
1509
+ if (existsSync12(npmrc)) {
1510
+ const content = readFileSync11(npmrc, "utf8");
1381
1511
  if (content.trim() === "" || content.includes("shamefully-hoist") || content.includes("node-linker")) {
1382
1512
  rmSync4(npmrc);
1383
- console.log(chalk18.gray(" Deleted .npmrc"));
1513
+ console.log(chalk20.gray(" Deleted .npmrc"));
1384
1514
  }
1385
1515
  }
1386
1516
  }
1387
1517
  function createYarnrc(cwd) {
1388
- const yarnrcPath = PATH10.join(cwd, ".yarnrc.yml");
1389
- if (existsSync10(yarnrcPath)) return;
1390
- writeFileSync7(yarnrcPath, YARNRC_TEMPLATE, "utf8");
1391
- console.log(chalk18.green(" Created .yarnrc.yml"));
1518
+ const yarnrcPath = PATH11.join(cwd, ".yarnrc.yml");
1519
+ if (existsSync12(yarnrcPath)) return;
1520
+ writeFileSync9(yarnrcPath, YARNRC_TEMPLATE, "utf8");
1521
+ console.log(chalk20.green(" Created .yarnrc.yml"));
1522
+ }
1523
+ function readWorkspacePatternsFromPackageJson(cwd) {
1524
+ const pkgPath = PATH11.join(cwd, "package.json");
1525
+ if (!existsSync12(pkgPath)) return [];
1526
+ const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
1527
+ return pkg.workspaces ?? [];
1392
1528
  }
1393
1529
  function convertToYarn(cwd, workspacePackageJsonPaths) {
1394
- console.log(chalk18.blue("\nConverting to yarn...\n"));
1395
- const workspacePatterns = readPnpmWorkspacePatterns(cwd);
1530
+ console.log(chalk20.blue("\nConverting to yarn...\n"));
1531
+ const workspacePatterns = readPnpmWorkspacePatterns2(cwd);
1396
1532
  if (workspacePatterns.length === 0) {
1397
- console.warn(chalk18.yellow(" No workspace patterns found in pnpm-workspace.yaml"));
1533
+ const fromPkg = readWorkspacePatternsFromPackageJson(cwd);
1534
+ if (fromPkg.length > 0) {
1535
+ workspacePatterns.push(...fromPkg);
1536
+ } else {
1537
+ console.warn(chalk20.yellow(" No workspace patterns found"));
1538
+ }
1398
1539
  }
1399
1540
  updateRootPackageJson2(cwd, workspacePatterns);
1400
1541
  for (const pkgPath of workspacePackageJsonPaths) {
1401
- const fullPath = PATH10.resolve(cwd, pkgPath, "package.json");
1402
- if (!existsSync10(fullPath)) continue;
1403
- const pkg = JSON.parse(readFileSync9(fullPath, "utf8"));
1542
+ const fullPath = PATH11.resolve(cwd, pkgPath, "package.json");
1543
+ if (!existsSync12(fullPath)) continue;
1544
+ const pkg = JSON.parse(readFileSync11(fullPath, "utf8"));
1404
1545
  const updated = rewriteScriptsInPackageJson(pkg, "pnpm-to-yarn");
1405
1546
  if (JSON.stringify(pkg) !== JSON.stringify(updated)) {
1406
- writeFileSync7(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
1547
+ writeFileSync9(fullPath, JSON.stringify(updated, null, 2) + "\n", "utf8");
1407
1548
  }
1408
1549
  }
1409
- console.log(chalk18.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
1550
+ console.log(chalk20.green(` Rewrote scripts in ${workspacePackageJsonPaths.length} workspace package(s)`));
1410
1551
  updateGitignore2(cwd);
1411
1552
  createYarnrc(cwd);
1553
+ swapTsScriptsDependency(cwd, workspacePackageJsonPaths, "pnpm-to-yarn");
1554
+ rewriteSourceImports(cwd, "pnpm-to-yarn");
1412
1555
  deletePnpmArtifacts(cwd);
1413
- console.log(chalk18.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
1556
+ console.log(chalk20.blue("\nConversion complete. Run `corepack enable yarn && yarn set version stable && yarn install` to finish setup.\n"));
1414
1557
  return 0;
1415
1558
  }
1416
1559
 
1417
1560
  // src/actions/packman/convert.ts
1418
1561
  function detectCurrentPM(cwd) {
1419
- if (existsSync11(PATH11.join(cwd, "pnpm-lock.yaml")) || existsSync11(PATH11.join(cwd, "pnpm-workspace.yaml"))) {
1562
+ if (existsSync13(PATH12.join(cwd, "pnpm-lock.yaml")) || existsSync13(PATH12.join(cwd, "pnpm-workspace.yaml"))) {
1420
1563
  return "pnpm";
1421
1564
  }
1422
- if (existsSync11(PATH11.join(cwd, "yarn.lock")) || existsSync11(PATH11.join(cwd, ".yarnrc.yml"))) {
1565
+ if (existsSync13(PATH12.join(cwd, "yarn.lock")) || existsSync13(PATH12.join(cwd, ".yarnrc.yml"))) {
1423
1566
  return "yarn";
1424
1567
  }
1425
1568
  return "unknown";
1426
1569
  }
1427
1570
  function findWorkspacePackagePaths(cwd) {
1428
- const pkgPath = PATH11.join(cwd, "package.json");
1429
- const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
1571
+ const pkgPath = PATH12.join(cwd, "package.json");
1572
+ const pkg = JSON.parse(readFileSync12(pkgPath, "utf8"));
1430
1573
  let patterns = pkg.workspaces ?? [];
1431
1574
  if (patterns.length === 0) {
1432
- const wsPath = PATH11.join(cwd, "pnpm-workspace.yaml");
1433
- if (existsSync11(wsPath)) {
1434
- const content = readFileSync10(wsPath, "utf8");
1575
+ const wsPath = PATH12.join(cwd, "pnpm-workspace.yaml");
1576
+ if (existsSync13(wsPath)) {
1577
+ const content = readFileSync12(wsPath, "utf8");
1435
1578
  const lines = content.split("\n");
1436
1579
  let inPackages = false;
1437
1580
  for (const line of lines) {
@@ -1461,15 +1604,15 @@ function resolveWorkspaceGlob(cwd, pattern) {
1461
1604
  }
1462
1605
  function walkGlob(basePath, parts, currentPath) {
1463
1606
  if (parts.length === 0) {
1464
- const fullPath = PATH11.join(basePath, currentPath);
1465
- if (existsSync11(PATH11.join(fullPath, "package.json"))) {
1607
+ const fullPath = PATH12.join(basePath, currentPath);
1608
+ if (existsSync13(PATH12.join(fullPath, "package.json"))) {
1466
1609
  return [currentPath];
1467
1610
  }
1468
1611
  return [];
1469
1612
  }
1470
1613
  const [part, ...rest] = parts;
1471
- const dirPath = PATH11.join(basePath, currentPath);
1472
- if (!existsSync11(dirPath) || !statSync3(dirPath).isDirectory()) {
1614
+ const dirPath = PATH12.join(basePath, currentPath);
1615
+ if (!existsSync13(dirPath) || !statSync3(dirPath).isDirectory()) {
1473
1616
  return [];
1474
1617
  }
1475
1618
  if (part === "*" || part === "**") {
@@ -1497,26 +1640,25 @@ function walkGlob(basePath, parts, currentPath) {
1497
1640
  function convert({ target, verbose }) {
1498
1641
  const validTargets = ["pnpm", "yarn"];
1499
1642
  if (!validTargets.includes(target)) {
1500
- console.error(chalk19.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
1643
+ console.error(chalk21.red(`Invalid target "${target}". Must be one of: ${validTargets.join(", ")}`));
1501
1644
  return 1;
1502
1645
  }
1503
1646
  const cwd = process.cwd();
1504
1647
  const currentPM = detectCurrentPM(cwd);
1505
1648
  if (verbose) {
1506
- console.log(chalk19.gray(`Current package manager: ${currentPM}`));
1507
- console.log(chalk19.gray(`Target package manager: ${target}`));
1649
+ console.log(chalk21.gray(`Current package manager: ${currentPM}`));
1650
+ console.log(chalk21.gray(`Target package manager: ${target}`));
1508
1651
  }
1509
1652
  if (currentPM === target) {
1510
- console.error(chalk19.red(`Already using ${target}. No conversion needed.`));
1511
- return 1;
1653
+ console.log(chalk21.yellow(`Already using ${target}. Re-applying conversion to fix any incomplete steps...`));
1512
1654
  }
1513
1655
  if (currentPM === "unknown") {
1514
- console.error(chalk19.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
1656
+ console.error(chalk21.red("Could not detect current package manager. No yarn.lock or pnpm-lock.yaml found."));
1515
1657
  return 1;
1516
1658
  }
1517
1659
  const workspacePaths = findWorkspacePackagePaths(cwd);
1518
1660
  if (verbose) {
1519
- console.log(chalk19.gray(`Found ${workspacePaths.length} workspace packages`));
1661
+ console.log(chalk21.gray(`Found ${workspacePaths.length} workspace packages`));
1520
1662
  }
1521
1663
  if (target === "pnpm") {
1522
1664
  return convertToPnpm(cwd, workspacePaths);