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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@contentstack/cli-cm-export-query

v1.0.0-beta.6

Published

Contentstack CLI plugin to export content from stack

Readme

Contentstack CLI Query Export Plugin

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
npm install -g @contentstack/cli-cm-export-query

# Or install locally
npm install @contentstack/cli-cm-export-query

Usage

Basic Export

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

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

Command Options

| Flag | Description | Required | |------|-------------|----------| | -a, --alias | Management token alias | Yes (or use -A) | | -A, --management-token | Management token | Yes (or use -a) | | --stack-api-key | Stack API key | Yes | | -q, --query | Query for content export | Yes | | -d, --data-dir | Export directory path | No | | --branch | Branch name | No | | --skip-references | Skip reference resolution | No | | --skip-dependencies | Skip dependency export | No | | --secured-assets | Include secured assets | No | | --config | External config file path | No |

Query Examples

Basic Content Query:

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

Date Range Query:

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

Complex Query:

csdx cm:stacks:export-query -a prod -q "{'$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 -q "{'title': {'$exists': true}}" --config ./my-config.json