Skip to content

Commit 1d362c2

Browse files
authored
Merge pull request #1442 from contentstack/staging
DX | 24-06-2024 | Release
2 parents ad17c58 + 475f73e commit 1d362c2

File tree

9 files changed

+46
-24
lines changed

9 files changed

+46
-24
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-clone/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"@colors/colors": "^1.5.0",
99
"@contentstack/cli-cm-export": "~1.11.4",
10-
"@contentstack/cli-cm-import": "~1.15.7",
10+
"@contentstack/cli-cm-import": "~1.15.8",
1111
"@contentstack/cli-command": "~1.2.18",
1212
"@contentstack/cli-utilities": "~1.6.2",
1313
"async": "^3.2.4",

packages/contentstack-import/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
4747
$ csdx COMMAND
4848
running command...
4949
$ csdx (--version)
50-
@contentstack/cli-cm-import/1.15.6 darwin-arm64 node-v21.6.2
50+
@contentstack/cli-cm-import/1.15.8 darwin-arm64 node-v18.20.2
5151
$ csdx --help [COMMAND]
5252
USAGE
5353
$ csdx COMMAND

packages/contentstack-import/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-import",
33
"description": "Contentstack CLI plugin to import content into stack",
4-
"version": "1.15.7",
4+
"version": "1.15.8",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {

packages/contentstack-import/src/import/modules/environments.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class ImportEnvironments extends BaseClass {
2020

2121
constructor({ importConfig, stackAPIClient }: ModuleClassParams) {
2222
super({ importConfig, stackAPIClient });
23-
this.environmentsConfig =importConfig.modules.environments;
23+
this.environmentsConfig = importConfig.modules.environments;
2424
this.mapperDirPath = join(this.importConfig.backupDir, 'mapper', 'environments');
2525
this.environmentsFolderPath = join(this.importConfig.backupDir, this.environmentsConfig.dirName);
2626
this.envUidMapperPath = join(this.mapperDirPath, 'uid-mapping.json');
@@ -40,7 +40,10 @@ export default class ImportEnvironments extends BaseClass {
4040

4141
//Step1 check folder exists or not
4242
if (fileHelper.fileExistsSync(this.environmentsFolderPath)) {
43-
this.environments = fsUtil.readFile(join(this.environmentsFolderPath, 'environments.json'), true) as Record<string,unknown>;
43+
this.environments = fsUtil.readFile(join(this.environmentsFolderPath, 'environments.json'), true) as Record<
44+
string,
45+
unknown
46+
>;
4447
} else {
4548
log(this.importConfig, `No such file or directory - '${this.environmentsFolderPath}'`, 'error');
4649
return;
@@ -79,10 +82,13 @@ export default class ImportEnvironments extends BaseClass {
7982
fsUtil.writeFile(this.envUidMapperPath, this.envUidMapper);
8083
};
8184

82-
const onReject = ({ error, apiData }: any) => {
85+
const onReject = async ({ error, apiData }: any) => {
8386
const err = error?.message ? JSON.parse(error.message) : error;
84-
const { name } = apiData;
87+
const { name, uid } = apiData;
8588
if (err?.errors?.name) {
89+
const res = await this.getEnvDetails(name);
90+
this.envUidMapper[uid] = res?.uid || ' ';
91+
fsUtil.writeFile(this.envUidMapperPath, this.envUidMapper);
8692
log(this.importConfig, `Environment '${name}' already exists`, 'info');
8793
} else {
8894
this.envFailed.push(apiData);
@@ -128,4 +134,14 @@ export default class ImportEnvironments extends BaseClass {
128134
}
129135
return apiOptions;
130136
}
137+
138+
async getEnvDetails(envName: string) {
139+
return await this.stack
140+
.environment(envName)
141+
.fetch()
142+
.then((data: any) => data)
143+
.catch((error: any) => {
144+
log(this.importConfig, `Failed to fetch environment details. ${formatError(error)}`, 'error');
145+
});
146+
}
131147
}

packages/contentstack-import/src/import/modules/taxonomies.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,20 @@ export default class ImportTaxonomies extends BaseClass {
8585

8686
const onReject = ({ error, apiData }: any) => {
8787
const taxonomyUID = apiData?.taxonomy?.uid;
88-
if (error?.errorMessage || error?.message) {
89-
const errorMsg = error?.errorMessage || error?.errors?.taxonomy || error?.errors?.term || error?.message;
90-
log(this.importConfig, `Taxonomy '${taxonomyUID}' failed to be import! ${errorMsg}`, 'error');
88+
if (error?.status === 409 && error?.statusText === 'Conflict') {
89+
log(this.importConfig, `Taxonomy '${taxonomyUID}' already exists!`, 'info');
90+
this.createdTaxonomies[taxonomyUID] = apiData?.taxonomy;
91+
this.createdTerms[taxonomyUID] = apiData?.terms;
9192
} else {
92-
log(this.importConfig, `Taxonomy '${taxonomyUID}' failed to be import! ${formatError(error)}`, 'error');
93+
if (error?.errorMessage || error?.message) {
94+
const errorMsg = error?.errorMessage || error?.errors?.taxonomy || error?.errors?.term || error?.message;
95+
log(this.importConfig, `Taxonomy '${taxonomyUID}' failed to be import! ${errorMsg}`, 'error');
96+
} else {
97+
log(this.importConfig, `Taxonomy '${taxonomyUID}' failed to be import! ${formatError(error)}`, 'error');
98+
}
99+
this.failedTaxonomies[taxonomyUID] = apiData?.taxonomy;
100+
this.failedTerms[taxonomyUID] = apiData?.terms;
93101
}
94-
this.failedTaxonomies[taxonomyUID] = apiData?.taxonomy;
95-
this.failedTerms[taxonomyUID] = apiData?.terms;
96102
};
97103

98104
await this.makeConcurrentCall(

packages/contentstack-seed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {
8-
"@contentstack/cli-cm-import": "~1.15.7",
8+
"@contentstack/cli-cm-import": "~1.15.8",
99
"@contentstack/cli-command": "~1.2.18",
1010
"@contentstack/cli-utilities": "~1.6.2",
1111
"inquirer": "8.2.4",

packages/contentstack/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli",
33
"description": "Command-line tool (CLI) to interact with Contentstack",
4-
"version": "1.19.0",
4+
"version": "1.19.1",
55
"author": "Contentstack",
66
"bin": {
77
"csdx": "./bin/run.js"
@@ -30,7 +30,7 @@
3030
"@contentstack/cli-cm-export": "~1.11.4",
3131
"@contentstack/cli-cm-clone": "~1.10.5",
3232
"@contentstack/cli-cm-export-to-csv": "~1.7.1",
33-
"@contentstack/cli-cm-import": "~1.15.7",
33+
"@contentstack/cli-cm-import": "~1.15.8",
3434
"@contentstack/cli-cm-migrate-rte": "~1.4.17",
3535
"@contentstack/cli-cm-seed": "~1.7.5",
3636
"@contentstack/cli-command": "~1.2.18",

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)