Repository navigation
feat(cli): generate the CLI reference with a dev script - #2091
mishushakov wants to merge 2 commits into
Conversation
PR SummaryLow Risk Overview The new For
Reviewed by Cursor Bugbot for commit c1ba4e8. Bugbot is set up for automated code reviews on this repo. Configure here. |
🦋 Changeset detectedLatest commit: c1ba4e8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
TASTE.md review: no violations. This PR only changes CLI internals and docs tooling (the reference generator, the --env default, and the pkg import), so most TASTE rules, which cover the SDK surface, don't apply. The ones that do (T-20 absence is undefined, T-56 version read from package.json, T-69/T-70 docs, T-62/T-63 error messages) all pass.
Package ArtifactsBuilt from b5c17ca. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-dockerfile-utils-0.1.2-mishushakov-cli-reference-generator.0.tgz ./e2b-2.63.1-mishushakov-cli-reference-generator.0.tgzCLI ( npm install ./e2b-cli-2.23.1-mishushakov-cli-reference-generator.0.tgzCode Interpreter JS SDK ( npm install ./e2b-code-interpreter-2.9.2-mishushakov-cli-reference-generator.0.tgzDesktop JS SDK ( npm install ./e2b-desktop-2.5.1-mishushakov-cli-reference-generator.0.tgzPython SDK ( pip install ./e2b_dockerfile_utils-0.1.1+mishushakov.cli.reference.generator-py3-none-any.whl ./e2b-2.63.0+mishushakov.cli.reference.generator-py3-none-any.whlCode Interpreter Python SDK ( pip install ./e2b_code_interpreter-2.11.9+mishushakov.cli.reference.generator-py3-none-any.whlDesktop Python SDK ( pip install ./e2b_desktop-2.7.2+mishushakov.cli.reference.generator-py3-none-any.whl |
The repeatable `-e, --env` option seeded its accumulator through the
option default, so help printed `(default: {})`, and the same object was
shared across parses. parseEnv now starts a fresh object itself.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Replace the `-cmd2md` flag baked into the shipped binary with `pnpm run generate:reference`, a tsx script that walks the command tree through commander's public Help API and writes sdk_ref/<command>.md. Compared to commands2md: - hidden options (deprecated --team, --config) are no longer documented - positional arguments and aliases are documented - defaults are formatted by commander, no more `[object Object]` - free text is escaped for MDX instead of the no-op `<` replacement - json2md and the flag no longer ship in dist/index.js The rendered reference is snapshotted in tests/__snapshots__/reference so help text changes show up in review. login.ts now reads package.json directly instead of importing the entrypoint, which ran main() when the command tree was imported on its own. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
f12fc8c to
c1ba4e8
Compare
Summary
Replaces the hidden
-cmd2mdflag in the published binary with a dev-only script,pnpm run generate:reference. The script walks the command tree through commander's public Help API (visibleCommands,visibleOptions,visibleArguments,optionDescription, …) and writessdk_ref/<command>.mdfor e2b-dev/docs to publish.Stacked on #2090. The matching docs-repo change is e2b-dev/docs#626.
Why
The old
commands2mdread commander's internal fields directly, which caused these problems on the docs site:--team, the ignored--config)--help[default: [object Object]]on every-e, --env(stripped by a regex in the docs repo)--envno longer has a fake default<with<(no-op); colour stripping only worked because stdout wasn't a TTY<placeholder>tokens become inline code; other<>{}become entities; ANSI stripped withutil.stripVTControlCharacters. All pages compile with@mdx-js/mdx3json2mdand the flag shipped indist/index.jsChanges
scripts/reference.ts(renderer) andscripts/generate-reference.ts(writessdk_ref/), run withtsx(new devDependency).lintandformatnow coverscripts/.tests/reference.test.ts: unit tests for the renderer, plus file snapshots of the real reference intests/__snapshots__/reference/*.md. Help-text changes now show up in review as docs diffs; update them withpnpm vitest run -u tests/reference.test.ts.-e, --env(sandbox create,connect,exec):parseEnvstarts its own accumulator instead of taking a{}option default. This drops(default: {})from--helpand stops one object being shared across parses (patch changeset).auth loginreadspackage.jsondirectly instead of importing the CLI entrypoint (src/index.ts). Importing the entrypoint ranmain()whenever the command tree was loaded on its own, which is how the script and tests load it.Usage
Merge order
Merge e2b-dev/docs#626 before the first
@e2b/clirelease that contains this PR. It runs the new script when a tag has it and keeps-cmd2mdfor older tags. Without it, the reference sync fails for that release.Testing
pnpm run testinpackages/cli: 24 files / 158 tests pass, including thetemplate createbackend test against prod.generate:referenceoutput is byte-identical to the vitest snapshots.generateCli()against this branch end to end; the resulting.mdxpages compile with@mdx-js/mdx3.pnpm run lintandpnpm run typecheckpass;knipreports nothing new.Closes SDK-432.
🤖 Generated with Claude Code