diff --git a/.github/config/release.json b/.github/config/release.json new file mode 100755 index 000000000..078a8824b --- /dev/null +++ b/.github/config/release.json @@ -0,0 +1,22 @@ +{ + "releaseAll": true, + "plugins": { + "utilities": false, + "command": false, + "config": false, + "auth": false, + "export": false, + "import": false, + "clone": false, + "export-to-csv": false, + "migrate-rte": false, + "migration": false, + "seed": false, + "bootstrap": false, + "bulk-publish": false, + "dev-dependencies": false, + "launch": false, + "branches": false, + "core": false + } +} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..ef4bb176c --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,68 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + pull_request: + # The branches below must be a subset of the branches above + branches: '*' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3.5.3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/policy-scan.yml b/.github/workflows/policy-scan.yml index ff2592318..33e68cf45 100644 --- a/.github/workflows/policy-scan.yml +++ b/.github/workflows/policy-scan.yml @@ -43,4 +43,4 @@ jobs: if [ "$license_file_found" = false ]; then echo "No license file found. Please add a license file to the repository." exit 1 - fi \ No newline at end of file + fi diff --git a/.github/workflows/release-v1-beta-plugins.yml b/.github/workflows/release-v1-beta-plugins.yml new file mode 100644 index 000000000..6c53041e3 --- /dev/null +++ b/.github/workflows/release-v1-beta-plugins.yml @@ -0,0 +1,253 @@ +name: Release CLI Plugins (v1 Beta) + +on: + push: + branches: [disable-v1-beta] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + with: + version: 10.28.0 + - uses: actions/setup-node@v4 + with: + node-version: '22.x' + + - name: Enable Corepack + run: corepack enable + + - name: Install pnpm + run: corepack prepare pnpm@10.28.0 --activate + + - name: Install root dependencies + run: pnpm install + + - name: Reading Configuration + id: release_config + uses: rgarcia-phi/json-to-variables@v1.1.0 + with: + filename: .github/config/release.json + prefix: release + + # Variants + - name: Installing dependencies of variants + id: variants-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_utilities == 'true'}} + working-directory: ./packages/contentstack-variants + run: npm install + - name: Compiling variants + if: ${{ steps.variants-installation.conclusion == 'success' }} + working-directory: ./packages/contentstack-variants + run: npm run prepack + - name: Publishing variants (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.variants-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-variants/package.json + access: public + tag: beta + + # Export + - name: Installing dependencies of export + id: export-installation + if: ${{ env.release_releaseAll == 'true' || env.release_plugins_export == 'true'}} + working-directory: ./packages/contentstack-export + run: npm install + - name: Compiling export + if: ${{ steps.export-installation.conclusion == 'success' }} + working-directory: ./packages/contentstack-export + run: npm run prepack + - name: Publishing export (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.export-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-export/package.json + tag: beta + + # Audit + - name: Installing dependencies of audit + id: audit-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_audit == 'true'}} + working-directory: ./packages/contentstack-audit + run: npm install + - name: Compiling audit + if: ${{ steps.audit-installation.conclusion == 'success' }} + working-directory: ./packages/contentstack-audit + run: npm run prepack + - name: Publishing audit (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.audit-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-audit/package.json + access: public + tag: beta + + # Import + - name: Installing dependencies of import + id: import-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_import == 'true'}} + working-directory: ./packages/contentstack-import + run: npm install + - name: Compiling import + if: ${{ steps.import-installation.conclusion == 'success' }} + working-directory: ./packages/contentstack-import + run: npm run prepack + - name: Publishing import (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.import-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-import/package.json + tag: beta + + # Clone + - name: Installing dependencies of clone + id: clone-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_clone == 'true'}} + working-directory: ./packages/contentstack-clone + run: npm install + - name: Publishing clone (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.clone-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-clone/package.json + tag: beta + + # Import Setup + - name: Installing dependencies of import-setup + id: import-setup-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_import_setup == 'true'}} + working-directory: ./packages/contentstack-import-setup + run: npm install + - name: Compiling import-setup + if: ${{ steps.import-setup-installation.conclusion == 'success' }} + working-directory: ./packages/contentstack-import-setup + run: npm run prepack + - name: Publishing import-setup (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.import-setup-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-import-setup/package.json + access: public + tag: beta + + # Export to CSV + - name: Installing dependencies of export to csv + id: export-to-csv-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_export-to-csv == 'true'}} + working-directory: ./packages/contentstack-export-to-csv + run: npm install + - name: Publishing export to csv (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.export-to-csv-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-export-to-csv/package.json + tag: beta + + # Migration + - name: Installing dependencies of migration + id: migration-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_migration == 'true'}} + working-directory: ./packages/contentstack-migration + run: npm install + - name: Publishing migration (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.migration-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-migration/package.json + tag: beta + + # Seed + - name: Installing dependencies of seed + id: seed-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_seed == 'true'}} + working-directory: ./packages/contentstack-seed + run: npm install + - name: Compiling seed + if: ${{ steps.seed-installation.conclusion == 'success' }} + working-directory: ./packages/contentstack-seed + run: npm run prepack + - name: Publishing seed (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.seed-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-seed/package.json + tag: beta + + # Bootstrap + - name: Installing dependencies of bootstrap + id: bootstrap-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_bootstrap == 'true'}} + working-directory: ./packages/contentstack-bootstrap + run: npm install + - name: Compiling bootstrap + if: ${{ steps.bootstrap-installation.conclusion == 'success' }} + working-directory: ./packages/contentstack-bootstrap + run: npm run prepack + - name: Publishing bootstrap (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.bootstrap-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-bootstrap/package.json + tag: beta + + # Bulk Publish + - name: Installing dependencies of bulk publish + id: bulk-publish-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_bulk-publish == 'true'}} + working-directory: ./packages/contentstack-bulk-publish + run: npm install + - name: Publishing bulk publish (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.bulk-publish-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-bulk-publish/package.json + tag: beta + + # Branches + - name: Installing dependencies of branches + id: branches-installation + if: ${{env.release_releaseAll == 'true' || env.release_plugins_branches == 'true'}} + working-directory: ./packages/contentstack-branches + run: npm install + - name: Compiling branches + if: ${{ steps.branches-installation.conclusion == 'success' }} + working-directory: ./packages/contentstack-branches + run: npm run prepack + - name: Publishing branches (Beta) + uses: JS-DevTools/npm-publish@v3 + if: ${{ steps.branches-installation.conclusion == 'success' }} + with: + token: ${{ secrets.NPM_TOKEN }} + package: ./packages/contentstack-branches/package.json + access: public + tag: beta + + - name: Create Beta Release + if: ${{ steps.publish-core.conclusion == 'success' }} + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.PKG_TOKEN }} + VERSION: ${{ steps.publish-core.outputs.version }} + run: | + # Get the previous beta release for comparison + PREVIOUS_BETA=$(gh release list --limit 10 | grep 'beta' | head -1 | cut -f1) + + if [ -n "$PREVIOUS_BETA" ]; then + gh release create v"$VERSION" --title "Beta Release $VERSION" --notes-from-tag "$PREVIOUS_BETA" --prerelease + else + gh release create v"$VERSION" --title "Beta Release $VERSION" --generate-notes --prerelease + fi diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 000000000..73c9b72cc --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,63 @@ +name: Run Unit Tests + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + run-tests: + 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 # or your local pnpm version + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22.x' + cache: 'pnpm' # optional but recommended + + - name: Install dependencies for all plugins + run: | + NODE_ENV=PREPACK_MODE npm run bootstrap + + - name: Build all plugins + run: | + NODE_ENV=PREPACK_MODE npm run build + + - name: Run tests for Contentstack Import Plugin + working-directory: ./packages/contentstack-import + run: npm run test:unit + + - name: Run tests for Contentstack Export Plugin + working-directory: ./packages/contentstack-export + run: npm run test:unit + + - name: Run tests for Audit plugin + working-directory: ./packages/contentstack-audit + run: npm run test:unit + + - name: Run tests for Contentstack Migration + working-directory: ./packages/contentstack-migration + run: npm run test + + - name: Run tests for Contentstack Export To CSV + working-directory: ./packages/contentstack-export-to-csv + run: npm run test:unit + + - name: Run tests for Contentstack Bootstrap + working-directory: ./packages/contentstack-bootstrap + run: npm run test + + # - name: Run tests for Contentstack Import Setup + # working-directory: ./packages/contentstack-import-setup + # run: npm run test:unit + + - name: Run tests for Contentstack Branches + working-directory: ./packages/contentstack-branches + run: npm run test:unit diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..5f12fba08 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +node_modules +.todo +.env +.dccache +logs +/contents +lerna-debug.log +.DS_Store +contentTest +build +_backup* +oclif.manifest.json +.vscode +.nyc_output +contentstack-cli-logs +packages/**/package-lock.json +.dccache +yarn.lock +contents-* +*.http +*.todo +talisman_output.log +snyk_output.log +# Snyk Security Extension - AI Rules (auto-generated) +.cursor/rules/snyk_rules.mdc +**/migration-logs +**/migration-logs/** +*.logs \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..da3763f0a --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,69 @@ +#!/usr/bin/env sh +# Pre-commit hook to run Talisman and Snyk scans, completing both before deciding to commit + +# Function to check if a command exists +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# Check if Talisman is installed +if ! command_exists talisman; then + echo "Error: Talisman is not installed. Please install it and try again." + exit 1 +fi + +# Check if Snyk is installed +if ! command_exists snyk; then + echo "Error: Snyk is not installed. Please install it and try again." + exit 1 +fi + +# Allow bypassing the hook with an environment variable +if [ "$SKIP_HOOK" = "1" ]; then + echo "Skipping Talisman and Snyk scans (SKIP_HOOK=1)." + exit 0 +fi + +# Initialize variables to track scan results +talisman_failed=false +snyk_failed=false + +# Run Talisman secret scan +echo "Running Talisman secret scan..." +talisman --githook pre-commit > talisman_output.log 2>&1 +talisman_exit_code=$? + +if [ $talisman_exit_code -eq 0 ]; then + echo "Talisman scan passed: No secrets found." +else + echo "Talisman scan failed (exit code $talisman_exit_code). See talisman_output.log for details." + talisman_failed=true +fi + +# Run Snyk vulnerability scan (continues even if Talisman failed) +echo "Running Snyk vulnerability scan..." +snyk test --all-projects --fail-on=all > snyk_output.log 2>&1 +snyk_exit_code=$? + +if [ $snyk_exit_code -eq 0 ]; then + echo "Snyk scan passed: No vulnerabilities found." +elif [ $snyk_exit_code -eq 1 ]; then + echo "Snyk found vulnerabilities. See snyk_output.log for details." + snyk_failed=true +else + echo "Snyk scan failed with error (exit code $snyk_exit_code). See snyk_output.log for details." + snyk_failed=true +fi + +# Evaluate results after both scans +if [ "$talisman_failed" = true ] || [ "$snyk_failed" = true ]; then + echo "Commit aborted due to issues found in one or both scans." + [ "$talisman_failed" = true ] && echo "- Talisman issues: Check talisman_output.log" + [ "$snyk_failed" = true ] && echo "- Snyk issues: Check snyk_output.log" + exit 1 +fi + +# If both scans pass, allow the commit +echo "All scans passed. Proceeding with commit." +rm -f talisman_output.log snyk_output.log +exit 0 diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..b49c801ac --- /dev/null +++ b/.npmrc @@ -0,0 +1,9 @@ +# Use workspace protocol for local development +link-workspace-packages=true +prefer-workspace-packages=true + +# Hoist dependencies to root node_modules +shamefully-hoist=true + +# Use strict peer dependencies +strict-peer-dependencies=false diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..70988e213 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +**/README.md \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..ba93fc77d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "semi": true, + "trailingComma": "all", + "singleQuote": true, + "printWidth": 120, + "tabWidth": 2 +} \ No newline at end of file diff --git a/.talismanrc b/.talismanrc new file mode 100644 index 000000000..eb4c5e60e --- /dev/null +++ b/.talismanrc @@ -0,0 +1,10 @@ +fileignoreconfig: + - filename: package-lock.json + checksum: c91b9e5fba1c84c0b6de15ad2f8cce698a5c781c9db31bebb7a3ad63ee88d9e1 + - filename: pnpm-lock.yaml + checksum: 1b80993eacbc8bf861883d3e5382e6c708e68d4c0b881e31251999285e772e9b + - filename: packages/contentstack-bootstrap/src/bootstrap/utils.ts + checksum: 6e6fb00bb11b03141e5ad27eeaa4af9718dc30520c3e73970bc208cc0ba2a7d2 + - filename: .husky/pre-commit + checksum: 7a12030ddfea18d6f85edc25f1721fb2009df00fdd42bab66b05de25ab3e32b2 +version: '1.0' diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..569097d77 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ +# Changelog + +Please refer to the Contentstack Command-line Interface release notes [here](https://www.contentstack.com/docs/developers/cli/cli-changelog). + + + + +#### Date: Feb-09-2025 +## cli + - Refactor Endpoints Integration using Utils SDK in cli-cm-config v1.9.0 +## cli beta + - Updated @contentstack/cli-cm-export from ~2.0.0-beta.6 to ~2.0.0-beta.7 + - Updated @contentstack/cli-cm-clone from ~2.0.0-beta.7 to ~2.0.0-beta.8 + +## @contentstack/cli-cm-clone +### Version: 1.8.2 +#### Date: June-30-2025 +##### Fix: + - resolve stack-clone auth failure for non-NA regions + +## @contentstack/cli-config +### Version: 1.13.1 +#### Date: July-21-2025 +##### Fix: + - Improve error handling in rate limit command + +## @contentstack/cli-cm-bulk-publish +### Version: 1.8.2 +#### Date: June-30-2025 +##### Fix: + - handle pagination in sync when no entries are returned. \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..aff1142ee --- /dev/null +++ b/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/README.md b/README.md index 5f07bd3c2..60eca7d5e 100644 --- a/README.md +++ b/README.md @@ -1 +1,57 @@ # Contentstack CLI + + +Contentstack is a headless CMS with an API-first approach that puts content at the centre. It is designed to simplify the process of publication by separating code from content. + +CLI supports content management scripts through which you can perform the following tasks: + +- Bulk publish content +- Export content +- Import content +- Clone Stack +- Seed Stack from GitHub +- Perform Launch operations +- Migrate content +- Migrate HTML RTE to JSON RTE content +- Change Master Locale +- Use Bootstrap plugin +- Use Tsgen plugin + + +## Installing CLI +### Prerequisites +Contentstack account +Node.js version 16 or above + +### Installation +To install CLI on your system, run the below command in your terminal: + +``` +npm install -g @contentstack/cli +``` + +To verify the installation, run `csdx` in the command window. + +## Usage +After the successful installation of CLI, use the `--help` parameter to display the help section of the CLI. You can even combine this parameter with a specific command to get the help section of that command. + +```shell +$ csdx --help +``` + +## Namespaces +**auth**: To perform [authentication-related](/packages/contentstack-auth) activities + +**cm**: To perform content management activities such as [bulk publish](/packages/contentstack-bulk-publish), [import](/packages/contentstack-import), and [export](/packages/contentstack-export), [export-to-csv] (/packages/contentstack-export-to-csv), [seed] (/packages/contentstack-seed) + +**help**: To list the helpful commands in CLI + +**config**: To set regions and customize them + +## Documentation + +To get a more detailed documentation for every command, visit the [CLI section](https://www.contentstack.com/docs/developers/cli) in our docs. + +## Useful Plugins + +- [Generate TypeScript typings from a Stack](https://github.com/Contentstack-Solutions/contentstack-cli-tsgen) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..1f44e3424 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +## Security + +Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations. + +If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Send email to [security@contentstack.com](mailto:security@contentstack.com). + +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + +- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) +- Full paths of source file(s) related to the manifestation of the issue +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- Step-by-step instructions to reproduce the issue +- Proof-of-concept or exploit code (if possible) +- Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/) diff --git a/install.sh b/install.sh new file mode 100755 index 000000000..54592a37c --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo 'Installing Contentstack CLI' +npm run setup || { echo -e '\e[31mFailed to install root dependencies.' && exit 1; } +echo 'Installtion, Done!!!' +cd packages/contentstack || { echo -e '\e[31mCould not found the working directory.' && exit 1; } +./bin/run --help \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 000000000..ef58763cb --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "csdx", + "version": "1.0.0", + "devDependencies": { + "husky": "^9.1.7", + "pnpm": "^10.28.0" + }, + "engines": { + "node": ">=18.0.0" + }, + "private": true, + "scripts": { + "clean": "pnpm -r --filter './packages/*' run clean", + "build": "pnpm -r --filter './packages/*' run build", + "test": "pnpm -r --filter './packages/*' run test", + "prepack": "pnpm -r --filter './packages/*' run prepack", + "bootstrap": "pnpm install", + "clean:modules": "rm -rf node_modules packages/**/node_modules", + "clean:lock": "rm -f pnpm-lock.yaml", + "clean:all": "pnpm store prune && rm -rf node_modules && pnpm run clean", + "setup": "pnpm run clean:all && pnpm run bootstrap && pnpm run build", + "prepare": "npx husky && chmod +x .husky/pre-commit" + }, + "license": "MIT", + "packageManager": "pnpm@10.28.0", + "workspaces": [ + "packages/*" + ] +} diff --git a/packages/contentstack-audit/.eslintignore b/packages/contentstack-audit/.eslintignore new file mode 100644 index 000000000..9b1c8b133 --- /dev/null +++ b/packages/contentstack-audit/.eslintignore @@ -0,0 +1 @@ +/dist diff --git a/packages/contentstack-audit/.eslintrc b/packages/contentstack-audit/.eslintrc new file mode 100644 index 000000000..7b846193c --- /dev/null +++ b/packages/contentstack-audit/.eslintrc @@ -0,0 +1,6 @@ +{ + "extends": [ + "oclif", + "oclif-typescript" + ] +} diff --git a/packages/contentstack-audit/.gitignore b/packages/contentstack-audit/.gitignore new file mode 100644 index 000000000..12a68582e --- /dev/null +++ b/packages/contentstack-audit/.gitignore @@ -0,0 +1,22 @@ +*-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/ +audit-report \ No newline at end of file diff --git a/packages/contentstack-audit/.mocharc.json b/packages/contentstack-audit/.mocharc.json new file mode 100644 index 000000000..4a09d1446 --- /dev/null +++ b/packages/contentstack-audit/.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-audit/LICENSE b/packages/contentstack-audit/LICENSE new file mode 100644 index 000000000..13a583708 --- /dev/null +++ b/packages/contentstack-audit/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. \ No newline at end of file diff --git a/packages/contentstack-audit/README.md b/packages/contentstack-audit/README.md new file mode 100644 index 000000000..cf0fa3427 --- /dev/null +++ b/packages/contentstack-audit/README.md @@ -0,0 +1,580 @@ + + + +# @contentstack/cli-audit + +Audit plugin + +## How to install this plugin + +```shell +$ csdx plugins:install @contentstack/cli-audit +``` + +## How to use this plugin + + +```sh-session +$ npm install -g @contentstack/cli-audit +$ csdx COMMAND +running command... +$ csdx (--version|-v) +@contentstack/cli-audit/1.17.1 darwin-arm64 node-v24.13.0 +$ csdx --help [COMMAND] +USAGE + $ csdx COMMAND +... +``` + + +# Commands + + +* [`csdx audit`](#csdx-audit) +* [`csdx audit:fix`](#csdx-auditfix) +* [`csdx cm:stacks:audit`](#csdx-cmstacksaudit) +* [`csdx cm:stacks:audit:fix`](#csdx-cmstacksauditfix) +* [`csdx help [COMMAND]`](#csdx-help-command) +* [`csdx plugins`](#csdx-plugins) +* [`csdx plugins:add PLUGIN`](#csdx-pluginsadd-plugin) +* [`csdx plugins:inspect PLUGIN...`](#csdx-pluginsinspect-plugin) +* [`csdx plugins:install PLUGIN`](#csdx-pluginsinstall-plugin) +* [`csdx plugins:link PATH`](#csdx-pluginslink-path) +* [`csdx plugins:remove [PLUGIN]`](#csdx-pluginsremove-plugin) +* [`csdx plugins:reset`](#csdx-pluginsreset) +* [`csdx plugins:uninstall [PLUGIN]`](#csdx-pluginsuninstall-plugin) +* [`csdx plugins:unlink [PLUGIN]`](#csdx-pluginsunlink-plugin) +* [`csdx plugins:update`](#csdx-pluginsupdate) + +## `csdx audit` + +Perform audits and find possible errors in the exported Contentstack data + +``` +USAGE + $ csdx audit [-c ] [-d ] [--show-console-output] [--report-path ] [--modules + content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules|composable-studio...] + [--columns ] [--sort ] [--filter ] [--csv] [--no-truncate] [--no-header] [--output + csv|json|yaml] + +FLAGS + --modules=