|
| 1 | +# contentstack-cli-tsgen – Agent guide |
| 2 | + |
| 3 | +**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**. |
| 4 | + |
| 5 | +## What this repo is |
| 6 | + |
| 7 | +| Field | Detail | |
| 8 | +| --- | --- | |
| 9 | +| **Name:** | `contentstack-cli-tsgen` ([contentstack/cli-plugins](https://github.com/contentstack/cli-plugins) → `packages/contentstack-cli-tsgen`) | |
| 10 | +| **Purpose:** | OCLIF plugin that adds **`csdx tsgen`** to generate TypeScript typings from a stack. Generation is delegated to **`@contentstack/types-generator`** (`generateTS` / `graphqlTS`); this package owns flags, auth alias, file output, and CLI error formatting. | |
| 11 | +| **Out of scope (if any):** | Core type-generation logic belongs in **`@contentstack/types-generator`** ([npm](https://www.npmjs.com/package/@contentstack/types-generator)), not reimplemented here. | |
| 12 | + |
| 13 | +## Tech stack (at a glance) |
| 14 | + |
| 15 | +| Area | Details | |
| 16 | +| --- | --- | |
| 17 | +| **Language** | TypeScript **5.9** (`strict` in [tsconfig.json](tsconfig.json)) | |
| 18 | +| **Build** | `pnpm run build` → `tsc -b` → `lib/`; OCLIF manifest + readme | |
| 19 | +| **Tests** | **Jest** + **ts-jest** ([jest.config.js](jest.config.js)); integration tests under `tests/integration/` | |
| 20 | +| **Lint / coverage** | ESLint via `lint` and `posttest` | |
| 21 | +| **Other** | OCLIF v4, Node **>= 14**; **v1** `@contentstack/cli-command` ~1.8.2 / `@contentstack/cli-utilities` ~1.18.3 | |
| 22 | + |
| 23 | +**Main dependencies:** `@contentstack/cli-command`, `@contentstack/cli-utilities`, `@contentstack/types-generator`. |
| 24 | + |
| 25 | +## Commands (quick reference) |
| 26 | + |
| 27 | +| Command type | Command | |
| 28 | +| --- | --- | |
| 29 | +| **Build** | `pnpm run build` (from repo root: `pnpm --filter contentstack-cli-tsgen run build`) | |
| 30 | +| **Test** | `pnpm test` (then **`posttest`** → ESLint) | |
| 31 | +| **Integration** | `pnpm run test:integration` | |
| 32 | +| **Lint** | `pnpm run lint` | |
| 33 | + |
| 34 | +CI: [tsgen-integration-test.yml](../../.github/workflows/tsgen-integration-test.yml) (live stack); tests in [unit-test.yml](../../.github/workflows/unit-test.yml); release via [release-production-plugins.yml](../../.github/workflows/release-production-plugins.yml) on **`main`** (`latest` tag). |
| 35 | + |
| 36 | +## Credentials and integration tests |
| 37 | + |
| 38 | +Integration tests spawn **`csdx tsgen`** and require a **delivery token alias**. Set **`TOKEN_ALIAS`** (e.g. **`.env`** at package root; see [tests/integration/tsgen.integration.test.ts](tests/integration/tsgen.integration.test.ts)). CI uses secrets **`REGION`**, **`TOKEN_ALIAS`**, **`APIKEY`**, **`DELIVERYKEY`**, **`ENVIRONMENT`**. |
| 39 | + |
| 40 | +## Where the documentation lives: skills |
| 41 | + |
| 42 | +| Skill | Path | What it covers | |
| 43 | +| --- | --- | --- | |
| 44 | +| Development workflow | [skills/dev-workflow/SKILL.md](skills/dev-workflow/SKILL.md) | pnpm, CI, PRs, releases | |
| 45 | +| TypeScript CLI tsgen | [skills/typescript-cli-tsgen/SKILL.md](skills/typescript-cli-tsgen/SKILL.md) | OCLIF command, flags, delegation to the library | |
| 46 | +| Testing | [skills/testing/SKILL.md](skills/testing/SKILL.md) | Jest, integration env, CI | |
| 47 | +| Code review | [skills/code-review/SKILL.md](skills/code-review/SKILL.md) | PR checklist, terminology, semver | |
| 48 | + |
| 49 | +An index with “when to use” hints is in [skills/README.md](skills/README.md). |
| 50 | + |
| 51 | +## Migration from standalone repo |
| 52 | + |
| 53 | +See [TSGEN-MIGRATION.md](../../TSGEN-MIGRATION.md) at the monorepo root. |
0 commit comments