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

Staging to development #1444

Merged
merged 6 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
116 changes: 58 additions & 58 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions packages/contentstack-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ FLAGS
-k, --stack-api-key=<value> API key of the target stack
-m, --module=<value> [optional] specific module name
-y, --yes [optional] Override marketplace prompts
--exclude-global-modules Excluded the Module that are branch independent from the import
--exclude-global-modules Excludes the branch-independent module from the import operation
--import-webhook-status=<option> [default: disable] [optional] Webhook state
<options: disable|current>
--replace-existing Replaces the existing module in the target stack.
Expand Down Expand Up @@ -129,7 +129,7 @@ FLAGS
-k, --stack-api-key=<value> API key of the target stack
-m, --module=<value> [optional] specific module name
-y, --yes [optional] Override marketplace prompts
--exclude-global-modules Excluded the Module that are branch independent from the import
--exclude-global-modules Excludes the branch-independent module from the import operation
--import-webhook-status=<option> [default: disable] [optional] Webhook state
<options: disable|current>
--replace-existing Replaces the existing module in the target stack.
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
4 changes: 2 additions & 2 deletions packages/contentstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2153,7 +2153,7 @@ FLAGS
-k, --stack-api-key=<value> API key of the target stack
-m, --module=<value> [optional] specific module name
-y, --yes [optional] Override marketplace prompts
--exclude-global-modules Excluded the Module that are branch independent from the import
--exclude-global-modules Excludes the branch-independent module from the import operation
--import-webhook-status=<option> [default: disable] [optional] Webhook state
<options: disable|current>
--replace-existing Replaces the existing module in the target stack.
Expand Down Expand Up @@ -2578,7 +2578,7 @@ FLAGS
-k, --stack-api-key=<value> API key of the target stack
-m, --module=<value> [optional] specific module name
-y, --yes [optional] Override marketplace prompts
--exclude-global-modules Excluded the Module that are branch independent from the import
--exclude-global-modules Excludes the branch-independent module from the import operation
--import-webhook-status=<option> [default: disable] [optional] Webhook state
<options: disable|current>
--replace-existing Replaces the existing module in the target stack.
Expand Down
Loading