diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 68db7d2..ea29d85 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,8 +86,9 @@ brackets (`[--worker-type eor]`, or a switch, `[--bulk]`): the command picks the every path ID has an argument in path order, no flag takes a global flag's name, command lines and endpoints are unique, no entry takes a hand-picked or static command's name, and a released command line (one in `src/public-api/manifest.json`) never changes by accident: [a released command line can change in a new version](#changing-a-released-command), on purpose. The generator also checks that every argument fills a -parameter and that a flag that picks an endpoint isn't another endpoint's own flag. Every domain (the first word) -needs an entry in `src/public-api/domains.json` with its stage and description, for `deel --help`. Names +parameter and that a flag that picks an endpoint isn't another endpoint's own flag. A domain (the first word) +can have an entry in `src/public-api/domains.json` with its stage and description, for `deel --help`; without one the +check warns, and `deel --help` lists the domain last, with only its command count. Names for new endpoints are reviewed by the maintainers; when you're unsure of one, ask in the PR. ### Changing a released command diff --git a/README.md b/README.md index 2eb2ae0..6691a05 100644 --- a/README.md +++ b/README.md @@ -516,7 +516,7 @@ src/ types.ts # shared descriptor/manifest types manifest.generated.ts # hand-picked command descriptors (generated by the deel-cli-extractor skill — never hand-edited) commands.map.ts # hand-picked command ↔ API endpoint mapping - public-api/ # generated public API commands: manifest.json (never hand-edited), commands.json (the command map), domains.json (each domain's description for help; its stage orders `deel --help`), loader + public-api/ # generated public API commands: manifest.json (never hand-edited), commands.json (the command map), domains.json (optional: each domain's description for help; its stage orders `deel --help`, and a domain it does not list comes last), loader commands/ # static commands (auth, job, commands) core/ # http, auth, keychain, config, tls, input, output, logging, … test/ # automated tests (node --test), one file per module diff --git a/scripts/check-command-map.ts b/scripts/check-command-map.ts index 977bede..1e0f330 100644 --- a/scripts/check-command-map.ts +++ b/scripts/check-command-map.ts @@ -92,11 +92,12 @@ export function checkMap(entries: MapEntry[], options: CheckOptions = {}): { fai else fail(`same command line as ${before.path}`); } - // Every domain has a stage and a description in domains.json, which deel --help lists it by. + // domains.json gives a domain its description and its place in deel --help; it is optional. A domain missing from it + // is listed last, with only its command count, and works as any other: a warning, so a new domain never stops a sync. if (options.domains) { const known = new Set(options.domains); for (const domain of new Set(parsed.map((p) => p.words[0]))) { - if (!known.has(domain)) failures.push({ entry: domain, message: `'${domain}' is not in src/public-api/domains.json, which gives every domain its stage and description` }); + if (!known.has(domain)) warnings.push({ entry: domain, message: `'${domain}' is not in src/public-api/domains.json: deel --help lists it last, without a description, until it has a stage and a description there` }); } // A domain is in use through the map, a hand-picked command or a static one. const used = new Set([...parsed.map((p) => p.words[0]), ...(options.reserved?.commands ?? []).map((d) => d.command[0])]); diff --git a/scripts/doctor-hashes.json b/scripts/doctor-hashes.json index ad1e419..df9fb58 100644 --- a/scripts/doctor-hashes.json +++ b/scripts/doctor-hashes.json @@ -16,15 +16,15 @@ ".husky/scripts/verify-before-push.sh": "18980ab4715cd3268052b5d4cd8295570fab3c63148be9ea446a03af43c40102", ".nvmrc": "f14b4987904bcb5814e4459a057ed4d20f58a633152288a761214dcd28780b56", "CLAUDE.md": "b06874c1143c15a838c286d1108588737b45a5405b2b4e18bc36c15c72558aa1", - "CONTRIBUTING.md": "bf9d9870d07cf1c27793ff8bc58edbd229b533e9a550007dd89b7fa106759067", + "CONTRIBUTING.md": "e0e6149c404729351a3f1db3fbd6ef7206602602c2484ec63a4f89d7297fdf47", "LICENSE": "6b2cb5591852863e1ac403b8fd7ec8c706de863bc1a737888322e9bf604af656", - "README.md": "2146920a6cc398d0189bd74ce9d6667f8c110048cb4e88e4ed6774572b81c39e", + "README.md": "269552158a972608cf1a8387f040923cac3eda4bd067acfcf5c53130cef7148b", "SECURITY.md": "6ad03fd32443e1dd7270e27180b5dfa6684826311543ae60b1cc6f937f9bcc53", "package-lock.json": "c66ea4ccbeb2a7393cdfa4ed87cee082ee8b9174fff0934a368c874136d1030f", "package.json": "7fa2b65175440d7ac0fd66e1359f3124ad2362a088680a930737ec351a984cc4", "packaging/install.sh": "6a7686f43c16b2f5cf0d41007ce40fd3f5421b0cac3ff7cb3c943b7edcb7f3ea", "scripts/build-all.sh": "7c830953964d5b77a71455f116d6f20565d42fb4df83055428c191376dcbb928", - "scripts/check-command-map.ts": "7f7dd085100146dab2783d1057b5b1b2964f260719f22d11a957b90e88b7106b", + "scripts/check-command-map.ts": "e9cee7b4cd42188f8ba47052d5332af260aa24075d33a48cf03849096d973ac6", "scripts/check-doctor.ts": "0e8c638711393276b31addfbe2f792b31203b9758a79c3e1415da46d724e21b3", "scripts/check-lockfile.ts": "9b156c0a699db3e5cc581246a7665a7797e2a8110c0c54a5dffc7748b0ce5e32", "scripts/check-macho-signature.ts": "1b953a3d74b7442ed4bc268dbb72217e464588854bbc81ab44431505fe4fa4a6", @@ -86,7 +86,7 @@ "test/auth-command.test.ts": "a424c43fdd705d3853e68698ae691f73166e24a2e37afcd6bd4b4d3b333cad55", "test/auth.test.ts": "5fe488919641cebbe7859f14e7613e68c1f47ba45c705b76a534fc312b99e6d3", "test/build-all.test.ts": "9d5cb432468a9b4194e8c583e912162376994439f928b0f376541a738830fbd3", - "test/check-command-map.test.ts": "9334c6867bdbc276ff1a46d342277c0de5528f92f565f1e87d39b5ee03b2ad3c", + "test/check-command-map.test.ts": "cc64726adcec927afd4c2d16b71e59ea5ea54cde589c9ee77f278a66b1824d1d", "test/check-doctor.test.ts": "4ae966ba51e61ab2d1a11655b344a1ecab0e57a4ea3f8d038c024d63405af145", "test/check-macho-signature.test.ts": "4ef01ed87b052c85aee27270a5738f992d51a80a4c36891f218a491d28e9c0dc", "test/check-manifest.test.ts": "__deleted__", diff --git a/test/check-command-map.test.ts b/test/check-command-map.test.ts index a483d6d..48e14fd 100644 --- a/test/check-command-map.test.ts +++ b/test/check-command-map.test.ts @@ -27,8 +27,9 @@ test("the check exits 1 and names each failure when the map file it is given has const run = spawnSync(process.execPath, ["scripts/check-command-map.ts", map], { cwd: ROOT, encoding: "utf8" }); assert.equal(run.status, 1, run.stderr); assert.match(run.stderr, /^FAIL {2}path param \{a_id\} of \/a\/\{a_id\} has no argument in the command$/m); - // The script passes the domains of domains.json to the check: `things` is not one of them. - assert.match(run.stderr, /^FAIL {2}'things' is not in src\/public-api\/domains.json/m); + // The script passes the domains of domains.json to the check: `things` is not one of them, which is a warning. + assert.match(run.stderr, /^warn {2}'things' is not in src\/public-api\/domains.json/m); + assert.doesNotMatch(run.stderr, /^FAIL {2}'things'/m); assert.match(run.stderr, /^command map: [1-9]\d* failure\(s\)/m); }); @@ -109,10 +110,11 @@ test("names: the map may not take a hand-picked or static name, and a released c assert.match(checkMap([entry("GET", "/other", "deel other list")], { released }).failures.map((f) => f.message).join(), /removed from the map/); }); -test("every domain of the map has a stage and description in domains.json", () => { - const failures = checkMap([entry("GET", "/x", "deel widgets list")], { domains: ["contracts"] }).failures; - assert.match(failures.map((f) => f.message).join(), /'widgets' is not in src\/public-api\/domains.json/); - assert.deepEqual(checkMap([entry("GET", "/x", "deel contracts list")], { domains: ["contracts"] }).failures, []); +test("a domain of the map that domains.json does not list is a warning, not a failure", () => { + const result = checkMap([entry("GET", "/x", "deel widgets list")], { domains: ["contracts"] }); + assert.deepEqual(result.failures, []); + assert.match(result.warnings.map((w) => w.message).join(), /'widgets' is not in src\/public-api\/domains.json/); + assert.deepEqual(checkMap([entry("GET", "/x", "deel contracts list")], { domains: ["contracts"] }).warnings.filter((w) => w.entry === "contracts"), []); }); test("readDomainNames reads every domain of every stage, and refuses a file that cannot give help its text", () => {