Repository navigation
refactor(cli): drop @redocly/openapi-core in favor of forge's overlay CLI - #846
Conversation
Shells `openapi-overlay.ts` out to `forge openapi overlay - <path>` on `@cloudflare/forge@0.4.0` instead of pulling `@redocly/openapi-core` in as a second overlay engine. One overlay implementation runs through the pipeline (overlay apply, then `forge generate`), keeping error wording and semantics consistent. Two overlay semantics change: - Invalid-JSONPath error wording moves from redocly's "Invalid JSONPath" to forge's "invalid RFC 9535 JSONPath target"; the unit test is retargeted at the new substring. - The post-overlay unresolved-`$ref` check goes away. Redocly's `bundleFromString` validated refs; `forge openapi overlay` does not post-validate. `forge generate` catches unresolved refs downstream, so the pipeline still fails on them, just at the next stage. The matching unit test is removed. Drops `@redocly/openapi-core` from `packages/cli/package.json` devDependencies (nothing else uses it) and bumps `@cloudflare/forge` to `0.4.0` for the new `openapi overlay` subcommand. Updates `docs/architecture.md` to describe the new engine. `pnpm-lock.yaml` is not touched in this commit: regenerating it needs Cloudflare-internal registry access. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Review: 2 findings. Posted 2 inline findings, including a concrete buffer-limit suggestion. |
…path - The Cloudflare OpenAPI spec is > 1 MiB, so Node's default 1 MiB stdio buffer rejects both the piped input and forge's output. Raises `maxBuffer` to 512 MiB. - forge prefixes overlay parse errors with the overlay path but surfaces apply-time errors on their own. Always include the path in the thrown message so callers can tell which overlay failed (matches redocly's behavior and the existing unit test). Regenerates `pnpm-lock.yaml` for `@cloudflare/forge@0.4.0` and the removal of `@redocly/openapi-core`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
commit: |
|
LGTM |
|
| mean | stddev | min | max | |
|---|---|---|---|---|
| PR | 251.3 ms | 4.3 ms | 243.8 ms | 262.5 ms |
| base | 250.8 ms | 5.3 ms | 242.5 ms | 260.0 ms |
Δ (PR vs base): — +0.5 ms (+0.2%)
Measured with hyperfine on ubuntu-latest (3 warmup runs, 20 timed runs). CI numbers carry ±a few ms of runner jitter; treat small deltas as noise.
- maxBuffer: 64 MiB is enough headroom over the spec's current ~1.1 MiB. - Drop the redundant stdio option (pipe is the default when input is set). - Shorten the function's doc comment and the two inline comments. - Replace the deleted unresolved-$ref test with one that asserts the ref passes through, documenting the new boundary (forge generate catches it downstream). - Loosen the invalid-JSONPath assertion to "JSONPath", not forge's exact wording. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
LGTM |
|
LGTM |
There was a problem hiding this comment.
✅ Approved — The forge-based overlay wrapper, the dependency swap, the test updates and the docs changes have no correctness, security, performance or documentation problems.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
This is generator code that runs at build time. The arguments to execFileSync come from a resolved package path and an overlay file in the repository, and the call does not use a shell. maxBuffer limits the output size.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md concerns.
📋 Code Quality: ✅ LGTM
The wrapper finds bin/forge.cjs the same way the existing test helper does.
It runs forge through process.execPath with an argv array, so it does not go through a shell and works the same on Windows, Linux and macOS.
Error handling covers an empty stderr by falling back to error.message. It always includes the overlay path and keeps the original error as cause.
No references to @redocly/openapi-core remain.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The docs/architecture.md updates match the new overlay engine.
Reviewed commit: 3a71ed0f
Summary
Removes
@redocly/openapi-coreand its 17 transitive npm dependencies (18 fewer third-party packages inpnpm-lock.yaml/node_modules) by applying the CLI compatibility overlay throughforge openapi overlay - <path>on@cloudflare/forge@0.4.0— a first-party binary we already pin and execute in the same generation pipeline.Why this matters
@redocly/openapi-core,@redocly/config,@redocly/ajv,ajv,ajv-formats,require-from-string,js-yaml,yaml-ast-parser,jsonpath-rfc9535, and friends) with zero new dependencies added.forge normalize/forge generate) now share one implementation and error model instead of maintaining a second third-party OpenAPI engine just for the compat overlay.pnpm generate), with an identical_generated/output tree.Changes
packages/cli/package.json&pnpm-lock.yaml— drops@redocly/openapi-core(18 packages removed from lockfile) and bumps@cloudflare/forgeto0.4.0(which addsforge openapi overlay).packages/cli/generator/openapi-overlay.ts— resolves the installed@cloudflare/forgeCLI viacreateRequire(import.meta.url)(same pattern aspackages/cli/src/__tests__/helpers/forge-cli.ts) and runsforge openapi overlay - <overlayPath>with piped stdio and a 256 MiB output buffer. On failure, strips theforge:prefix from stderr (falling back toerror.messageif stderr is empty) and ensures the overlay path is included in the thrown error.packages/cli/src/__tests__/generator/openapi-overlay.test.ts— updates the invalid-JSONPath assertion to"JSONPath"and replaces the post-overlay unresolved-$refrejection test with one asserting unresolved$refs pass through toforge generatedownstream.docs/architecture.md— updates both the repository map and the overlay-engine description to referenceforge openapi overlay.Semantic deltas
"Invalid JSONPath"to"invalid RFC 9535 JSONPath target \"<expr>\": …".$refintroduced by an overlay now fails atforge generate(one stage later), not insideapplyOpenApiOverlay. The pipeline still rejects it.No other semantic changes: all 24
cli-compat-overlay.test.tsscenarios pass andpnpm generateproduces an identical_generated/tree.Performance (local benchmark, pinned 29.9 MB spec)
main(@redocly/openapi-core)@cloudflare/forge@0.4.0)node_modulespackagesapplyOpenApiOverlay(5 runs, mean)tsx generate.tswith cached spec (3 runs, mean)Test plan
pnpm install --frozen-lockfilesucceedspnpm --filter cf test src/__tests__/generator/openapi-overlay.test.tspassespnpm --filter cf test src/__tests__/generator/cli-compat-overlay.test.tspasses (24 scenarios)pnpm checkpasses end-to-endpnpm generateproduces the same_generated/tree as beforeUpstream