diff --git a/.gitignore b/.gitignore index b75595e433..bb2ce6b953 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ yarn.lock contents-* *.http *.todo -talisman_output.log \ No newline at end of file +talisman_output.log +snyk_output.log diff --git a/.talismanrc b/.talismanrc index 7c87cd194d..de36ff0095 100644 --- a/.talismanrc +++ b/.talismanrc @@ -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 diff --git a/packages/contentstack-audit/src/modules/entries.ts b/packages/contentstack-audit/src/modules/entries.ts index f85a504293..d9ca16ada9 100644 --- a/packages/contentstack-audit/src/modules/entries.ts +++ b/packages/contentstack-audit/src/modules/entries.ts @@ -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] = []; @@ -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) => { @@ -248,7 +242,7 @@ export default class Entries { missingMandatoryFields: this.missingMandatoryFields, missingTitleFields: this.missingTitleFields, missingEnvLocale: this.missingEnvLocale, - missingMultipleFields: this.missingMultipleField, + missingMultipleFields: this.missingMultipleField }; } @@ -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, @@ -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 }], @@ -764,7 +758,7 @@ export default class Entries { .map(({ name }) => name) .filter(Boolean) .join(' ➜ '), - fixStatus: 'Fixed', + 'fixStatus': 'Fixed', }); entry[uid] = [entry[uid]]; @@ -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, '', ); diff --git a/packages/contentstack-config/src/commands/config/set/rate-limit.ts b/packages/contentstack-config/src/commands/config/set/rate-limit.ts index 4016a9b071..17b62fc512 100644 --- a/packages/contentstack-config/src/commands/config/set/rate-limit.ts +++ b/packages/contentstack-config/src/commands/config/set/rate-limit.ts @@ -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'; @@ -83,6 +83,7 @@ export default class SetRateLimitCommand extends BaseCommand { if (isAuthenticated()) { + this.exportStackSettings(); const stackData = await this.getStack(); if (stackData?.org_uid) { this.exportConfig.org_uid = stackData.org_uid; @@ -92,4 +97,19 @@ export default class ExportStack extends BaseClass { log(this.exportConfig, `Failed to export stack. ${formatError(error)}`, 'error'); }); } + + async exportStackSettings(): Promise { + 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'); + }); + } }