@ripast/cli 0.1.0 → 0.2.1

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 (2) hide show
  1. package/dist/cli.mjs +23 -8
  2. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { mkdirSync, readFileSync, renameSync } from "node:fs";
2
- import { dirname, resolve } from "node:path";
2
+ import { dirname, relative, resolve } from "node:path";
3
3
  import process from "node:process";
4
4
  import { buildDeclarationTree, buildScanGraph, buildUnusedDeclarations, formatAgentDeclarationTree, formatAgentFileScanHits, formatAgentHits, formatAgentScanHits, formatDeclarationTree, formatFileScanHits, formatHits, formatRegressions, formatScanGraph, formatScanHits, formatUnusedDeclarations, printDiffs, resolveVerifyMode, runCssClassFileScan, runCssClassRename, runCssClassScan, runDelete, runMove, runRename, runRenameFile, runReplace, scan, summarize, writeChanges } from "@ripast/core";
5
5
  import { defineCommand, runMain } from "citty";
@@ -401,25 +401,35 @@ const renameFileCmd = defineCommand({
401
401
  tsconfig: { type: "string" },
402
402
  apply: applyArg,
403
403
  verify: verifyArg,
404
+ verifyMode: verifyModeArg,
404
405
  profile: profileArg,
405
406
  json: jsonArg
406
407
  },
407
408
  async run({ args }) {
409
+ const verifyMode = resolveCliVerifyMode(args.verify, args.verifyMode);
408
410
  const r = await runRenameFile(args.old, args.new, {
409
411
  tsconfig: args.tsconfig,
410
- verify: args.verify
412
+ verify: verifyMode
411
413
  });
412
414
  const apply = !!args.apply;
413
- const verify = !!args.verify;
415
+ const verify = verifyMode !== "none";
414
416
  const json = !!args.json;
415
417
  const { agentProfile } = resolveProfile(args.profile);
416
- const s = summarize(r.changes);
418
+ const selfChangeDisplay = r.selfChange ? {
419
+ path: r.fileMove.to,
420
+ rel: relative(process.cwd(), r.fileMove.to),
421
+ before: r.selfChange.before,
422
+ after: r.selfChange.after
423
+ } : null;
424
+ const displayChanges = selfChangeDisplay ? [selfChangeDisplay, ...r.changes] : r.changes;
425
+ const s = summarize(displayChanges);
417
426
  const blockedByRegression = verify && apply && r.regressions.length > 0;
418
427
  const wrote = apply && !blockedByRegression;
419
428
  if (wrote) {
420
429
  writeChanges(r.changes);
421
430
  mkdirSync(dirname(r.fileMove.to), { recursive: true });
422
431
  renameSync(r.fileMove.from, r.fileMove.to);
432
+ if (selfChangeDisplay) writeChanges([selfChangeDisplay]);
423
433
  }
424
434
  if (json) {
425
435
  process.stdout.write(`${JSON.stringify({
@@ -429,6 +439,7 @@ const renameFileCmd = defineCommand({
429
439
  scanned: r.scanned,
430
440
  summary: s,
431
441
  fileMove: r.fileMove,
442
+ selfChange: r.selfChange,
432
443
  changes: r.changes.map((c) => ({
433
444
  path: c.rel,
434
445
  absolutePath: c.path,
@@ -446,10 +457,11 @@ const renameFileCmd = defineCommand({
446
457
  process.stdout.write(`${profileHeader()}\n`);
447
458
  process.stdout.write(`rename-file: ${args.old} -> ${args.new}\n`);
448
459
  process.stdout.write(`consumers: ${r.changes.length}/${r.scanned}, +${s.linesAdded} -${s.linesRemoved} lines\n`);
460
+ if (selfChangeDisplay) process.stdout.write(`self: rewrote moved file's own relative imports\n`);
449
461
  process.stdout.write(`mode: ${apply ? blockedByRegression ? "blocked" : "applied" : "dry-run"}\n`);
450
- if (r.changes.length) {
462
+ if (displayChanges.length) {
451
463
  process.stdout.write(`files:\n`);
452
- for (const c of r.changes) process.stdout.write(` ${c.rel}\n`);
464
+ for (const c of displayChanges) process.stdout.write(` ${c.rel}${selfChangeDisplay && c === selfChangeDisplay ? " (moved file, intra-file imports)" : ""}\n`);
453
465
  }
454
466
  if (verify && r.regressions.length) {
455
467
  process.stdout.write(`regressions: ${r.regressions.length}\n`);
@@ -463,8 +475,10 @@ const renameFileCmd = defineCommand({
463
475
  }
464
476
  if (!apply) {
465
477
  process.stdout.write(`rename ${args.old} -> ${args.new}\n`);
466
- process.stdout.write(`${s.files} consumer file${s.files === 1 ? "" : "s"}, +${s.linesAdded} -${s.linesRemoved} lines\n\n`);
467
- printDiffs(r.changes);
478
+ const consumerCount = r.changes.length;
479
+ const selfSuffix = selfChangeDisplay ? ` (+ moved file's own imports)` : "";
480
+ process.stdout.write(`${consumerCount} consumer file${consumerCount === 1 ? "" : "s"}${selfSuffix}, +${s.linesAdded} -${s.linesRemoved} lines\n\n`);
481
+ printDiffs(displayChanges);
468
482
  }
469
483
  if (verify && r.regressions.length) {
470
484
  process.stderr.write(`\n${formatRegressions(r.regressions, process.cwd())}\n`);
@@ -475,6 +489,7 @@ const renameFileCmd = defineCommand({
475
489
  }
476
490
  if (wrote) {
477
491
  for (const c of r.changes) process.stdout.write(`wrote ${c.rel}\n`);
492
+ if (selfChangeDisplay) process.stdout.write(`wrote ${selfChangeDisplay.rel} (moved file, intra-file imports)\n`);
478
493
  process.stdout.write(`renamed ${args.old} -> ${args.new}\n`);
479
494
  }
480
495
  const suffix = apply ? "" : " (dry run, pass --apply to write)";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ripast/cli",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.2.1",
5
5
  "description": "CLI for ripast. Deterministic AST refactors (rename, move, find-usages, tailwind/CSS class migration) for TypeScript and frontend frameworks. Auto-installs framework adapters as needed.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -50,7 +50,7 @@
50
50
  "dependencies": {
51
51
  "citty": "^0.2.2",
52
52
  "std-env": "^4.1.0",
53
- "@ripast/core": "0.1.0"
53
+ "@ripast/core": "0.2.1"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "obuild",