Monorepo for the Commerce Layer CLI, its shared libraries and its plugins.
See packages/cli/README.md for installation and usage.
Requires Node.js 20+ and pnpm.
pnpm install # install all workspace packages
pnpm build # build every package
pnpm test # run every package's tests
pnpm lint # lint the whole repositoryShared dependency versions live in the catalog: of pnpm-workspace.yaml: packages declare "<name>": "catalog:". pnpm check:packages (also run in CI) checks that the packages stay consistent: catalog and workspace dependencies, repository fields, oclif settings, scripts.
Run a single package's script with pnpm --filter <package name> <script>, for example pnpm --filter @commercelayer/cli test.
Some plugins generate part of their code: triggers and orders generate a command for each API trigger, and resources and provisioning generate their resource list. Each of them declares its generator in a gen.config.ts, run by the private packages/generator (cl-generate), in the same way as commercelayer-sdk does with its sdk.config.ts:
pnpm generate(at the root or in a plugin) downloads the schema, updates the plugin's snapshot (gen/triggers.json) and regenerates the code.pnpm generate-localregenerates from the committed snapshot, offline.resourcesandprovisioningread the installed SDK instead, so there both commands do the same thing.- CI (
verify.yml) regenerates everything withgenerate-localand fails if the result differs from what is committed. - The Regenerate code workflow (manual dispatch) regenerates against an API environment and opens a pull request when something changed.
Don't edit generated files by hand: change the templates (gen/templates) or the generator, then regenerate.
Every package is versioned and released on its own. A release starts from a tag <dir>-v<version>, where <dir> is the package's directory (cli-v6.10.0, core-v5.12.0, orders-v5.7.0).
- Bump: on an up-to-date
main, runpnpm release:version. Only packages with commits touching their folder since their last tag are released. Each one's version is derived from those commits (breaking → major,feat→ minor, anything else → patch), and you confirm the whole plan once. Use--interactiveto change or skip single packages,--yesto skip the confirmation,--preid <id>for a prerelease (x.y.z-<id>.n, published under the<id>dist-tag). The bumps go on arelease/…branch and achore(release)pull request. Packages depending on a released one aren't bumped: they pick it up through their^range. - Tag: after merging it, on an up-to-date
mainrunpnpm release:tag. It tags the merge commit for every package whose version isn't released yet and pushes the tags. - Draft: each tag makes release.yml draft a GitHub release, with notes built from the titles and labels of the PRs that touched that package.
- Publish: publishing the draft makes publish.yml build and test the package from the tag, check its command surface against npm, publish it to npm with provenance and announce it on Slack.
Internal dependencies need no manual step. When a released package uses unreleased changes of a workspace dependency (cli-core, cli-ux, …), pnpm release:version releases the dependency in the same PR, even if you skip it with --interactive. publish.yml then publishes the dependency to npm before the package, and marks the dependency's draft release as published.
PRs get a pkg:<dir> label from the files they touch; that's how each release lists only its own changes. After adding or removing a package, run pnpm release:config and commit the generated .github/labeler.yml and .github/release-*.yml.