Skip to content

Latest commit

 

History

History
89 lines (62 loc) · 4.11 KB

File metadata and controls

89 lines (62 loc) · 4.11 KB
name dev-workflow
description Branches, CI, pnpm workspace commands, PR expectations, and TDD workflow for the Contentstack CLI plugins monorepo.

Development workflow – Contentstack CLI plugins

When to use

  • Before you run builds or tests across the workspace
  • When wiring CI or interpreting .github/workflows/
  • When following TDD expectations for a plugin under packages/

Monorepo layout

Plugins live under packages/ (pnpm workspaces: packages/*). Current packages include:

  • contentstack-apps-cli — Developer Hub apps (app:* commands); npm package @contentstack/apps-cli
  • contentstack-cli-tsgen — TypeScript typings (csdx tsgen); npm package contentstack-cli-tsgen
  • contentstack-migrate-rte — HTML → JSON RTE (cm:entries:migrate-html-rte); npm @contentstack/cli-cm-migrate-rte
  • contentstack-bulk-operations — bulk publish/unpublish (cm:stacks:bulk-*); npm @contentstack/cli-bulk-operations
  • contentstack-audit, contentstack-bootstrap, contentstack-branches, contentstack-clone, contentstack-export, contentstack-export-to-csv, contentstack-import, contentstack-import-setup, contentstack-migration, contentstack-query-export, contentstack-seed, contentstack-variants

Plugins typically depend on @contentstack/cli-command and @contentstack/cli-utilities. Match dependency major/beta lines to the repo branch (v1-dev vs v2-dev).

Apps CLI package commands

From repo root or the package directory:

Command Purpose
pnpm --filter @contentstack/apps-cli run build Compile src/ → lib/
pnpm --filter @contentstack/apps-cli test Mocha unit tests + lint (posttest)
pnpm --filter @contentstack/apps-cli run test:unit:report Unit tests with nyc coverage

CI runs apps-cli tests in .github/workflows/unit-test.yml.

Tsgen package commands

Command Purpose
pnpm --filter contentstack-cli-tsgen run build Compile src/ → lib/ + OCLIF manifest
pnpm --filter contentstack-cli-tsgen test Jest + ESLint (posttest)
pnpm --filter contentstack-cli-tsgen run test:integration Live csdx tsgen integration tests

CI: integration in .github/workflows/tsgen-integration-test.yml; lint in unit-test.yml.

Migrate RTE package commands

Command Purpose
pnpm --filter @contentstack/cli-cm-migrate-rte run build oclif manifest
pnpm --filter @contentstack/cli-cm-migrate-rte test Mocha + nyc

Bulk operations package commands

Command Purpose
pnpm --filter @contentstack/cli-bulk-operations run build Compile src/ → lib/
pnpm --filter @contentstack/cli-bulk-operations test Mocha + lint (posttest)

Commands (root)

Command Purpose
pnpm install Install all workspace dependencies
pnpm build pnpm -r --filter './packages/*' run build
pnpm test pnpm -r --filter './packages/*' run test
pnpm prepack pnpm -r --filter './packages/*' run prepack

There is no root lint script; run ESLint in a package that defines lint (e.g. cd packages/contentstack-import && pnpm run lint). Filter example: pnpm --filter @contentstack/cli-cm-import test (adjust scope to the package you change).

TDD expectations

  1. RED — one failing test in the package’s unit test tree
  2. GREEN — minimal src/ change to pass
  3. REFACTOR — keep tests green

Do not commit test.only / test.skip. Target 80% coverage where nyc is configured. Mock external APIs; no real API calls in unit tests.

CI and hooks

  • Workflows: .github/workflows/ — e.g. unit-test.yml, tsgen-integration-test.yml, release-v2-beta-plugins.yml, sca-scan.yml, policy-scan.yml, codeql-analysis.yml
  • Husky: .husky/ when present

PR expectations

  • Tests and build pass for affected packages
  • No stray .only / .skip in tests
  • Follow testing and code-review