diff --git a/.talismanrc b/.talismanrc index 262b06313f..1fd306c0fe 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,9 +1,14 @@ - fileignoreconfig: -- filename: package-lock.json - checksum: fa2c81c72305bc19fa4f64457af1000aa2f0c179ecb7e46a5fc9d8b760c705a7 -- filename: pnpm-lock.yaml - checksum: faaef9e003c5ba45e56ab1ca24a4fc285f53a2b9ecc6d3dbd11e7130a31db4a2 -- filename: packages/contentstack-clone/src/core/util/clone-handler.ts - checksum: 0a7ed55e96aa5a94084538b4a480608593b04c316bf02cf54cdd3a647e9b714c + - filename: package-lock.json + checksum: d42b12a21c38a527fb850cbe8500160120ccb58e57aa0b4f8098b835e7ca0b4d + - filename: pnpm-lock.yaml + checksum: c442a57252ba95771003f170786afed30888f14f67dc59766352be4a57d5ad55 + - filename: packages/contentstack-clone/src/core/util/clone-handler.ts + checksum: 0a7ed55e96aa5a94084538b4a480608593b04c316bf02cf54cdd3a647e9b714c + - filename: packages/contentstack-config/src/interfaces/index.ts + checksum: 0c8e8a6e478151f6f6a1c50a5ce66c64e93d5d1d1bcd22344a9496cdc19f63b8 + - filename: packages/contentstack-config/src/utils/region-handler.ts + checksum: 0ce1a0f3e4228f5429661a32611fda32f04da038337b74bad93bc717406481f4 + - filename: packages/contentstack/README.md + checksum: 2f6da4ed14592fcb5c5fb8bc70bf57dd9fed512ed580b3edfad23055d8f05f38 version: '1.0' diff --git a/packages/contentstack-audit/src/audit-base-command.ts b/packages/contentstack-audit/src/audit-base-command.ts index 9b24b41800..f7a5799d8f 100644 --- a/packages/contentstack-audit/src/audit-base-command.ts +++ b/packages/contentstack-audit/src/audit-base-command.ts @@ -5,7 +5,7 @@ import { v4 as uuid } from 'uuid'; import isEmpty from 'lodash/isEmpty'; import { join, resolve } from 'path'; import cloneDeep from 'lodash/cloneDeep'; -import { cliux, sanitizePath, TableFlags, TableHeader, log, configHandler, CLIProgressManager, clearProgressModuleSetting } from '@contentstack/cli-utilities'; +import { cliux, sanitizePath, TableFlags, TableHeader, log, configHandler, CLIProgressManager, clearProgressModuleSetting, readContentTypeSchemas } from '@contentstack/cli-utilities'; import { createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'fs'; import config from './config'; import { print } from './util/log'; @@ -480,10 +480,9 @@ export abstract class AuditBaseCommand extends BaseCommand +* [@contentstack/cli-cm-bulk-publish](#contentstackcli-cm-bulk-publish) +* [Usage](#usage) +* [Commands](#commands) + + +# Usage + + +```sh-session +$ npm install -g @contentstack/cli-cm-bulk-publish +$ csdx COMMAND +running command... +$ csdx (--version) +@contentstack/cli-cm-bulk-publish/1.10.6 darwin-arm64 node-v23.11.0 +$ csdx --help [COMMAND] +USAGE + $ csdx COMMAND +... +``` + + +# Commands + + +* [`csdx cm:assets:publish [-a ] [--retry-failed ] [-e ] [--folder-uid ] [--bulk-publish ] [-c ] [-y] [--locales ] [--branch ] [--delivery-token ] [--source-env ]`](#csdx-cmassetspublish--a-value---retry-failed-value--e-value---folder-uid-value---bulk-publish-value--c-value--y---locales-value---branch-value---delivery-token-value---source-env-value) +* [`csdx cm:assets:unpublish`](#csdx-cmassetsunpublish) +* [`csdx cm:bulk-publish`](#csdx-cmbulk-publish) +* [`csdx cm:entries:update-and-publish [-a ] [--retry-failed ] [--bulk-publish ] [--content-types ] [-t ] [-e ] [-c ] [-y] [--locales ] [--branch ]`](#csdx-cmentriesupdate-and-publish--a-value---retry-failed-value---bulk-publish-value---content-types-value--t-value--e-value--c-value--y---locales-value---branch-value) +* [`csdx cm:assets:publish [-a ] [--retry-failed ] [-e ] [--folder-uid ] [--bulk-publish ] [-c ] [-y] [--locales ] [--branch ] [--delivery-token ] [--source-env ]`](#csdx-cmassetspublish--a-value---retry-failed-value--e-value---folder-uid-value---bulk-publish-value--c-value--y---locales-value---branch-value---delivery-token-value---source-env-value) +* [`csdx cm:bulk-publish:clear`](#csdx-cmbulk-publishclear) +* [`csdx cm:bulk-publish:configure`](#csdx-cmbulk-publishconfigure) +* [`csdx cm:bulk-publish:cross-publish [-a ] [--retry-failed ] [--bulk-publish ] [--content-type ] [--locales ] [--source-env ] [--environments ] [--delivery-token ] [-c ] [-y] [--branch ] [--onlyAssets] [--onlyEntries] [--include-variants]`](#csdx-cmbulk-publishcross-publish--a-value---retry-failed-value---bulk-publish-value---content-type-value---locales-value---source-env-value---environments-value---delivery-token-value--c-value--y---branch-value---onlyassets---onlyentries---include-variants) +* [`csdx cm:entries:publish [-a ] [--retry-failed ] [--bulk-publish ] [--publish-all-content-types] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ] [--delivery-token ] [--source-env ] [--entry-uid ] [--include-variants]`](#csdx-cmentriespublish--a-value---retry-failed-value---bulk-publish-value---publish-all-content-types---content-types-value---locales-value--e-value--c-value--y---branch-value---delivery-token-value---source-env-value---entry-uid-value---include-variants) +* [`csdx cm:entries:publish-modified [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ]`](#csdx-cmentriespublish-modified--a-value---retry-failed-value---bulk-publish-value---source-env-value---content-types-value---locales-value--e-value--c-value--y---branch-value) +* [`csdx cm:entries:publish-non-localized-fields [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [-e ] [-c ] [-y] [--branch ]`](#csdx-cmentriespublish-non-localized-fields--a-value---retry-failed-value---bulk-publish-value---source-env-value---content-types-value--e-value--c-value--y---branch-value) +* [`csdx cm:bulk-publish:revert`](#csdx-cmbulk-publishrevert) +* [`csdx csdx cm:stacks:unpublish [-a ] [-e ] [-c ] [-y] [--locale ] [--branch ] [--retry-failed ] [--bulk-unpublish ] [--content-type ] [--delivery-token ] [--only-assets] [--only-entries]`](#csdx-csdx-cmstacksunpublish--a-value--e-value--c-value--y---locale-value---branch-value---retry-failed-value---bulk-unpublish-value---content-type-value---delivery-token-value---only-assets---only-entries) +* [`csdx cm:entries:publish-only-unpublished [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ]`](#csdx-cmentriespublish-only-unpublished--a-value---retry-failed-value---bulk-publish-value---source-env-value---content-types-value---locales-value--e-value--c-value--y---branch-value) +* [`csdx cm:entries:publish [-a ] [--retry-failed ] [--bulk-publish ] [--publish-all-content-types] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ] [--delivery-token ] [--source-env ] [--entry-uid ] [--include-variants]`](#csdx-cmentriespublish--a-value---retry-failed-value---bulk-publish-value---publish-all-content-types---content-types-value---locales-value--e-value--c-value--y---branch-value---delivery-token-value---source-env-value---entry-uid-value---include-variants) +* [`csdx cm:entries:publish-modified [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ]`](#csdx-cmentriespublish-modified--a-value---retry-failed-value---bulk-publish-value---source-env-value---content-types-value---locales-value--e-value--c-value--y---branch-value) +* [`csdx cm:entries:publish-non-localized-fields [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [-e ] [-c ] [-y] [--branch ]`](#csdx-cmentriespublish-non-localized-fields--a-value---retry-failed-value---bulk-publish-value---source-env-value---content-types-value--e-value--c-value--y---branch-value) +* [`csdx cm:entries:publish-only-unpublished [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ]`](#csdx-cmentriespublish-only-unpublished--a-value---retry-failed-value---bulk-publish-value---source-env-value---content-types-value---locales-value--e-value--c-value--y---branch-value) +* [`csdx cm:entries:unpublish`](#csdx-cmentriesunpublish) +* [`csdx cm:entries:update-and-publish [-a ] [--retry-failed ] [--bulk-publish ] [--content-types ] [-t ] [-e ] [-c ] [-y] [--locales ] [--branch ]`](#csdx-cmentriesupdate-and-publish--a-value---retry-failed-value---bulk-publish-value---content-types-value--t-value--e-value--c-value--y---locales-value---branch-value) +* [`csdx cm:stacks:publish`](#csdx-cmstackspublish) +* [`csdx cm:stacks:publish-clear-logs`](#csdx-cmstackspublish-clear-logs) +* [`csdx cm:stacks:publish-configure`](#csdx-cmstackspublish-configure) +* [`csdx cm:stacks:publish-revert`](#csdx-cmstackspublish-revert) +* [`csdx csdx cm:stacks:unpublish [-a ] [-e ] [-c ] [-y] [--locale ] [--branch ] [--retry-failed ] [--bulk-unpublish ] [--content-type ] [--delivery-token ] [--only-assets] [--only-entries]`](#csdx-csdx-cmstacksunpublish--a-value--e-value--c-value--y---locale-value---branch-value---retry-failed-value---bulk-unpublish-value---content-type-value---delivery-token-value---only-assets---only-entries) + +## `csdx cm:assets:publish [-a ] [--retry-failed ] [-e ] [--folder-uid ] [--bulk-publish ] [-c ] [-y] [--locales ] [--branch ] [--delivery-token ] [--source-env ]` + +Publish assets to the specified environments + +``` +USAGE + $ csdx cm:assets:publish [-a ] [--retry-failed ] [-e ] [--folder-uid ] [--bulk-publish + ] [-c ] [-y] [--locales ] [--branch ] [--delivery-token ] [--source-env ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don’t mention the branch name, then by default the assets from the + main branch will be published. + -a, --alias= Alias (name) for the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the options + for a single run. Refer to the configure command to create a configuration file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -l, --locales=... Locales in which assets will be published, e.g., en-us. In the case of multiple + locales, specify the codes separated by spaces. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by + default. + --delivery-token= The delivery token of the source environment. + --folder-uid= (optional) The UID of the Assets’ folder from which the assets need to be published. + The default value is cs_root. + --retry-failed= Use this option to retry publishing the failed assets from the logfile. Specify the + name of the logfile that lists failed publish calls. If this option is used, it will + override all other flags. + --source-env= Source environment + +DESCRIPTION + Publish assets to the specified environments + The assets command is used to publish assets from the specified stack, to the specified environments + + Note: Environment(s) and Locale(s) are required to execute the command successfully + But, if retryFailed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:assets + +EXAMPLES + General Usage + + $ csdx cm:assets:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:stacks:publish-configure -a [ALIAS]` + + $ csdx cm:assets:publish --config [PATH TO CONFIG FILE] + + $ csdx cm:assets:publish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:assets:publish --retry-failed [LOG FILE NAME] + + + + Using --branch flag + + $ csdx cm:assets:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] + + + + Using --source-env + + $ csdx cm:assets:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] + + + + Using --stack-api-key flag + + $ csdx cm:assets:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --stack-api-key [STACK API KEY] +``` + +_See code: [src/commands/cm/assets/publish.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/assets/publish.js)_ + +## `csdx cm:assets:unpublish` + +Unpublish assets from given environment + +``` +USAGE + $ csdx cm:assets:unpublish [-a ] [-k ] [-e ] [-c ] [-y] [--locale ] [--branch + ] [--retry-failed ] [--bulk-unpublish ] [--api-version ] [--delivery-token ] + +FLAGS + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) Path of an optional configuration JSON file containing all the options for a + single run. Refer to the configure command to create a configuration file. + -e, --environment= The name of the environment from where entries/assets need to be unpublished. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the --alias + flag. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --branch= [default: main] The name of the branch where you want to perform the bulk unpublish + operation. If you don’t mention the branch name, then by default the content from the + main branch will be unpublished. + --bulk-unpublish= [default: true] Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by + default. + --delivery-token= The delivery token of the source environment. + --locale= Locale from which entries/assets will be unpublished, e.g., en-us. + --retry-failed= (optional) Use this option to retry unpublishing the failed entries from the logfile. + Specify the name of the logfile that lists failed unpublish calls. If this option is + used, it will override all other flags. + +DESCRIPTION + Unpublish assets from given environment + The unpublish command is used for unpublishing assets from the given environment + + Note: Environment (Source Environment) and Locale are required to execute the command successfully + But, if retry-failed flag is set, then only a logfile is required + +EXAMPLES + General Usage + + $ csdx cm:assets:unpublish --bulk-unpublish --environment [SOURCE ENV] --locale [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --delivery-token [DELIVERY TOKEN] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:bulk-publish:configure --alias [ALIAS]` + + $ csdx cm:assets:unpublish --config [PATH TO CONFIG FILE] + + $ csdx cm:assets:unpublish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:assets:unpublish --retry-failed [LOG FILE NAME] + + + + Using --branch flag + + $ csdx cm:assets:unpublish --bulk-unpublish --environment [SOURCE ENV] --locale [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --delivery-token [DELIVERY TOKEN] --branch [BRANCH NAME] + + + + Using --stack-api-key flag + + $ csdx cm:assets:unpublish --bulk-unpublish --environment [SOURCE ENV] --locale [LOCALE] --stack-api-key [STACK API KEY] --delivery-token [DELIVERY TOKEN] +``` + +_See code: [src/commands/cm/assets/unpublish.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/assets/unpublish.js)_ + +## `csdx cm:bulk-publish` + +Bulk Publish script for managing entries and assets + +``` +USAGE + $ csdx cm:bulk-publish + +DESCRIPTION + Bulk Publish script for managing entries and assets +``` + +_See code: [src/commands/cm/bulk-publish/index.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/bulk-publish/index.js)_ + +## `csdx cm:entries:update-and-publish [-a ] [--retry-failed ] [--bulk-publish ] [--content-types ] [-t ] [-e ] [-c ] [-y] [--locales ] [--branch ]` + +Add fields from updated content types to their respective entries + +``` +USAGE + $ csdx cm:bulk-publish:add-fields cm:entries:update-and-publish [-a ] [--retry-failed ] [--bulk-publish ] + [--content-types ] [-t ] [-e ] [-c ] [-y] [--locales ] [--branch ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don’t mention the branch name, then by default the content from the + main branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the options + for a single run. Refer to the configure command to create a configuration file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -l, --locales=... Locales in which entries will be published, e.g., en-us. In the case of multiple + locales, specify the codes separated by spaces. + -t, --contentTypes=... The Contenttypes from which entries will be published. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by + default. + --content-types=... The UID of the content type ID whose entries you want to publish in bulk. In case of + multiple content types, specify their IDs separated by spaces. + --force Update and publish all entries even if no fields have been added. + --retry-failed= Use this option to retry publishing the failed entries from the logfile. Specify the + name of the logfile that lists failed publish calls. If this option is used, it will + override all other flags. + +DESCRIPTION + Add fields from updated content types to their respective entries + The update-and-publish command is used to update existing entries with the updated schema of the respective content + type + + Note: Content types, Environments and Locales are required to execute the command successfully + But, if retry-failed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:add-fields + +EXAMPLES + General Usage + + $ csdx cm:entries:update-and-publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:stacks:publish-configure -a [ALIAS]` + + $ csdx cm:entries:update-and-publish --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:update-and-publish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed + + $ csdx cm:entries:update-and-publish --retry-failed [LOG FILE NAME] + + + + Using --branch + + $ csdx cm:entries:update-and-publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] + + + + Using --stack-api-key + + $ csdx cm:entries:update-and-publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] +``` + +## `csdx cm:assets:publish [-a ] [--retry-failed ] [-e ] [--folder-uid ] [--bulk-publish ] [-c ] [-y] [--locales ] [--branch ] [--delivery-token ] [--source-env ]` + +Publish assets to the specified environments + +``` +USAGE + $ csdx cm:bulk-publish:assets cm:assets:publish [-a ] [--retry-failed ] [-e ] [--folder-uid ] + [--bulk-publish ] [-c ] [-y] [--locales ] [--branch ] [--delivery-token ] + [--source-env ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don’t mention the branch name, then by default the assets from the + main branch will be published. + -a, --alias= Alias (name) for the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the options + for a single run. Refer to the configure command to create a configuration file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -l, --locales=... Locales in which assets will be published, e.g., en-us. In the case of multiple + locales, specify the codes separated by spaces. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by + default. + --delivery-token= The delivery token of the source environment. + --folder-uid= (optional) The UID of the Assets’ folder from which the assets need to be published. + The default value is cs_root. + --retry-failed= Use this option to retry publishing the failed assets from the logfile. Specify the + name of the logfile that lists failed publish calls. If this option is used, it will + override all other flags. + --source-env= Source environment + +DESCRIPTION + Publish assets to the specified environments + The assets command is used to publish assets from the specified stack, to the specified environments + + Note: Environment(s) and Locale(s) are required to execute the command successfully + But, if retryFailed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:assets + +EXAMPLES + General Usage + + $ csdx cm:assets:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:stacks:publish-configure -a [ALIAS]` + + $ csdx cm:assets:publish --config [PATH TO CONFIG FILE] + + $ csdx cm:assets:publish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:assets:publish --retry-failed [LOG FILE NAME] + + + + Using --branch flag + + $ csdx cm:assets:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] + + + + Using --source-env + + $ csdx cm:assets:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] + + + + Using --stack-api-key flag + + $ csdx cm:assets:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --stack-api-key [STACK API KEY] +``` + +## `csdx cm:bulk-publish:clear` + +Clear the log folder + +``` +USAGE + $ csdx cm:bulk-publish:clear [--log-files-count] [-y] + +FLAGS + -y, --yes Delete all files without asking for confirmation + --log-files-count List number of log files + +DESCRIPTION + Clear the log folder + +ALIASES + $ csdx cm:bulk-publish:clear + +EXAMPLES + $ csdx cm:stacks:publish-clear-logs + + $ csdx cm:stacks:publish-clear-logs --log-files-count + + $ csdx cm:stacks:publish-clear-logs --yes + + $ csdx cm:stacks:publish-clear-logs -y +``` + +## `csdx cm:bulk-publish:configure` + +The configure command is used to generate a configuration file for publish scripts. + +``` +USAGE + $ csdx cm:bulk-publish:configure [-a ] [-k ] + +FLAGS + -a, --alias= Name (alias) of the management token you want to use. You must use either the --alias + flag or the --stack-api-key flag. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the --alias + flag. + +DESCRIPTION + The configure command is used to generate a configuration file for publish scripts. + +ALIASES + $ csdx cm:bulk-publish:configure + +EXAMPLES + $ csdx cm:stacks:publish-configure + + $ csdx cm:stacks:publish-configure -a + + $ csdx cm:stacks:publish-configure --alias + + $ csdx cm:stacks:publish-configure --stack-api-key +``` + +## `csdx cm:bulk-publish:cross-publish [-a ] [--retry-failed ] [--bulk-publish ] [--content-type ] [--locales ] [--source-env ] [--environments ] [--delivery-token ] [-c ] [-y] [--branch ] [--onlyAssets] [--onlyEntries] [--include-variants]` + +Publish entries and assets from one environment to other environments + +``` +USAGE + $ csdx cm:bulk-publish:cross-publish [-a ] [--retry-failed ] [--bulk-publish ] [--content-type ] + [--locales ] [--source-env ] [--environments ] [--delivery-token ] [-c ] [-y] + [--branch ] [--onlyAssets] [--onlyEntries] [--include-variants] + +FLAGS + -B, --branch= [default: main] Specify the branch to fetch the content (by default the main branch is + selected) + -a, --alias= Alias(name) for the management token + -c, --config= Path to the config file + -k, --stack-api-key= Stack API key to be used + -y, --yes Agree to process the command with the current configuration + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by + default. + --content-type=... The Contenttypes from which entries will be published + --delivery-token= The delivery token of the source environment. + --environments=... Destination Environments + --include-variants Include Variants flag will publish all associated variant entries. + --locales= Source locale + --onlyAssets Unpublish only assets + --onlyEntries Unpublish only entries + --retry-failed= (optional) Retry publishing failed entries from the logfile (this flag overrides all + other flags) + --source-env= Source Env + +DESCRIPTION + Publish entries and assets from one environment to other environments + The cross-publish command is used to publish entries and assets from one environment to other environments + + Note: Content Type, Environment, Destination Environment(s) and Locale are required to execute the command + successfully + But, if retryFailed flag is set, then only a logfile is required + + +EXAMPLES + General Usage + + $ csdx cm:bulk-publish:cross-publish --content-type [CONTENT TYPE] --source-env [SOURCE ENV] --environments [DESTINATION ENVIRONMENT] --locales [LOCALE] -a [MANAGEMENT TOKEN ALIAS] --delivery-token [DELIVERY TOKEN] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:bulk-publish:configure -a [ALIAS]` + + $ csdx cm:bulk-publish:cross-publish --config [PATH TO CONFIG FILE] + + $ csdx cm:bulk-publish:cross-publish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:bulk-publish:cross-publish --retry-failed [LOG FILE NAME] + + $ csdx cm:bulk-publish:cross-publish -r [LOG FILE NAME] + + + + Using --branch flag + + $ csdx cm:bulk-publish:cross-publish --content-type [CONTENT TYPE] --source-env [SOURCE ENV] --environments [DESTINATION ENVIRONMENT] --locales [LOCALE] -a [MANAGEMENT TOKEN ALIAS] --delivery-token [DELIVERY TOKEN] --branch [BRANCH NAME] + + + + Using --stack-api-key flag + + $ csdx cm:bulk-publish:cross-publish --content-type [CONTENT TYPE] --source-env [SOURCE ENV] --environments [DESTINATION ENVIRONMENT] --locales [LOCALE] --stack-api-key [STACK API KEY] --delivery-token [DELIVERY TOKEN] + + + + Using --include-variants flag + + $ csdx cm:bulk-publish:cross-publish --content-type [CONTENT TYPE] --source-env [SOURCE ENV] --environments [DESTINATION ENVIRONMENT] --locales [LOCALE] --stack-api-key [STACK API KEY] --delivery-token [DELIVERY TOKEN] [--include-variants] +``` + +_See code: [src/commands/cm/bulk-publish/cross-publish.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/bulk-publish/cross-publish.js)_ + +## `csdx cm:entries:publish [-a ] [--retry-failed ] [--bulk-publish ] [--publish-all-content-types] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ] [--delivery-token ] [--source-env ] [--entry-uid ] [--include-variants]` + +Publish entries from multiple contenttypes to multiple environments and locales + +``` +USAGE + $ csdx cm:bulk-publish:entries cm:entries:publish [-a ] [--retry-failed ] [--bulk-publish ] + [--publish-all-content-types] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch + ] [--delivery-token ] [--source-env ] [--entry-uid ] [--include-variants] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don’t mention the branch name, then by default the content from + main branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the + options for a single run. Refer to the configure command to create a configuration + file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -l, --locales=... Locales in which entries will be published, e.g., en-us. In the case of multiple + locales, specify the codes separated by spaces. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack's Bulk Publish APIs. This flag is + set to true, by default. + --content-types=... The UID of the content type(s) whose entries you want to publish in bulk. In case of + multiple content types, specify the IDs separated by spaces. + --delivery-token= The delivery token of the source environment. + --entry-uid= Entry Uid for publish all associated variant entries. + --include-variants Include Variants flag will publish all associated variant entries with base entry. + --publish-all-content-types (optional) Set it to true to bulk publish entries from all content types. If the + --content-types option is already used, then you cannot use this option. + --retry-failed= (optional) Use this option to retry publishing the failed entries/ assets from the + logfile. Specify the name of the logfile that lists failed publish calls. If this + option is used, it will override all other flags. + --source-env= Source environment + +DESCRIPTION + Publish entries from multiple contenttypes to multiple environments and locales + The publish command is used to publish entries from the specified content types, to the + specified environments and locales + + Note: Content Types, Environments and Locales are required to execute the command successfully + But, if retry-failed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:entries + +EXAMPLES + General Usage + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:stacks:publish-configure -a [ALIAS]` + + $ csdx cm:entries:publish --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:publish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed + + $ csdx cm:entries:publish --retry-failed [LOG FILE NAME] + + $ csdx cm:entries:publish -r [LOG FILE NAME] + + + + Using --branch + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] + + + + Using --source-env + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] + + + + Using --stack-api-key + + $ csdx cm:entries:publish -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] + + + + Using --include-variants + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] [--include-variants] + + + + Using --entry-uid and --include-variants + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] --entry-uid [ENTRY UID] [--include-variants] +``` + +## `csdx cm:entries:publish-modified [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ]` + +Publish edited entries from a specified content type to the given locales and environments + +``` +USAGE + $ csdx cm:bulk-publish:entry-edits cm:entries:publish-modified [-a ] [--retry-failed ] [--bulk-publish ] + [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch + ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don't mention the branch name, then by default the entries from main + branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the options + for a single run. Refer to the configure command to create a configuration file. + -e, --environments=... The name of the environment(s) on which the entries will be published. In case of + multiple environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -l, --locales=... Locales in which entries will be published, e.g., en-us. In the case of multiple + locales, specify the codes separated by spaces. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack's Bulk Publish APIs. It is true, by + default. + --content-types=... The UID of the content type(s) whose edited entries you want to publish in bulk. In + case of multiple content types, specify the IDs separated by spaces. + --retry-failed= (optional) Use this option to retry publishing the failed entries/assets from the + logfile. Specify the name of the logfile that lists failed publish calls. If this + option is used, it will override all other flags + --source-env= The name of the source environment where the entries were initially published. + +DESCRIPTION + Publish edited entries from a specified content type to the given locales and environments + The publish-modified command is used to publish entries from the specified content types, to the + specified environments and locales + + Note: Content type(s), Source Environment, Destination Environment(s) and Locale(s) are required to execute the + command successfully + But, if retry-failed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:entry-edits + +EXAMPLES + General Usage + + $ csdx cm:entries:publish-modified --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --source-env [SOURCE_ENV] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:stacks:publish-configure -a [ALIAS]` + + $ csdx cm:entries:publish-modified --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:publish-modified -c [PATH TO CONFIG FILE] + + + + Using --retry-failed + + $ csdx cm:entries:publish-modified --retry-failed [LOG FILE NAME] + + $ csdx cm:entries:publish-modified -r [LOG FILE NAME] + + + + Using --branch + + $ csdx cm:entries:publish-modified --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --source-env [SOURCE_ENV] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] + + + + Using --stack-api-key + + $ csdx cm:entries:publish-modified --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --source-env [SOURCE_ENV] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -stack-api-key [STACK API KEY] +``` + +## `csdx cm:entries:publish-non-localized-fields [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [-e ] [-c ] [-y] [--branch ]` + +Publish non-localized fields for the given content types, from a particular source environment to the specified environments + +``` +USAGE + $ csdx cm:bulk-publish:nonlocalized-field-changes cm:entries:publish-non-localized-fields [-a ] [--retry-failed ] + [--bulk-publish ] [--source-env ] [--content-types ] [-e ] [-c ] [-y] [--branch + ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don’t mention the branch name, then by default the content from the + main branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the options + for a single run. Refer to the configure command to create a configuration file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by + default. + --content-types=... The UID of the content type whose entries you want to publish in bulk. In case of + multiple content types, specify their IDs separated by spaces. + --retry-failed= Use this option to retry publishing the failed entries from the logfile. Specify the + name of the logfile that lists failed publish calls. If this option is used, it will + override all other flags. + --source-env= The name of the source environment. + +DESCRIPTION + Publish non-localized fields for the given content types, from a particular source environment to the specified + environments + The non-localized field changes command is used to publish non-localized field changes from the given content types to + the specified environments + + Note: Content types, Environments and Source Environment are required to execute this command successfully. + But, if retryFailed flag is set, then only a logfile is required + +ALIASES + $ csdx cm:bulk-publish:nonlocalized-field-changes + +EXAMPLES + General Usage + + $ csdx cm:entries:publish-non-localized-fields --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --alias [MANAGEMENT TOKEN ALIAS] --source-env [SOURCE ENV] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:bulk-publish:configure -a [ALIAS]` + + $ csdx cm:entries:publish-non-localized-fields --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:publish-non-localized-fields -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:entries:publish-non-localized-fields --retry-failed [LOG FILE NAME] + + + + Using --branch flag + + $ csdx cm:entries:publish-non-localized-fields --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --alias [MANAGEMENT TOKEN ALIAS] --source-env [SOURCE ENV] --branch [BRANCH NAME] + + + + Using --stack-api-key flag + + $ csdx cm:entries:publish-non-localized-fields --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENV] +``` + +## `csdx cm:bulk-publish:revert` + +Revert publish operations by using a log file + +``` +USAGE + $ csdx cm:bulk-publish:revert [--retry-failed ] [--log-file ] + +FLAGS + --log-file= Path of the success logfile of a particular publish action. + --retry-failed= (optional) Use this option to retry publishing the failed entries from the logfile. Specify + the name of the logfile that lists failed publish calls. If this option is used, it will + override all other flags. + +DESCRIPTION + Revert publish operations by using a log file + The revert command is used to revert all publish operations performed using bulk-publish script. + A log file name is required to execute revert command + + +ALIASES + $ csdx cm:bulk-publish:revert + +EXAMPLES + Using --log-file + + cm:bulk-publish:revert --log-file [LOG FILE NAME] + + + + Using --retry-failed + + cm:bulk-publish:revert --retry-failed [LOG FILE NAME] +``` + +## `csdx csdx cm:stacks:unpublish [-a ] [-e ] [-c ] [-y] [--locale ] [--branch ] [--retry-failed ] [--bulk-unpublish ] [--content-type ] [--delivery-token ] [--only-assets] [--only-entries]` + +Unpublish entries or assets of given content types from the specified environment + +``` +USAGE + $ csdx cm:bulk-publish:unpublish csdx cm:stacks:unpublish [-a ] [-e ] [-c ] [-y] [--locale ] + [--branch ] [--retry-failed ] [--bulk-unpublish ] [--content-type ] [--delivery-token + ] [--only-assets] [--only-entries] + +FLAGS + -B, --branch= [default: main] Specify the branch to fetch the content from (default is main branch) + -a, --alias= Alias(name) for the management token + -c, --config= Path to the config file + -e, --environment= Source Environment + -k, --stack-api-key= Stack API key to be used + -l, --locale= Locale filter + -y, --yes Agree to process the command with the current configuration + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-unpublish= [default: true] This flag is set to true by default. It indicates that contentstack's + bulkpublish API will be used to unpublish the entries and assets + --content-type= Content type filter + --delivery-token= The delivery token of the source environment. + --retry-failed= Retry publishing failed entries from the logfile (optional, overrides all other flags) + +DESCRIPTION + Unpublish entries or assets of given content types from the specified environment + The unpublish command is used to unpublish entries or assets from given environment + + Environment (Source Environment) and Locale are required to execute the command successfully + But, if retry-failed flag is set, then only a logfile is required + + A content type can be specified for unpublishing entries, but if no content-type(s) is/are specified and --only-assets + is not used, + then all entries from all content types will be unpublished from the source environment + + Note: --only-assets can be used to unpublish only assets and --only-entries can be used to unpublish only entries. + (--only-assets and --only-entries cannot be used together at the same time) + + +ALIASES + $ csdx cm:bulk-publish:unpublish + +EXAMPLES + General Usage + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] ----delivery-token [DELIVERY TOKEN] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:bulk-publish:configure --alias [ALIAS]` + + $ csdx cm:stacks:unpublish --config [PATH TO CONFIG FILE] + + $ csdx cm:stacks:unpublish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:stacks:unpublish --retry-failed [LOG FILE NAME] + + + + No content type + + $ csdx cm:stacks:unpublish --environment [SOURCE ENV] --locale [LOCALE] (Will unpublish all entries from all content types and assets from the source environment) + + + + Using --only-assets + + $ csdx cm:stacks:unpublish --environment [SOURCE ENV] --locale [LOCALE] --only-assets (Will unpublish only assets from the source environment) + + + + Using --only-entries + + $ csdx cm:stacks:unpublish --environment [SOURCE ENV] --locale [LOCALE] --only-entries (Will unpublish only entries, all entries, from the source environment) + + $ csdx cm:stacks:unpublish --contentType [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --only-entries (Will unpublish only entries, (from CONTENT TYPE) from the source environment) + + + + Using --branch flag + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --delivery-token [DELIVERY TOKEN] --branch [BRANCH NAME] + + + + Using --stack-api-key flag + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --stack-api-key [STACK API KEY] --delivery-token [DELIVERY TOKEN] +``` + +## `csdx cm:entries:publish-only-unpublished [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ]` + +Publish unpublished entries from the source environment, to other environments and locales + +``` +USAGE + $ csdx cm:bulk-publish:unpublished-entries cm:entries:publish-only-unpublished [-a ] [--retry-failed ] [--bulk-publish + ] [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] + [--branch ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don't mention the branch name, then by default the entries from main + branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -b, --bulk-publish= [default: true] Set this flag to use Contentstack's Bulk Publish APIs. It is true, by + default. + -c, --config= (optional) The path of the optional configuration JSON file containing all the + options for a single run. Refer to the configure command to create a configuration + file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].. + --content-types=... The UID of the content type(s) whose entries you want to publish in bulk. In case of + multiple content types, specify their IDs separated by spaces. + --locales= Locale in which entries will be published, e.g., en-us + --retry-failed= (optional) Use this option to retry publishing the failed entries from the logfile. It + is optional. Specify the name of the logfile that lists failed publish calls. If this + option is used, it will override all other flags. + --source-env= The name of the source environment where the entries were initially published. + +DESCRIPTION + Publish unpublished entries from the source environment, to other environments and locales + The publish-only-unpublished command is used to publish unpublished entries from the source environment, to other + environments and locales + + Note: Content type(s), Source Environment, Destination Environment(s) and Source Locale are required to execute the + command successfully + But, if retry-failed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:unpublished-entries + +EXAMPLES + General Usage + + $ csdx cm:entries:publish-only-unpublished -b --content-types [CONTENT TYPES] -e [ENVIRONMENTS] --locales LOCALE -a [MANAGEMENT TOKEN ALIAS] -source-env [SOURCE ENV] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:bulk-publish:configure -a [ALIAS]` + + $ csdx cm:entries:publish-only-unpublished --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:publish-only-unpublished -c [PATH TO CONFIG FILE] + + + + Using --retry-failed + + $ csdx cm:entries:publish-only-unpublished --retry-failed [LOG FILE NAME] + + + + Using --branch + + $ csdx cm:entries:publish-only-unpublished -b --content-types [CONTENT TYPES] -e [ENVIRONMENTS] --locales LOCALE -a [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] -source-env [SOURCE ENV] + + + + Using --stack-api-key + + $ csdx cm:entries:publish-only-unpublished -b --content-types [CONTENT TYPES] -e [ENVIRONMENTS] --locales LOCALE -a [MANAGEMENT TOKEN ALIAS] --stack-api-key [STACK API KEY] -source-env [SOURCE ENV] +``` + +## `csdx cm:entries:publish [-a ] [--retry-failed ] [--bulk-publish ] [--publish-all-content-types] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ] [--delivery-token ] [--source-env ] [--entry-uid ] [--include-variants]` + +Publish entries from multiple contenttypes to multiple environments and locales + +``` +USAGE + $ csdx cm:entries:publish [-a ] [--retry-failed ] [--bulk-publish ] [--publish-all-content-types] + [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ] [--delivery-token + ] [--source-env ] [--entry-uid ] [--include-variants] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don’t mention the branch name, then by default the content from + main branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the + options for a single run. Refer to the configure command to create a configuration + file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -l, --locales=... Locales in which entries will be published, e.g., en-us. In the case of multiple + locales, specify the codes separated by spaces. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack's Bulk Publish APIs. This flag is + set to true, by default. + --content-types=... The UID of the content type(s) whose entries you want to publish in bulk. In case of + multiple content types, specify the IDs separated by spaces. + --delivery-token= The delivery token of the source environment. + --entry-uid= Entry Uid for publish all associated variant entries. + --include-variants Include Variants flag will publish all associated variant entries with base entry. + --publish-all-content-types (optional) Set it to true to bulk publish entries from all content types. If the + --content-types option is already used, then you cannot use this option. + --retry-failed= (optional) Use this option to retry publishing the failed entries/ assets from the + logfile. Specify the name of the logfile that lists failed publish calls. If this + option is used, it will override all other flags. + --source-env= Source environment + +DESCRIPTION + Publish entries from multiple contenttypes to multiple environments and locales + The publish command is used to publish entries from the specified content types, to the + specified environments and locales + + Note: Content Types, Environments and Locales are required to execute the command successfully + But, if retry-failed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:entries + +EXAMPLES + General Usage + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:stacks:publish-configure -a [ALIAS]` + + $ csdx cm:entries:publish --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:publish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed + + $ csdx cm:entries:publish --retry-failed [LOG FILE NAME] + + $ csdx cm:entries:publish -r [LOG FILE NAME] + + + + Using --branch + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] + + + + Using --source-env + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] + + + + Using --stack-api-key + + $ csdx cm:entries:publish -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] + + + + Using --include-variants + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] [--include-variants] + + + + Using --entry-uid and --include-variants + + $ csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN] --entry-uid [ENTRY UID] [--include-variants] +``` + +_See code: [src/commands/cm/entries/publish.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/entries/publish.js)_ + +## `csdx cm:entries:publish-modified [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ]` + +Publish edited entries from a specified content type to the given locales and environments + +``` +USAGE + $ csdx cm:entries:publish-modified [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] + [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don't mention the branch name, then by default the entries from main + branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the options + for a single run. Refer to the configure command to create a configuration file. + -e, --environments=... The name of the environment(s) on which the entries will be published. In case of + multiple environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -l, --locales=... Locales in which entries will be published, e.g., en-us. In the case of multiple + locales, specify the codes separated by spaces. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack's Bulk Publish APIs. It is true, by + default. + --content-types=... The UID of the content type(s) whose edited entries you want to publish in bulk. In + case of multiple content types, specify the IDs separated by spaces. + --retry-failed= (optional) Use this option to retry publishing the failed entries/assets from the + logfile. Specify the name of the logfile that lists failed publish calls. If this + option is used, it will override all other flags + --source-env= The name of the source environment where the entries were initially published. + +DESCRIPTION + Publish edited entries from a specified content type to the given locales and environments + The publish-modified command is used to publish entries from the specified content types, to the + specified environments and locales + + Note: Content type(s), Source Environment, Destination Environment(s) and Locale(s) are required to execute the + command successfully + But, if retry-failed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:entry-edits + +EXAMPLES + General Usage + + $ csdx cm:entries:publish-modified --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --source-env [SOURCE_ENV] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:stacks:publish-configure -a [ALIAS]` + + $ csdx cm:entries:publish-modified --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:publish-modified -c [PATH TO CONFIG FILE] + + + + Using --retry-failed + + $ csdx cm:entries:publish-modified --retry-failed [LOG FILE NAME] + + $ csdx cm:entries:publish-modified -r [LOG FILE NAME] + + + + Using --branch + + $ csdx cm:entries:publish-modified --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --source-env [SOURCE_ENV] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] + + + + Using --stack-api-key + + $ csdx cm:entries:publish-modified --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --source-env [SOURCE_ENV] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -stack-api-key [STACK API KEY] +``` + +_See code: [src/commands/cm/entries/publish-modified.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-modified.js)_ + +## `csdx cm:entries:publish-non-localized-fields [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [-e ] [-c ] [-y] [--branch ]` + +Publish non-localized fields for the given content types, from a particular source environment to the specified environments + +``` +USAGE + $ csdx cm:entries:publish-non-localized-fields [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] + [--content-types ] [-e ] [-c ] [-y] [--branch ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don’t mention the branch name, then by default the content from the + main branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the options + for a single run. Refer to the configure command to create a configuration file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by + default. + --content-types=... The UID of the content type whose entries you want to publish in bulk. In case of + multiple content types, specify their IDs separated by spaces. + --retry-failed= Use this option to retry publishing the failed entries from the logfile. Specify the + name of the logfile that lists failed publish calls. If this option is used, it will + override all other flags. + --source-env= The name of the source environment. + +DESCRIPTION + Publish non-localized fields for the given content types, from a particular source environment to the specified + environments + The non-localized field changes command is used to publish non-localized field changes from the given content types to + the specified environments + + Note: Content types, Environments and Source Environment are required to execute this command successfully. + But, if retryFailed flag is set, then only a logfile is required + +ALIASES + $ csdx cm:bulk-publish:nonlocalized-field-changes + +EXAMPLES + General Usage + + $ csdx cm:entries:publish-non-localized-fields --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --alias [MANAGEMENT TOKEN ALIAS] --source-env [SOURCE ENV] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:bulk-publish:configure -a [ALIAS]` + + $ csdx cm:entries:publish-non-localized-fields --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:publish-non-localized-fields -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:entries:publish-non-localized-fields --retry-failed [LOG FILE NAME] + + + + Using --branch flag + + $ csdx cm:entries:publish-non-localized-fields --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --alias [MANAGEMENT TOKEN ALIAS] --source-env [SOURCE ENV] --branch [BRANCH NAME] + + + + Using --stack-api-key flag + + $ csdx cm:entries:publish-non-localized-fields --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --stack-api-key [STACK API KEY] --source-env [SOURCE ENV] +``` + +_See code: [src/commands/cm/entries/publish-non-localized-fields.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-non-localized-fields.js)_ + +## `csdx cm:entries:publish-only-unpublished [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ]` + +Publish unpublished entries from the source environment, to other environments and locales + +``` +USAGE + $ csdx cm:entries:publish-only-unpublished [-a ] [--retry-failed ] [--bulk-publish ] [--source-env ] + [--content-types ] [--locales ] [-e ] [-c ] [-y] [--branch ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don't mention the branch name, then by default the entries from main + branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -b, --bulk-publish= [default: true] Set this flag to use Contentstack's Bulk Publish APIs. It is true, by + default. + -c, --config= (optional) The path of the optional configuration JSON file containing all the + options for a single run. Refer to the configure command to create a configuration + file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2].. + --content-types=... The UID of the content type(s) whose entries you want to publish in bulk. In case of + multiple content types, specify their IDs separated by spaces. + --locales= Locale in which entries will be published, e.g., en-us + --retry-failed= (optional) Use this option to retry publishing the failed entries from the logfile. It + is optional. Specify the name of the logfile that lists failed publish calls. If this + option is used, it will override all other flags. + --source-env= The name of the source environment where the entries were initially published. + +DESCRIPTION + Publish unpublished entries from the source environment, to other environments and locales + The publish-only-unpublished command is used to publish unpublished entries from the source environment, to other + environments and locales + + Note: Content type(s), Source Environment, Destination Environment(s) and Source Locale are required to execute the + command successfully + But, if retry-failed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:unpublished-entries + +EXAMPLES + General Usage + + $ csdx cm:entries:publish-only-unpublished -b --content-types [CONTENT TYPES] -e [ENVIRONMENTS] --locales LOCALE -a [MANAGEMENT TOKEN ALIAS] -source-env [SOURCE ENV] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:bulk-publish:configure -a [ALIAS]` + + $ csdx cm:entries:publish-only-unpublished --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:publish-only-unpublished -c [PATH TO CONFIG FILE] + + + + Using --retry-failed + + $ csdx cm:entries:publish-only-unpublished --retry-failed [LOG FILE NAME] + + + + Using --branch + + $ csdx cm:entries:publish-only-unpublished -b --content-types [CONTENT TYPES] -e [ENVIRONMENTS] --locales LOCALE -a [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] -source-env [SOURCE ENV] + + + + Using --stack-api-key + + $ csdx cm:entries:publish-only-unpublished -b --content-types [CONTENT TYPES] -e [ENVIRONMENTS] --locales LOCALE -a [MANAGEMENT TOKEN ALIAS] --stack-api-key [STACK API KEY] -source-env [SOURCE ENV] +``` + +_See code: [src/commands/cm/entries/publish-only-unpublished.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-only-unpublished.js)_ + +## `csdx cm:entries:unpublish` + +Unpublish entries from the given environment + +``` +USAGE + $ csdx cm:entries:unpublish [-a ] [-k ] [-e ] [-c ] [-y] [--locale ] [--branch + ] [--retry-failed ] [--bulk-unpublish ] [--api-version ] [--content-type ] + [--delivery-token ] [--include-variants] + +FLAGS + -a, --alias= Alias (name) for the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) Path to the configuration JSON file containing all options for a single run. + Refer to the configure command to create a configuration file. + -e, --environment= The name of the environment from where entries/assets need to be unpublished. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the --alias + flag. + -y, --yes Set to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --branch= [default: main] Specify the branch to fetch the content. If not mentioned, the main + branch will be used by default. + --bulk-unpublish= [default: true] This flag is set to true by default. It indicates that Contentstack's + Bulk Publish APIs will be used to unpublish the entries. + --content-type= The UID of the content type whose entries you want to unpublish in bulk. + --delivery-token= The delivery token of the source environment. + --include-variants Include Variants flag will unpublish all associated variant entries. + --locale= Locale from which entries/assets will be unpublished, e.g., en-us. + --retry-failed= (optional) Use this option to retry unpublishing the failed entries from the logfile. + Specify the name of the logfile that lists failed unpublish calls. If used, this option + will override all other flags. + +DESCRIPTION + Unpublish entries from the given environment + The unpublish command is used to unpublish entries from the given environment + + Note: Environment (Source Environment) and Locale are required to execute the command successfully + But, if retry-failed flag is set, then only a logfile is required + +EXAMPLES + General Usage + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --delivery-token [DELIVERY TOKEN] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:bulk-publish:configure --alias [ALIAS]` + + $ csdx cm:stacks:unpublish --config [PATH TO CONFIG FILE] + + $ csdx cm:stacks:unpublish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:stacks:unpublish --retry-failed [LOG FILE NAME] + + + + Using --branch flag + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --delivery-token [DELIVERY TOKEN] --branch [BRANCH NAME] + + + + Using --stack-api-key flag + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --stack-api-key [STACK API KEY] --delivery-token [DELIVERY TOKEN] + + + + Using --include-variants flag + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --stack-api-key [STACK API KEY] --delivery-token [DELIVERY TOKEN] --include-variants +``` + +_See code: [src/commands/cm/entries/unpublish.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/entries/unpublish.js)_ + +## `csdx cm:entries:update-and-publish [-a ] [--retry-failed ] [--bulk-publish ] [--content-types ] [-t ] [-e ] [-c ] [-y] [--locales ] [--branch ]` + +Add fields from updated content types to their respective entries + +``` +USAGE + $ csdx cm:entries:update-and-publish [-a ] [--retry-failed ] [--bulk-publish ] [--content-types ] [-t + ] [-e ] [-c ] [-y] [--locales ] [--branch ] + +FLAGS + -B, --branch= [default: main] The name of the branch where you want to perform the bulk publish + operation. If you don’t mention the branch name, then by default the content from the + main branch will be published. + -a, --alias= Alias (name) of the management token. You must use either the --alias flag or the + --stack-api-key flag. + -c, --config= (optional) The path of the optional configuration JSON file containing all the options + for a single run. Refer to the configure command to create a configuration file. + -e, --environments=... The name of the environment on which entries will be published. In case of multiple + environments, specify their names separated by spaces. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the + --alias flag. + -l, --locales=... Locales in which entries will be published, e.g., en-us. In the case of multiple + locales, specify the codes separated by spaces. + -t, --contentTypes=... The Contenttypes from which entries will be published. + -y, --yes Set it to true to process the command with the current configuration. + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-publish= [default: true] Set this flag to use Contentstack’s Bulk Publish APIs. It is true, by + default. + --content-types=... The UID of the content type ID whose entries you want to publish in bulk. In case of + multiple content types, specify their IDs separated by spaces. + --force Update and publish all entries even if no fields have been added. + --retry-failed= Use this option to retry publishing the failed entries from the logfile. Specify the + name of the logfile that lists failed publish calls. If this option is used, it will + override all other flags. + +DESCRIPTION + Add fields from updated content types to their respective entries + The update-and-publish command is used to update existing entries with the updated schema of the respective content + type + + Note: Content types, Environments and Locales are required to execute the command successfully + But, if retry-failed flag is set, then only a logfile is required + + +ALIASES + $ csdx cm:bulk-publish:add-fields + +EXAMPLES + General Usage + + $ csdx cm:entries:update-and-publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:stacks:publish-configure -a [ALIAS]` + + $ csdx cm:entries:update-and-publish --config [PATH TO CONFIG FILE] + + $ csdx cm:entries:update-and-publish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed + + $ csdx cm:entries:update-and-publish --retry-failed [LOG FILE NAME] + + + + Using --branch + + $ csdx cm:entries:update-and-publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] + + + + Using --stack-api-key + + $ csdx cm:entries:update-and-publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] --stack-api-key [STACK API KEY] +``` + +_See code: [src/commands/cm/entries/update-and-publish.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/entries/update-and-publish.js)_ + +## `csdx cm:stacks:publish` + +Publish entries and assets to multiple environments and locales + +``` +USAGE + $ csdx cm:stacks:publish + +DESCRIPTION + Publish entries and assets to multiple environments and locales + The publish command is used to publish entries and assets, to the specified environments and locales. + + Note: Content types, Environments and Locales are required to execute the publish entries command successfully. + Note: Environments and Locales are required to execute the publish assets command successfully. + But, if retry-failed flag is set, then only a logfile is required + +EXAMPLES + General Usage + + $ csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] + + + + Using --config or -c flag + + Generate a config file in the current working directory using `csdx cm:stacks:publish-configure -a [ALIAS]` + + $ csdx cm:stacks:publish --config [PATH TO CONFIG FILE] + + $ csdx cm:stacks:publish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:stacks:publish --retry-failed [LOG FILE NAME] + + + + Using --branch flag + + $ csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME] + + + + Using --api-version flag + + $ csdx cm:stacks:publish --environments [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --api-version [API VERSION] +``` + +_See code: [src/commands/cm/stacks/publish.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish.js)_ + +## `csdx cm:stacks:publish-clear-logs` + +Clear the log folder + +``` +USAGE + $ csdx cm:stacks:publish-clear-logs [--log-files-count] [-y] + +FLAGS + -y, --yes Delete all files without asking for confirmation + --log-files-count List number of log files + +DESCRIPTION + Clear the log folder + +ALIASES + $ csdx cm:bulk-publish:clear + +EXAMPLES + $ csdx cm:stacks:publish-clear-logs + + $ csdx cm:stacks:publish-clear-logs --log-files-count + + $ csdx cm:stacks:publish-clear-logs --yes + + $ csdx cm:stacks:publish-clear-logs -y +``` + +_See code: [src/commands/cm/stacks/publish-clear-logs.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-clear-logs.js)_ + +## `csdx cm:stacks:publish-configure` + +The configure command is used to generate a configuration file for publish scripts. + +``` +USAGE + $ csdx cm:stacks:publish-configure [-a ] [-k ] + +FLAGS + -a, --alias= Name (alias) of the management token you want to use. You must use either the --alias + flag or the --stack-api-key flag. + -k, --stack-api-key= API key of the source stack. You must use either the --stack-api-key flag or the --alias + flag. + +DESCRIPTION + The configure command is used to generate a configuration file for publish scripts. + +ALIASES + $ csdx cm:bulk-publish:configure + +EXAMPLES + $ csdx cm:stacks:publish-configure + + $ csdx cm:stacks:publish-configure -a + + $ csdx cm:stacks:publish-configure --alias + + $ csdx cm:stacks:publish-configure --stack-api-key +``` + +_See code: [src/commands/cm/stacks/publish-configure.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-configure.js)_ + +## `csdx cm:stacks:publish-revert` + +Revert publish operations by using a log file + +``` +USAGE + $ csdx cm:stacks:publish-revert [--retry-failed ] [--log-file ] + +FLAGS + --log-file= Path of the success logfile of a particular publish action. + --retry-failed= (optional) Use this option to retry publishing the failed entries from the logfile. Specify + the name of the logfile that lists failed publish calls. If this option is used, it will + override all other flags. + +DESCRIPTION + Revert publish operations by using a log file + The revert command is used to revert all publish operations performed using bulk-publish script. + A log file name is required to execute revert command + + +ALIASES + $ csdx cm:bulk-publish:revert + +EXAMPLES + Using --log-file + + cm:bulk-publish:revert --log-file [LOG FILE NAME] + + + + Using --retry-failed + + cm:bulk-publish:revert --retry-failed [LOG FILE NAME] +``` + +_See code: [src/commands/cm/stacks/publish-revert.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-revert.js)_ + +## `csdx csdx cm:stacks:unpublish [-a ] [-e ] [-c ] [-y] [--locale ] [--branch ] [--retry-failed ] [--bulk-unpublish ] [--content-type ] [--delivery-token ] [--only-assets] [--only-entries]` + +Unpublish entries or assets of given content types from the specified environment + +``` +USAGE + $ csdx cm:stacks:unpublish csdx cm:stacks:unpublish [-a ] [-e ] [-c ] [-y] [--locale ] + [--branch ] [--retry-failed ] [--bulk-unpublish ] [--content-type ] [--delivery-token + ] [--only-assets] [--only-entries] + +FLAGS + -B, --branch= [default: main] Specify the branch to fetch the content from (default is main branch) + -a, --alias= Alias(name) for the management token + -c, --config= Path to the config file + -e, --environment= Source Environment + -k, --stack-api-key= Stack API key to be used + -l, --locale= Locale filter + -y, --yes Agree to process the command with the current configuration + --api-version= API version to be used. Values [Default: 3, Nested Reference Publishing: 3.2]. + --bulk-unpublish= [default: true] This flag is set to true by default. It indicates that contentstack's + bulkpublish API will be used to unpublish the entries and assets + --content-type= Content type filter + --delivery-token= The delivery token of the source environment. + --retry-failed= Retry publishing failed entries from the logfile (optional, overrides all other flags) + +DESCRIPTION + Unpublish entries or assets of given content types from the specified environment + The unpublish command is used to unpublish entries or assets from given environment + + Environment (Source Environment) and Locale are required to execute the command successfully + But, if retry-failed flag is set, then only a logfile is required + + A content type can be specified for unpublishing entries, but if no content-type(s) is/are specified and --only-assets + is not used, + then all entries from all content types will be unpublished from the source environment + + Note: --only-assets can be used to unpublish only assets and --only-entries can be used to unpublish only entries. + (--only-assets and --only-entries cannot be used together at the same time) + + +ALIASES + $ csdx cm:bulk-publish:unpublish + +EXAMPLES + General Usage + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] ----delivery-token [DELIVERY TOKEN] + + + + Using --config or -c flag + + Generate a config file at the current working directory using `csdx cm:bulk-publish:configure --alias [ALIAS]` + + $ csdx cm:stacks:unpublish --config [PATH TO CONFIG FILE] + + $ csdx cm:stacks:unpublish -c [PATH TO CONFIG FILE] + + + + Using --retry-failed flag + + $ csdx cm:stacks:unpublish --retry-failed [LOG FILE NAME] + + + + No content type + + $ csdx cm:stacks:unpublish --environment [SOURCE ENV] --locale [LOCALE] (Will unpublish all entries from all content types and assets from the source environment) + + + + Using --only-assets + + $ csdx cm:stacks:unpublish --environment [SOURCE ENV] --locale [LOCALE] --only-assets (Will unpublish only assets from the source environment) + + + + Using --only-entries + + $ csdx cm:stacks:unpublish --environment [SOURCE ENV] --locale [LOCALE] --only-entries (Will unpublish only entries, all entries, from the source environment) + + $ csdx cm:stacks:unpublish --contentType [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --only-entries (Will unpublish only entries, (from CONTENT TYPE) from the source environment) + + + + Using --branch flag + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --alias [MANAGEMENT TOKEN ALIAS] --delivery-token [DELIVERY TOKEN] --branch [BRANCH NAME] + + + + Using --stack-api-key flag + + $ csdx cm:stacks:unpublish --bulk-unpublish --content-type [CONTENT TYPE] --environment [SOURCE ENV] --locale [LOCALE] --stack-api-key [STACK API KEY] --delivery-token [DELIVERY TOKEN] +``` + +_See code: [src/commands/cm/stacks/unpublish.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-bulk-publish/src/commands/cm/stacks/unpublish.js)_ + diff --git a/packages/contentstack-export/README.md b/packages/contentstack-export/README.md index 2f989ad87e..d64a7918fd 100755 --- a/packages/contentstack-export/README.md +++ b/packages/contentstack-export/README.md @@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-export/2.0.0-beta.7 darwin-arm64 node-v24.12.0 +@contentstack/cli-cm-export/2.0.0-beta.7 darwin-arm64 node-v23.11.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-export/src/export/modules/content-types.ts b/packages/contentstack-export/src/export/modules/content-types.ts index 61aa469aac..d5a781423b 100644 --- a/packages/contentstack-export/src/export/modules/content-types.ts +++ b/packages/contentstack-export/src/export/modules/content-types.ts @@ -155,10 +155,5 @@ export default class ContentTypesExport extends BaseClass { await executeTask(contentTypes, writeWithProgress.bind(this), { concurrency: this.exportConfig.writeConcurrency, }); - - const schemaFilePath = path.join(this.contentTypesDirPath, 'schema.json'); - log.debug(`Writing aggregate schema to: ${schemaFilePath}`, this.exportConfig.context); - - return fsUtil.writeFile(schemaFilePath, contentTypes); } } diff --git a/packages/contentstack-export/src/export/modules/entries.ts b/packages/contentstack-export/src/export/modules/entries.ts index 855a6348fb..b1c6dd0057 100644 --- a/packages/contentstack-export/src/export/modules/entries.ts +++ b/packages/contentstack-export/src/export/modules/entries.ts @@ -1,5 +1,5 @@ import * as path from 'path'; -import { ContentstackClient, FsUtility, handleAndLogError, messageHandler, log } from '@contentstack/cli-utilities'; +import { ContentstackClient, FsUtility, handleAndLogError, messageHandler, log, readContentTypeSchemas } from '@contentstack/cli-utilities'; import { Export, ExportProjects } from '@contentstack/cli-variants'; import { sanitizePath } from '@contentstack/cli-utilities'; @@ -30,7 +30,7 @@ export default class EntriesExport extends BaseClass { private variantEntries!: any; private entriesDirPath: string; private localesFilePath: string; - private schemaFilePath: string; + private contentTypesDirPath: string; private entriesFileHelper: FsUtility; private projectInstance: ExportProjects; public exportVariantEntry: boolean = false; @@ -51,11 +51,10 @@ export default class EntriesExport extends BaseClass { sanitizePath(exportConfig.modules.locales.dirName), sanitizePath(exportConfig.modules.locales.fileName), ); - this.schemaFilePath = path.resolve( + this.contentTypesDirPath = path.resolve( sanitizePath(exportConfig.exportDir), sanitizePath(exportConfig.branchName || ''), sanitizePath(exportConfig.modules.content_types.dirName), - 'schema.json', ); this.projectInstance = new ExportProjects(this.exportConfig); this.exportConfig.context.module = MODULE_CONTEXTS.ENTRIES; @@ -70,7 +69,7 @@ export default class EntriesExport extends BaseClass { const [locales, contentTypes, entryRequestOptions, totalEntriesCount, variantInfo] = await this.withLoadingSpinner('ENTRIES: Analyzing content structure and entries...', async () => { const locales = fsUtil.readFile(this.localesFilePath) as Array>; - const contentTypes = fsUtil.readFile(this.schemaFilePath) as Array>; + const contentTypes = readContentTypeSchemas(this.contentTypesDirPath); if (!Array.isArray(locales) || locales?.length === 0) { log.debug(`No locales found in ${this.localesFilePath}`, this.exportConfig.context); @@ -83,7 +82,7 @@ export default class EntriesExport extends BaseClass { return [locales, contentTypes, [], 0, null]; } log.debug( - `Loaded ${contentTypes?.length} content types from ${this.schemaFilePath}`, + `Loaded ${contentTypes?.length} content types from individual files in ${this.contentTypesDirPath}`, this.exportConfig.context, ); diff --git a/packages/contentstack-export/test/unit/export/modules/content-types.test.ts b/packages/contentstack-export/test/unit/export/modules/content-types.test.ts index e37aacc2db..749e17ca73 100644 --- a/packages/contentstack-export/test/unit/export/modules/content-types.test.ts +++ b/packages/contentstack-export/test/unit/export/modules/content-types.test.ts @@ -84,6 +84,9 @@ describe('ExportContentTypes', () => { // Stub FsUtility methods sinon.stub(FsUtility.prototype, 'writeFile').resolves(); sinon.stub(FsUtility.prototype, 'makeDirectory').resolves(); + // Stub FsUtility.prototype.readdir and readFile for readContentTypeSchemas support + sinon.stub(FsUtility.prototype, 'readdir').returns([]); + sinon.stub(FsUtility.prototype, 'readFile').returns(undefined); }); afterEach(() => { @@ -314,6 +317,7 @@ describe('ExportContentTypes', () => { it('should handle empty content types', async () => { const writeFileStub = FsUtility.prototype.writeFile as sinon.SinonStub; + const completeProgressStub = sinon.stub(exportContentTypes as any, 'completeProgress'); mockStackClient.contentType.returns({ query: sinon.stub().returns({ @@ -327,8 +331,10 @@ describe('ExportContentTypes', () => { exportContentTypes.contentTypes = []; await exportContentTypes.start(); - // Verify writeFile was called even with empty array - expect(writeFileStub.called).to.be.true; + // With empty content types, writeFile is not called (no files to write) + // But completeProgress should be called to mark the process as complete + expect(completeProgressStub.called).to.be.true; + expect(completeProgressStub.calledWith(true)).to.be.true; }); it('should handle errors during export without throwing', async () => { diff --git a/packages/contentstack-export/test/unit/export/modules/entries.test.ts b/packages/contentstack-export/test/unit/export/modules/entries.test.ts index e747f5802f..32a1924737 100644 --- a/packages/contentstack-export/test/unit/export/modules/entries.test.ts +++ b/packages/contentstack-export/test/unit/export/modules/entries.test.ts @@ -140,6 +140,11 @@ describe('EntriesExport', () => { createFolderStub.callsFake(() => { // Do nothing - prevent actual directory creation }); + + // Stub FsUtility.prototype.readdir and readFile for readContentTypeSchemas support + // readContentTypeSchemas creates its own FsUtility instance, so we need to stub the prototype + sandbox.stub(FsUtility.prototype, 'readdir').returns([]); + sandbox.stub(FsUtility.prototype, 'readFile').returns(undefined); entriesExport = new EntriesExport({ exportConfig: mockExportConfig, @@ -173,16 +178,15 @@ describe('EntriesExport', () => { mockExportConfig.modules.locales.dirName, mockExportConfig.modules.locales.fileName, ); - const expectedSchemaPath = path.resolve( + const expectedContentTypesDirPath = path.resolve( mockExportConfig.exportDir, mockExportConfig.branchName || '', mockExportConfig.modules.content_types.dirName, - 'schema.json', ); expect(entriesExport.entriesDirPath).to.equal(expectedEntriesPath); expect(entriesExport.localesFilePath).to.equal(expectedLocalesPath); - expect(entriesExport.schemaFilePath).to.equal(expectedSchemaPath); + expect(entriesExport.contentTypesDirPath).to.equal(expectedContentTypesDirPath); }); it('should initialize ExportProjects instance', () => { @@ -197,27 +201,29 @@ describe('EntriesExport', () => { describe('start() method - Early Returns', () => { it('should return early when no content types are found', async () => { - mockFsUtil.readFile - .onFirstCall() - .returns([{ code: 'en-us' }]) // locales - .onSecondCall() - .returns([]); // content types + // Stub mockFsUtil.readFile for locales + mockFsUtil.readFile.returns([{ code: 'en-us' }]); + + // Stub FsUtility.prototype for readContentTypeSchemas to return empty + (FsUtility.prototype.readdir as sinon.SinonStub).returns([]); // No content type files await entriesExport.start(); // Should not attempt to fetch entries expect(mockStackAPIClient.contentType.called).to.be.false; - // Should read both locales and content types files - expect(mockFsUtil.readFile.calledTwice).to.be.true; + // Should read locales file + expect(mockFsUtil.readFile.called).to.be.true; }); it('should handle empty locales array gracefully', async () => { - const contentTypes = [{ uid: 'ct-1', title: 'Content Type 1' }]; - mockFsUtil.readFile - .onFirstCall() - .returns([]) // empty locales - .onSecondCall() - .returns(contentTypes); + const contentTypes = [{ uid: 'ct-1', title: 'Content Type 1', schema: [] as any }]; + + // Stub mockFsUtil.readFile for locales + mockFsUtil.readFile.returns([]); // empty locales + + // Stub FsUtility.prototype for readContentTypeSchemas to return content types + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['ct-1.json']); + (FsUtility.prototype.readFile as sinon.SinonStub).returns(contentTypes[0]); await entriesExport.start(); @@ -226,14 +232,14 @@ describe('EntriesExport', () => { }); it('should handle non-array locales gracefully', async () => { - const contentTypes = [{ uid: 'ct-1', title: 'Content Type 1' }]; - // Use empty array instead of null to avoid Object.keys error - // The code checks !Array.isArray first, so empty array will work - mockFsUtil.readFile - .onFirstCall() - .returns([]) // empty locales array - .onSecondCall() - .returns(contentTypes); + const contentTypes = [{ uid: 'ct-1', title: 'Content Type 1', schema: [] as any }]; + + // Stub mockFsUtil.readFile for locales + mockFsUtil.readFile.returns([]); // empty locales array + + // Stub FsUtility.prototype for readContentTypeSchemas to return content types + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['ct-1.json']); + (FsUtility.prototype.readFile as sinon.SinonStub).returns(contentTypes[0]); // Mock entry query for when entries are processed const mockEntryQuery = { @@ -1055,11 +1061,19 @@ describe('EntriesExport', () => { it('should process all request objects and complete file writing', async () => { const locales = [{ code: 'en-us' }]; const contentTypes = [ - { uid: 'ct-1', title: 'Content Type 1' }, - { uid: 'ct-2', title: 'Content Type 2' }, + { uid: 'ct-1', title: 'Content Type 1', schema: [] as any }, + { uid: 'ct-2', title: 'Content Type 2', schema: [] as any }, ]; - mockFsUtil.readFile.onFirstCall().returns(locales).onSecondCall().returns(contentTypes); + mockFsUtil.readFile.returns(locales); // For locales file + + // Stub FsUtility.prototype for readContentTypeSchemas + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['ct-1.json', 'ct-2.json']); + (FsUtility.prototype.readFile as sinon.SinonStub).callsFake((filePath: string) => { + if (filePath.includes('ct-1.json')) return contentTypes[0]; + if (filePath.includes('ct-2.json')) return contentTypes[1]; + return undefined; + }); const mockEntryQuery = { query: sandbox.stub().returns({ @@ -1098,9 +1112,13 @@ describe('EntriesExport', () => { it('should handle errors during entry processing gracefully', async () => { const locales = [{ code: 'en-us' }]; - const contentTypes = [{ uid: 'ct-1', title: 'Content Type 1' }]; + const contentTypes = [{ uid: 'ct-1', title: 'Content Type 1', schema: [] as any }]; - mockFsUtil.readFile.onFirstCall().returns(locales).onSecondCall().returns(contentTypes); + mockFsUtil.readFile.returns(locales); // For locales file + + // Stub FsUtility.prototype for readContentTypeSchemas + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['ct-1.json']); + (FsUtility.prototype.readFile as sinon.SinonStub).returns(contentTypes[0]); const processingError = new Error('Entry processing failed'); const getEntriesStub = sandbox.stub(entriesExport, 'getEntries').rejects(processingError); diff --git a/packages/contentstack-import-setup/README.md b/packages/contentstack-import-setup/README.md index ce7bf7c58f..c27b10d66f 100644 --- a/packages/contentstack-import-setup/README.md +++ b/packages/contentstack-import-setup/README.md @@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import-setup $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-import-setup/2.0.0-beta.3 darwin-arm64 node-v24.12.0 +@contentstack/cli-cm-import-setup/2.0.0-beta.3 darwin-arm64 node-v23.11.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-import/README.md b/packages/contentstack-import/README.md index c85008b0f6..4dbd5a7710 100644 --- a/packages/contentstack-import/README.md +++ b/packages/contentstack-import/README.md @@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-import/2.0.0-beta.6 darwin-arm64 node-v24.12.0 +@contentstack/cli-cm-import/2.0.0-beta.6 darwin-arm64 node-v23.11.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-import/src/import/modules/content-types.ts b/packages/contentstack-import/src/import/modules/content-types.ts index a118a53c80..604850f38a 100644 --- a/packages/contentstack-import/src/import/modules/content-types.ts +++ b/packages/contentstack-import/src/import/modules/content-types.ts @@ -7,7 +7,7 @@ */ import * as path from 'path'; import { find, cloneDeep, map } from 'lodash'; -import { sanitizePath, log, handleAndLogError } from '@contentstack/cli-utilities'; +import { sanitizePath, log, handleAndLogError, readContentTypeSchemas } from '@contentstack/cli-utilities'; import { ImportConfig, ModuleClassParams } from '../../types'; import BaseClass, { ApiOptions } from './base-class'; import { updateFieldRules } from '../../utils/content-type-helper'; @@ -474,7 +474,7 @@ export default class ContentTypesImport extends BaseClass { const [cts, gfs, pendingGfs, pendingExt] = await this.withLoadingSpinner( 'CONTENT TYPES: Analyzing import data...', async () => { - const cts = fsUtil.readFile(path.join(this.cTsFolderPath, 'schema.json')); + const cts = readContentTypeSchemas(this.cTsFolderPath); const gfs = fsUtil.readFile(path.resolve(this.gFsFolderPath, this.gFsConfig.fileName)); const pendingGfs = fsUtil.readFile(this.gFsPendingPath); const pendingExt = fsUtil.readFile(this.extPendingPath); diff --git a/packages/contentstack-import/src/import/modules/entries.ts b/packages/contentstack-import/src/import/modules/entries.ts index 4b4706bb4b..322ed59456 100644 --- a/packages/contentstack-import/src/import/modules/entries.ts +++ b/packages/contentstack-import/src/import/modules/entries.ts @@ -7,7 +7,7 @@ import * as path from 'path'; import { writeFileSync } from 'fs'; import { isEmpty, values, cloneDeep, find, indexOf, forEach, remove } from 'lodash'; -import { FsUtility, sanitizePath, log, handleAndLogError } from '@contentstack/cli-utilities'; +import { FsUtility, sanitizePath, log, handleAndLogError, readContentTypeSchemas } from '@contentstack/cli-utilities'; import { fsUtil, lookupExtension, @@ -230,7 +230,8 @@ export default class EntriesImport extends BaseClass { return this.withLoadingSpinner('ENTRIES: Analyzing import data...', async () => { log.debug('Loading content types for entry analysis', this.importConfig.context); - this.cTs = fsUtil.readFile(path.join(this.cTsPath, 'schema.json')) as Record[]; + this.cTs = readContentTypeSchemas(this.cTsPath); + if (!this.cTs || isEmpty(this.cTs)) { return [0, 0, 0, 0, 0]; } @@ -1201,15 +1202,19 @@ export default class EntriesImport extends BaseClass { log.debug(`Found ${cTsWithFieldRules.length} content types with field rules to update`, this.importConfig.context); try { + // Read content types from individual files + const cTs = readContentTypeSchemas(this.cTsPath) || []; for (let cTUid of cTsWithFieldRules) { log.debug(`Processing field rules for content type: ${cTUid}`, this.importConfig.context); - const cTs: Record[] = fsUtil.readFile(path.join(this.cTsPath, 'schema.json')) as Record< - string, - unknown - >[]; + const contentType: any = find(cTs, { uid: cTUid }); + if (!contentType) { + log.debug(`Content type ${cTUid} not found in schemas`, this.importConfig.context); + continue; + } + if (contentType.field_rules) { log.debug( `Found ${contentType.field_rules.length} field rules for content type: ${cTUid}`, diff --git a/packages/contentstack-import/test/unit/import/modules/content-types.test.ts b/packages/contentstack-import/test/unit/import/modules/content-types.test.ts index 2a0ce8af27..313dceed77 100644 --- a/packages/contentstack-import/test/unit/import/modules/content-types.test.ts +++ b/packages/contentstack-import/test/unit/import/modules/content-types.test.ts @@ -6,6 +6,7 @@ import { fsUtil } from '../../../../src/utils'; import * as contentTypeHelper from '../../../../src/utils/content-type-helper'; import * as extensionHelper from '../../../../src/utils/extension-helper'; import * as taxonomiesHelper from '../../../../src/utils/taxonomies-helper'; +import { FsUtility } from '@contentstack/cli-utilities'; describe('ImportContentTypes', () => { let importContentTypes: ImportContentTypes; @@ -16,6 +17,8 @@ describe('ImportContentTypes', () => { let lookupExtensionStub: sinon.SinonStub; let lookUpTaxonomyStub: sinon.SinonStub; let makeConcurrentCallStub: sinon.SinonStub; + let fsUtilityReaddirStub: sinon.SinonStub; + let fsUtilityReadFileStub: sinon.SinonStub; beforeEach(() => { fsUtilStub = { @@ -27,6 +30,46 @@ describe('ImportContentTypes', () => { sinon.stub(fsUtil, 'writeFile').callsFake(fsUtilStub.writeFile); sinon.stub(fsUtil, 'makeDirectory').callsFake(fsUtilStub.makeDirectory); + // Stub FsUtility prototype to make readContentTypeSchemas work + // readContentTypeSchemas reads individual JSON files (ignoring schema.json) + // We'll check what fsUtilStub.readFile returns for schema.json and use that to populate individual files + fsUtilityReaddirStub = sinon.stub(FsUtility.prototype, 'readdir').callsFake((dirPath: string) => { + // Try to get mock CTs from the test's fsUtilStub setup for schema.json + // This allows tests to continue using schema.json pattern + try { + const mockCTs = fsUtilStub.readFile(dirPath + '/schema.json'); + if (Array.isArray(mockCTs) && mockCTs.length > 0) { + return mockCTs.map((ct: any) => `${ct.uid}.json`); + } + } catch (e) { + // If schema.json isn't stubbed, return empty + } + return []; + }); + + fsUtilityReadFileStub = sinon.stub(FsUtility.prototype, 'readFile').callsFake((filePath: string) => { + // Extract the UID from the file path and return matching content type + const match = filePath.match(/([^\/]+)\.json$/); + if (match) { + const uid = match[1]; + const dirPath = filePath.substring(0, filePath.lastIndexOf('/')); + try { + // Check if test has stubbed schema.json with mock content types + const mockCTs = fsUtilStub.readFile(dirPath + '/schema.json'); + if (Array.isArray(mockCTs)) { + const ct = mockCTs.find((ct: any) => ct.uid === uid); + if (ct) { + // FsUtility.readFile returns parsed JSON (object), not string + return ct; + } + } + } catch (e) { + // If schema.json isn't stubbed, return undefined (file doesn't exist) + } + } + return undefined; + }); + updateFieldRulesStub = sinon.stub(contentTypeHelper, 'updateFieldRules'); lookupExtensionStub = sinon.stub(extensionHelper, 'lookupExtension'); lookUpTaxonomyStub = sinon.stub(taxonomiesHelper, 'lookUpTaxonomy'); @@ -1164,4 +1207,36 @@ describe('ImportContentTypes', () => { expect(makeConcurrentCallStub.called).to.be.true; }); }); + + describe('analyzeImportData() with individual content type files', () => { + it('should read content types from individual files', async () => { + const mockContentTypes = [ + { uid: 'ct-1', title: 'CT 1', schema: [] as any }, + { uid: 'ct-2', title: 'CT 2', schema: [] as any }, + ]; + + // Configure FsUtility stubs to make readContentTypeSchemas return mock content types + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['ct-1.json', 'ct-2.json']); + (FsUtility.prototype.readFile as sinon.SinonStub).callsFake((filePath: string) => { + if (filePath.includes('ct-1.json')) return mockContentTypes[0]; + if (filePath.includes('ct-2.json')) return mockContentTypes[1]; + return {}; + }); + + fsUtilStub.readFile.returns([]); + + await (importContentTypes as any).analyzeImportData(); + + expect((importContentTypes as any).cTs).to.deep.equal(mockContentTypes); + }); + + it('should return empty array when no individual files are found', async () => { + // readdir returns [] by default, so readContentTypeSchemas will return [] + fsUtilStub.readFile.returns([]); + + await (importContentTypes as any).analyzeImportData(); + + expect((importContentTypes as any).cTs).to.deep.equal([]); + }); + }); }); diff --git a/packages/contentstack-import/test/unit/import/modules/entries.test.ts b/packages/contentstack-import/test/unit/import/modules/entries.test.ts index 7fd6818905..ee4e2d7c1f 100644 --- a/packages/contentstack-import/test/unit/import/modules/entries.test.ts +++ b/packages/contentstack-import/test/unit/import/modules/entries.test.ts @@ -27,7 +27,15 @@ describe('EntriesImport', () => { sinon.stub(FsUtility.prototype, 'createFolderIfNotExist').callsFake(() => { return Promise.resolve(); }); - fsUtilityReadFileStub = sinon.stub(fsUtil, 'readFile'); + + // Stub FsUtility prototype to support readContentTypeSchemas + // readContentTypeSchemas creates its own FsUtility instance, so we need to stub the prototype + sinon.stub(FsUtility.prototype, 'readdir').returns([]); + + // Stub FsUtility.prototype.readFile for readContentTypeSchemas (returns parsed objects) + // This also stubs fsUtil.readFile since fsUtil is an instance of FsUtility + // Don't set a default return value - let individual tests configure it + fsUtilityReadFileStub = sinon.stub(FsUtility.prototype, 'readFile'); fsUtilityWriteFileStub = sinon.stub(fsUtil, 'writeFile').callsFake(() => { return Promise.resolve(); }); @@ -503,8 +511,14 @@ describe('EntriesImport', () => { if (path.includes('schema.json')) { return [mockData.contentTypeWithFieldRules]; } - return {}; + if (path.includes('field_rules_ct.json')) { + return mockData.contentTypeWithFieldRules; + } + return undefined; }); + + // Override FsUtility.prototype.readdir for readContentTypeSchemas + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['field_rules_ct.json']); }); it('should update field rules with new UIDs', async () => { @@ -539,6 +553,9 @@ describe('EntriesImport', () => { }); it('should handle content type not found', async () => { + // This test expects the content type to be in schemas but API fetch returns null + // The beforeEach already sets up field_rules_ct, so this should work + mockStackClient.contentType.returns({ fetch: sinon.stub().resolves(null), }); @@ -561,8 +578,14 @@ describe('EntriesImport', () => { if (path.includes('schema.json')) { return [contentTypeWithoutFieldRules]; } - return {}; + if (path.includes('field_rules_ct.json')) { + return contentTypeWithoutFieldRules; + } + return undefined; }); + + // Override FsUtility.readdir for this test + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['field_rules_ct.json']); await entriesImport['updateFieldRules'](); @@ -3096,21 +3119,25 @@ describe('EntriesImport', () => { }); describe('updateFieldRules() Method Error Handling', () => { + beforeEach(() => { + // Override FsUtility stubs to return mock content types + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['simple_ct.json', 'ref_ct.json']); + }); + it('should handle content type fetch error', async () => { const mockContentTypes = [mockData.simpleContentType, mockData.contentTypeWithReferences]; + // Configure FsUtility.readFile to handle all file reads (for both fsUtil and readContentTypeSchemas) fsUtilityReadFileStub.callsFake((filePath) => { - console.log('fsUtil.readFile called with path:', filePath); if (filePath.includes('field_rules_uid.json')) { - console.log('Returning field rules data'); return ['simple_ct', 'ref_ct']; // array of strings } + if (filePath.includes('simple_ct.json')) return mockData.simpleContentType; + if (filePath.includes('ref_ct.json')) return mockData.contentTypeWithReferences; if (filePath.includes('schema.json')) { - console.log('Returning schema data'); return mockContentTypes; } - console.log('Returning empty array'); - return []; + return undefined; }); const mockContentType = { @@ -3134,14 +3161,17 @@ describe('EntriesImport', () => { it('should handle content type update error', async () => { const mockContentTypes = [mockData.simpleContentType, mockData.contentTypeWithReferences]; + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['simple_ct.json']); + fsUtilityReadFileStub.callsFake((path) => { if (path.includes('field_rules_uid.json')) { return ['simple_ct']; // array of strings } + if (path.includes('simple_ct.json')) return mockData.simpleContentType; if (path.includes('schema.json')) { return mockContentTypes; } - return []; + return undefined; }); const mockUpdate = sinon.stub().rejects(new Error('Update failed')); @@ -3171,14 +3201,17 @@ describe('EntriesImport', () => { it('should skip when content type not found', async () => { const mockContentTypes = [mockData.simpleContentType, mockData.contentTypeWithReferences]; + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['simple_ct.json']); + fsUtilityReadFileStub.callsFake((path) => { if (path.includes('field_rules_uid.json')) { return ['simple_ct']; // array of strings } + if (path.includes('simple_ct.json')) return mockData.simpleContentType; if (path.includes('schema.json')) { return mockContentTypes; } - return []; + return undefined; }); const mockContentType = { @@ -3213,14 +3246,17 @@ describe('EntriesImport', () => { delete contentTypeWithoutRules.field_rules; const mockContentTypes = [contentTypeWithoutRules]; + (FsUtility.prototype.readdir as sinon.SinonStub).returns(['simple_ct.json']); + fsUtilityReadFileStub.callsFake((path) => { if (path.includes('field_rules_uid.json')) { return ['simple_ct']; // array of strings } + if (path.includes('simple_ct.json')) return contentTypeWithoutRules; if (path.includes('schema.json')) { return mockContentTypes; } - return []; + return undefined; }); const mockLog = { diff --git a/packages/contentstack-migration/README.md b/packages/contentstack-migration/README.md index 52b2421b61..07558e1345 100644 --- a/packages/contentstack-migration/README.md +++ b/packages/contentstack-migration/README.md @@ -88,12 +88,12 @@ USAGE [--config ] [--multiple] FLAGS + -B, --branch= Use this flag to add the branch name where you want to perform the migration. (target + branch name) -a, --alias= Use this flag to add the management token alias. You must use either the --alias flag or the --stack-api-key flag. -k, --stack-api-key= Use this flag to add the API key of your stack. You must use either the --stack-api-key flag or the --alias flag. - --branch= Use this flag to add the branch name where you want to perform the migration. (target - branch name) --config=... [optional] Inline configuration, :. Passing an external configuration makes the script re-usable. --config-file= [optional] Path of the JSON configuration file. diff --git a/packages/contentstack-utilities/src/content-type-utils.ts b/packages/contentstack-utilities/src/content-type-utils.ts new file mode 100644 index 0000000000..fb628aff27 --- /dev/null +++ b/packages/contentstack-utilities/src/content-type-utils.ts @@ -0,0 +1,47 @@ +import { resolve as pResolve } from 'node:path'; +import { FsUtility } from './fs-utility'; + +/** + * Reads all content type schema files from a directory + * @param dirPath - Path to content types directory + * @param ignoredFiles - Files to ignore (defaults to schema.json, .DS_Store, __master.json, __priority.json) + * @returns Array of content type schemas + */ +export function readContentTypeSchemas( + dirPath: string, + ignoredFiles: string[] = ['schema.json', '.DS_Store', '__master.json', '__priority.json'], +): Record[] | null { + const fsUtil = new FsUtility(); + const files = fsUtil.readdir(dirPath); + + if (!files || files.length === 0) { + return null; + } + + const contentTypes: Record[] = []; + + for (const file of files) { + // Skip if not a JSON file + if (!file.endsWith('.json')) { + continue; + } + + // Skip ignored files + if (ignoredFiles.includes(file)) { + continue; + } + + try { + const filePath = pResolve(dirPath, file); + const contentType = fsUtil.readFile(filePath); + if (contentType) { + contentTypes.push(contentType as Record); + } + } catch (error) { + // Skip files that cannot be parsed + console.warn(`Failed to read content type file ${file}:`, error); + } + } + + return contentTypes; +} diff --git a/packages/contentstack-utilities/src/index.ts b/packages/contentstack-utilities/src/index.ts index fce08d2e42..65cb20f198 100644 --- a/packages/contentstack-utilities/src/index.ts +++ b/packages/contentstack-utilities/src/index.ts @@ -23,6 +23,7 @@ export { } from './contentstack-management-sdk'; export * from './http-client'; export * from './fs-utility'; +export * from './content-type-utils'; export { default as NodeCrypto } from './encrypter'; export { Args as args, Flags as flags, Command } from './cli-ux'; export * from './helpers'; diff --git a/packages/contentstack-utilities/test/unit/content-type-utils.test.ts b/packages/contentstack-utilities/test/unit/content-type-utils.test.ts new file mode 100644 index 0000000000..89778292be --- /dev/null +++ b/packages/contentstack-utilities/test/unit/content-type-utils.test.ts @@ -0,0 +1,147 @@ +import { expect } from 'chai'; +import sinon from 'sinon'; +import { readContentTypeSchemas } from '../../src/content-type-utils'; + +describe('readContentTypeSchemas', () => { + afterEach(() => { + sinon.restore(); + }); + + it('should return empty array when directory does not exist', () => { + sinon.stub(require('fs'), 'existsSync').returns(false); + + const result = readContentTypeSchemas('/nonexistent/path'); + + expect(result).to.be.an('array'); + expect(result).to.have.lengthOf(0); + + sinon.restore(); + }); + + it('should read all JSON files and return content types', () => { + const mockContentTypes = [ + { uid: 'ct-1', title: 'Content Type 1', schema: [] }, + { uid: 'ct-2', title: 'Content Type 2', schema: [] }, + ]; + + sinon.stub(require('fs'), 'existsSync').returns(true); + sinon.stub(require('fs'), 'readdirSync').returns(['ct-1.json', 'ct-2.json', 'schema.json', '.DS_Store']); + const readFileStub = sinon.stub(require('fs'), 'readFileSync'); + readFileStub.withArgs(sinon.match(/ct-1\.json/), 'utf8').returns(JSON.stringify(mockContentTypes[0])); + readFileStub.withArgs(sinon.match(/ct-2\.json/), 'utf8').returns(JSON.stringify(mockContentTypes[1])); + + const result = readContentTypeSchemas('/test/path'); + + expect(result).to.be.an('array'); + expect(result).to.have.lengthOf(2); + expect(result[0].uid).to.equal('ct-1'); + expect(result[1].uid).to.equal('ct-2'); + + sinon.restore(); + }); + + it('should ignore files in ignoredFiles list', () => { + const mockContentType = { uid: 'ct-1', title: 'Content Type 1', schema: [] }; + + sinon.stub(require('fs'), 'existsSync').returns(true); + sinon.stub(require('fs'), 'readdirSync').returns([ + 'ct-1.json', + 'schema.json', + '__master.json', + '__priority.json', + '.DS_Store', + ]); + const readFileStub = sinon.stub(require('fs'), 'readFileSync'); + readFileStub.withArgs(sinon.match(/ct-1\.json/), 'utf8').returns(JSON.stringify(mockContentType)); + + const result = readContentTypeSchemas('/test/path'); + + expect(result).to.be.an('array'); + expect(result).to.have.lengthOf(1); + expect(result[0].uid).to.equal('ct-1'); + + sinon.restore(); + }); + + it('should skip non-JSON files', () => { + const mockContentType = { uid: 'ct-1', title: 'Content Type 1', schema: [] }; + + sinon.stub(require('fs'), 'existsSync').returns(true); + sinon.stub(require('fs'), 'readdirSync').returns(['ct-1.json', 'readme.txt', 'config.yaml']); + const readFileStub = sinon.stub(require('fs'), 'readFileSync'); + readFileStub.withArgs(sinon.match(/ct-1\.json/), 'utf8').returns(JSON.stringify(mockContentType)); + + const result = readContentTypeSchemas('/test/path'); + + expect(result).to.be.an('array'); + expect(result).to.have.lengthOf(1); + expect(result[0].uid).to.equal('ct-1'); + + sinon.restore(); + }); + + it('should handle malformed JSON files gracefully', () => { + const mockContentType = { uid: 'ct-1', title: 'Content Type 1', schema: [] }; + + sinon.stub(require('fs'), 'existsSync').returns(true); + sinon.stub(require('fs'), 'readdirSync').returns(['ct-1.json', 'ct-2.json']); + const readFileStub = sinon.stub(require('fs'), 'readFileSync'); + readFileStub.withArgs(sinon.match(/ct-1\.json/), 'utf8').returns(JSON.stringify(mockContentType)); + readFileStub.withArgs(sinon.match(/ct-2\.json/), 'utf8').returns('invalid json{'); + + const consoleWarnStub = sinon.stub(console, 'warn'); + + const result = readContentTypeSchemas('/test/path'); + + expect(result).to.be.an('array'); + expect(result).to.have.lengthOf(1); + expect(result[0].uid).to.equal('ct-1'); + expect(consoleWarnStub.called).to.be.true; + + sinon.restore(); + }); + + it('should accept custom ignoredFiles list', () => { + const mockContentTypes = [ + { uid: 'ct-1', title: 'Content Type 1', schema: [] }, + { uid: 'schema', title: 'Schema Type', schema: [] }, + ]; + + sinon.stub(require('fs'), 'existsSync').returns(true); + sinon.stub(require('fs'), 'readdirSync').returns(['ct-1.json', 'schema.json']); + const readFileStub = sinon.stub(require('fs'), 'readFileSync'); + readFileStub.withArgs(sinon.match(/ct-1\.json/), 'utf8').returns(JSON.stringify(mockContentTypes[0])); + readFileStub.withArgs(sinon.match(/schema\.json/), 'utf8').returns(JSON.stringify(mockContentTypes[1])); + + const result = readContentTypeSchemas('/test/path', []); + + expect(result).to.be.an('array'); + expect(result).to.have.lengthOf(2); + + sinon.restore(); + }); + + it('should handle empty directory', () => { + sinon.stub(require('fs'), 'existsSync').returns(true); + sinon.stub(require('fs'), 'readdirSync').returns([]); + + const result = readContentTypeSchemas('/test/path'); + + expect(result).to.be.an('array'); + expect(result).to.have.lengthOf(0); + + sinon.restore(); + }); + + it('should handle directory with only ignored files', () => { + sinon.stub(require('fs'), 'existsSync').returns(true); + sinon.stub(require('fs'), 'readdirSync').returns(['schema.json', '.DS_Store', '__master.json']); + + const result = readContentTypeSchemas('/test/path'); + + expect(result).to.be.an('array'); + expect(result).to.have.lengthOf(0); + + sinon.restore(); + }); +});