From bb80a6c5e65e93ffd32b391739a00ffd5464ccbb Mon Sep 17 00:00:00 2001 From: naman-contentstack Date: Mon, 18 Nov 2024 11:42:52 +0530 Subject: [PATCH] fix invalid environment error while importing asset --- package-lock.json | 112 +++++++++++------- packages/contentstack-clone/package.json | 2 +- packages/contentstack-import/README.md | 2 +- packages/contentstack-import/package.json | 2 +- .../src/import/modules/assets.ts | 18 ++- packages/contentstack-seed/package.json | 2 +- packages/contentstack/package.json | 2 +- pnpm-lock.yaml | 6 +- 8 files changed, 91 insertions(+), 55 deletions(-) diff --git a/package-lock.json b/package-lock.json index 03a1bc0277..fe81792d01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,9 +33,9 @@ } }, "node_modules/@apollo/client": { - "version": "3.11.9", - "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.11.9.tgz", - "integrity": "sha512-aQ6VL+CPO1G4DLS/3FelfA+nl+ZQCP5qeN1NS6J8xh9wumUM/2W1ccneqCYmbTMDtoSunxE1BV2W6u0FF4axwQ==", + "version": "3.11.10", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.11.10.tgz", + "integrity": "sha512-IfGc+X4il0rDqVQBBWdxIKM+ciDCiDzBq9+Bg9z4tJMi87uF6po4v+ddiac1wP0ARgVPsFwEIGxK7jhN4pW8jg==", "license": "MIT", "dependencies": { "@graphql-typed-document-node/core": "^3.1.1", @@ -890,9 +890,9 @@ } }, "node_modules/@contentstack/utils": { - "version": "1.3.13", - "resolved": "https://registry.npmjs.org/@contentstack/utils/-/utils-1.3.13.tgz", - "integrity": "sha512-Lp4UIHMdSxMjCmcK93L987Kxa/wnucRlR7CjVBMd1bD8auJSPFh7E3aP9fnvzjzSWockBRYbXkOq6KLojgXlPA==", + "version": "1.3.14", + "resolved": "https://registry.npmjs.org/@contentstack/utils/-/utils-1.3.14.tgz", + "integrity": "sha512-TFOwN0lKKot06DTSwiOFwbgQoyAB8toNWrDcOGR6JdMg3IMecLPawOk38uJMg+q8u7gMpta70HSVaKbSW9JlEw==", "license": "MIT" }, "node_modules/@cspotcode/source-map-support": { @@ -2391,12 +2391,12 @@ } }, "node_modules/@oclif/plugin-plugins": { - "version": "5.4.15", - "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.4.15.tgz", - "integrity": "sha512-0cnTFaRWdXkWgKTrwgjoggcq/A3MaIl1GkDs3BFFjesYlFEs5Fb2HcN42rY+2ja4jBkXrjXBkLS+9faAtdCH6A==", + "version": "5.4.17", + "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.4.17.tgz", + "integrity": "sha512-V5W5jiGfWYEFS1v6j0+l0sTkRdvuHpZm9zKyEzC1i6IFFx4S4oR2IMjTwJRopyGH2TZDNVQOGilp3Cxu73pbsQ==", "license": "MIT", "dependencies": { - "@oclif/core": "^4.0.28", + "@oclif/core": "^4.0.32", "ansis": "^3.3.2", "debug": "^4.3.7", "npm": "^10.9.0", @@ -2413,9 +2413,9 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/@oclif/core": { - "version": "4.0.31", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.31.tgz", - "integrity": "sha512-7oyIZv/C1TP+fPc2tSzVPYqG1zU+nel1QvJxjAWyVhud0J8B5SpKZnryedxs3nlSVPJ6K1MT31C9esupCBYgZw==", + "version": "4.0.32", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.32.tgz", + "integrity": "sha512-O3jfIAhqaJxXI2dzF81PLTMhKpFFA0Nyz8kfBnc9WYDJnvdmXK0fVAOSpwpi2mHTow/9FXxY6Kww8+Kbe7/sag==", "license": "MIT", "dependencies": { "ansi-escapes": "^4.3.2", @@ -2550,9 +2550,9 @@ } }, "node_modules/@oclif/test": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@oclif/test/-/test-4.1.0.tgz", - "integrity": "sha512-2ugir6NhRsWJqHM9d2lMEWNiOTD678Jlx5chF/fg6TCAlc7E6E/6+zt+polrCTnTIpih5P/HxOtDekgtjgARwQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@oclif/test/-/test-4.1.1.tgz", + "integrity": "sha512-eltLnzdRKXaCQbwl7fSWHUHaHGvYNld0gpKjav6QHvM03w7NV7k4jYMEwQXwf+qmh9LuaFyADDi/tpZfrWNQVQ==", "license": "MIT", "dependencies": { "ansis": "^3.3.2", @@ -5043,6 +5043,21 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, + "node_modules/body-parser/node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", @@ -7197,9 +7212,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.55", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.55.tgz", - "integrity": "sha512-6maZ2ASDOTBtjt9FhqYPRnbvKU5tjG0IN9SztUOWYw2AzNDNpKJYLJmlK0/En4Hs/aiWnB+JZ+gW19PIGszgKg==", + "version": "1.5.62", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.62.tgz", + "integrity": "sha512-t8c+zLmJHa9dJy96yBZRXGQYoiCEnHYgFwn1asvSPZSUdVxnB62A4RASd7k41ytG3ErFBA0TpHlKg9D9SQBmLg==", "dev": true, "license": "ISC" }, @@ -7352,9 +7367,9 @@ } }, "node_modules/es-abstract": { - "version": "1.23.3", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", - "integrity": "sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==", + "version": "1.23.5", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.5.tgz", + "integrity": "sha512-vlmniQ0WNPwXqA0BnmwV3Ng7HxiGlh6r5U6JcTMNx8OilcAGqVJBHJcPjqOMaczU9fRuRK5Px2BdVyPRnKMMVQ==", "license": "MIT", "dependencies": { "array-buffer-byte-length": "^1.0.1", @@ -7372,7 +7387,7 @@ "function.prototype.name": "^1.1.6", "get-intrinsic": "^1.2.4", "get-symbol-description": "^1.0.2", - "globalthis": "^1.0.3", + "globalthis": "^1.0.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2", "has-proto": "^1.0.3", @@ -7388,10 +7403,10 @@ "is-string": "^1.0.7", "is-typed-array": "^1.1.13", "is-weakref": "^1.0.2", - "object-inspect": "^1.13.1", + "object-inspect": "^1.13.3", "object-keys": "^1.1.1", "object.assign": "^4.1.5", - "regexp.prototype.flags": "^1.5.2", + "regexp.prototype.flags": "^1.5.3", "safe-array-concat": "^1.1.2", "safe-regex-test": "^1.0.3", "string.prototype.trim": "^1.2.9", @@ -9008,6 +9023,21 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, + "node_modules/express/node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -20752,9 +20782,9 @@ "license": "MIT" }, "node_modules/process-on-spawn": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", - "integrity": "sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.1.0.tgz", + "integrity": "sha512-JOnOPQ/8TZgjs1JIH/m9ni7FfimjNa/PRx7y/Wb5qdItsnhO0jE4AT7fC0HjC28DUQWDr50dwSYZLdRMlqDq3Q==", "dev": true, "license": "MIT", "dependencies": { @@ -21059,9 +21089,9 @@ "license": "MIT" }, "node_modules/qs": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", - "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.1.tgz", + "integrity": "sha512-EJPeIn0CYrGu+hli1xilKAPXODtJ12T0sP63Ijx2/khC2JtuaN3JyNIpvmnkmaEtha9ocbG4A4cMcr+TvqvwQg==", "license": "BSD-3-Clause", "dependencies": { "side-channel": "^1.0.6" @@ -22905,9 +22935,9 @@ } }, "node_modules/sort-array/node_modules/typical": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/typical/-/typical-7.2.0.tgz", - "integrity": "sha512-W1+HdVRUl8fS3MZ9ogD51GOb46xMmhAZzR0WPw5jcgIZQJVvkddYzAl4YTU6g5w33Y1iRQLdIi2/1jhi2RNL0g==", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/typical/-/typical-7.3.0.tgz", + "integrity": "sha512-ya4mg/30vm+DOWfBg4YK3j2WD6TWtRkCbasOJr40CseYENzCUby/7rIvXA99JGsQHeNxLbnXdyLLxKSv3tauFw==", "dev": true, "license": "MIT", "engines": { @@ -24553,9 +24583,9 @@ "license": "MIT" }, "node_modules/undici": { - "version": "6.20.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.20.1.tgz", - "integrity": "sha512-AjQF1QsmqfJys+LXfGTNum+qw4S88CojRInG/6t31W/1fk6G59s92bnAvGz5Cmur+kQv2SURXEvvudLmbrE8QA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.0.tgz", + "integrity": "sha512-BUgJXc752Kou3oOIuU1i+yZZypyZRqNPW0vqoMPl8VaoalSfeR0D8/t4iAS3yirs79SSMTxTag+ZC86uswv+Cw==", "license": "MIT", "engines": { "node": ">=18.17" @@ -26588,7 +26618,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.2", + "@contentstack/cli-cm-import": "~1.19.3", "@contentstack/cli-cm-migrate-rte": "~1.4.20", "@contentstack/cli-cm-seed": "~1.10.0", "@contentstack/cli-command": "~1.3.2", @@ -27325,7 +27355,7 @@ "dependencies": { "@colors/colors": "^1.6.0", "@contentstack/cli-cm-export": "~1.14.1", - "@contentstack/cli-cm-import": "~1.19.2", + "@contentstack/cli-cm-import": "~1.19.3", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", "async": "^3.2.6", @@ -28208,7 +28238,7 @@ }, "packages/contentstack-import": { "name": "@contentstack/cli-cm-import", - "version": "1.19.2", + "version": "1.19.3", "license": "MIT", "dependencies": { "@contentstack/cli-audit": "~1.7.3", @@ -28657,7 +28687,7 @@ "version": "1.10.0", "license": "MIT", "dependencies": { - "@contentstack/cli-cm-import": "~1.19.2", + "@contentstack/cli-cm-import": "~1.19.3", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", "@contentstack/management": "~1.18.3", diff --git a/packages/contentstack-clone/package.json b/packages/contentstack-clone/package.json index 318fc0f736..a7ce3a46ce 100644 --- a/packages/contentstack-clone/package.json +++ b/packages/contentstack-clone/package.json @@ -7,7 +7,7 @@ "dependencies": { "@colors/colors": "^1.6.0", "@contentstack/cli-cm-export": "~1.14.1", - "@contentstack/cli-cm-import": "~1.19.2", + "@contentstack/cli-cm-import": "~1.19.3", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", "async": "^3.2.6", diff --git a/packages/contentstack-import/README.md b/packages/contentstack-import/README.md index ec43c1d56f..16f78435e7 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.2 darwin-arm64 node-v22.8.0 +@contentstack/cli-cm-import/1.19.3 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-import/package.json b/packages/contentstack-import/package.json index 4a1cc74040..256be8e167 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.2", + "version": "1.19.3", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { diff --git a/packages/contentstack-import/src/import/modules/assets.ts b/packages/contentstack-import/src/import/modules/assets.ts index b4286605fd..88e5e7c04d 100644 --- a/packages/contentstack-import/src/import/modules/assets.ts +++ b/packages/contentstack-import/src/import/modules/assets.ts @@ -265,15 +265,21 @@ export default class ImportAssets extends BaseClass { const serializeData = (apiOptions: ApiOptions) => { const { apiData: asset } = apiOptions; const publishDetails = filter(asset.publish_details, ({ environment }) => { - return this.environments.hasOwnProperty(environment); + return this.environments?.hasOwnProperty(environment); }); - const environments = uniq(map(publishDetails, ({ environment }) => this.environments[environment].name)); - const locales = uniq(map(publishDetails, 'locale')); + if (publishDetails.length) { + const environments = uniq(map(publishDetails, ({ environment }) => this.environments[environment].name)); + const locales = uniq(map(publishDetails, 'locale')); + if (environments.length === 0 || locales.length === 0) { + apiOptions.entity = undefined + return apiOptions; + } + asset.locales = locales; + asset.environments = environments; + apiOptions.apiData.publishDetails = { locales, environments }; + } - asset.locales = locales; - asset.environments = environments; apiOptions.uid = this.assetsUidMap[asset.uid] as string; - apiOptions.apiData.publishDetails = { locales, environments }; if (!apiOptions.uid) apiOptions.entity = undefined; diff --git a/packages/contentstack-seed/package.json b/packages/contentstack-seed/package.json index 23d61eae2c..0e649f5858 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.2", + "@contentstack/cli-cm-import": "~1.19.3", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", "@contentstack/management": "~1.18.3", diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index c3690e5fbe..c133aca753 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.2", + "@contentstack/cli-cm-import": "~1.19.3", "@contentstack/cli-cm-migrate-rte": "~1.4.20", "@contentstack/cli-cm-seed": "~1.10.0", "@contentstack/cli-command": "~1.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 676b16217a..5b80ad6d00 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.2 + '@contentstack/cli-cm-import': ~1.19.3 '@contentstack/cli-cm-migrate-rte': ~1.4.20 '@contentstack/cli-cm-seed': ~1.10.0 '@contentstack/cli-command': ~1.3.2 @@ -426,7 +426,7 @@ importers: specifiers: '@colors/colors': ^1.6.0 '@contentstack/cli-cm-export': ~1.14.1 - '@contentstack/cli-cm-import': ~1.19.2 + '@contentstack/cli-cm-import': ~1.19.3 '@contentstack/cli-command': ~1.3.2 '@contentstack/cli-utilities': ~1.8.0 '@oclif/test': ^4.1.0 @@ -998,7 +998,7 @@ importers: packages/contentstack-seed: specifiers: - '@contentstack/cli-cm-import': ~1.19.2 + '@contentstack/cli-cm-import': ~1.19.3 '@contentstack/cli-command': ~1.3.2 '@contentstack/cli-utilities': ~1.8.0 '@contentstack/management': ~1.18.3