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
15 changes: 15 additions & 0 deletions .changeset/11488-retire-generate-from.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@object-ui/cli': minor
---

**BREAKING (`@object-ui/cli`):** `objectui generate` no longer accepts `--from`. The flag is retired, with no alias window and no placeholder, and the CLI now refuses it as an unknown option (objectui#11488).

(The bump is `minor` by this repo's release model: objectui's major follows the `@objectstack` family major, and its own breaking changes ship as `minor` with the breaking semantics stated here.)

- FROM `objectui generate TYPE NAME --from SOURCE` TO `objectui generate TYPE NAME`: drop the flag. No import from an external source (OpenAPI, Prisma) exists, so there is nothing to replace it with; `generate` scaffolds the resource in the generator's per-type layout under the current directory, e.g. `pages/NAME.json`.

**Why.** The flag was declared ("Generate schema from external source (openapi.yaml, prisma.schema)") and documented as *experimental*, but no importer was ever built. A run with `--from openapi.yaml` printed "not yet implemented", exited 0 and wrote nothing, so a script or CI step read the no-op as success. No producer of the flag was measured, and building an OpenAPI or Prisma importer would be a new capability with no pull, so the flag goes instead.

**What changes at the command line.** `objectui generate page NAME --from SOURCE` now exits non-zero with commander's unknown-option error and writes nothing. Without the flag, `generate` behaves exactly as before. `objectui generate --help` no longer lists `--from`, and the `generate` section of the CLI docs drops its flag table, which `--from` was the last row of.

**Clause-②: yes.** The published CLI's accept set narrows: an option `generate` used to accept (and answer with a no-op that exited 0) is now refused. No exported symbol moves.
4 changes: 0 additions & 4 deletions content/docs/utilities/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ objectui g page Dashboard
objectui generate plugin my-widget
```

| Flag | Default | Description |
|---|---|---|
| `--from <source>` | — | Generate schema from external source (`openapi.yaml`, `prisma.schema`) — *experimental* |

### `objectui validate [schema]`

Validate a schema file against the ObjectUI specification. Exits with code `0`
Expand Down
36 changes: 22 additions & 14 deletions packages/cli/src/__tests__/cli-bin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('@object-ui/cli bin', () => {
['init', [/-t, --template <template>/]],
['lint', [/--fix/]],
['test', [/-w, --watch/, /-c, --coverage/, /--ui/]],
['generate', [/--from <source>/]],
['generate', [/<type> <name>/]],
['analyze', [/--bundle-size/, /--render-performance/]],
['validate', [/\[schema\]/]],
];
Expand All @@ -222,23 +222,30 @@ describe('@object-ui/cli bin', () => {

// objectui#11476. `generate` used to declare `--output <dir>` (documented
// default `schemas/`), but the action never read it: `generate(type, name)`
// writes in the generator's own per-type layout whatever the flag said. The
// flag is retired with no alias window, so the bin must REFUSE it rather than
// accept it and do nothing. Asserted through the built bin, which is where
// the card measured the defect. The flag-free run is the control the refusal
// is read against: same command, same empty directory, one file written.
describe('generate refuses the retired --output flag (objectui#11476)', () => {
// writes in the generator's own per-type layout whatever the flag said.
// objectui#11488. It also declared `--from <source>` ("Generate schema from
// external source"), whose branch printed "not yet implemented" and exited 0
// having written nothing, so a script read the no-op as success. Both flags
// are retired with no alias window, so the bin must REFUSE each one rather
// than accept it and do nothing. Asserted through the built bin, which is
// where both cards measured the defect. The flag-free run is the control the
// refusals are read against: same command, same empty directory, one file
// written.
describe('generate refuses its retired flags (objectui#11476, objectui#11488)', () => {
const tree = (dir: string) =>
(readdirSync(dir, { recursive: true }) as string[])
.map((p) => p.split(sep).join('/'))
.sort();

it('exits non-zero naming --output as an unknown option, and writes nothing', () => {
const work = mkdtempSync(join(tmpdir(), 'objectui-cli-generate-output-'));
const res = run(['g', 'page', 'Probe', '--output', 'custom/'], { cwd: work });
it.each([
['--output', 'custom/'],
['--from', 'openapi.yaml'],
])('exits non-zero naming %s as an unknown option, and writes nothing', (flag, value) => {
const work = mkdtempSync(join(tmpdir(), 'objectui-cli-generate-retired-'));
const res = run(['g', 'page', 'Probe', flag, value], { cwd: work });
expect(res.code, res.stdout + res.stderr).not.toBe(0);
expect(res.stderr).toMatch(/unknown option/i);
expect(res.stderr).toContain('--output');
expect(res.stderr).toContain(flag);
expect(tree(work)).toEqual([]);
});

Expand All @@ -249,12 +256,13 @@ describe('@object-ui/cli bin', () => {
expect(tree(work)).toEqual(['pages', 'pages/probe.json']);
});

it('does not list --output in generate --help', () => {
it('lists neither --output nor --from in generate --help', () => {
const res = run(['generate', '--help']);
expect(res.code, res.stderr).toBe(0);
// Lit control: the help text that was read is generate's own.
expect(res.stdout).toMatch(/--from <source>/);
// Lit control: the help text that was read is generate's own usage line.
expect(res.stdout).toMatch(/objectui generate\|g .*<type> <name>/);
expect(res.stdout).not.toMatch(/--output\b/);
expect(res.stdout).not.toMatch(/--from\b/);
});
});

Expand Down
10 changes: 1 addition & 9 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,8 @@ program
.description('Generate new resources (objects, pages, plugins)')
.argument('<type>', 'Type of resource to generate (resource/object, page, plugin)')
.argument('<name>', 'Name of the resource')
.option('--from <source>', 'Generate schema from external source (openapi.yaml, prisma.schema)')
.action(async (type, name, options) => {
.action(async (type, name) => {
try {
// Handle schema generation from external sources
if (options.from) {
console.log(chalk.yellow('\n⚠ Schema generation from external sources (OpenAPI/Prisma) is not yet implemented.'));
console.log(chalk.gray('This feature will be available in a future release.\n'));
process.exit(0);
}

await generate(type, name);
} catch (error) {
console.error(chalk.red('Error:'), error instanceof Error ? error.message : error);
Expand Down
Loading