Skip to content

Commit ee2be77

Browse files
authored
Merge pull request #2010 from contentstack/fix/import-stack-settings-management-token
[DX-3281] fix: Skip stack settings import when using management token
2 parents 4d964f9 + 870fc03 commit ee2be77

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

packages/contentstack-import/src/import/module-importer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class ModuleImporter {
6565
this.importConfig.masterLocale = { code: masterLocalResponse.code };
6666
}
6767

68-
await sanitizeStack(this.stackAPIClient);
68+
await sanitizeStack(this.importConfig);
6969

7070
return this.import();
7171
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ export default class ImportStack extends BaseClass { // classname
2424
throw new Error('Please run the environments migration first.');
2525
}
2626

27+
if (this.importConfig.management_token) {
28+
log(this.importConfig, 'Skipping stack settings import: Operation is not supported when using a management token.', 'info');
29+
log(this.importConfig, 'Successfully imported stack', 'success');
30+
return;
31+
}
32+
2733
if (fileHelper.fileExistsSync(this.stackSettingsPath)) {
2834
this.stackSettings = fsUtil.readFile(this.stackSettingsPath, true) as Record<string, any>;
2935
} else {

packages/contentstack-import/src/utils/common-helper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ export const sanitizeStack = (importConfig: ImportConfig) => {
5656
if (typeof importConfig.preserveStackVersion !== 'boolean' || !importConfig.preserveStackVersion) {
5757
return Promise.resolve();
5858
}
59+
60+
if (importConfig.management_token) {
61+
log(importConfig, 'Skipping stack version sanitization: Operation is not supported when using a management token.', 'info');
62+
return Promise.resolve();
63+
}
64+
5965
log(importConfig, 'Running script to maintain stack version.', 'success');
6066
try {
6167
const httpClient = HttpClient.create();

0 commit comments

Comments
 (0)