Skip to content

Commit

Permalink
Merge pull request #1442 from contentstack/staging
Browse files Browse the repository at this point in the history
DX | 24-06-2024 | Release
  • Loading branch information
cs-raj authored Jun 24, 2024
2 parents ea04520 + 0d4a884 commit a430b18
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 24 deletions.
10 changes: 5 additions & 5 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.5.0",
"@contentstack/cli-cm-export": "~1.11.4",
"@contentstack/cli-cm-import": "~1.15.7",
"@contentstack/cli-cm-import": "~1.15.8",
"@contentstack/cli-command": "~1.2.18",
"@contentstack/cli-utilities": "~1.6.2",
"async": "^3.2.4",
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.15.6 darwin-arm64 node-v21.6.2
@contentstack/cli-cm-import/1.15.8 darwin-arm64 node-v18.20.2
$ 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.15.7",
"version": "1.15.8",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
24 changes: 20 additions & 4 deletions packages/contentstack-import/src/import/modules/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class ImportEnvironments extends BaseClass {

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

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

const onReject = ({ error, apiData }: any) => {
const onReject = async ({ error, apiData }: any) => {
const err = error?.message ? JSON.parse(error.message) : error;
const { name } = apiData;
const { name, uid } = apiData;
if (err?.errors?.name) {
const res = await this.getEnvDetails(name);
this.envUidMapper[uid] = res?.uid || ' ';
fsUtil.writeFile(this.envUidMapperPath, this.envUidMapper);
log(this.importConfig, `Environment '${name}' already exists`, 'info');
} else {
this.envFailed.push(apiData);
Expand Down Expand Up @@ -128,4 +134,14 @@ export default class ImportEnvironments extends BaseClass {
}
return apiOptions;
}

async getEnvDetails(envName: string) {
return await this.stack
.environment(envName)
.fetch()
.then((data: any) => data)
.catch((error: any) => {
log(this.importConfig, `Failed to fetch environment details. ${formatError(error)}`, 'error');
});
}
}
18 changes: 12 additions & 6 deletions packages/contentstack-import/src/import/modules/taxonomies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,20 @@ export default class ImportTaxonomies extends BaseClass {

const onReject = ({ error, apiData }: any) => {
const taxonomyUID = apiData?.taxonomy?.uid;
if (error?.errorMessage || error?.message) {
const errorMsg = error?.errorMessage || error?.errors?.taxonomy || error?.errors?.term || error?.message;
log(this.importConfig, `Taxonomy '${taxonomyUID}' failed to be import! ${errorMsg}`, 'error');
if (error?.status === 409 && error?.statusText === 'Conflict') {
log(this.importConfig, `Taxonomy '${taxonomyUID}' already exists!`, 'info');
this.createdTaxonomies[taxonomyUID] = apiData?.taxonomy;
this.createdTerms[taxonomyUID] = apiData?.terms;
} else {
log(this.importConfig, `Taxonomy '${taxonomyUID}' failed to be import! ${formatError(error)}`, 'error');
if (error?.errorMessage || error?.message) {
const errorMsg = error?.errorMessage || error?.errors?.taxonomy || error?.errors?.term || error?.message;
log(this.importConfig, `Taxonomy '${taxonomyUID}' failed to be import! ${errorMsg}`, 'error');
} else {
log(this.importConfig, `Taxonomy '${taxonomyUID}' failed to be import! ${formatError(error)}`, 'error');
}
this.failedTaxonomies[taxonomyUID] = apiData?.taxonomy;
this.failedTerms[taxonomyUID] = apiData?.terms;
}
this.failedTaxonomies[taxonomyUID] = apiData?.taxonomy;
this.failedTerms[taxonomyUID] = apiData?.terms;
};

await this.makeConcurrentCall(
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.15.7",
"@contentstack/cli-cm-import": "~1.15.8",
"@contentstack/cli-command": "~1.2.18",
"@contentstack/cli-utilities": "~1.6.2",
"inquirer": "8.2.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.19.0",
"version": "1.19.1",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run.js"
Expand Down Expand Up @@ -30,7 +30,7 @@
"@contentstack/cli-cm-export": "~1.11.4",
"@contentstack/cli-cm-clone": "~1.10.5",
"@contentstack/cli-cm-export-to-csv": "~1.7.1",
"@contentstack/cli-cm-import": "~1.15.7",
"@contentstack/cli-cm-import": "~1.15.8",
"@contentstack/cli-cm-migrate-rte": "~1.4.17",
"@contentstack/cli-cm-seed": "~1.7.5",
"@contentstack/cli-command": "~1.2.18",
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.

0 comments on commit a430b18

Please sign in to comment.