Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<name>` 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`
Expand Down
2 changes: 1 addition & 1 deletion docs/TOOLING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<name>`, 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-<name>` that runs the same file draws no warning, and an override never covers a CLI without `wcat-<name>`, 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`,
Expand Down
9 changes: 5 additions & 4 deletions docs/standards/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<name>`
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-<name>` 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-<name>`: `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.
Expand Down
2 changes: 1 addition & 1 deletion src/dev/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ else process.stdout.write(${JSON.stringify(tree)})\n`,
document(clean())
const bin = (bin: Record<string, string>) =>
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(
Expand Down
10 changes: 10 additions & 0 deletions src/dev/wcat-lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ describe("the wcat lint warnings", () => {
expect(binNameWarnings({})).toEqual([])
})

it("accept a short name beside a wcat-<name> 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)
Expand Down
10 changes: 8 additions & 2 deletions src/dev/wcat-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@ 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-<name>`, and a package outside `@wirecat/` takes no reserved name. */
/**
* Each command is `wcat-<name>`, and a package outside `@wirecat/` takes no reserved name. A short name is fine beside
* a `wcat-<name>` 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<string, unknown>) : {}
if (bins[command] !== undefined && bins[`${PROGRAM_PREFIX}${command}`] === bins[command]) return []
return [
{
rule: "wcat-bin-name",
target,
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 -" }]
Expand Down