diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a58f50..2618122 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,11 @@ Every entry says what changed as a caller sees it, why, and what to watch for ### Changed — may break callers +- **`cli-dev lint` no longer warns about a short `"bin"` name beside a `wcat-` that runs the same file**, the + pair the template writes (`ydisk` and `wcat-ydisk`). A short name alone, or one that runs another file, still warns. + Watch for: an override in `lint/overrides.json` for such a pair is now stale, and `cli-dev lint` fails until it is + removed. asterisk-cli (`pbx`), beeline-cli and gcal-cli carry one; delete that entry when bumping cli-base. See + [WC-CMD-29](docs/standards/commands.md). - **The version-level check reads 1.0.0 rules.** From 1.0.0 on, a stable break needs a major, an experimental change a minor. A release candidate (`1.0.0-rc.1`) counts as its plain version and is never read as the release below. - **The optional peers `commander` and `vitest` are now `^15.0.0` and `^5.0.0`** instead of open ranges: `./commands` diff --git a/docs/TOOLING.md b/docs/TOOLING.md index 47d904c..de1506c 100644 --- a/docs/TOOLING.md +++ b/docs/TOOLING.md @@ -77,7 +77,7 @@ files to today's violations. Permanent exceptions go in `lint/overrides.json` — `[{ "rule", "target", "reason", "owner", "review_after" }]`, `owner` a GitHub handle (`@octocat`), `review_after` a date — and more than `--budget` (10) of them fails, as does one past its `review_after`. An entry that does not fit that shape fails the run by its number and is ignored; the others still -apply. The `wcat-bin-name`, `wcat-describe` and `wcat-hosts` warnings are overridden the same way; an override covers a short name kept beside `wcat-`, never a CLI without one, which `cli-dev release-pr` refuses at its first release. `cli-dev audit` names a rule overridden more than three times across the CLIs it reads, for review. +apply. The `wcat-bin-name`, `wcat-describe` and `wcat-hosts` warnings are overridden the same way; a short name beside a `wcat-` that runs the same file draws no warning, and an override never covers a CLI without `wcat-`, which `cli-dev release-pr` refuses at its first release. `cli-dev audit` names a rule overridden more than three times across the CLIs it reads, for review. `flag-synonym` reports another name for a vocabulary flag (`--take` for `--limit`, from the flag's `replaces`), and `identifier-name` an identifier key the glossary (`IDENTIFIERS`) names another way (`execution_id` for `run_id`). Every option needs a role from the vocabulary (`paging`, `output`, `sort`, `mode`, `action`, `budget`, `scope`, diff --git a/docs/standards/commands.md b/docs/standards/commands.md index ffdc0f4..7ead86a 100644 --- a/docs/standards/commands.md +++ b/docs/standards/commands.md @@ -412,10 +412,11 @@ does not take a reserved one. answer `--wcat-describe`. `cli-dev manifest --program dist/program.js --identity dist/wcat.js --check` fails when `contracts/wirecat.json` is stale. `cli-dev release-pr` fails the pull request that raises the version from `0.0.0`, the version `new` writes, when `package.json` has no `wcat-` `"bin"` key. -- **Exceptions:** `cli-dev lint` warns about every `"bin"` key without the prefix, the short name beside `wcat-` - included. A CLI that keeps the short name says why in `lint/overrides.json` (`"rule": "wcat-bin-name"`, the target - as the warning prints it), which silences the warning and counts against the budget; gcal, pbx and beeline do, - and the other CLIs carry the warning. Either is allowed: the warning is not a failure. +- **Exceptions:** a short `"bin"` key beside a `wcat-` key that runs the same file is allowed, and `cli-dev lint` + says nothing about it: the template installs both while users move to the long name. A short key alone, or one that + runs another file, gets the warning. A CLI that keeps such a key says why in `lint/overrides.json` + (`"rule": "wcat-bin-name"`, the target as the warning prints it), which silences the warning and counts against the + budget. Either is allowed: the warning is not a failure. An override covers the short name only, never a CLI with no `wcat-`: `cli-dev release-pr` does not read `lint/overrides.json`. A WireCat CLI listed in Desktop's own catalog needs no manifest until Desktop reads one for it. diff --git a/src/dev/lint.test.ts b/src/dev/lint.test.ts index a80c609..90582e1 100644 --- a/src/dev/lint.test.ts +++ b/src/dev/lint.test.ts @@ -1235,7 +1235,7 @@ else process.stdout.write(${JSON.stringify(tree)})\n`, document(clean()) const bin = (bin: Record) => writeFileSync(join(root, "package.json"), JSON.stringify({ name: "@wirecat/tool-cli", bin })) - bin({ tool: "bin.mjs", "wcat-tool": "bin.mjs" }) + bin({ tool: "bin.mjs", "wcat-tool": "other.mjs" }) mkdirSync(join(root, "contracts")) writeFileSync(join(root, "contracts/wirecat.json"), JSON.stringify({ network: { hosts: [] } })) writeFileSync( diff --git a/src/dev/wcat-lint.test.ts b/src/dev/wcat-lint.test.ts index 08b7fb6..3e370d9 100644 --- a/src/dev/wcat-lint.test.ts +++ b/src/dev/wcat-lint.test.ts @@ -16,6 +16,16 @@ describe("the wcat lint warnings", () => { expect(binNameWarnings({})).toEqual([]) }) + it("accept a short name beside a wcat- that runs the same file, and warn when the file differs", () => { + expect(binNameWarnings({ name: "@wirecat/ydisk-cli", bin: { ydisk: "a.js", "wcat-ydisk": "a.js" } })).toEqual([]) + expect(binNameWarnings({ name: "@wirecat/ydisk-cli", bin: { ydisk: "a.js", "wcat-ydisk": "b.js" } })).toMatchObject( + [{ rule: "wcat-bin-name", target: 'package.json "bin" ydisk' }], + ) + expect(binNameWarnings({ name: "@wirecat/ydisk-cli", bin: { ydisk: "a.js" } })).toMatchObject([ + { rule: "wcat-bin-name", target: 'package.json "bin" ydisk' }, + ]) + }) + it("want a --wcat-describe answer in the format wcat reads", () => { expect(describeWarnings({ status: 0, stdout: '{"wcat_describe":1,"version":"1","description":"d"}' })).toEqual([]) expect(describeWarnings({ status: 0, stdout: "usage: tool" })).toHaveLength(1) diff --git a/src/dev/wcat-lint.ts b/src/dev/wcat-lint.ts index f5d753f..e7b6cb1 100644 --- a/src/dev/wcat-lint.ts +++ b/src/dev/wcat-lint.ts @@ -24,11 +24,16 @@ export const binNames = (pkg: { name?: unknown; bin?: unknown }): string[] => { return typeof pkg.bin === "object" && pkg.bin !== null ? Object.keys(pkg.bin) : [] } -/** Each command is `wcat-`, and a package outside `@wirecat/` takes no reserved name. */ +/** + * Each command is `wcat-`, and a package outside `@wirecat/` takes no reserved name. A short name is fine beside + * a `wcat-` that runs the same file: the template installs both while users move to the long one. + */ export const binNameWarnings = (pkg: { name?: unknown; bin?: unknown }): WcatWarning[] => binNames(pkg).flatMap((command): WcatWarning[] => { const target = `package.json "bin" ${command}` - if (!command.startsWith(PROGRAM_PREFIX)) + if (!command.startsWith(PROGRAM_PREFIX)) { + const bins = typeof pkg.bin === "object" && pkg.bin !== null ? (pkg.bin as Record) : {} + if (bins[command] !== undefined && bins[`${PROGRAM_PREFIX}${command}`] === bins[command]) return [] return [ { rule: "wcat-bin-name", @@ -36,6 +41,7 @@ export const binNameWarnings = (pkg: { name?: unknown; bin?: unknown }): WcatWar message: `install the command as ${PROGRAM_PREFIX}${command}, so no other program on PATH has its name`, }, ] + } const name = command.slice(PROGRAM_PREFIX.length) if (!TOOL_NAME.test(name)) return [{ rule: "wcat-bin-name", target, message: "the name after wcat- is lower-case letters, digits and -" }]