Skip to content
Closed
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ yarn.lock
contents-*
*.http
*.todo
talisman_output.log
talisman_output.log
snyk_output.log
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fileignoreconfig:
- filename: packages/contentstack-bootstrap/test/bootstrap.test.js
checksum: 5f0355a5048183d61b605cbc160e6727a9de32832d9159e903fee49f9ab751d5
- filename: package-lock.json
checksum: 35c1a3c35a923ddf97a42edc85708a1bee9352710ebe135b6be6a32c95bde908
checksum: e61bb635c0fa3c37ca9ea06b1ee77aab0b3c4c8bcee9013a375d5734104aff49
- filename: packages/contentstack-utilities/test/unit/logger.test.ts
checksum: c773181ea55c49d91363adacf0424b84c927e3cffd6bef1444ec2559ddf1b3b0
- filename: packages/contentstack-utilities/src/logger/cliErrorHandler.ts
Expand Down
28 changes: 11 additions & 17 deletions packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ export default class Entries {
const { uid, title } = entry;
this.currentUid = uid;
this.currentTitle = title;
if (this.currentTitle) {
this.currentTitle = this.removeEmojiAndImages(this.currentTitle);
}
this.currentTitle = this.removeEmojiAndImages(this.currentTitle)

if (!this.missingRefs[this.currentUid]) {
this.missingRefs[this.currentUid] = [];
Expand All @@ -135,11 +133,7 @@ export default class Entries {
this.removeMissingKeysOnEntry(ctSchema.schema as ContentTypeSchemaType[], this.entries[entryUid]);
}

this.lookForReference(
[{ locale: code, uid, name: this.removeEmojiAndImages(this.currentTitle) }],
ctSchema,
this.entries[entryUid],
);
this.lookForReference([{ locale: code, uid, name: this.removeEmojiAndImages(title) }], ctSchema, this.entries[entryUid]);

if (this.missingRefs[this.currentUid]?.length) {
this.missingRefs[this.currentUid].forEach((entry: any) => {
Expand Down Expand Up @@ -248,7 +242,7 @@ export default class Entries {
missingMandatoryFields: this.missingMandatoryFields,
missingTitleFields: this.missingTitleFields,
missingEnvLocale: this.missingEnvLocale,
missingMultipleFields: this.missingMultipleField,
missingMultipleFields: this.missingMultipleField
};
}

Expand Down Expand Up @@ -360,11 +354,11 @@ export default class Entries {
for (const child of field?.schema ?? []) {
const { uid, multiple, data_type } = child;

if (multiple && entry[uid] && !Array.isArray(entry[uid])) {
if (!this.missingMultipleField[this.currentUid]) {
this.missingMultipleField[this.currentUid] = [];
}

if(multiple && entry[uid] && !Array.isArray(entry[uid])) {
if (!this.missingMultipleField[this.currentUid]) {
this.missingMultipleField[this.currentUid] = [];
}
this.missingMultipleField[this.currentUid].push({
uid: this.currentUid,
name: this.currentTitle,
Expand All @@ -377,7 +371,7 @@ export default class Entries {
.filter((val) => val)
.join(' ➜ '),
});
}
}
this.missingMandatoryFields[this.currentUid].push(
...this.validateMandatoryFields(
[...tree, { uid: field.uid, name: child.display_name, field: uid }],
Expand Down Expand Up @@ -764,7 +758,7 @@ export default class Entries {
.map(({ name }) => name)
.filter(Boolean)
.join(' ➜ '),
fixStatus: 'Fixed',
'fixStatus': 'Fixed',
});

entry[uid] = [entry[uid]];
Expand Down Expand Up @@ -848,7 +842,7 @@ export default class Entries {
* Else empty array
*/
removeEmojiAndImages(str: string) {
return str?.replace(
return str.replace(
/[\p{Emoji}\p{Emoji_Presentation}\p{Emoji_Modifier}\p{Emoji_Modifier_Base}\p{Emoji_Component}]+/gu,
'',
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flags, isAuthenticated, FlagInput, managementSDKClient, cliux } from '@contentstack/cli-utilities';
import { flags, isAuthenticated, FlagInput, managementSDKClient, cliux, formatError } from '@contentstack/cli-utilities';
import { RateLimitHandler } from '../../../utils/rate-limit-handler';
import { BaseCommand } from '../../../base-command';
import { askOrgID } from '../../../utils/interactive';
Expand Down Expand Up @@ -83,6 +83,7 @@ export default class SetRateLimitCommand extends BaseCommand<typeof SetRateLimit
await limitHandler.setRateLimit(config);
} catch (error) {
cliux.error(`Error: Something went wrong while setting rate limit for org: ${org}`);
cliux.error(formatError(error));
cliux.error(error);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { cliux, configHandler, formatError } from '@contentstack/cli-utilities';
import { cliux, configHandler } from '@contentstack/cli-utilities';
import { limitNamesConfig, defaultRalteLimitConfig } from '../utils/common-utilities';
import { Limit } from '../interfaces';

let client: any;

Check warning on line 5 in packages/contentstack-config/src/utils/rate-limit-handler.ts

View workflow job for this annotation

GitHub Actions / run-tests

Unexpected any. Specify a different type

Check warning on line 5 in packages/contentstack-config/src/utils/rate-limit-handler.ts

View workflow job for this annotation

GitHub Actions / run-tests

Unexpected any. Specify a different type

export class RateLimitHandler {
setClient(managementSDKClient) {
Expand Down Expand Up @@ -66,7 +66,6 @@
}
});
} catch (error) {
console.log('Something went wrong while setting rate limit for org:', formatError(error));
throw new Error(error);
}
}
Expand Down
22 changes: 21 additions & 1 deletion packages/contentstack-export/src/export/modules/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ export default class ExportStack extends BaseClass {
super({ exportConfig, stackAPIClient });
this.stackConfig = exportConfig.modules.stack;
this.qs = { include_count: true };
this.stackFolderPath = pResolve(this.exportConfig.data, this.stackConfig.dirName);
this.stackFolderPath = pResolve(
this.exportConfig.data,
this.exportConfig.branchName || '',
this.stackConfig.dirName,
);
}

async start(): Promise<void> {
if (isAuthenticated()) {
this.exportStackSettings();
const stackData = await this.getStack();
if (stackData?.org_uid) {
this.exportConfig.org_uid = stackData.org_uid;
Expand Down Expand Up @@ -92,4 +97,19 @@ export default class ExportStack extends BaseClass {
log(this.exportConfig, `Failed to export stack. ${formatError(error)}`, 'error');
});
}

async exportStackSettings(): Promise<any> {
log(this.exportConfig, 'Exporting stack settings', 'success');
await fsUtil.makeDirectory(this.stackFolderPath);
return this.stack
.settings()
.then((resp: any) => {
fsUtil.writeFile(pResolve(this.stackFolderPath, 'settings.json'), resp);
log(this.exportConfig, 'Exported stack settings successfully!', 'success');
return resp;
})
.catch((error: any) => {
log(this.exportConfig, `Failed to export stack settings. ${formatError(error)}`, 'error');
});
}
}
Loading