Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX-1656 - fix invalid environment error while importing asset #1681

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 50 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
18 changes: 12 additions & 6 deletions packages/contentstack-import/src/import/modules/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading