Skip to content

Conversation

@shafeeqd959
Copy link
Contributor

@shafeeqd959 shafeeqd959 commented Jul 9, 2025

Query-based Export Plugin for Contentstack CLI

Overview

Introducing a new plugin for Contentstack CLI that enables query-based content export. This plugin allows users to selectively export content types and their dependencies using MongoDB-style queries, improving the flexibility of content migration and backup processes.

Key Features

  • Query-based filtering for content types
  • Automatic dependency resolution (global fields, extensions, taxonomies)
  • Recursive reference detection and export
  • Smart asset reference handling
  • Complete dependency chain export

Implementation Details

  • Created as a standalone plugin (@contentstack/cli-cm-export-query)
  • Leverages existing export command internally with query support
  • Focuses on content type queries with automatic dependency resolution
  • Implements intelligent reference detection across various field types

Current Scope

✅ Supported:

  • Content type query filtering
  • Automatic dependency resolution
  • Referenced content type export
  • Asset reference detection
  • Entry export for matched content types

❌ Not Yet Supported:

  • Direct queries for other modules (entries, assets)
  • Cross-module querying
  • Custom reference handling

Usage Examples

# Export content types with "blog" in title
csdx cm:stacks:export-query -a <alias> --query '{"title": {"$regex": "blog"}}'

# Export content types updated after specific date
csdx cm:stacks:export-query -a <alias> --query '{
  "$and": [
    {"title": {"$exists": true}},
    {"updated_at": {"$gte": "2024-01-01"}}
  ]
}'

Testing

  • Unit tests added for core functionality
  • Integration tests for query processing
  • Test coverage for dependency resolution
  • Reference handling test cases

Documentation

  • Added comprehensive documentation
  • Included usage examples
  • Documented query format and options
  • Added technical architecture details

Future Enhancements

  • Query support for other modules
  • Cross-module query capabilities
  • Enhanced filtering options
  • Performance optimizations

Breaking Changes

None - This is a new plugin that doesn't affect existing functionality

Related Issues

Closes #[issue_number]

Checklist

  • Tests added/updated
  • Documentation updated
  • Code follows project style guidelines
  • All tests passing
  • PR is properly scoped

@shafeeqd959 shafeeqd959 requested review from aman19K and cs-raj July 9, 2025 07:09
@aman19K aman19K requested a review from Copilot July 9, 2025 10:52

This comment was marked as outdated.

@netrajpatel
Copy link

@shafeeqd959 Can you fix the GH workflow

@aman19K aman19K requested a review from Copilot July 17, 2025 07:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new CLI plugin for query-based exports, including test scaffolding, core export logic, utilities, configuration, and documentation updates.

  • Adds test configuration and runner (test/tsconfig.json, test/run.test.js, Mocha configs)
  • Implements core query export components (QueryParser, QueryExporter, ModuleExporter) and related utility modules
  • Updates CLI command, package manifest, README, and CI workflows

Reviewed Changes

Copilot reviewed 38 out of 46 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/tsconfig.json Adds TypeScript config for tests
test/run.test.js Implements integration test runner with file inclusion
src/utils/file-helper.ts Provides file read/write utilities
src/utils/logger.ts Implements logging with Winston
src/utils/query-parser.ts Parses and validates JSON queries
src/core/query-executor.ts Coordinates the query-based export flow
src/core/module-exporter.ts Wraps the Contentstack export command invocation
src/commands/cm/stacks/export-query.ts Defines the CLI command entry point
README.md Documents plugin usage and features
package.json Declares plugin metadata, dependencies, scripts, and flags
.nycrc.json Configures coverage reporting (typo)
Comments suppressed due to low confidence (1)

README.md:77

  • The path src/config/export-defaults.json does not match the actual file (src/config/export-config.json). Update the documentation to point to the correct file.
The plugin includes a default configuration file at `src/config/export-defaults.json`:

@shafeeqd959 shafeeqd959 changed the base branch from development to main July 21, 2025 02:53
@shafeeqd959 shafeeqd959 requested review from a team as code owners July 21, 2025 02:53
@shafeeqd959
Copy link
Contributor Author

@shafeeqd959 Can you fix the GH workflow

this workflow will be fixed once we made the repo public

cs-raj
cs-raj previously approved these changes Jul 21, 2025
aman19K
aman19K previously approved these changes Jul 21, 2025
netrajpatel
netrajpatel previously approved these changes Jul 21, 2025
@shafeeqd959 shafeeqd959 dismissed stale reviews from netrajpatel, aman19K, and cs-raj via ba0c63b July 21, 2025 08:30
@aravindbuilt aravindbuilt merged commit 5bb0870 into main Jul 21, 2025
4 checks passed
@aravindbuilt aravindbuilt deleted the feat/base-setup branch July 21, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants