An open source design system that's fully customizable and agent ready
TypeScript
fix(cli): four commands refuse silently ignored option pairs (#7132)
Joey61d059a6c5e3
diff --git a/.changeset/cli-option-pair-refusals.md b/.changeset/cli-option-pair-refusals.mdnew file mode 100644index 0000000000..d9531b998f--- /dev/null+++ b/.changeset/cli-option-pair-refusals.md@@ -0,0 +1,11 @@+---+'@astryxdesign/cli': minor+---++[breaking] Four commands refuse silently ignored option pairs.++- incompatible-fix `IFIX-0005` / cleanup `CLN-0011`++Migration: remove the option the command was ignoring.++@josephfarinadiff --git a/packages/cli/api/gap-report/gap-report.doc.mjs b/packages/cli/api/gap-report/gap-report.doc.mjsindex e5d7d12336..377d21d5ae 100644--- a/packages/cli/api/gap-report/gap-report.doc.mjs+++ b/packages/cli/api/gap-report/gap-report.doc.mjs@@ -74,7 +74,7 @@ export const doc = {name: 'options.listCategories',type: 'boolean',description:- 'Return categories without resolving a route or writing; the component and every other option are ignored.',+ 'Return categories without resolving a route or writing; the component and every other option are refused with ERR_INVALID_ARGUMENT.',default: 'false',},{diff --git a/packages/cli/api/gap-report/gap-report.mjs b/packages/cli/api/gap-report/gap-report.mjsindex e38908ca34..dcd3262a96 100644--- a/packages/cli/api/gap-report/gap-report.mjs+++ b/packages/cli/api/gap-report/gap-report.mjs@@ -595,6 +595,21 @@ function aggregateStatus(deliveries) {*/export async function gapReport(component, options = {}) {if (options.listCategories) {+ const ignored = [+ component ? 'component' : null,+ options.category ? '--category' : null,+ options.reason ? '--reason' : null,+ options.detail ? '--additional-context' : null,+ options.package ? '--package' : null,+ options.confirmPublic ? '--confirm-public' : null,+ ].filter(Boolean);+ if (ignored.length > 0) {+ throw new AstryxError(+ `\`--list-categories\` cannot be combined with ${ignored.join(', ')}: it lists categories and ignores submission options.`,+ undefined,+ ERROR_CODES.ERR_INVALID_ARGUMENT,+ );+ }return {type: 'gap-report.categories',data: GAP_REPORT_CATEGORIES.map(category => ({...category})),diff --git a/packages/cli/api/init/init.mjs b/packages/cli/api/init/init.mjsindex c18b6b993b..1edec29783 100644--- a/packages/cli/api/init/init.mjs+++ b/packages/cli/api/init/init.mjs@@ -18,6 +18,8 @@import {run} from './run/run.mjs';import {remove} from './remove/remove.mjs';+import {AstryxError} from '../error.mjs';+import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';export {getNextSteps} from './run/run.mjs';@@ -42,7 +44,27 @@ export {getNextSteps} from './run/run.mjs';*/export async function init(options = {}, {cwd = process.cwd()} = {}) {if (options.removeAgents) {+ const ignored = [+ options.features ? '--features' : null,+ options.all ? '--all' : null,+ options.agent ? '--agent' : null,+ options.agentDocsPath ? '--agent-docs-path' : null,+ ].filter(Boolean);+ if (ignored.length > 0) {+ throw new AstryxError(+ `\`--remove-agents\` cannot be combined with ${ignored.join(', ')}: it removes the managed block and ignores install options.`,+ undefined,+ ERROR_CODES.ERR_INVALID_ARGUMENT,+ );+ }return remove({cwd});}+ if (options.all && options.features) {+ throw new AstryxError(+ '`--all` and `--features` cannot be used together: `--all` installs every feature, so a feature list is redundant.',+ undefined,+ ERROR_CODES.ERR_INVALID_ARGUMENT,+ );+ }return run(options, {cwd});}diff --git a/packages/cli/api/template/template.doc.mjs b/packages/cli/api/template/template.doc.mjsindex ccd06aaf44..9318cd7372 100644--- a/packages/cli/api/template/template.doc.mjs+++ b/packages/cli/api/template/template.doc.mjs@@ -48,7 +48,7 @@ export const doc = {{name: 'options.list',type: 'boolean',- description: 'Force the list response even when a name is given.',+ description: 'List templates instead of scaffolding; refused with ERR_INVALID_ARGUMENT when a name or path is also given.',default: 'false',},{@@ -133,6 +133,10 @@ export const doc = {},],throws: [+ {+ code: 'ERR_INVALID_ARGUMENT',+ when: '--cdn is combined with <name>, --list, --skeleton, --type, or --package; --list is combined with <name>, <path>, --skeleton, or --overwrite; --skeleton is combined with <path> or --overwrite',+ },{code: 'ERR_UNKNOWN_TEMPLATE',when: 'the named template does not exist, or options.skeleton is set without a name',diff --git a/packages/cli/api/template/template.mjs b/packages/cli/api/template/template.mjsindex 0058b9f521..96f88c4e00 100644--- a/packages/cli/api/template/template.mjs+++ b/packages/cli/api/template/template.mjs@@ -86,6 +86,51 @@ export async function template(name, options = {}) {cwd = process.cwd(),} = options;+ if (cdn) {+ const ignored = [+ name ? '<name>' : null,+ list ? '--list' : null,+ skeleton ? '--skeleton' : null,+ type ? '--type' : null,+ packageFilter ? '--package' : null,+ ].filter(Boolean);+ if (ignored.length > 0) {+ throw new AstryxError(+ `\`--cdn\` cannot be combined with ${ignored.join(', ')}: the CDN starter does not use templates.`,+ undefined,+ ERROR_CODES.ERR_INVALID_ARGUMENT,+ );+ }+ }+ if (list) {+ const ignored = [+ name ? '<name>' : null,+ targetPath ? '<path>' : null,+ skeleton ? '--skeleton' : null,+ overwrite ? '--overwrite' : null,+ ].filter(Boolean);+ if (ignored.length > 0) {+ throw new AstryxError(+ `\`--list\` cannot be combined with ${ignored.join(', ')}: it lists templates and does not scaffold.`,+ undefined,+ ERROR_CODES.ERR_INVALID_ARGUMENT,+ );+ }+ }+ if (skeleton) {+ const ignored = [+ targetPath ? '<path>' : null,+ overwrite ? '--overwrite' : null,+ ].filter(Boolean);+ if (ignored.length > 0) {+ throw new AstryxError(+ `\`--skeleton\` cannot be combined with ${ignored.join(', ')}: it prints the skeleton and does not write files.`,+ undefined,+ ERROR_CODES.ERR_INVALID_ARGUMENT,+ );+ }+ }+// The CDN starter ships as an asset rather than as a discovered template, so// it answers before discovery — nothing here needs a name resolved.if (cdn) {diff --git a/packages/cli/api/upgrade/upgrade.doc.mjs b/packages/cli/api/upgrade/upgrade.doc.mjsindex 812ac40aa6..7258cd01de 100644--- a/packages/cli/api/upgrade/upgrade.doc.mjs+++ b/packages/cli/api/upgrade/upgrade.doc.mjs@@ -129,7 +129,7 @@ export const doc = {throws: [{code: 'ERR_INVALID_ARGUMENT',- when: '`from` is missing (and neither `list` nor `registry` is set); `list` and `registry` are both set; `registry` is combined with `from`, `force`, `codemod`, `skipCodemod`, `integration` or `installDeps`; an `integration` specifier is invalid or not installed; or astryx.config fails to load or validate and no pending config codemod repairs it',+ when: '`from` is missing (and neither `list` nor `registry` is set); `list` and `registry` are both set; `list` is combined with `from`, `force`, `apply`, `path` (non-default), `codemod`, `skipCodemod`, `integration` or `installDeps`; `registry` is combined with `from`, `force`, `codemod`, `skipCodemod`, `integration` or `installDeps`; an `integration` specifier is invalid or not installed; or astryx.config fails to load or validate and no pending config codemod repairs it',},{code: 'ERR_INVALID_VERSION', when: '`from` is not a valid semver string'},{code: 'ERR_PATH_TRAVERSAL', when: '`path` resolves outside cwd'},diff --git a/packages/cli/api/upgrade/upgrade.mjs b/packages/cli/api/upgrade/upgrade.mjsindex 97b92e75ad..cc59fd6a8a 100644--- a/packages/cli/api/upgrade/upgrade.mjs+++ b/packages/cli/api/upgrade/upgrade.mjs@@ -53,6 +53,25 @@ export async function upgrade(options = {}, {cwd = process.cwd()} = {}) {throw new AstryxError(msg, undefined, ERROR_CODES.ERR_INVALID_ARGUMENT);}+ if (options.list) {+ const ignored = [+ options.from ? '--from' : null,+ options.force ? '--force' : null,+ options.apply ? '--apply' : null,+ options.path && options.path !== './src' ? '--path' : null,+ options.codemod ? '--codemod' : null,+ options.skipCodemod?.length ? '--skip-codemod' : null,+ options.integration?.length ? '--integration' : null,+ options.installDeps ? '--install-deps' : null,+ ].filter(Boolean);+ if (ignored.length > 0) {+ const msg = `\`--list\` cannot be combined with ${ignored.join(', ')}: it lists available codemods and does not run a migration.`;+ logger.error(msg);+ logger.log('Aborted\n');+ throw new AstryxError(msg, undefined, ERROR_CODES.ERR_INVALID_ARGUMENT);+ }+ }+if (options.registry) {const incompatible = [options.from ? '--from' : null,diff --git a/packages/cli/clients/cli/commands/gap-report.doc.mjs b/packages/cli/clients/cli/commands/gap-report.doc.mjsindex 6fccbe0eef..f18da40b14 100644--- a/packages/cli/clients/cli/commands/gap-report.doc.mjs+++ b/packages/cli/clients/cli/commands/gap-report.doc.mjs@@ -61,7 +61,7 @@ export const doc = {flag: '--list-categories',param: 'options.listCategories',description:- 'List valid report categories without filing; the component and the other gap-report options are ignored',+ 'List valid report categories without filing; the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',},],examples: [diff --git a/packages/cli/clients/cli/commands/gap-report.test.mjs b/packages/cli/clients/cli/commands/gap-report.test.mjsindex 62b0766909..e0f4f435b6 100644--- a/packages/cli/clients/cli/commands/gap-report.test.mjs+++ b/packages/cli/clients/cli/commands/gap-report.test.mjs@@ -282,7 +282,7 @@ describe('gap-report control docs', () => {expect(help.stdout).toContain(text);}expect(option('--list-categories')).toContain(- 'the component and the other gap-report options are ignored',+ 'the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',);const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-limits-'));@@ -328,6 +328,6 @@ describe('gap-report control docs', () => {}await expect(gapReport(undefined, {listCategories: true, category: 'not_real', package: 'nope'}),- ).resolves.toMatchObject({type: 'gap-report.categories'});+ ).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});});});diff --git a/packages/cli/clients/cli/commands/init.doc.mjs b/packages/cli/clients/cli/commands/init.doc.mjsindex e657564947..9facd85acf 100644--- a/packages/cli/clients/cli/commands/init.doc.mjs+++ b/packages/cli/clients/cli/commands/init.doc.mjs@@ -27,13 +27,13 @@ export const doc = {param: 'options.features',description:'Comma-separated features: agents (agent docs), theme (writes theme.template.ts), template (prints the page-building commands; writes no file). ' +- 'An unknown feature exits 1 with ERR_UNKNOWN_FEATURE. Ignored with --all or --remove-agents',+ 'An unknown feature exits 1 with ERR_UNKNOWN_FEATURE. Refused with --all or --remove-agents',},{flag: '--all',param: 'options.all',description:- 'Install all features (agents, theme, template); overrides --features. Prints their guidance instead of the getting-started steps',+ 'Install all features (agents, theme, template); refused with --features. Prints their guidance instead of the getting-started steps',},{flag: '--remove-agents',@@ -41,7 +41,7 @@ export const doc = {description:'Remove the managed block from AGENTS.md, CLAUDE.md, .claude/CLAUDE.md, .cursorrules, .hermes.md and HERMES.md ' +"(deleting AGENTS.md or .claude/CLAUDE.md when only init's heading is left) and do nothing else. " +- '--features, --all, --agent and --agent-docs-path are ignored; a file written with --agent-docs-path keeps its block',+ '--features, --all, --agent and --agent-docs-path are refused; a file written with --agent-docs-path keeps its block',},{flag: '--agent <tool>',@@ -74,7 +74,7 @@ export const doc = {},{code: 1,- when: 'an unknown --agent or feature, or an --agent-docs-path outside the project',+ when: 'an unknown --agent or feature, an --agent-docs-path outside the project, --remove-agents combined with install options, or --all with --features (ERR_INVALID_ARGUMENT)',},],related: ['doctor', 'upgrade', 'build', 'theme'],diff --git a/packages/cli/clients/cli/commands/init.flag-help.test.mjs b/packages/cli/clients/cli/commands/init.flag-help.test.mjsindex 47b59f1949..9a68567fb9 100644--- a/packages/cli/clients/cli/commands/init.flag-help.test.mjs+++ b/packages/cli/clients/cli/commands/init.flag-help.test.mjs@@ -66,7 +66,7 @@ describe('astryx init flag interactions', () => {for (const file of ['AGENTS.md', '.claude/CLAUDE.md', '.cursorrules', '.hermes.md', 'HERMES.md']) {expect(help).toContain(file);}- expect(help).toMatch(/--agent-docs-path keeps its block/);+ expect(help).toMatch(/--agent-docs-path are refused/);await initJson(['--agent-docs-path', 'docs/AI.md']);await initJson([]);@@ -82,22 +82,19 @@ describe('astryx init flag interactions', () => {'--agent-docs-path','docs/AI.md',]);- expect(removed.status).toBe(0);- expect(removed.envelope.type).toBe('init.remove');- expect(exists('AGENTS.md')).toBe(false);- expect(exists('theme.template.ts')).toBe(false);- expect(read('docs/AI.md')).toContain(MARKER_START);+ expect(removed.status).toBe(1);+ expect(removed.envelope.code).toBe('ERR_INVALID_ARGUMENT');});it('--all: help says it overrides --features, and an unknown feature beside it is not checked', async () => {const options = await initOptions();- expect(options['--all']).toMatch(/overrides --features/);- expect(options['--features']).toMatch(/Ignored with --all or --remove-agents/);+ expect(options['--all']).toMatch(/refused with --features/);+ expect(options['--features']).toMatch(/Refused with --all or --remove-agents/);expect(options['--features']).toContain('ERR_UNKNOWN_FEATURE');const {status, envelope} = await initJson(['--all', '--features', 'bogus']);- expect(status).toBe(0);- expect(envelope.data.features).toEqual(['agents', 'theme', 'template']);+ expect(status).toBe(1);+ expect(envelope.code).toBe('ERR_INVALID_ARGUMENT');});it('--agent and --agent-docs-path: help states their scope and precedence, and the CLI follows it', async () => {diff --git a/packages/cli/clients/cli/commands/option-pair-refusals.test.mjs b/packages/cli/clients/cli/commands/option-pair-refusals.test.mjsnew file mode 100644index 0000000000..f175d2c945--- /dev/null+++ b/packages/cli/clients/cli/commands/option-pair-refusals.test.mjs@@ -0,0 +1,37 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+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';+let dir;+beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(),'astryx-op-')); fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'s',version:'1.0.0',dependencies:{'@astryxdesign/core':'0.6.3'}})); const c=path.join(dir,'node_modules','@astryxdesign','core'); fs.mkdirSync(c,{recursive:true}); fs.writeFileSync(path.join(c,'package.json'),JSON.stringify({name:'@astryxdesign/core',version:'0.6.3'})); });+afterEach(() => fs.rmSync(dir, {recursive:true,force:true}));+const json = async a => { const {status,stdout}=await runCli(['--json',...a],{cwd:dir}); return {status,body:JSON.parse(stdout)}; };+describe('option-pair refusals (AST-042 FR5)', () => {+ it('template --list + name', async () => { const {status,body}=await json(['template','ai-chat','--list']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('template --list + path', async () => { const {status,body}=await json(['template','ai-chat','src/p.tsx','--list']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('template --list + --skeleton', async () => { const {status,body}=await json(['template','--list','--skeleton']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('template --cdn + --list', async () => { const {status,body}=await json(['template','--cdn','--list']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('template --cdn + name', async () => { const {status,body}=await json(['template','ai-chat','--cdn']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('template --cdn + --type', async () => { const {status,body}=await json(['template','--cdn','--type','page']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('template --cdn + --package', async () => { const {status,body}=await json(['template','--cdn','--package','@astryxdesign/core']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('template --skeleton + --overwrite', async () => { const {status,body}=await json(['template','ai-chat','--skeleton','--overwrite']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('upgrade --list + --from', async () => { const {status,body}=await json(['upgrade','--list','--from','0.5.0']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('upgrade --list + --force', async () => { const {status,body}=await json(['upgrade','--list','--force']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('upgrade --list + --apply', async () => { const {status,body}=await json(['upgrade','--list','--apply']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('upgrade --list + --path', async () => { const {status,body}=await json(['upgrade','--list','--path','../x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('upgrade --list + --codemod', async () => { const {status,body}=await json(['upgrade','--list','--codemod','x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('upgrade --list + --skip-codemod', async () => { const {status,body}=await json(['upgrade','--list','--skip-codemod','x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('upgrade --list + --integration', async () => { const {status,body}=await json(['upgrade','--list','--integration','@acme/x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('upgrade --list + --install-deps', async () => { const {status,body}=await json(['upgrade','--list','--install-deps']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('init --remove-agents + --features', async () => { const {status,body}=await json(['init','--remove-agents','--features','agents']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('init --remove-agents + --all', async () => { const {status,body}=await json(['init','--remove-agents','--all']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('init --remove-agents + --agent', async () => { const {status,body}=await json(['init','--remove-agents','--agent','claude']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('init --remove-agents + --agent-docs-path', async () => { const {status,body}=await json(['init','--remove-agents','--agent-docs-path','docs/AI.md']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('init --all + --features', async () => { const {status,body}=await json(['init','--all','--features','agents']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('gap-report --list-categories + component', async () => { const {status,body}=await json(['gap-report','Button','--list-categories']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('gap-report --list-categories + --category', async () => { const {status,body}=await json(['gap-report','--list-categories','--category','docs_gap']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('gap-report --list-categories + --reason', async () => { const {status,body}=await json(['gap-report','--list-categories','--reason','test']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('gap-report --list-categories + --package', async () => { const {status,body}=await json(['gap-report','--list-categories','--package','@acme/x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('gap-report --list-categories + --additional-context', async () => { const {status,body}=await json(['gap-report','--list-categories','--additional-context','extra']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+ it('gap-report --list-categories + --confirm-public', async () => { const {status,body}=await json(['gap-report','--list-categories','--confirm-public']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });+});diff --git a/packages/cli/clients/cli/commands/template.doc.mjs b/packages/cli/clients/cli/commands/template.doc.mjsindex 395a3b5ab0..b0cb16a6b4 100644--- a/packages/cli/clients/cli/commands/template.doc.mjs+++ b/packages/cli/clients/cli/commands/template.doc.mjs@@ -46,7 +46,7 @@ export const doc = {flag: '--list',param: 'options.list',description:- 'List available templates (narrow with --type and --package) and do nothing else: <name>, <path>, --skeleton and --overwrite are ignored',+ 'List available templates (narrow with --type and --package) and do nothing else: <name>, <path>, --skeleton and --overwrite are refused',},{flag: '--type <type>',@@ -65,13 +65,13 @@ export const doc = {param: 'options.skeleton',description:'Show layout skeleton with spatial annotations (padding, gap, nesting) instead of the source. Needs <name>. ' +- 'It writes nothing, so <path> and --overwrite are ignored; --list and --cdn take precedence',+ 'It writes nothing, so <path> and --overwrite are refused with ERR_INVALID_ARGUMENT',},{flag: '--cdn [path]',param: 'options.cdn',description:- 'Write the no-build-step CDN starter page and do nothing else: <name>, --list, --skeleton, --type and --package are ignored. ' ++ 'Write the no-build-step CDN starter page and do nothing else: <name>, --list, --skeleton, --type and --package are refused. ' +'The page goes to the --cdn value, else to <path>, else cdn.template.html, and that path is always the file itself. ' +'A value right after --cdn (anything not starting with -) is taken as that path',},diff --git a/packages/cli/clients/cli/commands/template.flag-help.test.mjs b/packages/cli/clients/cli/commands/template.flag-help.test.mjsindex 17e2554a07..cc6cabab4e 100644--- a/packages/cli/clients/cli/commands/template.flag-help.test.mjs+++ b/packages/cli/clients/cli/commands/template.flag-help.test.mjs@@ -56,12 +56,12 @@ async function templateJson(args) {}describe('astryx template flag precedence', () => {- it('--list: help says <name>, <path>, --skeleton and --overwrite are ignored, and they are', async () => {+ it('--list: help says <name>, <path>, --skeleton and --overwrite are refused, and they are', async () => {const help = (await templateOptions())['--list'];for (const ignored of ['<name>', '<path>', '--skeleton', '--overwrite']) {expect(help).toContain(ignored);}- expect(help).toMatch(/are ignored/);+ expect(help).toMatch(/are refused/);const {status, envelope} = await templateJson(['dashboard',@@ -70,22 +70,25 @@ describe('astryx template flag precedence', () => {'--skeleton','--overwrite',]);- expect(status).toBe(0);- expect(envelope.type).toBe('template.list');- expect(written()).toEqual([]);+ expect(status).toBe(1);+ expect(envelope.code).toBe('ERR_INVALID_ARGUMENT');}, SLOW);it('--skeleton: help says it needs <name> and writes nothing, and it does', async () => {const help = (await templateOptions())['--skeleton'];expect(help).toMatch(/Needs <name>/);- expect(help).toMatch(/writes nothing, so <path> and --overwrite are ignored/);- expect(help).toMatch(/--list and --cdn take precedence/);+ expect(help).toMatch(/writes nothing, so <path> and --overwrite are refused/);+ // --list and --cdn are now refused, not precedence- const shown = await templateJson(['dashboard', './src/page.tsx', '--skeleton', '--overwrite']);+ const shown = await templateJson(['dashboard', '--skeleton']);expect(shown.status).toBe(0);expect(shown.envelope.type).toBe('template.skeleton');expect(written()).toEqual([]);+ const refused = await templateJson(['dashboard', './src/page.tsx', '--skeleton', '--overwrite']);+ expect(refused.status).toBe(1);+ expect(refused.envelope.code).toBe('ERR_INVALID_ARGUMENT');+const nameless = await templateJson(['--skeleton']);expect(nameless.status).toBe(1);expect(nameless.envelope.code).toBe('ERR_UNKNOWN_TEMPLATE');@@ -101,11 +104,15 @@ describe('astryx template flag precedence', () => {expect(help).toMatch(/value right after --cdn/);const everything = await templateJson(['dashboard', '--list', '--skeleton', '--type', 'bogus', '--cdn']);- expect(everything.envelope.type).toBe('template.cdn');- expect(everything.envelope.data.path).toBe('cdn.template.html');+ expect(everything.status).toBe(1);+ expect(everything.envelope.code).toBe('ERR_INVALID_ARGUMENT');++ const bare = await templateJson(['--cdn']);+ expect(bare.envelope.type).toBe('template.cdn');+ expect(bare.envelope.data.path).toBe('cdn.template.html');// A bare --cdn writes to <path>, and a path with no extension is still the file.- const positional = await templateJson(['dashboard', 'demo', '--cdn']);+ const positional = await templateJson(['--cdn', 'demo']);expect(positional.envelope.data.path).toBe('demo');expect(fs.statSync(path.join(tmpDir, 'demo')).isFile()).toBe(true);diff --git a/packages/cli/clients/cli/commands/upgrade.doc.mjs b/packages/cli/clients/cli/commands/upgrade.doc.mjsindex c0bb17ba23..5240f8d6f5 100644--- a/packages/cli/clients/cli/commands/upgrade.doc.mjs+++ b/packages/cli/clients/cli/commands/upgrade.doc.mjs@@ -90,7 +90,7 @@ export const doc = {flag: '--list',param: 'options.list',description:- 'List available codemods and do nothing else. Every other flag is ignored, except --registry, which is refused (exit 1)',+ 'List available codemods and do nothing else. Every other flag is refused, as is --registry (exit 1)',default: false,},],diff --git a/packages/cli/clients/cli/commands/upgrade.flag-help.test.mjs b/packages/cli/clients/cli/commands/upgrade.flag-help.test.mjsindex 3406a91a7e..db78e1ab41 100644--- a/packages/cli/clients/cli/commands/upgrade.flag-help.test.mjs+++ b/packages/cli/clients/cli/commands/upgrade.flag-help.test.mjs@@ -79,22 +79,18 @@ const MIGRATION_FLAGS = [describe('astryx upgrade flag interactions', () => {it('--list: help says it ignores every other flag but --registry, and it does', async () => {const options = await upgradeOptions();- expect(options['--list']).toMatch(/Every other flag is ignored, except --registry/);+ expect(options['--list']).toMatch(/Every other flag is refused, as is --registry/);installPackage('@astryxdesign/core', '0.6.0');- const listed = await upgradeJson([- '--list',- '--from',- 'bogus',- '--codemod',- 'bogus',- '--apply',- '--path',- '../outside',- ]);++ const listed = await upgradeJson(['--list']);expect(listed.status).toBe(0);expect(listed.envelope.type).toBe('upgrade.list');+ const withFlags = await upgradeJson(['--list', '--from', 'bogus']);+ expect(withFlags.status).toBe(1);+ expect(withFlags.envelope.code).toBe('ERR_INVALID_ARGUMENT');+const refused = await upgradeJson(['--list', '--registry']);expect(refused.status).toBe(1);expect(refused.envelope.code).toBe('ERR_INVALID_ARGUMENT');