@genxapi/cli
v1.3.0
Published
GenX API CLI - Orchestration for API client generation workflows.
Readme
@genxapi/cli
CLI for GenX API orchestration. The current public command surface is intentionally small and explicit.
Requirements
- Node.js v20+.
- Access tokens if you plan to push to GitHub (
GITHUB_TOKEN) or publish to npm (NPM_TOKEN).
Commands
genxapi generate– Generate clients defined in configuration, optionally override the output directory (--target), and run configured post-generation GitHub or registry steps.genxapi diff– Compare two OpenAPI contracts, render a human-readable summary or JSON report, and optionally write release metadata.genxapi publish– Create GitHub releases using Octokit.
Running the CLI
- Primary public alias:
npx genxapi --help - Direct package alternative:
npx @genxapi/cli --help - Local install: add
"cli": "genxapi"topackage.jsonscripts, then runnpm run cli -- --help
Environment Variables
GITHUB_TOKEN(configurable viaproject.repository.tokenEnv) – required to push commits or open pull requests.NPM_TOKEN(configurable viaproject.publish.npm.tokenEnv) – required to publish the generated package to npm.
Ensure
project.repository.ownermatches your GitHub login (case-insensitive). Leading@characters are stripped automatically before syncing.
Use project.readme in your configuration to customise the generated package README (introduction, usage text, extra sections).
- Navigate to Settings ▸ Developer settings ▸ Personal access tokens in GitHub.
- Create either:
- a Fine-grained token scoped to the repos you will update and enable:
- Repository permissions → Contents → Read and write (allows pushing commits and editing files)
- Repository permissions → Pull requests → Read and write
- or a Classic token and tick the single checkbox repo (minimal scope for commit + PR access).
- a Fine-grained token scoped to the repos you will update and enable:
- Copy the token and export it as GITHUB_TOKEN before running the generator.
- Sign in to npmjs.com.
- Go to Access Tokens and click Generate new token.
- Choose an Automation or Publish token (Automation is recommended for CI).
- Copy the token and export it as NPM_TOKEN before running the generator.
Sample Usage
GITHUB_TOKEN=ghp_xxx NPM_TOKEN=xxx \
genxapi generate \
--config samples/orval-multi-client.config.json \
--target ./examples/multi-client-demo \
--log-level debugThis command will:
- Load the config (including repository/publish settings) from the provided path or cosmiconfig search.
- Call
@genxapi/template-orvalto scaffold the template, apply replacements, copy swagger files, run Orval, and execute hooks. - Commit and push the generated changes to GitHub and open a pull request if
project.repositoryexists. - Publish the package if
project.publish.npm.enabledistrue.
Contract diff example:
genxapi diff \
--base ./contracts/petstore-prev.json \
--head ./contracts/petstore-next.json \
--format json \
--output ./artifacts/genxapi-diff.json \
--release-manifest-output ./artifacts/genxapi-release.jsonGeneration can append planning metadata to the same release manifest:
genxapi generate \
--config ./genxapi.config.json \
--dry-run \
--plan-output ./artifacts/genxapi-plan.json \
--release-manifest-output ./artifacts/genxapi-release.jsonType safety
Run npm run typecheck at the repository root to validate both packages before raising a PR or publishing.
Publishing the CLI
From the repository root:
# Dry-run the repository release configuration locally
npm run release:dry:cliThe published npm release for @genxapi/cli is handled by semantic-release from .github/workflows/publish-cli.yml after merge to main. The genxapi proxy package remains a separate manual release.
