adsa-cli 0.1.0 → 0.1.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/bin/adsa.mjs +17 -2
  2. package/package.json +1 -1
package/bin/adsa.mjs CHANGED
@@ -18,6 +18,7 @@ import { scan } from "../lib/scan.mjs";
18
18
  import { RUBRIC, score, scoreFile } from "../lib/score.mjs";
19
19
  import { buildTodo, html, markdown } from "../lib/report.mjs";
20
20
  import { badgeEndpoint, badgeMarkdown } from "../lib/badge.mjs";
21
+ import { isDir } from "../lib/fsx.mjs";
21
22
  import { DIR, appendHistory, compare, readHistory, write } from "../lib/history.mjs";
22
23
  import { FIXES, applyFix } from "../lib/fix.mjs";
23
24
  import { evaluate, taskFile } from "../lib/eval.mjs";
@@ -222,8 +223,22 @@ function cmdFix(args, flags, out, json) {
222
223
  out(" your repository's own stack, and a generic codemod would do them badly.");
223
224
  return 0;
224
225
  }
225
- const { root, config, facts } = load(flags.cwd || ".");
226
- const ids = flags.all ? Object.keys(FIXES) : args;
226
+ // `audit <dir>` takes a directory, so `fix <dir>` has to as well. A positional
227
+ // that names a fix is a fix; anything else is where to write. Silently writing
228
+ // into the current folder because the argument was in the wrong place is the
229
+ // worst thing this command could do.
230
+ const named = args.filter((a) => a in FIXES);
231
+ const rest = args.filter((a) => !(a in FIXES));
232
+ if (rest.length > 1) {
233
+ out(`Unknown fix "${rest[1]}". Run \`npx adsa-cli fix --list\`.`);
234
+ return 1;
235
+ }
236
+ if (rest.length === 1 && !isDir(rest[0])) {
237
+ out(`Unknown fix "${rest[0]}", and no directory by that name. Run \`npx adsa-cli fix --list\`.`);
238
+ return 1;
239
+ }
240
+ const { root, config, facts } = load(flags.cwd || rest[0] || ".");
241
+ const ids = flags.all ? Object.keys(FIXES) : named;
227
242
  const actions = [];
228
243
  for (const id of ids) {
229
244
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adsa-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Score a design system on how well coding agents can use it, then fix what is missing.",
5
5
  "type": "module",
6
6
  "bin": {