From ef8067b4307aba4ce8ccfefeac0fd5b3f05f9f1d Mon Sep 17 00:00:00 2001 From: raj pandey Date: Fri, 22 Mar 2024 21:09:31 +0530 Subject: [PATCH 1/2] added case to handle when the references in entries are in a string format and version bump --- package-lock.json | 53 ++++++++++--------- packages/contentstack-audit/package.json | 2 +- .../contentstack-audit/src/modules/entries.ts | 5 ++ packages/contentstack-import/package.json | 2 +- packages/contentstack/package.json | 4 +- pnpm-lock.yaml | 4 +- 6 files changed, 39 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 481ae29974..364c96bd7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8352,9 +8352,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1582.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1582.0.tgz", - "integrity": "sha512-oPSk5e1D0oegX3lC+pUIKmI5e4depLi0+9fU7C73KDq65nq8NmdehpbytPHGPqfftqfa3FTEXb2yUPA4A9wM9w==", + "version": "2.1583.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1583.0.tgz", + "integrity": "sha512-gpJFO1kWC4qHPFMRgtjp15X48W8UrU1BvhYNUE7vv4O2YFHWbfulDp1hAdv6NN1sFkq/gvK2gdo5+qjj+4wdOQ==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -9098,9 +9098,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001599", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001599.tgz", - "integrity": "sha512-LRAQHZ4yT1+f9LemSMeqdMpMxZcc4RMWdj4tiFe3G8tNkWK+E58g+/tzotb5cU6TbcVJLr4fySiAW7XmxQvZQA==", + "version": "1.0.30001600", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001600.tgz", + "integrity": "sha512-+2S9/2JFhYmYaDpZvo0lKkfvuKIglrx68MwOBqMGHhQsNkLjB5xtc/TGoEPs+MxjSyN/72qer2g97nzR641mOQ==", "dev": true, "funding": [ { @@ -10621,9 +10621,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.713", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.713.tgz", - "integrity": "sha512-vDarADhwntXiULEdmWd77g2dV6FrNGa8ecAC29MZ4TwPut2fvosD0/5sJd1qWNNe8HcJFAC+F5Lf9jW1NPtWmw==", + "version": "1.4.715", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.715.tgz", + "integrity": "sha512-XzWNH4ZSa9BwVUQSDorPWAUQ5WGuYz7zJUNpNif40zFCiCl20t8zgylmreNmn26h5kiyw2lg7RfTmeMBsDklqg==", "dev": true }, "node_modules/elegant-spinner": { @@ -22610,13 +22610,16 @@ } }, "node_modules/string.prototype.trimstart": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.7.tgz", - "integrity": "sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz", + "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "es-abstract": "^1.22.1" + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -22827,9 +22830,9 @@ } }, "node_modules/tar": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", - "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", @@ -23641,9 +23644,9 @@ } }, "node_modules/typed-array-length": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.5.tgz", - "integrity": "sha512-yMi0PlwuznKHxKmcpoOdeLwxBoVPkqZxd7q2FgMkmD3bNwvF5VW0+UlUQ1k1vmktTu4Yu13Q0RIxEP8+B+wloA==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.6.tgz", + "integrity": "sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==", "dependencies": { "call-bind": "^1.0.7", "for-each": "^0.3.3", @@ -25675,10 +25678,10 @@ }, "packages/contentstack": { "name": "@contentstack/cli", - "version": "1.17.0", + "version": "1.17.1", "license": "MIT", "dependencies": { - "@contentstack/cli-audit": "~1.5.1", + "@contentstack/cli-audit": "~1.5.2", "@contentstack/cli-auth": "~1.3.17", "@contentstack/cli-cm-bootstrap": "~1.9.0", "@contentstack/cli-cm-branches": "~1.0.24", @@ -25743,7 +25746,7 @@ }, "packages/contentstack-audit": { "name": "@contentstack/cli-audit", - "version": "1.5.1", + "version": "1.5.2", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.16", @@ -27191,7 +27194,7 @@ "version": "1.15.0", "license": "MIT", "dependencies": { - "@contentstack/cli-audit": "~1.5.1", + "@contentstack/cli-audit": "~1.5.2", "@contentstack/cli-command": "~1.2.16", "@contentstack/cli-utilities": "~1.6.0", "@contentstack/management": "~1.15.3", diff --git a/packages/contentstack-audit/package.json b/packages/contentstack-audit/package.json index 78df337130..dec6ce90ca 100644 --- a/packages/contentstack-audit/package.json +++ b/packages/contentstack-audit/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-audit", - "version": "1.5.1", + "version": "1.5.2", "description": "Contentstack audit plugin", "author": "Contentstack CLI", "homepage": "https://github.com/contentstack/cli", diff --git a/packages/contentstack-audit/src/modules/entries.ts b/packages/contentstack-audit/src/modules/entries.ts index 87082a369c..b9fab26cec 100644 --- a/packages/contentstack-audit/src/modules/entries.ts +++ b/packages/contentstack-audit/src/modules/entries.ts @@ -826,6 +826,11 @@ export default class Entries { entry: EntryReferenceFieldDataType[], ) { const missingRefs: Record[] = []; + if (typeof entry === 'string') { + let stringReference = entry as string; + stringReference = stringReference.replace(/'/g, '"'); + entry = JSON.parse(stringReference); + } entry = entry ?.map((reference) => { const { uid } = reference; diff --git a/packages/contentstack-import/package.json b/packages/contentstack-import/package.json index 722ff6c208..8a7df52ad9 100644 --- a/packages/contentstack-import/package.json +++ b/packages/contentstack-import/package.json @@ -5,7 +5,7 @@ "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { - "@contentstack/cli-audit": "~1.5.1", + "@contentstack/cli-audit": "~1.5.2", "@contentstack/cli-command": "~1.2.16", "@contentstack/cli-utilities": "~1.6.0", "@contentstack/management": "~1.15.3", diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index dc91fc8e98..8d3d1e70ac 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.17.0", + "version": "1.17.1", "author": "Contentstack", "bin": { "csdx": "./bin/run" @@ -22,7 +22,7 @@ "prepack": "pnpm compile && oclif manifest && oclif readme" }, "dependencies": { - "@contentstack/cli-audit": "~1.5.1", + "@contentstack/cli-audit": "~1.5.2", "@contentstack/cli-auth": "~1.3.17", "@contentstack/cli-cm-bootstrap": "~1.9.0", "@contentstack/cli-cm-branches": "~1.0.24", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61d66c7bc6..5488bd7ccd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: packages/contentstack: specifiers: - '@contentstack/cli-audit': ~1.5.1 + '@contentstack/cli-audit': ~1.5.2 '@contentstack/cli-auth': ~1.3.17 '@contentstack/cli-cm-bootstrap': ~1.9.0 '@contentstack/cli-cm-branches': ~1.0.24 @@ -730,7 +730,7 @@ importers: packages/contentstack-import: specifiers: - '@contentstack/cli-audit': ~1.5.1 + '@contentstack/cli-audit': ~1.5.2 '@contentstack/cli-command': ~1.2.16 '@contentstack/cli-utilities': ~1.6.0 '@contentstack/management': ~1.15.3 From 918aa21949588bd10c920efaebb83dd77b687939 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 2 Apr 2024 13:04:25 +0530 Subject: [PATCH 2/2] if the ref field is string, converted it to array of object for audit command --- packages/contentstack-audit/src/modules/entries.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/contentstack-audit/src/modules/entries.ts b/packages/contentstack-audit/src/modules/entries.ts index b9fab26cec..b02899eada 100644 --- a/packages/contentstack-audit/src/modules/entries.ts +++ b/packages/contentstack-audit/src/modules/entries.ts @@ -301,6 +301,11 @@ export default class Entries { fieldStructure: ReferenceFieldDataType, field: EntryReferenceFieldDataType[], ) { + if (typeof field === 'string') { + let stringReference = field as string; + stringReference = stringReference.replace(/'/g, '"'); + field = JSON.parse(stringReference); + } return this.validateReferenceValues(tree, fieldStructure, field); }