diff --git a/.cursor/rules/dev-workflow.md b/.cursor/rules/dev-workflow.md index 04ac39af6..757e305fd 100644 --- a/.cursor/rules/dev-workflow.md +++ b/.cursor/rules/dev-workflow.md @@ -9,7 +9,8 @@ alwaysApply: true ## Monorepo Structure ### Package Organization -- **11 plugin packages** under `packages/` +- **12+ plugin packages** under `packages/` +- `contentstack-cli-cm-regex-validate` - Regex validation for Content Type/Global Field fields (`cm:stacks:validate-regex`; npm `@contentstack/cli-cm-regex-validate`; Jest tests) - **pnpm workspaces** with `workspaces: ["packages/*"]` - **Shared dependencies**: `@contentstack/cli-command`, `@contentstack/cli-utilities` - **Build artifacts**: `lib/` directory (compiled from `src/`) diff --git a/.github/config/release.json b/.github/config/release.json index d3bff31b6..9863bcf7c 100755 --- a/.github/config/release.json +++ b/.github/config/release.json @@ -9,6 +9,12 @@ "migration": false, "seed": false, "bootstrap": false, - "branches": false + "branches": false, + "apps-cli": false, + "tsgen": false, + "content-type": false, + "regex-validate": false, + "migrate-rte": false, + "bulk-operations": false } } diff --git a/.github/workflows/release-v2-beta-plugins.yml b/.github/workflows/release-v2-beta-plugins.yml index 482b0a9bc..58c10ac87 100644 --- a/.github/workflows/release-v2-beta-plugins.yml +++ b/.github/workflows/release-v2-beta-plugins.yml @@ -142,3 +142,53 @@ jobs: token: ${{ secrets.NPM_TOKEN }} package: ./packages/contentstack-query-export/package.json tag: beta + + # Content Type + - name: Publishing content-type (Beta) + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-content-type/package.json + tag: beta + + # Apps CLI + - name: Publishing apps-cli (Beta) + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-apps-cli/package.json + tag: beta + + # Tsgen + - name: Publishing tsgen (Beta) + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-cli-tsgen/package.json + tag: beta + # Regex Validate + - name: Publishing regex-validate (Beta) + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-cli-cm-regex-validate/package.json + access: public + tag: beta + + # Migrate RTE + - name: Publishing migrate-rte (Beta) + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-migrate-rte/package.json + access: public + tag: beta + + # Bulk Operations + - name: Publishing bulk-operations (Beta) + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-bulk-operations/package.json + access: public + tag: beta diff --git a/.github/workflows/tsgen-integration-test.yml b/.github/workflows/tsgen-integration-test.yml new file mode 100644 index 000000000..8e44035d0 --- /dev/null +++ b/.github/workflows/tsgen-integration-test.yml @@ -0,0 +1,52 @@ +name: Tsgen Integration Tests + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + tsgen-integration: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.28.0 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22.x' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build tsgen plugin + run: pnpm --filter contentstack-cli-tsgen run build + + - name: Install Contentstack CLI (v2 beta) + run: npm i -g @contentstack/cli@beta + + - name: Configure CLI region + run: csdx config:set:region ${{ secrets.REGION }} + + - name: Add delivery token + run: csdx auth:tokens:add -a ${{ secrets.TOKEN_ALIAS }} --delivery -k ${{ secrets.APIKEY }} --token ${{ secrets.DELIVERYKEY }} -e ${{ secrets.ENVIRONMENT }} + + - name: Link tsgen plugin + working-directory: ./packages/contentstack-cli-tsgen + run: csdx plugins:link + + - name: Run integration tests + run: pnpm --filter contentstack-cli-tsgen run test:integration + env: + TOKEN_ALIAS: ${{ secrets.TOKEN_ALIAS }} + + - name: Unlink tsgen plugin + working-directory: ./packages/contentstack-cli-tsgen + run: csdx plugins:unlink + if: always() diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 62c048f9b..e6878f06c 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -66,3 +66,27 @@ jobs: - name: Run tests for Contentstack Query Export working-directory: ./packages/contentstack-query-export run: npm run test:unit + + - 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 Tsgen plugin + working-directory: ./packages/contentstack-cli-tsgen + run: npm run test + + - name: Run tests for Contentstack Content Type plugin + working-directory: ./packages/contentstack-content-type + run: npm run test:unit + + - name: Run tests for Contentstack Regex Validate plugin + working-directory: ./packages/contentstack-cli-cm-regex-validate + run: npm run test:unit + + - name: Run tests for Contentstack Migrate RTE + working-directory: ./packages/contentstack-migrate-rte + run: npm test + + - name: Run tests for Contentstack Bulk Operations + working-directory: ./packages/contentstack-bulk-operations + run: npm test diff --git a/AGENTS.md b/AGENTS.md index c1c1995d0..2ebc39eb1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,7 +7,7 @@ | 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, etc.). | +| **Purpose:** | OCLIF plugins that extend the Contentstack CLI (import/export, clone, migration, migrate RTE, bulk operations, seed, audit, variants, Developer Hub apps, TypeScript codegen, 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) @@ -35,11 +35,60 @@ CI: [.github/workflows/unit-test.yml](.github/workflows/unit-test.yml) and other | 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 | -| Framework | [skills/framework/SKILL.md](skills/framework/SKILL.md) | Utilities, config, logging, errors | +| 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) + +## Tsgen plugin (`contentstack-cli-tsgen`) + +- **Package path:** [packages/contentstack-cli-tsgen](packages/contentstack-cli-tsgen) +- **npm name:** `contentstack-cli-tsgen` (unchanged for consumers) +- **Migrated from:** standalone `contentstack-cli-tsgen` repos — see [TSGEN-MIGRATION.md](TSGEN-MIGRATION.md) +- **v2 beta only:** `5.0.0-beta.0`+ on `feat/migrate-external-cli-plugins-v2` / `v2-beta`; requires CLI 2.x beta. +- **Docs:** `csdx tsgen` → [typescript-cli-tsgen](packages/contentstack-cli-tsgen/skills/typescript-cli-tsgen/SKILL.md); tests → [package testing skill](packages/contentstack-cli-tsgen/skills/testing/SKILL.md) + +## 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:** Maintain on `v1-dev` / `main` (1.x CLI deps) and `v2-beta` (2.x beta deps) branches; align `@contentstack/cli-command` and `@contentstack/cli-utilities` versions with the target CLI line. +- **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) + +## Regex Validate plugin (`@contentstack/cli-cm-regex-validate`) + +- **Package path:** [packages/contentstack-cli-cm-regex-validate](packages/contentstack-cli-cm-regex-validate) +- **npm name:** `@contentstack/cli-cm-regex-validate` +- **Migrated from:** [contentstack/cli-cm-regex-validate](https://github.com/contentstack/cli-cm-regex-validate) — see [REGEX-VALIDATE-MIGRATION.md](REGEX-VALIDATE-MIGRATION.md) +- **v1 / v2:** Maintain on `v1-dev` / `main` (v1 CLI deps) and `v2-beta` (`~2.0.0-beta.7` / `~2.0.0-beta.8`, version `2.0.0-beta.0`); align with target CLI line. +- **Tests:** Jest + ts-jest (unlike most other packages which use Mocha + Chai) +- **Command:** Single command `cm:stacks:validate-regex` (short name `RGXVLD`) +- **Docs:** [packages/contentstack-cli-cm-regex-validate/AGENTS.md](packages/contentstack-cli-cm-regex-validate/AGENTS.md) + +## Migrate RTE plugin (`@contentstack/cli-cm-migrate-rte`) + +- **Package path:** [packages/contentstack-migrate-rte](packages/contentstack-migrate-rte) +- **npm name:** `@contentstack/cli-cm-migrate-rte` (unchanged) +- **Migrated from:** [contentstack/cli-cm-migrate-rte](https://github.com/contentstack/cli-cm-migrate-rte) — see [MIGRATE-RTE-MIGRATION.md](MIGRATE-RTE-MIGRATION.md) +- **Command:** `csdx cm:entries:migrate-html-rte` — JS sources in `src/`; `pnpm --filter @contentstack/cli-cm-migrate-rte run build` (`oclif manifest`) and `test` (see [dev-workflow](skills/dev-workflow/SKILL.md)) + +## Bulk operations plugin (`@contentstack/cli-bulk-operations`) + +- **Package path:** [packages/contentstack-bulk-operations](packages/contentstack-bulk-operations) +- **npm name:** `@contentstack/cli-bulk-operations` (unchanged) +- **Migrated from:** [contentstack/cli-bulk-operations](https://github.com/contentstack/cli-bulk-operations) — see [BULK-OPERATIONS-MIGRATION.md](BULK-OPERATIONS-MIGRATION.md) (commands + repository) +- **Commands:** `csdx cm:stacks:bulk-entries`, `csdx cm:stacks:bulk-assets`, `csdx cm:stacks:bulk-taxonomies` — see [dev-workflow](skills/dev-workflow/SKILL.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/APPS-CLI-MIGRATION.md b/APPS-CLI-MIGRATION.md new file mode 100644 index 000000000..db2851072 --- /dev/null +++ b/APPS-CLI-MIGRATION.md @@ -0,0 +1,51 @@ +# Apps CLI migration: standalone repo → cli-plugins monorepo + +## Summary + +The **@contentstack/apps-cli** plugin (`contentstack-apps-cli`) has moved from the standalone repository [contentstack/contentstack-apps-cli](https://github.com/contentstack/contentstack-apps-cli) into the [contentstack/cli-plugins](https://github.com/contentstack/cli-plugins) monorepo at **`packages/contentstack-apps-cli`**. + +The **npm package name is unchanged**: `@contentstack/apps-cli`. Install and command usage stay the same. + +## Repository and issue tracking + +| Before | After | +| --- | --- | +| Source: `github.com/contentstack/contentstack-apps-cli` | Source: `github.com/contentstack/cli-plugins` → `packages/contentstack-apps-cli` | +| Issues: contentstack-apps-cli repo | Issues: [cli-plugins issues](https://github.com/contentstack/cli-plugins/issues) (label or mention `apps-cli` / `@contentstack/apps-cli`) | + +The standalone **contentstack-apps-cli** repository is **archived** after the first release from cli-plugins. Open PRs and bugs should be recreated or linked in cli-plugins. + +## Version lines (1.x vs 2.x) + +| CLI line | cli-plugins branch | Apps plugin notes | +| --- | --- | --- | +| **1.x** | `v1-dev` / `v1-beta` | `@contentstack/cli-command` and `@contentstack/cli-utilities` on 1.x-compatible ranges | +| **2.x beta** | `v2-dev` / `v2-beta` | Align with 2.x beta core packages (same pattern as export, import, bootstrap) | + +Develop and release each line on its branch; do not mix 1.x and 2.x dependency pins in the same branch. + +## Install (unchanged) + +```bash +csdx plugins:install @contentstack/apps-cli +# or +npm install -g @contentstack/apps-cli +``` + +## Local development + +Clone [cli-dev-workspace](https://github.com/contentstack/cli-dev-workspace) (or cli-plugins only), then: + +```bash +cd cli-plugins +pnpm install +pnpm --filter @contentstack/apps-cli run build +pnpm --filter @contentstack/apps-cli test +``` + +See [AGENTS.md](./AGENTS.md), [skills/contentstack-cli/SKILL.md](./skills/contentstack-cli/SKILL.md#apps-cli-commands-app), and [skills/framework/SKILL.md](./skills/framework/SKILL.md#apps-cli-plugin-contentstackapps-cli) for contributor docs. + +## Related migrations + +- Core CLI: [cli](https://github.com/contentstack/cli) monorepo +- Other external plugins (bulk operations, migrate-rte): same cli-plugins consolidation effort diff --git a/BULK-OPERATIONS-MIGRATION.md b/BULK-OPERATIONS-MIGRATION.md index fecea2cb6..576e83c0b 100644 --- a/BULK-OPERATIONS-MIGRATION.md +++ b/BULK-OPERATIONS-MIGRATION.md @@ -1,6 +1,16 @@ # 🔄 Migration Guide: From Bulk Publish to Bulk Operations Commands > **Migrating from @contentstack/cli-cm-bulk-publish (v1.x) to New Unified Commands @contentstack/cli-bulk-operations (v1.x)** + +## Repository + +| Before | After | +| --- | --- | +| [contentstack/cli-bulk-operations](https://github.com/contentstack/cli-bulk-operations) | [contentstack/cli-plugins](https://github.com/contentstack/cli-plugins) → `packages/contentstack-bulk-operations` | +| Issues on standalone repo | [cli-plugins issues](https://github.com/contentstack/cli-plugins/issues) | + +npm package name unchanged: **`@contentstack/cli-bulk-operations`**. Local dev: `pnpm --filter @contentstack/cli-bulk-operations run build` / `test` from cli-plugins (or cli-dev-workspace). + --- ## What Changed? diff --git a/CONTENT-TYPE-MIGRATION.md b/CONTENT-TYPE-MIGRATION.md new file mode 100644 index 000000000..83d4ef2ef --- /dev/null +++ b/CONTENT-TYPE-MIGRATION.md @@ -0,0 +1,76 @@ +# Content Type plugin migration: standalone repo → cli-plugins monorepo + +## Summary + +The **contentstack-cli-content-type** plugin has moved from the standalone repository [contentstack/contentstack-cli-content-type](https://github.com/contentstack/contentstack-cli-content-type) into the [contentstack/cli-plugins](https://github.com/contentstack/cli-plugins) monorepo at **`packages/contentstack-content-type`**. + +The **npm package name is unchanged**: `contentstack-cli-content-type`. Install and command usage stay the same. + +First release from the monorepo: **2.0.0-beta.0** (previously 1.4.6 from the standalone repo). + +## Repository and issue tracking + +| Before | After | +| --- | --- | +| Source: `github.com/contentstack/contentstack-cli-content-type` | Source: `github.com/contentstack/cli-plugins` → `packages/contentstack-content-type` | +| Issues: contentstack-cli-content-type repo | Issues: [cli-plugins issues](https://github.com/contentstack/cli-plugins/issues) (label or mention `content-type` / `contentstack-cli-content-type`) | + +The standalone **contentstack-cli-content-type** repository should be **archived** after the first release from cli-plugins. Open PRs and bugs should be recreated or linked in cli-plugins. + +## Version lines (1.x vs 2.x) + +| CLI line | cli-plugins branch | Plugin notes | +| --- | --- | --- | +| **1.x** | `v1-dev` / `main` | `@contentstack/cli-command ~1.8.2`, `@contentstack/cli-utilities ~1.18.3`; npm tag `latest` | +| **2.x beta** | `v2-dev` / `v2-beta` | Align with 2.x beta core packages; npm tag `beta` | + +Develop and release each line on its branch; do not mix 1.x and 2.x dependency pins in the same branch. + +## Install (unchanged) + +```bash +csdx plugins:install contentstack-cli-content-type +``` + +## Commands (unchanged) + +All 6 commands are identical to the standalone version: + +| Command | Description | +| --- | --- | +| `csdx content-type:list` | List all Content Types in a Stack | +| `csdx content-type:details` | Display Content Type fields, types, references, and paths | +| `csdx content-type:audit` | Display recent changes (audit log) for a Content Type | +| `csdx content-type:compare` | Compare two versions of a Content Type in the same Stack | +| `csdx content-type:compare-remote` | Compare the same Content Type across two Stacks | +| `csdx content-type:diagram` | Generate a visual diagram (SVG or DOT) of the Stack content model | + +## Local development + +Clone [cli-dev-workspace](https://github.com/contentstack/cli-dev-workspace) (or cli-plugins only), then: + +```bash +cd cli-plugins +pnpm install +pnpm --filter contentstack-cli-content-type run build +pnpm --filter contentstack-cli-content-type test +``` + +To link the plugin locally into your `csdx` installation: + +```bash +cd packages/contentstack-content-type +csdx plugins:link +``` + +See [packages/contentstack-content-type/AGENTS.md](./packages/contentstack-content-type/AGENTS.md) and the [skills/](./packages/contentstack-content-type/skills/) directory for contributor docs. + +## Test framework note + +This package uses **Jest + ts-jest** (unlike most other packages in this monorepo which use Mocha + Chai). Tests live under `packages/contentstack-content-type/tests/` and run via `pnpm test` or `pnpm run test:unit`. + +## Related migrations + +- Apps CLI: [APPS-CLI-MIGRATION.md](./APPS-CLI-MIGRATION.md) +- Tsgen plugin: [TSGEN-MIGRATION.md](./TSGEN-MIGRATION.md) +- Core CLI: [cli](https://github.com/contentstack/cli) monorepo diff --git a/MIGRATE-RTE-MIGRATION.md b/MIGRATE-RTE-MIGRATION.md new file mode 100644 index 000000000..d46ea6917 --- /dev/null +++ b/MIGRATE-RTE-MIGRATION.md @@ -0,0 +1,40 @@ +# Migrate RTE migration: standalone repo → cli-plugins monorepo + +## Summary + +**@contentstack/cli-cm-migrate-rte** moved from [contentstack/cli-cm-migrate-rte](https://github.com/contentstack/cli-cm-migrate-rte) into [contentstack/cli-plugins](https://github.com/contentstack/cli-plugins) at **`packages/contentstack-migrate-rte`**. + +The npm package name and command **`csdx cm:entries:migrate-html-rte`** are unchanged. + +## Repository and issues + +| Before | After | +| --- | --- | +| `github.com/contentstack/cli-cm-migrate-rte` | `github.com/contentstack/cli-plugins` → `packages/contentstack-migrate-rte` | +| Issues on standalone repo | [cli-plugins issues](https://github.com/contentstack/cli-plugins/issues) | + +## Version lines (1.x vs 2.x) + +| CLI line | cli-plugins branch | Plugin notes | +| --- | --- | --- | +| **1.x** | `v1-dev` / `v1-beta` | 1.x-compatible `cli-command` / `cli-utilities` | +| **2.x beta** | `v2-dev` / `v2-beta` | e.g. `2.0.0-beta.x`; uses `@contentstack/json-rte-serializer`, jsdom | + +## Install + +```bash +csdx plugins:install @contentstack/cli-cm-migrate-rte +# or +npm install -g @contentstack/cli-cm-migrate-rte +``` + +## Local development + +```bash +cd cli-dev-workspace +pnpm install +pnpm --filter @contentstack/cli-cm-migrate-rte run build +pnpm --filter @contentstack/cli-cm-migrate-rte test +``` + +Core CLI: add `@contentstack/cli-cm-migrate-rte` to `cli/packages/contentstack` dependencies and `oclif.plugins` (use `workspace:*` in cli-dev-workspace). diff --git a/MIGRATION.md b/MIGRATION.md index 7853bc0d8..41922466f 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -158,6 +158,8 @@ npm install -g @contentstack/cli-cm-migrate-rte csdx plugins:install @contentstack/cli-cm-migrate-rte@2.0.0-beta ``` +**Source repository:** Plugin code lives in [cli-plugins](https://github.com/contentstack/cli-plugins) at `packages/contentstack-migrate-rte` (formerly [cli-cm-migrate-rte](https://github.com/contentstack/cli-cm-migrate-rte)). See [MIGRATE-RTE-MIGRATION.md](./MIGRATE-RTE-MIGRATION.md). + **Usage:** After installation, RTE migration commands will be available through the CLI: ```bash @@ -180,6 +182,14 @@ csdx cm:migrate-rte --help **Migration Action:** Refer to the detailed [Bulk Operations Migration Guide](./BULK-OPERATIONS-MIGRATION.md) for complete command mappings and examples. +### 7. 📱 Apps CLI plugin repository move + +**What Changed:** +- The Apps CLI plugin (`@contentstack/apps-cli`) source moved from the standalone [contentstack-apps-cli](https://github.com/contentstack/contentstack-apps-cli) repository into this **cli-plugins** monorepo at `packages/contentstack-apps-cli` +- The npm package name and `csdx app:*` commands are unchanged + +**Migration Action:** For repository location, branching (1.x vs 2.x), and issue tracking, see the [Apps CLI Migration Guide](./APPS-CLI-MIGRATION.md). + **Quick Example:** ```bash # Before (1.x.x) diff --git a/README.md b/README.md index 6b922e41e..cbea6fb4b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Contentstack is a headless CMS with an API-first approach that puts content at t CLI supports content management scripts through which you can perform the following tasks: -- Bulk publish content +- Bulk publish content (`cm:stacks:bulk-*` via `@contentstack/cli-bulk-operations`) - Export content - Import content - Clone Stack @@ -15,6 +15,7 @@ CLI supports content management scripts through which you can perform the follow - Migrate HTML RTE to JSON RTE content - Change Master Locale - Use Bootstrap plugin +- Manage Developer Hub apps (`app:*` via `@contentstack/apps-cli`) - Use Tsgen plugin @@ -66,4 +67,7 @@ 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/cli-plugins/tree/v2-beta/packages/contentstack-cli-tsgen) (`contentstack-cli-tsgen`) - [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`) +- [Validate regex fields in Content Types and Global Fields](https://github.com/contentstack/cli-plugins/tree/main/packages/contentstack-cli-cm-regex-validate) (`@contentstack/cli-cm-regex-validate`) diff --git a/REGEX-VALIDATE-MIGRATION.md b/REGEX-VALIDATE-MIGRATION.md new file mode 100644 index 000000000..742d17fc2 --- /dev/null +++ b/REGEX-VALIDATE-MIGRATION.md @@ -0,0 +1,57 @@ +# Regex Validate plugin migration: standalone repo → cli-plugins monorepo + +## Summary + +The **@contentstack/cli-cm-regex-validate** plugin has moved from the standalone repository [contentstack/cli-cm-regex-validate](https://github.com/contentstack/cli-cm-regex-validate) into the [contentstack/cli-plugins](https://github.com/contentstack/cli-plugins) monorepo at **`packages/contentstack-cli-cm-regex-validate`**. + +The **npm package name is unchanged**: `@contentstack/cli-cm-regex-validate`. This is the **first npm release** — the package was previously not published. + +First release: **1.0.0** (v1 line) / **2.0.0-beta.0** (v2-beta line). + +## Repository and issue tracking + +| Before | After | +| --- | --- | +| Source: `github.com/contentstack/cli-cm-regex-validate` | Source: `github.com/contentstack/cli-plugins` → `packages/contentstack-cli-cm-regex-validate` | +| Issues: cli-cm-regex-validate repo | Issues: [cli-plugins issues](https://github.com/contentstack/cli-plugins/issues) (label or mention `regex-validate`) | + +The standalone **cli-cm-regex-validate** repository should be **archived** after the first release from cli-plugins. + +## Version lines + +| CLI line | cli-plugins branch | Plugin notes | +| --- | --- | --- | +| **1.x** | `v1-dev` / `main` | `@contentstack/cli-command ^1.8.2`, `@contentstack/cli-utilities ^1.18.3`; npm tag `latest`; version `1.0.0` | +| **2.x beta** | `v2-dev` / `v2-beta` | `@contentstack/cli-command ~2.0.0-beta.7`, `@contentstack/cli-utilities ~2.0.0-beta.8`; npm tag `beta`; version `2.0.0-beta.0` | + +## Install + +```bash +csdx plugins:install @contentstack/cli-cm-regex-validate +``` + +## Command (unchanged) + +| Command | Description | +| --- | --- | +| `csdx cm:stacks:validate-regex` | Validate fields with regex property in Content Types and Global Fields of a Stack | + +Flags: `-a` (token alias), `-c` (content types), `-g` (global fields), `-f` (CSV output path). + +## Local development + +```bash +cd cli-plugins +pnpm install +pnpm --filter @contentstack/cli-cm-regex-validate run build +pnpm --filter @contentstack/cli-cm-regex-validate test +``` + +## Test framework note + +This package uses **Jest + ts-jest** (unlike most other packages in this monorepo which use Mocha + Chai). Tests live under `packages/contentstack-cli-cm-regex-validate/test/` and run via `pnpm test` or `pnpm run test:unit`. + +## Related migrations + +- Content Type plugin: [CONTENT-TYPE-MIGRATION.md](./CONTENT-TYPE-MIGRATION.md) +- Apps CLI: [APPS-CLI-MIGRATION.md](./APPS-CLI-MIGRATION.md) diff --git a/TSGEN-MIGRATION.md b/TSGEN-MIGRATION.md new file mode 100644 index 000000000..a57e865d6 --- /dev/null +++ b/TSGEN-MIGRATION.md @@ -0,0 +1,54 @@ +# Tsgen CLI migration: standalone repo → cli-plugins monorepo + +## Summary + +The **contentstack-cli-tsgen** plugin has moved from the standalone repositories [Contentstack-Solutions/contentstack-cli-tsgen](https://github.com/Contentstack-Solutions/contentstack-cli-tsgen) and [contentstack/contentstack-cli-tsgen](https://github.com/contentstack/contentstack-cli-tsgen) into the [contentstack/cli-plugins](https://github.com/contentstack/cli-plugins) monorepo at **`packages/contentstack-cli-tsgen`**. + +The **npm package name is unchanged**: `contentstack-cli-tsgen`. Install and command usage stay the same (`csdx tsgen`). + +## Repository and issue tracking + +| Before | After | +| --- | --- | +| Source: standalone `contentstack-cli-tsgen` repos | Source: `github.com/contentstack/cli-plugins` → `packages/contentstack-cli-tsgen` | +| Issues: standalone repo | Issues: [cli-plugins issues](https://github.com/contentstack/cli-plugins/issues) (label or mention `tsgen` / `contentstack-cli-tsgen`) | + +The standalone **contentstack-cli-tsgen** repository should be **archived** after the first release from cli-plugins. Open PRs and bugs should be recreated or linked in cli-plugins. + +## Version line (2.x beta only) + +| CLI line | cli-plugins branch | Tsgen plugin notes | +| --- | --- | --- | +| **2.x beta** | `feat/migrate-external-cli-plugins-v2` → `v2-beta` | `@contentstack/cli-command` and `@contentstack/cli-utilities` on `~2.0.0-beta.*`; first monorepo release **`5.0.0-beta.0`** | + +This migration does not maintain a `v1-dev` line for tsgen. + +## Install (unchanged) + +```bash +csdx plugins:install contentstack-cli-tsgen@beta +# or +npm install -g contentstack-cli-tsgen +``` + +Requires **Contentstack CLI 2.x beta** and a **delivery token** alias for `csdx tsgen`. + +## Local development + +Clone [cli-dev-workspace](https://github.com/contentstack/cli-dev-workspace) (or cli-plugins only), then: + +```bash +cd cli-plugins +pnpm install +pnpm --filter contentstack-cli-tsgen run build +cd packages/contentstack-cli-tsgen && csdx plugins:link +csdx tsgen --help +``` + +See [AGENTS.md](./AGENTS.md), package [AGENTS.md](./packages/contentstack-cli-tsgen/AGENTS.md), and [skills/typescript-cli-tsgen](./packages/contentstack-cli-tsgen/skills/typescript-cli-tsgen/SKILL.md) for contributor docs. + +## Related migrations + +- Core CLI: [cli](https://github.com/contentstack/cli) monorepo +- Apps CLI: [APPS-CLI-MIGRATION.md](./APPS-CLI-MIGRATION.md) +- Other external plugins: same cli-plugins consolidation effort diff --git a/packages/contentstack-apps-cli/.eslintignore b/packages/contentstack-apps-cli/.eslintignore new file mode 100644 index 000000000..9b1c8b133 --- /dev/null +++ b/packages/contentstack-apps-cli/.eslintignore @@ -0,0 +1 @@ +/dist diff --git a/packages/contentstack-apps-cli/.eslintrc b/packages/contentstack-apps-cli/.eslintrc new file mode 100644 index 000000000..aa58bce72 --- /dev/null +++ b/packages/contentstack-apps-cli/.eslintrc @@ -0,0 +1,42 @@ +{ + "env": { + "node": true + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "extends": [ + "plugin:@typescript-eslint/recommended" + ], + "ignorePatterns": [ + "lib/**/*", + "test/**/*" + ], + "rules": { + "@typescript-eslint/no-unused-vars": [ + "error", + { + "args": "none" + } + ], + "@typescript-eslint/prefer-namespace-keyword": "error", + "quotes": "off", + "semi": "off", + "@typescript-eslint/no-redeclare": "off", + "eqeqeq": [ + "error", + "smart" + ], + "id-match": "error", + "no-eval": "error", + "no-var": "error", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-require-imports": "off", + "prefer-const": "error" + } +} \ No newline at end of file diff --git a/packages/contentstack-apps-cli/.gitignore b/packages/contentstack-apps-cli/.gitignore new file mode 100644 index 000000000..976172982 --- /dev/null +++ b/packages/contentstack-apps-cli/.gitignore @@ -0,0 +1,21 @@ +*-debug.log +*-error.log +/.nyc_output +/dist +/lib +/package-lock.json +/tmp +/yarn.lock +node_modules +oclif.manifest.json +.env +*.log +tsconfig.tsbuildinfo +dependabot.yml +.vscode +*.todo +/bkp +.editorconfig +oclif.manifest.json +*.env +.vscode/ diff --git a/packages/contentstack-apps-cli/.mocharc.json b/packages/contentstack-apps-cli/.mocharc.json new file mode 100644 index 000000000..4a09d1446 --- /dev/null +++ b/packages/contentstack-apps-cli/.mocharc.json @@ -0,0 +1,12 @@ +{ + "require": [ + "test/helpers/init.js", + "ts-node/register" + ], + "watch-extensions": [ + "ts" + ], + "recursive": true, + "reporter": "spec", + "timeout": 60000 +} diff --git a/packages/contentstack-apps-cli/LICENSE b/packages/contentstack-apps-cli/LICENSE new file mode 100644 index 000000000..c409861bc --- /dev/null +++ b/packages/contentstack-apps-cli/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Contentstack + +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-apps-cli/README.md b/packages/contentstack-apps-cli/README.md new file mode 100644 index 000000000..2a21c7384 --- /dev/null +++ b/packages/contentstack-apps-cli/README.md @@ -0,0 +1,313 @@ +> **Source of truth:** [cli-plugins monorepo](https://github.com/contentstack/cli-plugins) — `packages/contentstack-apps-cli` +> Migrated from [contentstack-apps-cli](https://github.com/contentstack/contentstack-apps-cli). See [APPS-CLI-MIGRATION.md](../../APPS-CLI-MIGRATION.md). + + + + +# @contentstack/apps-cli + +Contentstack lets you develop apps in your organization using the Developer Hub portal. With the Apps CLI plugin, Contentstack CLI allows you to perform the CRUD operations on your app in Developer Hub and then use the app in your organization or stack by installing or uninstalling your app as required. + +## How to install this plugin + +```shell +$ csdx plugins:install @contentstack/apps-cli +``` + +## 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/). + + +```sh-session +$ npm install -g @contentstack/apps-cli +$ csdx COMMAND +running command... +$ csdx (--version|-v) +@contentstack/apps-cli/1.6.1 darwin-arm64 node-v18.20.2 +$ csdx --help [COMMAND] +USAGE + $ csdx COMMAND +... +``` + + +# Commands + + +* [`csdx app`](#csdx-app) +* [`csdx app:create`](#csdx-appcreate) +* [`csdx app:delete`](#csdx-appdelete) +* [`csdx app:deploy`](#csdx-appdeploy) +* [`csdx app:get`](#csdx-appget) +* [`csdx app:install`](#csdx-appinstall) +* [`csdx app:reinstall`](#csdx-appreinstall) +* [`csdx app:uninstall`](#csdx-appuninstall) +* [`csdx app:update`](#csdx-appupdate) + +## `csdx app` + +Apps CLI plugin + +``` +USAGE + $ csdx app + +DESCRIPTION + Apps CLI plugin + +EXAMPLES + $ csdx app:create + + $ csdx app:delete + + $ csdx app:deploy + + $ csdx app:get + + $ csdx app:install + + $ csdx app:reinstall + + $ csdx app:uninstall + + $ csdx app:update +``` + +_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.6.1/src/commands/app/index.ts)_ + +## `csdx app:create` + +Create a new app in Developer Hub and optionally clone a boilerplate locally. + +``` +USAGE + $ csdx app:create [--org ] [-n ] [--app-type stack|organization] [-c ] [-d ] + [--boilerplate ] + +FLAGS + -c, --config= Path of the external config + -d, --data-dir= Current working directory. + -n, --name= Name of the app to be created + --app-type=