Skip to content

Commit

Permalink
Merge branch 'development' into fix/CS-42524
Browse files Browse the repository at this point in the history
  • Loading branch information
aman19K committed Mar 4, 2024
2 parents df8504b + 63ec8fa commit 3c9e178
Show file tree
Hide file tree
Showing 22 changed files with 180 additions and 146 deletions.
118 changes: 52 additions & 66 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-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.4.0",
"version": "1.4.1",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand Down
21 changes: 19 additions & 2 deletions packages/contentstack-audit/src/audit-base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
let { ctSchema, gfSchema } = this.getCtAndGfSchema();
let missingCtRefs, missingGfRefs, missingEntryRefs;
for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
ux.action.start(this.$t(this.messages.AUDIT_START_SPINNER, { module }));
print([
{
bold: true,
color: 'whiteBright',
message: this.$t(this.messages.AUDIT_START_SPINNER, { module }),
},
]);

const constructorParam = {
ctSchema,
Expand All @@ -109,7 +115,18 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
break;
}

ux.action.stop();
print([
{
bold: true,
color: 'whiteBright',
message: this.$t(this.messages.AUDIT_START_SPINNER, { module }),
},
{
bold: true,
message: ' done',
color: 'whiteBright',
},
]);
}

return { missingCtRefs, missingGfRefs, missingEntryRefs };
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-audit/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
showTerminalOutput: true,
skipRefs: ['sys_assets'],
skipFieldTypes: ['taxonomy'],
skipFieldTypes: ['taxonomy', 'group'],
modules: ['content-types', 'global-fields', 'entries'],
'fix-fields': ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group'],
moduleConfig: {
Expand Down
18 changes: 12 additions & 6 deletions packages/contentstack-audit/src/messages/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import memoize from 'lodash/memoize';

const errors = {};

const tableColumnDescriptions = {
Expand Down Expand Up @@ -59,14 +61,18 @@ const messages: typeof errors &
* @returns a string.
*/
function $t(msg: string, args: Record<string, string>): string {
if (!msg) return '';
const transfer = memoize(function (msg: string, args: Record<string, string>) {
if (!msg) return '';

for (const key of Object.keys(args)) {
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
msg = msg.replace(new RegExp(`{${escapedKey}}`, 'g'), args[key] || escapedKey);
}

for (const key of Object.keys(args)) {
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
msg = msg.replace(new RegExp(`{${escapedKey}}`, 'g'), args[key]);
}
return msg;
});

return msg;
return transfer(msg, args);
}

export default messages;
Expand Down
18 changes: 9 additions & 9 deletions packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
ExtensionOrAppFieldDataType,
EntryExtensionOrAppFieldDataType,
} from '../types';
import { print } from '../util';
import GlobalField from './global-fields';
import { MarketplaceAppsInstallationData } from '../types/extension';

Expand Down Expand Up @@ -106,14 +107,13 @@ export default class Entries {
}

this.lookForReference([{ locale: code, uid, name: title }], ctSchema, this.entries[entryUid]);
this.log(
$t(auditMsg.SCAN_ENTRY_SUCCESS_MSG, {
title,
local: code,
module: this.config.moduleConfig.entries.name,
}),
'info',
);
const message = $t(auditMsg.SCAN_ENTRY_SUCCESS_MSG, {
title,
local: code,
module: this.config.moduleConfig.entries.name,
});
this.log(message, 'hidden');
print([{ message: `info: ${message}`, color: 'green' }]);
}

if (this.fix) {
Expand All @@ -122,7 +122,7 @@ export default class Entries {
}
}
}
this.log('', 'info'); // Adding empty line
// this.log('', 'info'); // Adding empty line

this.removeEmptyVal();

Expand Down
Loading

0 comments on commit 3c9e178

Please sign in to comment.