Skip to content

Commit b9e2737

Browse files
Merge pull request #1144 from contentstack/release/CS-42287-sprint45
Release/cs 42287 sprint45
2 parents b5eb420 + b6a53b9 commit b9e2737

53 files changed

Lines changed: 2001 additions & 817 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 422 additions & 268 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-audit/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
1919
$ csdx COMMAND
2020
running command...
2121
$ csdx (--version|-v)
22-
@contentstack/cli-audit/1.2.0 darwin-arm64 node-v20.8.0
22+
@contentstack/cli-audit/1.2.1 darwin-arm64 node-v21.1.0
2323
$ csdx --help [COMMAND]
2424
USAGE
2525
$ csdx COMMAND

packages/contentstack-audit/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-audit",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Contentstack audit plugin",
55
"author": "Contentstack CLI",
66
"homepage": "https://github.com/contentstack/cli",
@@ -18,8 +18,8 @@
1818
"/oclif.manifest.json"
1919
],
2020
"dependencies": {
21-
"@contentstack/cli-command": "~1.2.14",
22-
"@contentstack/cli-utilities": "~1.5.4",
21+
"@contentstack/cli-command": "~1.2.15",
22+
"@contentstack/cli-utilities": "~1.5.5",
2323
"@oclif/plugin-help": "^5",
2424
"@oclif/plugin-plugins": "^3.8.4",
2525
"chalk": "^4.1.2",

packages/contentstack-audit/src/audit-base-command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
176176
}
177177
}
178178

179-
let gfSchema = existsSync(gfPath) ? (JSON.parse(readFileSync(gfPath, 'utf-8')) as ContentTypeStruct[]) : [];
180-
let ctSchema = existsSync(ctPath) ? (JSON.parse(readFileSync(ctPath, 'utf-8')) as ContentTypeStruct[]) : [];
179+
const gfSchema = existsSync(gfPath) ? (JSON.parse(readFileSync(gfPath, 'utf8')) as ContentTypeStruct[]) : [];
180+
const ctSchema = existsSync(ctPath) ? (JSON.parse(readFileSync(ctPath, 'utf8')) as ContentTypeStruct[]) : [];
181181

182182
return { ctSchema, gfSchema };
183183
}

packages/contentstack-audit/src/modules/entries.ts

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,7 @@ export default class Entries {
7272
}
7373

7474
await this.prepareEntryMetaData();
75-
76-
this.ctSchema = (await new ContentType({
77-
fix: true,
78-
log: () => {},
79-
config: this.config,
80-
moduleName: 'content-types',
81-
ctSchema: this.ctSchema,
82-
gfSchema: this.gfSchema,
83-
}).run(true)) as ContentTypeStruct[];
84-
this.gfSchema = (await new ContentType({
85-
fix: true,
86-
log: () => {},
87-
config: this.config,
88-
moduleName: 'entries',
89-
ctSchema: this.ctSchema,
90-
gfSchema: this.gfSchema,
91-
}).run(true)) as ContentTypeStruct[];
75+
await this.fixPrerequisiteData();
9276

9377
for (const { code } of this.locales) {
9478
for (const ctSchema of this.ctSchema) {
@@ -125,13 +109,43 @@ export default class Entries {
125109
}
126110
this.log('', 'info'); // Adding empty line
127111

112+
this.removeEmptyVal();
113+
114+
return this.missingRefs;
115+
}
116+
117+
/**
118+
* The function removes any properties from the `missingRefs` object that have an empty array value.
119+
*/
120+
removeEmptyVal() {
128121
for (let propName in this.missingRefs) {
129122
if (!this.missingRefs[propName].length) {
130123
delete this.missingRefs[propName];
131124
}
132125
}
126+
}
133127

134-
return this.missingRefs;
128+
/**
129+
* The function `fixPrerequisiteData` fixes the prerequisite data by updating the `ctSchema` and
130+
* `gfSchema` properties using the `ContentType` class.
131+
*/
132+
async fixPrerequisiteData() {
133+
this.ctSchema = (await new ContentType({
134+
fix: true,
135+
log: () => {},
136+
config: this.config,
137+
moduleName: 'content-types',
138+
ctSchema: this.ctSchema,
139+
gfSchema: this.gfSchema,
140+
}).run(true)) as ContentTypeStruct[];
141+
this.gfSchema = (await new ContentType({
142+
fix: true,
143+
log: () => {},
144+
config: this.config,
145+
moduleName: 'entries',
146+
ctSchema: this.ctSchema,
147+
gfSchema: this.gfSchema,
148+
}).run(true)) as ContentTypeStruct[];
135149
}
136150

137151
/**
@@ -449,13 +463,14 @@ export default class Entries {
449463
if (data_type === 'json') {
450464
if (field.field_metadata.extension) {
451465
// NOTE Custom field type
452-
return field;
466+
break;
453467
} else if (field.field_metadata.allow_json_rte) {
454-
return this.fixJsonRteMissingReferences(
468+
this.fixJsonRteMissingReferences(
455469
[...tree, { uid: field.uid, name: field.display_name, data_type: field.data_type }],
456470
field as JsonRTEFieldDataType,
457471
entry[uid] as EntryJsonRTEFieldDataType,
458472
);
473+
break;
459474
}
460475
}
461476

@@ -464,7 +479,7 @@ export default class Entries {
464479
[...tree, { uid: field.uid, name: field.display_name, data_type: field.data_type }],
465480
field as ReferenceFieldDataType,
466481
entry[uid] as EntryReferenceFieldDataType[],
467-
) as EntryReferenceFieldDataType[];
482+
);
468483
break;
469484
case 'blocks':
470485
entry[uid] = this.fixModularBlocksReferences(
@@ -541,7 +556,7 @@ export default class Entries {
541556

542557
return eBlock;
543558
})
544-
.filter((val) => !isEmpty(val)) as EntryModularBlocksDataType[];
559+
.filter((val) => !isEmpty(val));
545560
});
546561

547562
return entry;
@@ -604,11 +619,7 @@ export default class Entries {
604619
) {
605620
if (Array.isArray(entry)) {
606621
entry = entry.map((child: any, index) => {
607-
return this.fixJsonRteMissingReferences(
608-
[...tree, { index, type: (child as any)?.type, uid: child?.uid }],
609-
field,
610-
child,
611-
);
622+
return this.fixJsonRteMissingReferences([...tree, { index, type: child?.type, uid: child?.uid }], field, child);
612623
}) as EntryJsonRTEFieldDataType[];
613624
} else {
614625
entry.children = entry.children
@@ -669,7 +680,7 @@ export default class Entries {
669680
data_type: field.data_type,
670681
display_name: field.display_name,
671682
treeStr: tree
672-
.map(({ name, index }) => (index || index === 0 ? `[${index}].${name}` : name))
683+
.map(({ name, index }) => (index || index === 0 ? `[${+index}].${name}` : name))
673684
.filter((val) => val)
674685
.join(' ➜ '),
675686
missingRefs,
@@ -697,7 +708,7 @@ export default class Entries {
697708
tree: Record<string, unknown>[],
698709
blocks: ModularBlockType[],
699710
entryBlock: EntryModularBlocksDataType,
700-
index: Number,
711+
index: number,
701712
) {
702713
const validBlockUid = blocks.map((block) => block.uid);
703714
const invalidKeys = Object.keys(entryBlock).filter((key) => !validBlockUid.includes(key));
@@ -715,7 +726,7 @@ export default class Entries {
715726
fixStatus: this.fix ? 'Fixed' : undefined,
716727
tree: [...tree, { index, uid: key, name: key }],
717728
treeStr: [...tree, { index, uid: key, name: key }]
718-
.map(({ name, index }) => (index || index === 0 ? `[${index}].${name}` : name))
729+
.map(({ name, index }) => (index || index === 0 ? `[${+index}].${name}` : name))
719730
.filter((val) => val)
720731
.join(' ➜ '),
721732
missingRefs: [key],
@@ -775,8 +786,8 @@ export default class Entries {
775786
const localesFolderPath = resolve(this.config.basePath, this.config.moduleConfig.locales.dirName);
776787
const localesPath = join(localesFolderPath, this.config.moduleConfig.locales.fileName);
777788
const masterLocalesPath = join(localesFolderPath, 'master-locale.json');
778-
this.locales = values(JSON.parse(readFileSync(masterLocalesPath, 'utf-8')));
779-
this.locales.push(...values(JSON.parse(readFileSync(localesPath, 'utf-8'))));
789+
this.locales = values(JSON.parse(readFileSync(masterLocalesPath, 'utf8')));
790+
this.locales.push(...values(JSON.parse(readFileSync(localesPath, 'utf8'))));
780791

781792
for (const { code } of this.locales) {
782793
for (const { uid } of this.ctSchema) {

packages/contentstack-auth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth
1818
$ csdx COMMAND
1919
running command...
2020
$ csdx (--version)
21-
@contentstack/cli-auth/1.3.15 darwin-arm64 node-v20.8.0
21+
@contentstack/cli-auth/1.3.16 darwin-arm64 node-v21.1.0
2222
$ csdx --help [COMMAND]
2323
USAGE
2424
$ csdx COMMAND

packages/contentstack-auth/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-auth",
33
"description": "Contentstack CLI plugin for authentication activities",
4-
"version": "1.3.15",
4+
"version": "1.3.16",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {
@@ -22,8 +22,8 @@
2222
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
2323
},
2424
"dependencies": {
25-
"@contentstack/cli-command": "~1.2.13",
26-
"@contentstack/cli-utilities": "~1.5.4",
25+
"@contentstack/cli-command": "~1.2.15",
26+
"@contentstack/cli-utilities": "~1.5.5",
2727
"chalk": "^4.0.0",
2828
"debug": "^4.1.1",
2929
"inquirer": "8.2.4",

packages/contentstack-bootstrap/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
1515
$ csdx COMMAND
1616
running command...
1717
$ csdx (--version)
18-
@contentstack/cli-cm-bootstrap/1.6.0 darwin-arm64 node-v20.8.0
18+
@contentstack/cli-cm-bootstrap/1.6.1 darwin-arm64 node-v21.1.0
1919
$ csdx --help [COMMAND]
2020
USAGE
2121
$ csdx COMMAND

packages/contentstack-bootstrap/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-bootstrap",
33
"description": "Bootstrap contentstack apps",
4-
"version": "1.6.0",
4+
"version": "1.6.1",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {
@@ -17,9 +17,9 @@
1717
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
1818
},
1919
"dependencies": {
20-
"@contentstack/cli-cm-seed": "~1.6.0",
21-
"@contentstack/cli-command": "~1.2.14",
22-
"@contentstack/cli-utilities": "~1.5.4",
20+
"@contentstack/cli-cm-seed": "~1.6.1",
21+
"@contentstack/cli-command": "~1.2.15",
22+
"@contentstack/cli-utilities": "~1.5.5",
2323
"inquirer": "8.2.4",
2424
"mkdirp": "^1.0.4",
2525
"tar": "^6.1.13"

packages/contentstack-branches/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches
3737
$ csdx COMMAND
3838
running command...
3939
$ csdx (--version)
40-
@contentstack/cli-cm-branches/1.0.15 darwin-arm64 node-v20.3.1
40+
@contentstack/cli-cm-branches/1.0.16 darwin-arm64 node-v21.1.0
4141
$ csdx --help [COMMAND]
4242
USAGE
4343
$ csdx COMMAND

0 commit comments

Comments
 (0)