From 2535ee5fcb2bd9d5c57434123ce50345d28515f4 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Mon, 25 May 2026 01:38:08 +0530 Subject: [PATCH] feat(DX-7525): migrate contentstack-cli-content-type v1 into cli-plugins monorepo --- .cursor/rules/README.md | 1 + .github/config/release.json | 1 + .../workflows/release-production-plugins.yml | 8 + .github/workflows/unit-test.yml | 4 + .talismanrc | 40 +- AGENTS.md | 62 ++ README.md | 1 + .../.cursor/rules/README.md | 5 + .../contentstack-content-type/.editorconfig | 11 + .../contentstack-content-type/.eslintignore | 1 + packages/contentstack-content-type/.eslintrc | 51 + packages/contentstack-content-type/.gitignore | 14 + packages/contentstack-content-type/AGENTS.md | 51 + packages/contentstack-content-type/LICENSE | 21 + packages/contentstack-content-type/README.md | 234 +++++ .../contentstack-content-type/SECURITY.md | 27 + packages/contentstack-content-type/bin/dev | 6 + .../contentstack-content-type/bin/dev.cmd | 3 + packages/contentstack-content-type/bin/dev.js | 7 + packages/contentstack-content-type/bin/run | 7 + .../contentstack-content-type/bin/run.cmd | 3 + packages/contentstack-content-type/bin/run.js | 7 + .../contentstack-content-type/jest.config.js | 26 + .../contentstack-content-type/package.json | 91 ++ .../screenshots/starter-app.svg | 989 ++++++++++++++++++ .../skills/README.md | 14 + .../skills/code-review/SKILL.md | 82 ++ .../contentstack-cli-content-type/SKILL.md | 177 ++++ .../skills/dev-workflow/SKILL.md | 54 + .../skills/testing/SKILL.md | 103 ++ .../src/commands/content-type/audit.ts | 89 ++ .../commands/content-type/compare-remote.ts | 106 ++ .../src/commands/content-type/compare.ts | 119 +++ .../src/commands/content-type/details.ts | 101 ++ .../src/commands/content-type/diagram.ts | 128 +++ .../src/commands/content-type/list.ts | 82 ++ .../src/config/index.ts | 6 + .../src/core/command.ts | 87 ++ .../src/core/content-type/audit.ts | 26 + .../src/core/content-type/compare.ts | 52 + .../src/core/content-type/details.ts | 120 +++ .../src/core/content-type/diagram.ts | 301 ++++++ .../src/core/content-type/formatting.ts | 39 + .../src/core/content-type/list.ts | 38 + .../src/core/contentstack/client.ts | 80 ++ .../src/core/contentstack/error.ts | 16 + .../src/types/index.ts | 62 ++ .../src/utils/index.ts | 115 ++ .../tests/commands/content-type/audit.test.ts | 101 ++ .../content-type/compare-remote.test.ts | 131 +++ .../commands/content-type/compare.test.ts | 159 +++ .../commands/content-type/details.test.ts | 97 ++ .../commands/content-type/diagram.test.ts | 125 +++ .../tests/commands/content-type/list.test.ts | 82 ++ .../tests/core/command.test.ts | 183 ++++ .../tests/core/content-type/audit.test.ts | 38 + .../tests/core/content-type/compare.test.ts | 56 + .../tests/core/content-type/details.test.ts | 136 +++ .../tests/core/content-type/diagram.test.ts | 165 +++ .../core/content-type/formatting.test.ts | 102 ++ .../tests/core/content-type/list.test.ts | 49 + .../tests/core/contentstack/client.test.ts | 138 +++ .../tests/core/contentstack/error.test.ts | 16 + .../tests/utils/index.test.ts | 292 ++++++ .../contentstack-content-type/tsconfig.json | 18 + pnpm-lock.yaml | 714 ++++++++++++- 66 files changed, 6258 insertions(+), 12 deletions(-) create mode 100644 AGENTS.md create mode 100644 packages/contentstack-content-type/.cursor/rules/README.md create mode 100644 packages/contentstack-content-type/.editorconfig create mode 100644 packages/contentstack-content-type/.eslintignore create mode 100644 packages/contentstack-content-type/.eslintrc create mode 100644 packages/contentstack-content-type/.gitignore create mode 100644 packages/contentstack-content-type/AGENTS.md create mode 100644 packages/contentstack-content-type/LICENSE create mode 100644 packages/contentstack-content-type/README.md create mode 100644 packages/contentstack-content-type/SECURITY.md create mode 100755 packages/contentstack-content-type/bin/dev create mode 100644 packages/contentstack-content-type/bin/dev.cmd create mode 100644 packages/contentstack-content-type/bin/dev.js create mode 100755 packages/contentstack-content-type/bin/run create mode 100644 packages/contentstack-content-type/bin/run.cmd create mode 100755 packages/contentstack-content-type/bin/run.js create mode 100644 packages/contentstack-content-type/jest.config.js create mode 100644 packages/contentstack-content-type/package.json create mode 100644 packages/contentstack-content-type/screenshots/starter-app.svg create mode 100644 packages/contentstack-content-type/skills/README.md create mode 100644 packages/contentstack-content-type/skills/code-review/SKILL.md create mode 100644 packages/contentstack-content-type/skills/contentstack-cli-content-type/SKILL.md create mode 100644 packages/contentstack-content-type/skills/dev-workflow/SKILL.md create mode 100644 packages/contentstack-content-type/skills/testing/SKILL.md create mode 100644 packages/contentstack-content-type/src/commands/content-type/audit.ts create mode 100644 packages/contentstack-content-type/src/commands/content-type/compare-remote.ts create mode 100644 packages/contentstack-content-type/src/commands/content-type/compare.ts create mode 100644 packages/contentstack-content-type/src/commands/content-type/details.ts create mode 100644 packages/contentstack-content-type/src/commands/content-type/diagram.ts create mode 100644 packages/contentstack-content-type/src/commands/content-type/list.ts create mode 100644 packages/contentstack-content-type/src/config/index.ts create mode 100644 packages/contentstack-content-type/src/core/command.ts create mode 100644 packages/contentstack-content-type/src/core/content-type/audit.ts create mode 100644 packages/contentstack-content-type/src/core/content-type/compare.ts create mode 100644 packages/contentstack-content-type/src/core/content-type/details.ts create mode 100644 packages/contentstack-content-type/src/core/content-type/diagram.ts create mode 100644 packages/contentstack-content-type/src/core/content-type/formatting.ts create mode 100644 packages/contentstack-content-type/src/core/content-type/list.ts create mode 100644 packages/contentstack-content-type/src/core/contentstack/client.ts create mode 100644 packages/contentstack-content-type/src/core/contentstack/error.ts create mode 100644 packages/contentstack-content-type/src/types/index.ts create mode 100644 packages/contentstack-content-type/src/utils/index.ts create mode 100644 packages/contentstack-content-type/tests/commands/content-type/audit.test.ts create mode 100644 packages/contentstack-content-type/tests/commands/content-type/compare-remote.test.ts create mode 100644 packages/contentstack-content-type/tests/commands/content-type/compare.test.ts create mode 100644 packages/contentstack-content-type/tests/commands/content-type/details.test.ts create mode 100644 packages/contentstack-content-type/tests/commands/content-type/diagram.test.ts create mode 100644 packages/contentstack-content-type/tests/commands/content-type/list.test.ts create mode 100644 packages/contentstack-content-type/tests/core/command.test.ts create mode 100644 packages/contentstack-content-type/tests/core/content-type/audit.test.ts create mode 100644 packages/contentstack-content-type/tests/core/content-type/compare.test.ts create mode 100644 packages/contentstack-content-type/tests/core/content-type/details.test.ts create mode 100644 packages/contentstack-content-type/tests/core/content-type/diagram.test.ts create mode 100644 packages/contentstack-content-type/tests/core/content-type/formatting.test.ts create mode 100644 packages/contentstack-content-type/tests/core/content-type/list.test.ts create mode 100644 packages/contentstack-content-type/tests/core/contentstack/client.test.ts create mode 100644 packages/contentstack-content-type/tests/core/contentstack/error.test.ts create mode 100644 packages/contentstack-content-type/tests/utils/index.test.ts create mode 100644 packages/contentstack-content-type/tsconfig.json diff --git a/.cursor/rules/README.md b/.cursor/rules/README.md index 325fa7b53..5683213e8 100644 --- a/.cursor/rules/README.md +++ b/.cursor/rules/README.md @@ -51,6 +51,7 @@ This is a **CLI plugins** monorepo with plugin packages under `packages/`, inclu - `contentstack-seed` - Seed stacks with generated data - `contentstack-variants` - Manage content variants - `contentstack-apps-cli` - Developer Hub apps (`app:*` commands; npm `@contentstack/apps-cli`) +- `contentstack-content-type` - Content Type introspection (`content-type:*` commands; npm `contentstack-cli-content-type`; Jest tests) All plugins depend on: - `@contentstack/cli-command` - Base Command class diff --git a/.github/config/release.json b/.github/config/release.json index 1ea83997c..8a65c5ee7 100755 --- a/.github/config/release.json +++ b/.github/config/release.json @@ -20,6 +20,7 @@ "launch": false, "branches": false, "apps-cli": false, + "content-type": false, "core": false } } diff --git a/.github/workflows/release-production-plugins.yml b/.github/workflows/release-production-plugins.yml index e17f9a817..553b3cd51 100644 --- a/.github/workflows/release-production-plugins.yml +++ b/.github/workflows/release-production-plugins.yml @@ -143,6 +143,14 @@ jobs: package: ./packages/contentstack-query-export/package.json tag: latest + # Content Type + - name: Publishing content-type (Production) + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-content-type/package.json + tag: latest + - name: Create Production Release id: create_release env: diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 7c306cae7..cfc9ad9ac 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -69,3 +69,7 @@ jobs: - name: Run tests for Contentstack Apps CLI working-directory: ./packages/contentstack-apps-cli run: npm run test:unit:report:json + + - name: Run tests for Contentstack Content Type plugin + working-directory: ./packages/contentstack-content-type + run: npm run test:unit diff --git a/.talismanrc b/.talismanrc index 3e8b96c8b..6ad164a2a 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,4 +1,42 @@ fileignoreconfig: - filename: pnpm-lock.yaml - checksum: 89acb731dc98c886694fa4d267c11c188000b8ecbe5ee6e4809e5bc6ec33a2f3 + checksum: b37c8a782a95412347394c79010601d99265163a590ad5dd15bee765142a3750 + - filename: packages/contentstack-content-type/.eslintrc + checksum: 6a5fa2bef65bf5a62598c10d45d83dfdef2dc32675aca5827ef31c230fa29c97 + - filename: packages/contentstack-content-type/src/commands/content-type/list.ts + checksum: a584f002cf6c8b124d832339b646dac492a9e2e9607c8b570f7e0df666bf5991 + - filename: packages/contentstack-content-type/README.md + checksum: cfb10c8dd1848df7a4a47cf7eb8fa57a81b97994394a289a93c41a930f4b2a38 + - filename: packages/contentstack-content-type/src/utils/index.ts + checksum: 3209ee03042b33b491443bd2aabd273125eb1808607c9ef0b231323f2616092e + - filename: packages/contentstack-content-type/skills/code-review/SKILL.md + checksum: e784c95e1efba37e79acc5d6187d26f25bea9228f9c28bbcac0dd9285c70381f + - filename: packages/contentstack-content-type/tests/commands/content-type/compare-remote.test.ts + checksum: 68beeddf34261799b38259925e8d9b5d2426bd827864ff1e5b5cdf3356fdfe5a + - filename: packages/contentstack-content-type/src/core/command.ts + checksum: ee30e78b945495baa9d064c96feee454ec73607420b8a3b1da2ecc3be4c9a85d + - filename: packages/contentstack-content-type/skills/contentstack-cli-content-type/SKILL.md + checksum: f52be931ec23638c76b44652921c4b45dbca9edf558f05bf465f33bcadf20790 + - filename: packages/contentstack-content-type/skills/testing/SKILL.md + checksum: 1da781909a238a7e96dea43ed74ca97cd405e10d6a95dd2042a5280a7a9172f8 + - filename: packages/contentstack-content-type/src/commands/content-type/audit.ts + checksum: 2b38703b8452222024188118c65e1a5beb792072cd5f4eb6deda12133fd4dfd2 + - filename: packages/contentstack-content-type/src/commands/content-type/compare-remote.ts + checksum: 91f2a8cba4703a480086e6a257e4c96ac0c3d7fda5c5531e8ea0cb56be8b18e7 + - filename: packages/contentstack-content-type/src/commands/content-type/compare.ts + checksum: 91f8eb42a2f8c4f3845940418ecdc07f11cbc62e732cfc0042b092d9cc3a8b03 + - filename: packages/contentstack-content-type/src/commands/content-type/details.ts + checksum: 4fa7adeee4a82a8ab1b8206fa5c020babf3bb5341db351bc86069624028f911d + - filename: packages/contentstack-content-type/src/commands/content-type/diagram.ts + checksum: e6a2a5349421976e343c1cf149011e79e2bd319e61630e6d9f9edacb1e5b6be5 + - filename: packages/contentstack-content-type/tests/commands/content-type/list.test.ts + checksum: 728221e17384a6940d0e8e38f3111522927b49e415daba9fafe13dc3507e8406 + - filename: packages/contentstack-content-type/tests/core/command.test.ts + checksum: 65b8a60273110303467ce56438370f24d4803301c86fe1823c33233c523795d3 + - filename: packages/contentstack-content-type/tests/core/contentstack/client.test.ts + checksum: 5c4b952c5bee5c4e05825e24a7f953cd9ddebbe07e7dbae73e4e959730683988 + - filename: packages/contentstack-content-type/tests/core/content-type/diagram.test.ts + checksum: 75b5882e09a2f9f21d12236c8c64ed0d09bcbe9ff4a65f76b4b9f9b63b1a130c + - filename: packages/contentstack-content-type/tests/utils/index.test.ts + checksum: ba3137f99bba3d430145088fabf560ec9324a3fe14699eb7eacf1a863243f4b9 version: '1.0' diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..c56183c9f --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,62 @@ +# Contentstack CLI plugins – Agent guide + +**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**. + +## What this repo is + +| Field | Detail | +| --- | --- | +| **Name:** | Contentstack CLI plugins (pnpm monorepo; root package name `csdx`) | +| **Purpose:** | OCLIF plugins that extend the Contentstack CLI (import/export, clone, migration, seed, audit, variants, Developer Hub apps, etc.). | +| **Out of scope (if any):** | The **core** CLI aggregation lives in the separate `cli` monorepo; this repo ships plugin packages only. | + +## Tech stack (at a glance) + +| Area | Details | +| --- | --- | +| **Language** | TypeScript / JavaScript, Node **>= 18** (`engines` in root `package.json`) | +| **Build** | pnpm workspaces (`packages/*`); per package: `tsc`, OCLIF manifest/readme where applicable → `lib/` | +| **Tests** | Mocha + Chai; layouts under `packages/*/test/` (see [skills/testing/SKILL.md](skills/testing/SKILL.md)) | +| **Lint / coverage** | ESLint in packages that define `lint` scripts; nyc where configured | +| **Other** | OCLIF v4, Husky | + +## Commands (quick reference) + +| Command type | Command | +| --- | --- | +| **Build** | `pnpm build` | +| **Test** | `pnpm test` | +| **Lint** | `pnpm run lint` in a package that defines `lint` (no root aggregate lint script) | + +CI: [.github/workflows/unit-test.yml](.github/workflows/unit-test.yml) and other workflows under [.github/workflows/](.github/workflows/). + +## Where the documentation lives: skills + +| Skill | Path | What it covers | +| --- | --- | --- | +| Development workflow | [skills/dev-workflow/SKILL.md](skills/dev-workflow/SKILL.md) | pnpm commands, CI, TDD expectations, PR checklist | +| Contentstack CLI | [skills/contentstack-cli/SKILL.md](skills/contentstack-cli/SKILL.md) | Plugin commands, OCLIF, Contentstack APIs (incl. `app:*` / `@contentstack/apps-cli`) | +| Framework | [skills/framework/SKILL.md](skills/framework/SKILL.md) | Utilities, config, logging, errors (incl. Developer Hub SDK, manifests, GraphQL) | +| Testing | [skills/testing/SKILL.md](skills/testing/SKILL.md) | Mocha/Chai, coverage, mocks | +| Code review | [skills/code-review/SKILL.md](skills/code-review/SKILL.md) | PR review for this monorepo | + +## Apps CLI plugin (`@contentstack/apps-cli`) + +- **Package path:** [packages/contentstack-apps-cli](packages/contentstack-apps-cli) +- **npm name:** `@contentstack/apps-cli` (unchanged for consumers) +- **Migrated from:** [contentstack/contentstack-apps-cli](https://github.com/contentstack/contentstack-apps-cli) — see [APPS-CLI-MIGRATION.md](APPS-CLI-MIGRATION.md) +- **v1 / v2:** Maintain on `v1-dev` (1.x CLI deps) and `v2-dev` / `v2-beta` (2.x beta deps) branches; align `@contentstack/cli-command` and `@contentstack/cli-utilities` versions with the target CLI line. +- **Docs:** OCLIF / `app:*` commands → [contentstack-cli](skills/contentstack-cli/SKILL.md#apps-cli-commands-app); SDK, manifests, GraphQL, HTTP → [framework](skills/framework/SKILL.md#apps-cli-plugin-contentstackapps-cli) + +## Content Type plugin (`contentstack-cli-content-type`) + +- **Package path:** [packages/contentstack-content-type](packages/contentstack-content-type) +- **npm name:** `contentstack-cli-content-type` +- **Migrated from:** [contentstack/contentstack-cli-content-type](https://github.com/contentstack/contentstack-cli-content-type) — see [CONTENT-TYPE-MIGRATION.md](CONTENT-TYPE-MIGRATION.md) +- **v1 / v2:** This branch carries the **v1 line** (`@contentstack/cli-command ^1.8.2`, `@contentstack/cli-utilities ^1.18.3`, npm tag `latest`). The v2-beta line lives on `v2-beta`. +- **Tests:** Jest + ts-jest (unlike most other packages which use Mocha + Chai) +- **Docs:** 6 commands under `content-type:*` → [packages/contentstack-content-type/AGENTS.md](packages/contentstack-content-type/AGENTS.md) + +## Using Cursor (optional) + +If you use **Cursor**, [.cursor/rules/README.md](.cursor/rules/README.md) only points to **`AGENTS.md`**—same docs as everyone else. diff --git a/README.md b/README.md index b3660d6ba..73f555006 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,4 @@ To get a more detailed documentation for every command, visit the [CLI section]( ## Useful Plugins - [Generate TypeScript typings from a Stack](https://github.com/Contentstack-Solutions/contentstack-cli-tsgen) +- [Manage Content Types (list, details, audit, compare, diagram)](https://github.com/contentstack/cli-plugins/tree/main/packages/contentstack-content-type) (`contentstack-cli-content-type`) diff --git a/packages/contentstack-content-type/.cursor/rules/README.md b/packages/contentstack-content-type/.cursor/rules/README.md new file mode 100644 index 000000000..f5c1f8701 --- /dev/null +++ b/packages/contentstack-content-type/.cursor/rules/README.md @@ -0,0 +1,5 @@ +# Cursor (optional) + +**Cursor** users: start at **[AGENTS.md](../../AGENTS.md)**. All conventions live in **`skills/*/SKILL.md`**. + +This folder only points contributors to **`AGENTS.md`** so editor-specific config does not duplicate the canonical docs. diff --git a/packages/contentstack-content-type/.editorconfig b/packages/contentstack-content-type/.editorconfig new file mode 100644 index 000000000..beffa3084 --- /dev/null +++ b/packages/contentstack-content-type/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/packages/contentstack-content-type/.eslintignore b/packages/contentstack-content-type/.eslintignore new file mode 100644 index 000000000..dc555529d --- /dev/null +++ b/packages/contentstack-content-type/.eslintignore @@ -0,0 +1 @@ +/lib \ No newline at end of file diff --git a/packages/contentstack-content-type/.eslintrc b/packages/contentstack-content-type/.eslintrc new file mode 100644 index 000000000..dffeb7eca --- /dev/null +++ b/packages/contentstack-content-type/.eslintrc @@ -0,0 +1,51 @@ +{ + "extends": [ + // "oclif", + "oclif-typescript", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@typescript-eslint/no-unused-vars": [ + "error", + { + "args": "none" + } + ], + "@typescript-eslint/prefer-namespace-keyword": "error", + "@typescript-eslint/quotes": [ + "error", + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": true + } + ], + "semi": "off", + "@typescript-eslint/type-annotation-spacing": "error", + "@typescript-eslint/no-redeclare": "off", + "eqeqeq": [ + "error", + "smart" + ], + "id-match": "error", + "no-eval": "error", + "no-var": "error", + "quotes": "off", + "indent": "off", + "camelcase": "off", + "comma-dangle": "off", + "arrow-parens": "off", + "operator-linebreak": "off", + "object-curly-spacing": "off", + "node/no-missing-import": "off", + "padding-line-between-statements": "off", + "@typescript-eslint/ban-ts-ignore": "off", + "unicorn/no-abusive-eslint-disable": "off", + "unicorn/consistent-function-scoping": "off", + "@typescript-eslint/no-use-before-define": "off", + "@typescript-eslint/camelcase": "off", + "no-process-exit":"off", + "unicorn/no-process-exit": "off", + "@typescript-eslint/no-var-requires": "off" + } +} \ No newline at end of file diff --git a/packages/contentstack-content-type/.gitignore b/packages/contentstack-content-type/.gitignore new file mode 100644 index 000000000..f12d14f61 --- /dev/null +++ b/packages/contentstack-content-type/.gitignore @@ -0,0 +1,14 @@ +*-debug.log +*-error.log +/.nyc_output +/dist +/lib +/tmp +node_modules +.DS_Store +coverage +.env +oclif.manifest.json +talisman_output.log +snyk_output.log +tsconfig.tsbuildinfo diff --git a/packages/contentstack-content-type/AGENTS.md b/packages/contentstack-content-type/AGENTS.md new file mode 100644 index 000000000..cc48b9875 --- /dev/null +++ b/packages/contentstack-content-type/AGENTS.md @@ -0,0 +1,51 @@ +# contentstack-cli-content-type – Agent guide + +**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**. + +## What this repo is + +| Field | Detail | +|-------|--------| +| **Name:** | `contentstack-cli-content-type` ([contentstack/cli-plugins](https://github.com/contentstack/cli-plugins) → `packages/contentstack-content-type`) | +| **Purpose:** | Contentstack CLI (`csdx`) plugin that reads Content Type metadata from a stack: list, details, audit logs, same-stack or cross-stack JSON compare (HTML diff), and stack content-model diagrams. | +| **Out of scope (if any):** | Bulk entry/asset mutations, Delivery API consumption, and unrelated HTTP clients—this package focuses on content-type introspection via the Management API patterns documented in the plugin skill. | + +## Tech stack (at a glance) + +| Area | Details | +|------|---------| +| Language | TypeScript, **`strict`** ([tsconfig.json](tsconfig.json)), target ES2017, CommonJS | +| Build | `tsc -b`; output **`lib/`**; **`npm run prepack`** runs compile + `oclif manifest` + `oclif readme` | +| Tests | Jest + ts-jest; tests under **`tests/`** ([jest.config.js](jest.config.js)) | +| Lint / coverage | ESLint via **`npm run posttest`** ([.eslintrc](.eslintrc)); Jest coverage **`npm run test:coverage`**, global thresholds in [jest.config.js](jest.config.js) | +| CLI / runtime | oclif; Node engines per [package.json](package.json); `bin` is `csdx` when installed as a CLI plugin | + +## Commands (quick reference) + +| Command type | Command | +|--------------|---------| +| Build (publishable) | `pnpm run build` | +| Test | `pnpm test` | +| Test + coverage | `pnpm run test:coverage` | +| Lint | `pnpm run lint` (or `eslint . --ext .ts --config .eslintrc`) | + +CI: [.github/workflows](.github/workflows) includes policy/SCA/release/issue automation—there is no single `ci.yml` that only runs `npm test`; follow team merge requirements. + +## Where the documentation lives: skills + +| Skill | Path | What it covers | +|-------|------|----------------| +| Dev workflow | [skills/dev-workflow/SKILL.md](skills/dev-workflow/SKILL.md) | Scripts, `tsconfig`, ESLint, Jest/coverage, oclif README/manifest, PR checks | +| Content Type plugin | [skills/contentstack-cli-content-type/SKILL.md](skills/contentstack-cli-content-type/SKILL.md) | `ContentTypeCommand`, CMA vs SDK, auth, commands, compare/diagram | +| Testing | [skills/testing/SKILL.md](skills/testing/SKILL.md) | Jest layout, mocks, conventions, coverage | +| Code review | [skills/code-review/SKILL.md](skills/code-review/SKILL.md) | PR checklist, security and dependency review | + +An index with “when to use” hints is in [skills/README.md](skills/README.md). + +## Security + +See [SECURITY.md](SECURITY.md) for reporting issues. + +## Using Cursor (optional) + +If you use **Cursor**, [.cursor/rules/README.md](.cursor/rules/README.md) only points to **[AGENTS.md](AGENTS.md)**—same docs as everyone else. diff --git a/packages/contentstack-content-type/LICENSE b/packages/contentstack-content-type/LICENSE new file mode 100644 index 000000000..562c492a2 --- /dev/null +++ b/packages/contentstack-content-type/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Contentstack Solutions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/contentstack-content-type/README.md b/packages/contentstack-content-type/README.md new file mode 100644 index 000000000..429b3bedf --- /dev/null +++ b/packages/contentstack-content-type/README.md @@ -0,0 +1,234 @@ +![npm](https://img.shields.io/npm/v/contentstack-cli-content-type) + +## Description +This is a plugin for [Contentstack's](https://www.contentstack.com/) CLI. +It allows you to quickly retrieve information about Content Types in a Stack. + +## Why use this plugin +1. The `csdx content-type:audit` command lists recent changes to a content type and by whom. +This is useful when needing to find Content Type versions to compare with `csdx content-type:compare`. +[Audit logs](https://www.contentstack.com/docs/developers/set-up-stack/monitor-stack-activities-in-audit-log/) are stored for 90 days within Contentstack. + +1. The `csdx content-type:compare-remote` command allows you to compare the same Content Type between two Stacks. +This is useful when you have cloned or duplicated a Stack, and want to check what has changed in a child Stack. + +1. The `csdx content-type:compare` command allows you to compare multiple versions of a Content Type within a single Stack. +This is useful when you are working in a development team, and want to compare changes made by colleagues. + +1. The `csdx content-type:list` command is useful when you want to see all the Content Types within a Stack. +The Content Type's Display Name, UID, Last Modified Date, and Version number is shown. The list can be ordered by `title` or `modified` date. When developing against Contentstack, Content Type UIDs are needed when requesting data. + +1. The `csdx content-type:details` command provides useful information, such as: + * Field UID and Data Types + * Referenced Content Types + * Options such as required, multiple, and unique + * The full path to a field, useful when using the [include reference endpoint](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#include-reference) or filtering operations, such as the [equality endpoint](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#equals-operator). + +1. The `csdx content-type:diagram` command creates a visual representation of a Stack's content model. + * The ouput format can be either `svg` or `dot`. + * The diagram's orientation can be changed, using the `-d landscape|portrait` flag. + * [GraphViz](https://graphviz.org/) is the layout engine. You can export the generated DOT Language source, using the `-t dot` flag. + * ![Diagram Output](https://github.com/contentstack/contentstack-cli-content-type/blob/main/screenshots/starter-app.svg) + +## How to install this plugin + +```shell +$ csdx plugins:install contentstack-cli-content-type +``` + +## How to use this plugin +This plugin requires you to be authenticated using [csdx auth:login](https://www.contentstack.com/docs/developers/cli/authenticate-with-the-cli/). + +Several commands, such as `csdx content-type:compare` support token aliases as input. +These token aliases should be created using `csdx auth:tokens:add`. + +The commands only use the **Stack API Key**. The management token is ignored. +They are provided as a convenience, so the Stack API Keys do not have to be re-typed. + +## Usability +The `csdx content-type:details` command requires a wide terminal window. If the `path` column is not needed, you can hide it: + +```shell +$ csdx content-type:details -a "management token" -c "content type" --no-path +``` + +# Commands + +* [`csdx content-type:audit`](#csdx-content-typeaudit) +* [`csdx content-type:compare`](#csdx-content-typecompare) +* [`csdx content-type:compare-remote`](#csdx-content-typecompare-remote) +* [`csdx content-type:details`](#csdx-content-typedetails) +* [`csdx content-type:diagram`](#csdx-content-typediagram) +* [`csdx content-type:list`](#csdx-content-typelist) + +## `csdx content-type:audit` + +Display recent changes to a Content Type + +``` +USAGE + $ csdx content-type:audit -c [-s | -a | -a ] [-k | | ] + +FLAGS + -a, --alias= Alias of the management token + -a, --token-alias= Management token alias + -c, --content-type= (required) Content Type UID + -k, --stack-api-key= Stack API Key + -s, --stack= Stack UID + +DESCRIPTION + Display recent changes to a Content Type + +EXAMPLES + $ csdx content-type:audit --stack-api-key "xxxxxxxxxxxxxxxxxxx" --content-type "home_page" + + $ csdx content-type:audit --alias "management token" --content-type "home_page" +``` + +_See code: [src/commands/content-type/audit.ts](https://github.com/contentstack/contentstack-cli-content-type/blob/v1.3.0/src/commands/content-type/audit.ts)_ + +## `csdx content-type:compare` + +Compare two Content Type versions + +``` +USAGE + $ csdx content-type:compare -c [-s | -a ] [-k | ] [-a ] [-l -r ] + +FLAGS + -a, --alias= Alias of the management token + -a, --token-alias= Management token alias + -c, --content-type= (required) Content Type UID + -k, --stack-api-key= Stack API Key + -l, --left= Content Type version, i.e. prev version + -r, --right= Content Type version, i.e. later version + -s, --stack= Stack UID + +DESCRIPTION + Compare two Content Type versions + +EXAMPLES + $ csdx content-type:compare --stack-api-key "xxxxxxxxxxxxxxxxxxx" --content-type "home_page" + + $ csdx content-type:compare --stack-api-key "xxxxxxxxxxxxxxxxxxx" --content-type "home_page" --left # --right # + + $ csdx content-type:compare --alias "management token" --content-type "home_page" --left # --right # +``` + +_See code: [src/commands/content-type/compare.ts](https://github.com/contentstack/contentstack-cli-content-type/blob/v1.3.0/src/commands/content-type/compare.ts)_ + +## `csdx content-type:compare-remote` + +compare two Content Types on different Stacks + +``` +USAGE + $ csdx content-type:compare-remote (-o -r ) -c + +FLAGS + -c, --content-type= (required) Content Type UID + -o, --origin-stack= (required) Origin Stack API Key + -r, --remote-stack= (required) Remote Stack API Key + +DESCRIPTION + compare two Content Types on different Stacks + +EXAMPLES + $ csdx content-type:compare-remote --origin-stack "xxxxxxxxxxxxxxxxxxx" --remote-stack "xxxxxxxxxxxxxxxxxxx" -content-type "home_page" +``` + +_See code: [src/commands/content-type/compare-remote.ts](https://github.com/contentstack/contentstack-cli-content-type/blob/v1.3.0/src/commands/content-type/compare-remote.ts)_ + +## `csdx content-type:details` + +Display Content Type details + +``` +USAGE + $ csdx content-type:details -c [-s | -a ] [-k | ] [-a ] [-p] + +FLAGS + -a, --alias= Alias of the management token + -a, --token-alias= Management token alias + -c, --content-type= (required) Content Type UID + -k, --stack-api-key= Stack API Key + -p, --[no-]path show path column + -s, --stack= Stack UID + +DESCRIPTION + Display Content Type details + +EXAMPLES + $ csdx content-type:details --stack-api-key "xxxxxxxxxxxxxxxxxxx" --content-type "home_page" + + $ csdx content-type:details --alias "management token" --content-type "home_page" + + $ csdx content-type:details --alias "management token" --content-type "home_page" --no-path +``` + +_See code: [src/commands/content-type/details.ts](https://github.com/contentstack/contentstack-cli-content-type/blob/v1.3.0/src/commands/content-type/details.ts)_ + +## `csdx content-type:diagram` + +Create a visual diagram of a Stack's Content Types + +``` +USAGE + $ csdx content-type:diagram -o -d portrait|landscape -t svg|dot [-s | -a | -a ] [-k + | | ] + +FLAGS + -a, --alias= Alias of the management token + -a, --token-alias= Management token alias + -d, --direction=