Skip to content

Commit deb79d1

Browse files
committed
feat(DX-7531): migrate contentstack-cli-tsgen v1 into cli-plugins monorepo
Adds the contentstack-cli-tsgen OCLIF plugin package under packages/, wires it into CI (unit tests, integration tests, production release), and registers it in the monorepo config and README.
1 parent 137f9ae commit deb79d1

32 files changed

Lines changed: 1569 additions & 49 deletions

File tree

.cursor/rules/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ This is a **CLI plugins** monorepo with plugin packages under `packages/`, inclu
5151
- `contentstack-seed` - Seed stacks with generated data
5252
- `contentstack-variants` - Manage content variants
5353
- `contentstack-apps-cli` - Developer Hub apps (`app:*` commands; npm `@contentstack/apps-cli`)
54+
- `contentstack-cli-tsgen` - TypeScript typings (`csdx tsgen`; npm `contentstack-cli-tsgen`; Jest integration tests)
5455

5556
All plugins depend on:
5657
- `@contentstack/cli-command` - Base Command class

.github/config/release.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"launch": false,
2121
"branches": false,
2222
"apps-cli": false,
23-
"core": false
23+
"core": false,
24+
"tsgen": false
2425
}
2526
}

.github/workflows/release-production-plugins.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ jobs:
143143
package: ./packages/contentstack-query-export/package.json
144144
tag: latest
145145

146+
# Tsgen
147+
- name: Publishing tsgen (Production)
148+
uses: JS-DevTools/npm-publish@v3
149+
with:
150+
token: ${{ secrets.NPM_TOKEN }}
151+
package: ./packages/contentstack-cli-tsgen/package.json
152+
tag: latest
153+
146154
- name: Create Production Release
147155
id: create_release
148156
env:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Tsgen Integration Tests
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
tsgen-integration:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup pnpm
15+
uses: pnpm/action-setup@v4
16+
with:
17+
version: 10.28.0
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '22.x'
23+
cache: 'pnpm'
24+
25+
- name: Install dependencies
26+
run: pnpm install --frozen-lockfile
27+
28+
- name: Build tsgen plugin
29+
run: pnpm --filter contentstack-cli-tsgen run build
30+
31+
- name: Install Contentstack CLI (v1)
32+
run: npm i -g @contentstack/cli
33+
34+
- name: Configure CLI region
35+
run: csdx config:set:region ${{ secrets.REGION }}
36+
37+
- name: Add delivery token
38+
run: csdx auth:tokens:add -a ${{ secrets.TOKEN_ALIAS }} --delivery -k ${{ secrets.APIKEY }} --token ${{ secrets.DELIVERYKEY }} -e ${{ secrets.ENVIRONMENT }}
39+
40+
- name: Link tsgen plugin
41+
working-directory: ./packages/contentstack-cli-tsgen
42+
run: csdx plugins:link
43+
44+
- name: Run integration tests
45+
run: pnpm --filter contentstack-cli-tsgen run test:integration
46+
env:
47+
TOKEN_ALIAS: ${{ secrets.TOKEN_ALIAS }}
48+
49+
- name: Unlink tsgen plugin
50+
working-directory: ./packages/contentstack-cli-tsgen
51+
run: csdx plugins:unlink
52+
if: always()

.github/workflows/unit-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@ jobs:
6969
- name: Run tests for Contentstack Apps CLI
7070
working-directory: ./packages/contentstack-apps-cli
7171
run: npm run test:unit:report:json
72+
73+
- name: Run tests for Contentstack Tsgen plugin
74+
working-directory: ./packages/contentstack-cli-tsgen
75+
run: npm run test

.talismanrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
fileignoreconfig:
22
- filename: pnpm-lock.yaml
3-
checksum: 89acb731dc98c886694fa4d267c11c188000b8ecbe5ee6e4809e5bc6ec33a2f3
3+
checksum: a5fd5bbb109364fc980359e175fde60bd0fec3241953bb93362928de80f3f0ac
4+
- filename: packages/contentstack-cli-tsgen/AGENTS.md
5+
checksum: 75b4f1414b547d0bd83df5ed4fb80020acc0ed849619bed2639491b565be7a1b
6+
- filename: packages/contentstack-cli-tsgen/src/lib/helper.ts
7+
checksum: a7ead0030ead9d15b6b6e9623f61e7def77b00325e3988f0e3d73a145180dedc
8+
- filename: packages/contentstack-cli-tsgen/src/commands/tsgen.ts
9+
checksum: 054ea78f765edca62c785714cf8962df4fb91529c0851439d1ed61e963467408
410
version: '1.0'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ To get a more detailed documentation for every command, visit the [CLI section](
5555

5656
## Useful Plugins
5757

58-
- [Generate TypeScript typings from a Stack](https://github.com/Contentstack-Solutions/contentstack-cli-tsgen)
58+
- [Generate TypeScript typings from a Stack](https://github.com/contentstack/cli-plugins/tree/v1-dev/packages/contentstack-cli-tsgen) (`contentstack-cli-tsgen`)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
parser: "@typescript-eslint/parser",
3+
parserOptions: {
4+
ecmaVersion: 2020,
5+
sourceType: "module",
6+
},
7+
plugins: ["@typescript-eslint"],
8+
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
9+
rules: {
10+
"unicorn/prefer-module": "off",
11+
"unicorn/no-abusive-eslint-disable": "off",
12+
"@typescript-eslint/no-use-before-define": "off",
13+
"node/no-missing-import": "off",
14+
"@typescript-eslint/no-explicit-any": "off",
15+
"@typescript-eslint/no-require-imports": "off",
16+
"no-useless-escape": "off",
17+
},
18+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*-debug.log
2+
*-error.log
3+
/.nyc_output
4+
/dist
5+
/lib
6+
/tmp
7+
node_modules
8+
.DS_Store
9+
coverage
10+
.env
11+
oclif.manifest.json
12+
talisman_output.log
13+
snyk_output.log
14+
tsconfig.tsbuildinfo
15+
tests/integration/generated.d.ts
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

Comments
 (0)