|
1 | | -# `contentstack-cli-tsgen` |
| 1 | +# contentstack-cli-tsgen – Agent guide |
2 | 2 |
|
3 | | -**Purpose:** Contentstack CLI (**OCLIF**) plugin that adds **`csdx tsgen`** to generate TypeScript typings from a stack. Generation is delegated to the **`@contentstack/types-generator`** npm package (`generateTS` / `graphqlTS`); this repo owns the command surface (flags, auth alias, file output, CLI error formatting). |
| 3 | +**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**. |
4 | 4 |
|
5 | | -- **Repository:** [github.com/Contentstack-Solutions/contentstack-cli-tsgen](https://github.com/Contentstack-Solutions/contentstack-cli-tsgen) |
6 | | -- **Homepage:** [https://github.com/Contentstack-Solutions/contentstack-cli-tsgen](https://github.com/Contentstack-Solutions/contentstack-cli-tsgen) |
| 5 | +## What this repo is |
7 | 6 |
|
8 | | -**Library dependency (separate repo):** [`@contentstack/types-generator`](https://www.npmjs.com/package/@contentstack/types-generator) (see version in [package.json](package.json)). Source for the generator itself: [github.com/contentstack/types-generator](https://github.com/contentstack/types-generator). Do not assume a local sibling folder; treat it as an npm dependency only. |
| 7 | +| Field | Detail | |
| 8 | +| --- | --- | |
| 9 | +| **Name:** | [Contentstack-Solutions/contentstack-cli-tsgen](https://github.com/Contentstack-Solutions/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 repo 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. | |
9 | 12 |
|
10 | | -## Tech stack |
| 13 | +## Tech stack (at a glance) |
11 | 14 |
|
12 | 15 | | Area | Details | |
13 | 16 | | --- | --- | |
14 | | -| Language | TypeScript **5.9** (`strict` in [tsconfig.json](tsconfig.json)) | |
15 | | -| Runtime | Node (CI **18.x** / **20.x**; release **22.x**) | |
16 | | -| Build | **`tsc -b`** → **`lib/`**; **`npm run prepack`** runs `tsc -b`, **`oclif manifest`**, **`oclif readme`** | |
17 | | -| CLI | **OCLIF** — commands compiled to **`lib/commands`** (see `oclif.commands` in [package.json](package.json)) | |
18 | | -| Tests | **Jest** + **ts-jest** ([jest.config.js](jest.config.js)) | |
19 | | -| Lint | **ESLint** runs in **`posttest`** after tests ([package.json](package.json) scripts) | |
| 17 | +| **Language** | TypeScript **5.9** (`strict` in [tsconfig.json](tsconfig.json)) | |
| 18 | +| **Build** | **`tsc -b`** → **`lib/`**; **`npm run prepack`** runs compile, **`oclif manifest`**, **`oclif readme`** | |
| 19 | +| **Tests** | **Jest** + **ts-jest** ([jest.config.js](jest.config.js)); integration tests under `tests/integration/` | |
| 20 | +| **Lint / coverage** | ESLint in **`posttest`** after **`npm test`** ([package.json](package.json)) | |
| 21 | +| **Other** | OCLIF, Node (CI **18.x** / **20.x**; release **22.x**) | |
20 | 22 |
|
21 | 23 | **Main dependencies:** `@contentstack/cli-command`, `@contentstack/cli-utilities`, `@contentstack/types-generator`, `dotenv`. |
22 | 24 |
|
23 | | -## Source layout |
24 | | - |
25 | | -- **Commands:** [src/commands/](src/commands/) (e.g. `tsgen.ts`) |
26 | | -- **Helpers / errors:** [src/lib/](src/lib/) |
27 | | -- **Types:** [src/types/](src/types/) |
28 | | -- **Build output:** **`lib/`** (not committed as source of truth; produced by `prepack`) |
29 | | - |
30 | | -## Common commands |
| 25 | +## Commands (quick reference) |
31 | 26 |
|
32 | | -| Command | Purpose | |
| 27 | +| Command type | Command | |
33 | 28 | | --- | --- | |
34 | | -| `npm run prepack` | Clean `lib/`, compile TypeScript, generate OCLIF manifest and README | |
35 | | -| `npm test` | Jest (`--testPathPattern=tests`); then **`posttest`** runs ESLint with fix | |
36 | | -| `npm run test:integration` | Jest for `tests/integration` only | |
| 29 | +| **Build** | `npm run prepack` (canonical compile; no separate `build` script) | |
| 30 | +| **Test** | `npm test` (then **`posttest`** → ESLint) | |
| 31 | +| **Lint** | via **`posttest`** after tests | |
37 | 32 |
|
38 | | -There is no dedicated `build` script; **`prepack`** is the canonical compile path. CI may run `npm run build --if-present` (no-op here if no `build` script). |
| 33 | +**Integration tests:** `npm run test:integration` — Jest for `tests/integration` only. |
| 34 | + |
| 35 | +CI: [.github/workflows/node.js.yml](.github/workflows/node.js.yml); release: [.github/workflows/release.yml](.github/workflows/release.yml); SCA: [.github/workflows/sca-scan.yml](.github/workflows/sca-scan.yml). |
39 | 36 |
|
40 | 37 | ## Credentials and integration tests |
41 | 38 |
|
42 | | -Integration tests spawn **`csdx tsgen`** and require a configured **delivery token alias**. Set **`TOKEN_ALIAS`** (e.g. in **`.env`** at the package root; see [tests/integration/tsgen.integration.test.ts](tests/integration/tsgen.integration.test.ts)). |
| 39 | +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 such as **`REGION`**, **`TOKEN_ALIAS`**, **`APIKEY`**, **`DELIVERYKEY`**, **`ENVIRONMENT`**. |
| 40 | + |
| 41 | +## Where the documentation lives: skills |
43 | 42 |
|
44 | | -CI uses GitHub secrets such as **`REGION`**, **`TOKEN_ALIAS`**, **`APIKEY`**, **`DELIVERYKEY`**, **`ENVIRONMENT`** (see [.github/workflows/node.js.yml](.github/workflows/node.js.yml)). |
| 43 | +| Skill | Path | What it covers | |
| 44 | +| --- | --- | --- | |
| 45 | +| Development workflow | [skills/dev-workflow/SKILL.md](skills/dev-workflow/SKILL.md) | Branches, CI, prepack, PRs, releases | |
| 46 | +| TypeScript CLI tsgen | [skills/typescript-cli-tsgen/SKILL.md](skills/typescript-cli-tsgen/SKILL.md) | OCLIF command, flags, delegation to the library | |
| 47 | +| Testing | [skills/testing/SKILL.md](skills/testing/SKILL.md) | Jest, ESLint posttest, integration env | |
| 48 | +| Code review | [skills/code-review/SKILL.md](skills/code-review/SKILL.md) | PR checklist, terminology, semver | |
45 | 49 |
|
46 | | ---- |
| 50 | +An index with “when to use” hints is in [skills/README.md](skills/README.md). |
47 | 51 |
|
48 | | -## AI guidance index |
| 52 | +## Using Cursor (optional) |
49 | 53 |
|
50 | | -- [Cursor rules (overview)](.cursor/rules/README.md) |
51 | | -- [Skills index](skills/README.md) |
| 54 | +If you use **Cursor**, [.cursor/rules/README.md](.cursor/rules/README.md) only points to **`AGENTS.md`**—same docs as everyone else. |
0 commit comments