@ripast/cli 0.0.1 → 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 +26 -9
  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,25 +439,29 @@ 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,
435
446
  before: c.before,
436
447
  after: c.after
437
448
  })),
438
- regressions: r.regressions
449
+ regressions: r.regressions,
450
+ warnings: r.warnings
439
451
  })}\n`);
440
452
  if (blockedByRegression) process.exit(1);
441
453
  return;
442
454
  }
455
+ for (const w of r.warnings) process.stderr.write(`warning: ${w}\n`);
443
456
  if (agentProfile) {
444
457
  process.stdout.write(`${profileHeader()}\n`);
445
458
  process.stdout.write(`rename-file: ${args.old} -> ${args.new}\n`);
446
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`);
447
461
  process.stdout.write(`mode: ${apply ? blockedByRegression ? "blocked" : "applied" : "dry-run"}\n`);
448
- if (r.changes.length) {
462
+ if (displayChanges.length) {
449
463
  process.stdout.write(`files:\n`);
450
- 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`);
451
465
  }
452
466
  if (verify && r.regressions.length) {
453
467
  process.stdout.write(`regressions: ${r.regressions.length}\n`);
@@ -461,8 +475,10 @@ const renameFileCmd = defineCommand({
461
475
  }
462
476
  if (!apply) {
463
477
  process.stdout.write(`rename ${args.old} -> ${args.new}\n`);
464
- process.stdout.write(`${s.files} consumer file${s.files === 1 ? "" : "s"}, +${s.linesAdded} -${s.linesRemoved} lines\n\n`);
465
- 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);
466
482
  }
467
483
  if (verify && r.regressions.length) {
468
484
  process.stderr.write(`\n${formatRegressions(r.regressions, process.cwd())}\n`);
@@ -473,6 +489,7 @@ const renameFileCmd = defineCommand({
473
489
  }
474
490
  if (wrote) {
475
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`);
476
493
  process.stdout.write(`renamed ${args.old} -> ${args.new}\n`);
477
494
  }
478
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.0.1",
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.0.1"
53
+ "@ripast/core": "0.2.1"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "obuild",