From d21ef2a57f08927bb089789ffed8e7194d7abf19 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Thu, 17 Oct 2024 18:14:34 +0530 Subject: [PATCH 1/2] fix: import command not importing localised variant entries and only publishing in master locale issue --- package-lock.json | 16 ++++---- packages/contentstack-clone/package.json | 2 +- packages/contentstack-export/package.json | 2 +- packages/contentstack-import/README.md | 2 +- packages/contentstack-import/package.json | 4 +- .../src/import/modules/entries.ts | 3 +- packages/contentstack-seed/package.json | 2 +- packages/contentstack-variants/package.json | 2 +- .../src/import/variant-entries.ts | 37 ++++++++++++------- .../src/types/variant-entry.ts | 4 +- .../src/utils/variant-api-adapter.ts | 5 ++- packages/contentstack/README.md | 2 +- packages/contentstack/package.json | 4 +- pnpm-lock.yaml | 12 +++--- 14 files changed, 54 insertions(+), 43 deletions(-) diff --git a/package-lock.json b/package-lock.json index 92e51d3a22..d692864f07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26975,7 +26975,7 @@ "@contentstack/cli-cm-clone": "~1.13.0", "@contentstack/cli-cm-export": "~1.14.1", "@contentstack/cli-cm-export-to-csv": "~1.7.3", - "@contentstack/cli-cm-import": "~1.19.1", + "@contentstack/cli-cm-import": "~1.19.2", "@contentstack/cli-cm-migrate-rte": "~1.4.20", "@contentstack/cli-cm-seed": "~1.10.0", "@contentstack/cli-command": "~1.3.2", @@ -26983,7 +26983,7 @@ "@contentstack/cli-launch": "~1.2.3", "@contentstack/cli-migration": "~1.6.3", "@contentstack/cli-utilities": "~1.8.0", - "@contentstack/cli-variants": "~1.1.1", + "@contentstack/cli-variants": "~1.1.2", "@contentstack/management": "~1.17.0", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", @@ -27509,7 +27509,7 @@ "dependencies": { "@colors/colors": "^1.5.0", "@contentstack/cli-cm-export": "~1.14.1", - "@contentstack/cli-cm-import": "~1.19.1", + "@contentstack/cli-cm-import": "~1.19.2", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", "async": "^3.2.4", @@ -28103,7 +28103,7 @@ "dependencies": { "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", - "@contentstack/cli-variants": "~1.1.1", + "@contentstack/cli-variants": "~1.1.2", "@oclif/core": "^3.26.5", "async": "^3.2.4", "big-json": "^3.2.0", @@ -28679,13 +28679,13 @@ }, "packages/contentstack-import": { "name": "@contentstack/cli-cm-import", - "version": "1.19.1", + "version": "1.19.2", "license": "MIT", "dependencies": { "@contentstack/cli-audit": "~1.7.2", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", - "@contentstack/cli-variants": "~1.1.1", + "@contentstack/cli-variants": "~1.1.2", "@contentstack/management": "~1.17.0", "@oclif/core": "^3.26.5", "big-json": "^3.2.0", @@ -29127,7 +29127,7 @@ "version": "1.10.0", "license": "MIT", "dependencies": { - "@contentstack/cli-cm-import": "~1.19.1", + "@contentstack/cli-cm-import": "~1.19.2", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", "inquirer": "8.2.4", @@ -29295,7 +29295,7 @@ }, "packages/contentstack-variants": { "name": "@contentstack/cli-variants", - "version": "1.1.1", + "version": "1.1.2", "license": "MIT", "dependencies": { "@contentstack/cli-utilities": "^1.8.0", diff --git a/packages/contentstack-clone/package.json b/packages/contentstack-clone/package.json index e8fa497b33..913642a2cd 100644 --- a/packages/contentstack-clone/package.json +++ b/packages/contentstack-clone/package.json @@ -7,7 +7,7 @@ "dependencies": { "@colors/colors": "^1.5.0", "@contentstack/cli-cm-export": "~1.14.1", - "@contentstack/cli-cm-import": "~1.19.1", + "@contentstack/cli-cm-import": "~1.19.2", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", "async": "^3.2.4", diff --git a/packages/contentstack-export/package.json b/packages/contentstack-export/package.json index aca3b69cd6..d83ddcd1b8 100644 --- a/packages/contentstack-export/package.json +++ b/packages/contentstack-export/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.3.2", - "@contentstack/cli-variants": "~1.1.1", + "@contentstack/cli-variants": "~1.1.2", "@contentstack/cli-utilities": "~1.8.0", "@oclif/core": "^3.26.5", "async": "^3.2.4", diff --git a/packages/contentstack-import/README.md b/packages/contentstack-import/README.md index d5cc0408eb..755aa6537e 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/1.19.1 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-import/1.19.2 darwin-arm64 node-v22.2.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-import/package.json b/packages/contentstack-import/package.json index 5c30eedaf3..0713a27e68 100644 --- a/packages/contentstack-import/package.json +++ b/packages/contentstack-import/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-import", "description": "Contentstack CLI plugin to import content into stack", - "version": "1.19.1", + "version": "1.19.2", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { @@ -9,7 +9,7 @@ "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", "@contentstack/management": "~1.17.0", - "@contentstack/cli-variants": "~1.1.1", + "@contentstack/cli-variants": "~1.1.2", "@oclif/core": "^3.26.5", "big-json": "^3.2.0", "bluebird": "^3.7.2", diff --git a/packages/contentstack-import/src/import/modules/entries.ts b/packages/contentstack-import/src/import/modules/entries.ts index 5a86e03b62..d75e36d62d 100644 --- a/packages/contentstack-import/src/import/modules/entries.ts +++ b/packages/contentstack-import/src/import/modules/entries.ts @@ -356,9 +356,9 @@ export default class EntriesImport extends BaseClass { const contentType = find(this.cTs, { uid: cTUid }); const onSuccess = ({ response, apiData: entry, additionalInfo }: any) => { - this.entriesForVariant.push({ content_type: cTUid, entry_uid: entry.uid, locale }); if (additionalInfo[entry.uid]?.isLocalized) { let oldUid = additionalInfo[entry.uid].entryOldUid; + this.entriesForVariant.push({ content_type: cTUid, entry_uid: oldUid, locale }); log( this.importConfig, `Localized entry: '${entry.title}' of content type ${cTUid} in locale ${locale}`, @@ -370,6 +370,7 @@ export default class EntriesImport extends BaseClass { entriesCreateFileHelper.writeIntoFile({ [oldUid]: entry } as any, { mapKeyVal: true }); } else { log(this.importConfig, `Created entry: '${entry.title}' of content type ${cTUid} in locale ${locale}`, 'info'); + this.entriesForVariant.push({ content_type: cTUid, entry_uid: entry.uid, locale }); // This is for creating localized entries that do not have a counterpart in master locale. // For example : To create entry1 in fr-fr, where en-us is the master locale // entry1 will get created in en-us first, then fr-fr version will be created diff --git a/packages/contentstack-seed/package.json b/packages/contentstack-seed/package.json index cc81afc951..d5716f585a 100644 --- a/packages/contentstack-seed/package.json +++ b/packages/contentstack-seed/package.json @@ -5,7 +5,7 @@ "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { - "@contentstack/cli-cm-import": "~1.19.1", + "@contentstack/cli-cm-import": "~1.19.2", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", "inquirer": "8.2.4", diff --git a/packages/contentstack-variants/package.json b/packages/contentstack-variants/package.json index 5cc360a5d0..66deb8dc2b 100644 --- a/packages/contentstack-variants/package.json +++ b/packages/contentstack-variants/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-variants", - "version": "1.1.1", + "version": "1.1.2", "description": "Variants plugin", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/contentstack-variants/src/import/variant-entries.ts b/packages/contentstack-variants/src/import/variant-entries.ts index 9cff1da62a..7934b61fbf 100644 --- a/packages/contentstack-variants/src/import/variant-entries.ts +++ b/packages/contentstack-variants/src/import/variant-entries.ts @@ -54,16 +54,9 @@ export default class VariantEntries extends VariantAdapter { - log(this.config, `Created entry variant: '${variantUid}' of entry uid ${entryUid}`, 'info'); + log( + this.config, + `Created entry variant: '${variantUid}' of entry uid ${entryUid} locale '${locale}'`, + 'info', + ); }; const onReject = ({ error, apiData, log }: any) => { const { entryUid, variantUid } = apiData; this.failedVariantEntries.set(variantUid, apiData); - log(this.config, `Failed to create entry variant: '${variantUid}' of entry uid ${entryUid}`, 'error'); + log( + this.config, + `Failed to create entry variant: '${variantUid}' of entry uid ${entryUid} locale '${locale}'`, + 'error', + ); log(this.config, error, 'error'); }; // NOTE Find new variant Id by old Id @@ -440,10 +441,18 @@ export default class VariantEntries extends VariantAdapter { - log(this.config, `Entry variant: '${variantUid}' of entry uid ${entryUid} published successfully!`, 'info'); + log( + this.config, + `Entry variant: '${variantUid}' of entry '${entryUid}' published on locales '${locales.join(',')}'`, + 'info', + ); }; const onReject = ({ error, apiData: { entryUid, variantUid }, log }: any) => { - log(this.config, `Failed to publish entry variant: '${variantUid}' of entry uid ${entryUid}`, 'error'); + log( + this.config, + `Failed to publish entry variant: '${variantUid}' of entry uid ${entryUid} on locales '${locales.join(',')}'`, + 'error', + ); log(this.config, formatError(error), 'error'); }; diff --git a/packages/contentstack-variants/src/types/variant-entry.ts b/packages/contentstack-variants/src/types/variant-entry.ts index a231026971..b55ac29396 100644 --- a/packages/contentstack-variants/src/types/variant-entry.ts +++ b/packages/contentstack-variants/src/types/variant-entry.ts @@ -54,7 +54,7 @@ export type PublishVariantEntryDto = { uid: string; version?: number; }[]; - } + }; locale: string; version?: number; -} & AnyProperty; \ No newline at end of file +} & AnyProperty; diff --git a/packages/contentstack-variants/src/utils/variant-api-adapter.ts b/packages/contentstack-variants/src/utils/variant-api-adapter.ts index b9e95c0e6f..1f7c9d9c97 100644 --- a/packages/contentstack-variants/src/utils/variant-api-adapter.ts +++ b/packages/contentstack-variants/src/utils/variant-api-adapter.ts @@ -226,11 +226,12 @@ export class VariantHttpClient extends AdapterHelper implement const { entry_uid, content_type_uid } = options; let endpoint = `content_types/${content_type_uid}/entries/${entry_uid}/publish`; - const onSuccess = (response: any) => resolve({ response, apiData: { entryUid: entry_uid, variantUid }, log }); + const onSuccess = (response: any) => + resolve({ response, apiData: { entryUid: entry_uid, variantUid, locales: input.entry.locales }, log }); const onReject = (error: any) => reject({ error, - apiData: { entryUid: entry_uid, variantUid }, + apiData: { entryUid: entry_uid, variantUid, locales: input.entry.locales }, log, }); diff --git a/packages/contentstack/README.md b/packages/contentstack/README.md index 782b846a8c..434b0a1005 100644 --- a/packages/contentstack/README.md +++ b/packages/contentstack/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli/1.28.0 darwin-arm64 node-v22.8.0 +@contentstack/cli/1.28.0 darwin-arm64 node-v22.2.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 8d842be637..0b89e504f9 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -30,7 +30,7 @@ "@contentstack/cli-cm-export": "~1.14.1", "@contentstack/cli-cm-clone": "~1.13.0", "@contentstack/cli-cm-export-to-csv": "~1.7.3", - "@contentstack/cli-cm-import": "~1.19.1", + "@contentstack/cli-cm-import": "~1.19.2", "@contentstack/cli-cm-migrate-rte": "~1.4.20", "@contentstack/cli-cm-seed": "~1.10.0", "@contentstack/cli-command": "~1.3.2", @@ -39,7 +39,7 @@ "@contentstack/cli-migration": "~1.6.3", "@contentstack/cli-utilities": "~1.8.0", "@contentstack/management": "~1.17.0", - "@contentstack/cli-variants": "~1.1.1", + "@contentstack/cli-variants": "~1.1.2", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", "@oclif/plugin-not-found": "^2.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 695cc8097f..685ee5bb42 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,7 +18,7 @@ importers: '@contentstack/cli-cm-clone': ~1.13.0 '@contentstack/cli-cm-export': ~1.14.1 '@contentstack/cli-cm-export-to-csv': ~1.7.3 - '@contentstack/cli-cm-import': ~1.19.1 + '@contentstack/cli-cm-import': ~1.19.2 '@contentstack/cli-cm-migrate-rte': ~1.4.20 '@contentstack/cli-cm-seed': ~1.10.0 '@contentstack/cli-command': ~1.3.2 @@ -26,7 +26,7 @@ importers: '@contentstack/cli-launch': ~1.2.3 '@contentstack/cli-migration': ~1.6.3 '@contentstack/cli-utilities': ~1.8.0 - '@contentstack/cli-variants': ~1.1.1 + '@contentstack/cli-variants': ~1.1.2 '@contentstack/management': ~1.17.0 '@oclif/core': ^3.26.5 '@oclif/plugin-help': ^5 @@ -426,7 +426,7 @@ importers: specifiers: '@colors/colors': ^1.5.0 '@contentstack/cli-cm-export': ~1.14.1 - '@contentstack/cli-cm-import': ~1.19.1 + '@contentstack/cli-cm-import': ~1.19.2 '@contentstack/cli-command': ~1.3.2 '@contentstack/cli-utilities': ~1.8.0 '@oclif/test': ^2.5.6 @@ -613,7 +613,7 @@ importers: '@contentstack/cli-config': ~1.8.0 '@contentstack/cli-dev-dependencies': ~1.2.4 '@contentstack/cli-utilities': ~1.8.0 - '@contentstack/cli-variants': ~1.1.1 + '@contentstack/cli-variants': ~1.1.2 '@oclif/core': ^3.26.5 '@oclif/plugin-help': ^5.1.19 '@oclif/test': ^2.5.6 @@ -737,7 +737,7 @@ importers: '@contentstack/cli-audit': ~1.7.2 '@contentstack/cli-command': ~1.3.2 '@contentstack/cli-utilities': ~1.8.0 - '@contentstack/cli-variants': ~1.1.1 + '@contentstack/cli-variants': ~1.1.2 '@contentstack/management': ~1.17.0 '@oclif/core': ^3.26.5 '@oclif/test': ^2.5.6 @@ -996,7 +996,7 @@ importers: packages/contentstack-seed: specifiers: - '@contentstack/cli-cm-import': ~1.19.1 + '@contentstack/cli-cm-import': ~1.19.2 '@contentstack/cli-command': ~1.3.2 '@contentstack/cli-utilities': ~1.8.0 '@oclif/plugin-help': ^5.1.19 From e7a866b0468edff015f2e671c79b9983b32151c3 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 18 Oct 2024 14:40:10 +0530 Subject: [PATCH 2/2] lock file updated --- package-lock.json | 2 +- packages/contentstack/README.md | 2 +- packages/contentstack/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d692864f07..266c988396 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26964,7 +26964,7 @@ }, "packages/contentstack": { "name": "@contentstack/cli", - "version": "1.28.0", + "version": "1.28.1", "license": "MIT", "dependencies": { "@contentstack/cli-audit": "~1.7.2", diff --git a/packages/contentstack/README.md b/packages/contentstack/README.md index 434b0a1005..7d2d5b1d2f 100644 --- a/packages/contentstack/README.md +++ b/packages/contentstack/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli/1.28.0 darwin-arm64 node-v22.2.0 +@contentstack/cli/1.28.1 darwin-arm64 node-v22.2.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 0b89e504f9..20c1575a26 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli", "description": "Command-line tool (CLI) to interact with Contentstack", - "version": "1.28.0", + "version": "1.28.1", "author": "Contentstack", "bin": { "csdx": "./bin/run.js"