TypeScript monorepo for the Datadog CI CLI tool. Uses Yarn 4 workspaces, Clipanion for CLI commands, and Jest for testing.
See CONTRIBUTING.md for full details on creating commands, releasing, and CI.
yarn install # install dependencies
yarn build # compile TypeScript
yarn launch <scope> <cmd> [args] # run a command in dev (no build needed)
yarn test # run all tests
yarn test <path> # run tests for a specific package/file
yarn lint # lint (fails on errors)
yarn format # lint + auto-fixpackages/base-- command definitions (descriptions, paths, args), extendsBaseCommand. Does NOT hold implementations (with some exceptions).packages/plugin-<scope>-- command implementations for a scope. ExportsPluginCommandextending the base command.packages/datadog-ci-- thin CLI entrypoint, lists built-in plugins as dependencies.
Commands are registered in packages/base/src/cli.ts (auto-generated by bin/lint-packages.ts -- do not edit manually).
- Create the base command in
packages/base/src/commands/<scope>/<command>.tsextendingBaseCommand - The
execute()method should callexecutePluginCommand(this) - Run
yarn plugin:create <scope>to scaffold the plugin package - Implement the plugin in
packages/plugin-<scope>/src/commands/<command>.ts - Update CODEOWNERS, README, labels per the checklist in CONTRIBUTING.md
File config -> environment variables -> CLI args (highest priority).
Prettier + ESLint enforce formatting and style. Run yarn format to auto-fix, yarn lint to check. A post-commit hook runs lint automatically.
Not enforced by lint -- follow manually:
- Use
getRequestBuilder()fromhelpers/utilsorhttpRequest()fromhelpers/requestfor HTTP -- not raw fetch or axios - Use
datadogRoute()fromhelpers/request/datadog-routeto build Datadog API paths, andthirdParty()fromhelpers/request/third-partyfor external URLs. Never try to bypass this with casts, and never usethirdParty()for Datadog API calls.
- Jest, files in
__tests__/*.test.ts, fixtures in__tests__/fixtures/ - Use
createMockContext()andmakeRunCLI()frompackages/base/src/helpers/__tests__/testing-tools.ts - Use
createCommand()to instantiate a command with mock context for unit tests jest.spyOn()for mocking, follow existing patterns in nearby test files
After making changes, always verify by running:
yarn build-- ensure TypeScript compiles cleanlyyarn lint-- ensure no lint errors (useyarn formatto auto-fix)yarn test <path to relevant test files>-- ensure tests pass for affected packages