diff --git a/.github/config/release.json b/.github/config/release.json index d3bff31b6..f43492a73 100755 --- a/.github/config/release.json +++ b/.github/config/release.json @@ -9,6 +9,7 @@ "migration": false, "seed": false, "bootstrap": false, - "branches": false + "branches": false, + "apps-cli": false } } diff --git a/.github/workflows/release-v2-beta-plugins.yml b/.github/workflows/release-v2-beta-plugins.yml index 482b0a9bc..fa5a42c6e 100644 --- a/.github/workflows/release-v2-beta-plugins.yml +++ b/.github/workflows/release-v2-beta-plugins.yml @@ -142,3 +142,11 @@ jobs: token: ${{ secrets.NPM_TOKEN }} package: ./packages/contentstack-query-export/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 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 62c048f9b..853bb54e9 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -66,3 +66,7 @@ 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 diff --git a/.talismanrc b/.talismanrc index 16286bff7..dcc9f80ae 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,18 +1,6 @@ fileignoreconfig: - filename: pnpm-lock.yaml - checksum: 264c0294416c2aa2028c8283831aa7ed17d63e8c69553a7b2b9774336bc0811f - - filename: packages/contentstack-bootstrap/test/bootstrap.test.js - checksum: 37b502482fc32831c39091dd1755e8b0a9f6f8bac89e5eb9d397c6af1f213d83 - - filename: packages/contentstack-bootstrap/test/utils.test.js - checksum: e0ca2eb58ab1c3ac3b4d9c14a17bb8f4788678074dd65f6acc128a8a8f51997f - - filename: packages/contentstack-export-to-csv/test/unit/base-command.test.ts - checksum: 4c2befce053135453c1db31f21351bf3f797ff2f15723ca52e183ed6ed9e48e4 - - filename: packages/contentstack-export-to-csv/test/unit/utils/teams-export.functional.test.ts - checksum: 17cdae91c22a935309bf4514b6616f1aea91fd0166fede182e673ade43667a36 - - filename: packages/contentstack-export-to-csv/test/unit/utils/interactive.test.ts - checksum: 72c1e719e5c51a42debc817a5fe5bb1adee63b2d823df2e9ee36d0b970db7886 - - filename: packages/contentstack-export-to-csv/test/unit/utils/api-client.functional.test.ts - checksum: 6d6638919ef7260f642d32cf730e2654d159d2d3582714fb2d7a9c209b9c6eeb - - filename: packages/contentstack-export-to-csv/test/unit/commands/export-to-csv.test.ts - checksum: 9621a9d013796e99a25e894404c4d7c6799bd33bde77852f09d5e32b4d1c1c49 + checksum: e5b5f8ab64f4f27a1483e426cc01d7388482263e1d6fe3baf1caafcf2878ebb2 + - filename: skills/framework/SKILL.md + checksum: c5746de64b1e7d1df051c4337de5eb32de6a4c85c7297aa408838d304bb2d771 version: '1.0' diff --git a/AGENTS.md b/AGENTS.md index c1c1995d0..cb3fd24d1 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, 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) @@ -35,11 +35,19 @@ 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) + ## 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/MIGRATION.md b/MIGRATION.md index 7853bc0d8..d9fe2acfe 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -180,6 +180,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..ef8ea5843 100644 --- a/README.md +++ b/README.md @@ -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 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=