npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@contentstack/cli-cm-export-query

v1.0.5

Published

Contentstack CLI plugin to export content from stack

Readme

@contentstack/cli-cm-export-query

A powerful CLI plugin for Contentstack that enables query-based content export with intelligent dependency resolution and asset reference detection.

Overview

This plugin extends the Contentstack CLI to export content based on custom queries, automatically resolving dependencies between content types, global fields, extensions, and taxonomies. It intelligently detects and exports referenced assets to ensure complete content portability.

Features

  • Query-based Export: Export content using custom queries instead of entire content types
  • Dependency Resolution: Automatically resolve and export dependencies (global fields, extensions, taxonomies)
  • Asset Reference Detection: Intelligent detection of asset references in various formats
  • Organized Output: Well-structured export with separate folders for each module
  • Configurable: Support for external config files and flexible options
  • Multi-locale Support: Export content across different locales
  • Export Metadata: Comprehensive metadata tracking for export operations

Installation

# Install as a Contentstack CLI plugin
csdx plugins:install @contentstack/cli-cm-export-query

Usage

Basic Export

# Export using management token alias
csdx cm:stacks:export-query -a <alias> --query '{"title": {"$exists": true}}'

# Export using API key and alias
csdx cm:stacks:export-query --stack-api-key <api-key> -a <alias> --query '{"title": {"$exists": true}}'

Command Options

| Flag | Description | Required | |------|-------------|----------| | -a, --alias | Management token alias | Yes (or use -k, --stack-api-key) | | -k, --stack-api-key | Stack API key | Yes (or use --alias) | | -c, --config | External config file path | No | | --query | Query as JSON string or file path | Yes | | -d, --data-dir | Export directory path | No | | --branch | Branch name to export from | No | | --branch-alias | Alias of branch to export from (mutually exclusive with --branch) | No | | --skip-references | Skip referenced content types | No | | --skip-dependencies | Skip dependent modules (global-fields, extensions, taxonomies) | No | | --secured-assets | Export secured assets | No | | -y, --yes | Skip confirmation prompts | No |

Query Examples

Basic Content Query:

csdx cm:stacks:export-query -a prod --query '{"title": {"$regex": "blog"}}'

Date Range Query:

csdx cm:stacks:export-query -a prod --query '{"updated_at": {"$gte": "2024-01-01"}}'

Complex Query:

csdx cm:stacks:export-query -a prod --query '{"$and": [{"title": {"$exists": true}}, {"tags": {"$in": ["featured"]}}]}'

Configuration

Default Configuration

The plugin includes a default configuration file at src/config/export-defaults.json:

{
  "skipReferences": false,
  "skipDependencies": false,
  "securedAssets": false,
  "includeGlobalFieldSchema": true,
  "includePublishDetails": true,
  "includeDimension": false,
  "fetchConcurrency": 5,
  "writeConcurrency": 5,
  "batchSize": 100
}

External Configuration

Create a custom config file and pass it using the --config flag:

{
  "skipReferences": true,
  "batchSize": 50,
  "fetchConcurrency": 3,
  "securedAssets": true
}
csdx cm:stacks:export-query -a prod --query '{"title": {"$exists": true}}' --config ./my-config.json

Commands

csdx cm:stacks:export-query --query <value> [options]

Export content from a stack using query-based filtering

USAGE
  $ csdx cm:stacks:export-query --query <value> [options]

FLAGS
  -a, --alias=<value>          Management token alias
  -c, --config=<value>         Path to the configuration file
  -d, --data-dir=<value>       Path to store exported content
  -k, --stack-api-key=<value>  Stack API key
  -y, --yes                    Skip confirmation prompts
      --branch=<value>         Branch name to export from
      --branch-alias=<value>   Alias of Branch to export from
      --query=<value>          (required) Query as JSON string or file path
      --secured-assets         Export secured assets
      --skip-dependencies      Skip dependent modules (global-fields, extensions, taxonomies)
      --skip-references        Skip referenced content types

DESCRIPTION
  Export content from a stack using query-based filtering

EXAMPLES
  $ csdx cm:stacks:export-query --query '{"modules":{"content-types":{"title":{"$in":["Blog","Author"]}}}}'

  $ csdx cm:stacks:export-query --query ./ct-query.json --skip-references

  $ csdx cm:stacks:export-query --alias <alias> --query '{"modules":{"entries":{"content_type_uid":"blog"}}}'

  $ csdx cm:stacks:export-query --query '{"modules":{"assets":{"title":{"$regex":"image"}}}}'

See code: src/commands/cm/stacks/export-query.ts