An open source design system that's fully customizable and agent ready
TypeScript
docs(cli): list the missing-core failure in build's exit codes (#6592)
Joeya9486d34b10f
diff --git a/.changeset/cli-spec-build-core-not-found-doc.md b/.changeset/cli-spec-build-core-not-found-doc.mdnew file mode 100644index 0000000000..33eef7abae--- /dev/null+++ b/.changeset/cli-spec-build-core-not-found-doc.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[docs] The documented exit codes for `astryx build` now say that a query exits 1 when `@astryxdesign/core` cannot be found, while the playbook (`astryx build` with no query) needs no core.++@josephfarinadiff --git a/packages/cli/clients/cli/commands/build.doc.mjs b/packages/cli/clients/cli/commands/build.doc.mjsindex 69d696cf43..9f881637d6 100644--- a/packages/cli/clients/cli/commands/build.doc.mjs+++ b/packages/cli/clients/cli/commands/build.doc.mjs@@ -44,7 +44,10 @@ export const doc = {],exitCodes: [{code: 0, when: 'success (including zero matches)'},- {code: 1, when: 'invalid --type or a non-positive --limit'},+ {+ code: 1,+ when: 'invalid --type, a non-positive --limit, or a query when @astryxdesign/core cannot be found (the playbook needs no core)',+ },],related: ['search', 'template', 'component', 'hook', 'init'],};diff --git a/packages/cli/clients/cli/commands/build.exit-codes-doc.test.mjs b/packages/cli/clients/cli/commands/build.exit-codes-doc.test.mjsnew file mode 100644index 0000000000..e582bb2f47--- /dev/null+++ b/packages/cli/clients/cli/commands/build.exit-codes-doc.test.mjs@@ -0,0 +1,50 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file `astryx build` documents that a query needs @astryxdesign/core while+ * the playbook does not, and exits as documented without it.+ */++import {describe, it, expect, beforeEach, afterEach} from 'vitest';+import * as fs from 'node:fs';+import * as os from 'node:os';+import * as path from 'node:path';+import {runCli} from '../../../test-utils/run-cli.mjs';+import {doc as buildDoc} from './build.doc.mjs';++const SLOW = 30_000;++/** @type {string} */+let tmpDir;++beforeEach(() => {+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-build-no-core-'));+ fs.writeFileSync(path.join(tmpDir, 'package.json'), JSON.stringify({name: 'consumer'}));+});++afterEach(() => {+ fs.rmSync(tmpDir, {recursive: true, force: true});+});++/** @param {number} code */+const exitWhen = code => buildDoc.exitCodes?.find(e => e.code === code)?.when ?? '';++describe('astryx build without @astryxdesign/core', () => {+ it('the CommandDoc lists a query without core under exit 1, and both modes exit 1', async () => {+ expect(exitWhen(1)).toMatch(/a query when @astryxdesign\/core cannot be found/);++ const text = await runCli(['build', 'dashboard'], tmpDir);+ const json = await runCli(['--json', 'build', 'dashboard'], tmpDir);+ expect(text.status).toBe(1);+ expect(json.status).toBe(1);+ expect(JSON.parse(json.stdout).error).toMatch(/@astryxdesign\/core/);+ }, SLOW);++ it('the CommandDoc says the playbook needs no core, and it exits 0', async () => {+ expect(exitWhen(1)).toMatch(/the playbook needs no core/);++ const {status, stdout} = await runCli(['--json', 'build'], tmpDir);+ expect(status).toBe(0);+ expect(JSON.parse(stdout).type).toBe('build.help');+ }, SLOW);+});