From 7ebf54ee9ea527388f29845030c36f2a86340af4 Mon Sep 17 00:00:00 2001 From: shafeeqd959 Date: Fri, 2 Feb 2024 12:10:12 +0530 Subject: [PATCH] fixed export of specific content types --- packages/contentstack-audit/README.md | 2 +- packages/contentstack-export/package.json | 2 +- .../contentstack-export/src/commands/cm/stacks/export.ts | 2 -- .../src/export/modules-js/content-types.js | 4 +++- .../contentstack-export/src/export/modules/content-types.ts | 5 +++++ packages/contentstack-launch/README.md | 2 +- packages/contentstack/README.md | 2 +- packages/contentstack/package.json | 4 ++-- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/contentstack-audit/README.md b/packages/contentstack-audit/README.md index a9766ba649..5af1961475 100644 --- a/packages/contentstack-audit/README.md +++ b/packages/contentstack-audit/README.md @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli-audit/1.3.4 darwin-arm64 node-v20.8.0 +@contentstack/cli-audit/1.3.5 darwin-arm64 node-v20.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-export/package.json b/packages/contentstack-export/package.json index 3583b17951..a54abb68d4 100644 --- a/packages/contentstack-export/package.json +++ b/packages/contentstack-export/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-export", "description": "Contentstack CLI plugin to export content from stack", - "version": "1.10.4", + "version": "1.10.5", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { diff --git a/packages/contentstack-export/src/commands/cm/stacks/export.ts b/packages/contentstack-export/src/commands/cm/stacks/export.ts index eb6e3a51d9..805a420f16 100644 --- a/packages/contentstack-export/src/commands/cm/stacks/export.ts +++ b/packages/contentstack-export/src/commands/cm/stacks/export.ts @@ -71,14 +71,12 @@ export default class ExportCommand extends Command { module: flags.string({ char: 'm', description: '[optional] specific module name', - exclusive: ['content-types'], parse: printFlagDeprecation(['-m'], ['--module']), }), 'content-types': flags.string({ char: 't', description: '[optional] content type', multiple: true, - exclusive: ['module'], parse: printFlagDeprecation(['-t'], ['--content-types']), }), branch: flags.string({ diff --git a/packages/contentstack-export/src/export/modules-js/content-types.js b/packages/contentstack-export/src/export/modules-js/content-types.js index 72affabb9f..45e19f68c8 100644 --- a/packages/contentstack-export/src/export/modules-js/content-types.js +++ b/packages/contentstack-export/src/export/modules-js/content-types.js @@ -14,7 +14,7 @@ class ContentTypesExport { include_global_field_schema: true, }; // If content type id is provided then use it as part of query - if (Array.isArray(this.exportConfig.contentTypes) && this.exportConfig.length > 0) { + if (Array.isArray(this.exportConfig.contentTypes) && this.exportConfig.contentTypes.length > 0) { this.qs.uid = { $in: this.exportConfig.contentTypes }; } this.contentTypesPath = path.resolve( @@ -45,6 +45,8 @@ class ContentTypesExport { this.qs.skip = skip; } + console.log("QS", this.qs); + const contentTypeSearchResponse = await this.stackAPIClient.contentType().query(this.qs).find(); if (Array.isArray(contentTypeSearchResponse.items) && contentTypeSearchResponse.items.length > 0) { let updatedContentTypes = this.sanitizeAttribs(contentTypeSearchResponse.items); diff --git a/packages/contentstack-export/src/export/modules/content-types.ts b/packages/contentstack-export/src/export/modules/content-types.ts index 7b2ba3fbf9..7905dc9c1a 100644 --- a/packages/contentstack-export/src/export/modules/content-types.ts +++ b/packages/contentstack-export/src/export/modules/content-types.ts @@ -13,6 +13,7 @@ export default class ContentTypesExport extends BaseClass { skip?: number; limit?: number; include_global_field_schema: boolean; + uid?: Record }; private contentTypesConfig: { dirName?: string; @@ -35,6 +36,10 @@ export default class ContentTypesExport extends BaseClass { limit: this.contentTypesConfig.limit, include_global_field_schema: true, }; + // If content type id is provided then use it as part of query + if (Array.isArray(this.exportConfig.contentTypes) && this.exportConfig.contentTypes.length > 0) { + this.qs.uid = { $in: this.exportConfig.contentTypes }; + } this.contentTypesDirPath = path.resolve( exportConfig.data, exportConfig.branchName || '', diff --git a/packages/contentstack-launch/README.md b/packages/contentstack-launch/README.md index acf6a6c9db..dbef306de9 100755 --- a/packages/contentstack-launch/README.md +++ b/packages/contentstack-launch/README.md @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-launch $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli-launch/1.0.16 darwin-arm64 node-v20.10.0 +@contentstack/cli-launch/1.0.16 darwin-arm64 node-v20.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack/README.md b/packages/contentstack/README.md index 058af6fa94..b57b537cf2 100644 --- a/packages/contentstack/README.md +++ b/packages/contentstack/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli/1.13.0 darwin-arm64 node-v20.10.0 +@contentstack/cli/1.13.0 darwin-arm64 node-v20.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 951045a93d..58408fd4b9 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli", "description": "Command-line tool (CLI) to interact with Contentstack", - "version": "1.13.0", + "version": "1.13.1", "author": "Contentstack", "bin": { "csdx": "./bin/run" @@ -28,7 +28,7 @@ "@contentstack/cli-cm-branches": "~1.0.22", "@contentstack/cli-cm-bulk-publish": "~1.4.0", "@contentstack/cli-cm-clone": "~1.10.0", - "@contentstack/cli-cm-export": "~1.10.4", + "@contentstack/cli-cm-export": "~1.10.5", "@contentstack/cli-cm-export-to-csv": "~1.6.2", "@contentstack/cli-cm-import": "~1.13.2", "@contentstack/cli-cm-migrate-rte": "~1.4.15",