Skip to content

Commit 9c30891

Browse files
Merge pull request #1954 from contentstack/staging
DX | 09-06-2025 | Release
2 parents 85d1151 + c803b75 commit 9c30891

File tree

63 files changed

+18302
-15165
lines changed

Some content is hidden

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

63 files changed

+18302
-15165
lines changed

.github/workflows/unit-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
- name: Run tests for Contentstack Export To CSV
4040
working-directory: ./packages/contentstack-export-to-csv
4141
run: npm run test:unit
42+
43+
- name: Run tests for Contentstack Bootstrap
44+
working-directory: ./packages/contentstack-bootstrap
45+
run: npm run test
4246
# - name: Fetch latest references
4347
# run: |
4448
# git fetch --prune

.talismanrc

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,28 @@ fileignoreconfig:
110110
checksum: 8cbd32dbbd2989c7c082f8a0b7615916125d211bce25531e9a882b8ebd5674af
111111
- filename: .husky/pre-commit
112112
checksum: 7a12030ddfea18d6f85edc25f1721fb2009df00fdd42bab66b05de25ab3e32b2
113+
- filename: packages/contentstack-bootstrap/src/bootstrap/utils.ts
114+
checksum: 0b0af505ce1a74eb8df519f106291e319eb3ea74003ca63e03527f59a8821d39
115+
- filename: packages/contentstack-bootstrap/test/bootstrap.test.js
116+
checksum: 5f0355a5048183d61b605cbc160e6727a9de32832d9159e903fee49f9ab751d5
113117
- filename: packages/contentstack/package.json
114118
checksum: 9b0fdd100effcdbb5ee3809f7f102bfd11c88dd76e49db5103434f3aa29473dd
115119
- filename: pnpm-lock.yaml
116-
checksum: 2edf846869b73d6fd640d9f660f9fdd664e721946a891554dad5297c75a1bfba
117-
- filename: package-lock.json
118-
checksum: 0c00a0335d48791b0736aae44c900c3e729de728c0bb62489d0697c9a2ed4200
120+
checksum: 579849ef155d487ed7d1a8d30dab6ea906da2d571c725b3b033543a9a609f75c
121+
- filename: packages/contentstack-audit/src/audit-base-command.ts
122+
checksum: bd99d269c0b6694577f4751fa96b3d85856e41bbef624b4ec1196630d6c1d168
119123
- filename: packages/contentstack-migrate-rte/test/commands/json-migration.test.js
120124
checksum: 1f5ee5b39119667bd4830f9dbbbf757fb922f4ec3b7f6fad06bbfbf214fe7f73
121-
version: '1.0'
125+
- filename: packages/contentstack-bootstrap/src/bootstrap/utils.ts
126+
checksum: 0b0af505ce1a74eb8df519f106291e319eb3ea74003ca63e03527f59a8821d39
127+
- filename: packages/contentstack-bootstrap/test/bootstrap.test.js
128+
checksum: 5f0355a5048183d61b605cbc160e6727a9de32832d9159e903fee49f9ab751d5
129+
- filename: package-lock.json
130+
checksum: 35c1a3c35a923ddf97a42edc85708a1bee9352710ebe135b6be6a32c95bde908
131+
- filename: packages/contentstack-utilities/test/unit/logger.test.ts
132+
checksum: c773181ea55c49d91363adacf0424b84c927e3cffd6bef1444ec2559ddf1b3b0
133+
- filename: packages/contentstack-utilities/src/logger/cliErrorHandler.ts
134+
checksum: 023cf08f215cd0778599fb8478c94419373d4687f04421c4eb99d87de86a4a3e
135+
- filename: packages/contentstack-utilities/src/logger/logger.ts
136+
checksum: 09f3b73dd995bafc253265c676f06308513e6b1842d9bc01d39e6b6945a54c7d
137+
version: "1.0"

package-lock.json

Lines changed: 11940 additions & 9117 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: 9 additions & 9 deletions
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.12.1 darwin-arm64 node-v22.14.0
22+
@contentstack/cli-audit/1.13.0 darwin-arm64 node-v22.14.0
2323
$ csdx --help [COMMAND]
2424
USAGE
2525
$ csdx COMMAND
@@ -282,7 +282,7 @@ DESCRIPTION
282282
Display help for csdx.
283283
```
284284

285-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.27/src/commands/help.ts)_
285+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.28/src/commands/help.ts)_
286286

287287
## `csdx plugins`
288288

@@ -305,7 +305,7 @@ EXAMPLES
305305
$ csdx plugins
306306
```
307307

308-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/index.ts)_
308+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.39/src/commands/plugins/index.ts)_
309309

310310
## `csdx plugins:add PLUGIN`
311311

@@ -379,7 +379,7 @@ EXAMPLES
379379
$ csdx plugins:inspect myplugin
380380
```
381381

382-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/inspect.ts)_
382+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.39/src/commands/plugins/inspect.ts)_
383383

384384
## `csdx plugins:install PLUGIN`
385385

@@ -428,7 +428,7 @@ EXAMPLES
428428
$ csdx plugins:install someuser/someplugin
429429
```
430430

431-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/install.ts)_
431+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.39/src/commands/plugins/install.ts)_
432432

433433
## `csdx plugins:link PATH`
434434

@@ -459,7 +459,7 @@ EXAMPLES
459459
$ csdx plugins:link myplugin
460460
```
461461

462-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/link.ts)_
462+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.39/src/commands/plugins/link.ts)_
463463

464464
## `csdx plugins:remove [PLUGIN]`
465465

@@ -500,7 +500,7 @@ FLAGS
500500
--reinstall Reinstall all plugins after uninstalling.
501501
```
502502

503-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/reset.ts)_
503+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.39/src/commands/plugins/reset.ts)_
504504

505505
## `csdx plugins:uninstall [PLUGIN]`
506506

@@ -528,7 +528,7 @@ EXAMPLES
528528
$ csdx plugins:uninstall myplugin
529529
```
530530

531-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/uninstall.ts)_
531+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.39/src/commands/plugins/uninstall.ts)_
532532

533533
## `csdx plugins:unlink [PLUGIN]`
534534

@@ -572,5 +572,5 @@ DESCRIPTION
572572
Update installed plugins.
573573
```
574574

575-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/update.ts)_
575+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.39/src/commands/plugins/update.ts)_
576576
<!-- commandsstop -->

packages/contentstack-audit/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-audit",
3-
"version": "1.12.1",
3+
"version": "1.13.0",
44
"description": "Contentstack audit plugin",
55
"author": "Contentstack CLI",
66
"homepage": "https://github.com/contentstack/cli",
@@ -19,8 +19,8 @@
1919
],
2020
"dependencies": {
2121
"@contentstack/cli-command": "~1.5.0",
22-
"@oclif/plugin-help": "^6.2.27",
23-
"@contentstack/cli-utilities": "~1.11.1",
22+
"@oclif/plugin-help": "^6.2.28",
23+
"@contentstack/cli-utilities": "~1.12.0",
2424
"@oclif/plugin-plugins": "^5.4.36",
2525
"chalk": "^4.1.2",
2626
"fast-csv": "^4.3.6",
@@ -30,19 +30,19 @@
3030
"winston": "^3.17.0"
3131
},
3232
"devDependencies": {
33-
"@oclif/test": "^4.1.12",
33+
"@oclif/test": "^4.1.13",
3434
"@types/chai": "^4.3.20",
3535
"@types/fs-extra": "^11.0.4",
3636
"@types/mocha": "^10.0.10",
37-
"@types/node": "^20.17.30",
37+
"@types/node": "^20.17.50",
3838
"@types/uuid": "^9.0.8",
3939
"chai": "^4.5.0",
4040
"eslint": "^8.57.1",
41-
"eslint-config-oclif": "^6.0.42",
41+
"eslint-config-oclif": "^6.0.62",
4242
"eslint-config-oclif-typescript": "^3.1.14",
4343
"mocha": "^10.8.2",
4444
"nyc": "^15.1.0",
45-
"oclif": "^4.17.43",
45+
"oclif": "^4.17.46",
4646
"shx": "^0.4.0",
4747
"sinon": "^19.0.5",
4848
"ts-node": "^10.9.2",

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
259259

260260
break;
261261
case 'field-rules':
262+
// NOTE: We are using the fixed content-type for validation of field rules
263+
const data = this.getCtAndGfSchema();
264+
constructorParam.ctSchema = data.ctSchema;
265+
constructorParam.gfSchema = data.gfSchema;
262266
missingFieldRules = await new FieldRule(cloneDeep(constructorParam)).run();
263267
await this.prepareReport(module, missingFieldRules);
264268
this.getAffectedData('field-rules', dataModuleWise['content-types'], missingFieldRules);
@@ -456,7 +460,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
456460
key === 'missingCTSelectFieldValues' ||
457461
key === 'missingFieldUid' ||
458462
key === 'action' ||
459-
key === 'Non-Fixable' ||
463+
key === 'Non-Fixable' ||
460464
key === 'Not-Fixed'
461465
) {
462466
return chalk.red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);

packages/contentstack-audit/src/modules/content-types.ts

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export default class ContentType {
149149
*/
150150
async writeFixContent() {
151151
let canWrite = true;
152-
152+
153153
if (!this.inMemoryFix && this.fix) {
154154
if (!this.config.flags['copy-dir'] && !this.config.flags['external-config']?.skipConfirm) {
155155
canWrite = this.config.flags.yes ?? (await cliux.confirm(commonMsg.FIX_CONFIRMATION));
@@ -301,18 +301,35 @@ export default class ContentType {
301301
*/
302302
async validateGlobalField(tree: Record<string, unknown>[], field: GlobalFieldDataType): Promise<void> {
303303
// NOTE Any GlobalField related logic can be added here
304-
if (!field.schema && !this.fix) {
305-
this.missingRefs[this.currentUid].push({
306-
tree,
307-
ct_uid: this.currentUid,
308-
name: this.currentTitle,
309-
data_type: field.data_type,
310-
display_name: field.display_name,
311-
missingRefs: 'Empty schema found',
312-
treeStr: tree.map(({ name }) => name).join(' ➜ '),
313-
});
304+
if (this.moduleName === 'global-fields') {
305+
let { reference_to } = field;
306+
const refExist = find(this.schema, { uid: reference_to });
307+
if (!refExist) {
308+
this.missingRefs[this.currentUid].push({
309+
tree,
310+
ct: this.currentUid,
311+
name: this.currentTitle,
312+
data_type: field.data_type,
313+
display_name: field.display_name,
314+
missingRefs: 'Referred Global Field Does not Exist',
315+
treeStr: tree.map(({ name }) => name).join(' ➜ '),
316+
});
317+
return void 0;
318+
}
319+
} else if (this.moduleName === 'content-types') {
320+
if (!field.schema && !this.fix) {
321+
this.missingRefs[this.currentUid].push({
322+
tree,
323+
ct_uid: this.currentUid,
324+
name: this.currentTitle,
325+
data_type: field.data_type,
326+
display_name: field.display_name,
327+
missingRefs: 'Empty schema found',
328+
treeStr: tree.map(({ name }) => name).join(' ➜ '),
329+
});
314330

315-
return void 0;
331+
return void 0;
332+
}
316333
}
317334

318335
await this.lookForReference(tree, field);
@@ -443,7 +460,7 @@ export default class ContentType {
443460
runFixOnSchema(tree: Record<string, unknown>[], schema: ContentTypeSchemaType[]) {
444461
// NOTE Global field Fix
445462
return schema
446-
.map((field) => {
463+
?.map((field) => {
447464
const { data_type } = field;
448465
const fixTypes = this.config.flags['fix-only'] ?? this.config['fix-fields'];
449466

@@ -524,12 +541,11 @@ export default class ContentType {
524541
missingRefs: [reference_to],
525542
treeStr: tree.map(({ name }) => name).join(' ➜ '),
526543
});
527-
} else if (!field.schema) {
544+
} else if (!field.schema && this.moduleName === 'content-types') {
528545
const gfSchema = find(this.gfSchema, { uid: field.reference_to })?.schema;
529-
530546
if (gfSchema) {
531547
field.schema = gfSchema as GlobalFieldSchemaTypes[];
532-
548+
} else {
533549
this.missingRefs[this.currentUid].push({
534550
tree,
535551
data_type,
@@ -541,8 +557,27 @@ export default class ContentType {
541557
treeStr: tree.map(({ name }) => name).join(' ➜ '),
542558
});
543559
}
560+
} else if (!field.schema && this.moduleName === 'global-fields') {
561+
const gfSchema = find(this.gfSchema, { uid: field.reference_to })?.schema;
562+
if (gfSchema) {
563+
field.schema = gfSchema as GlobalFieldSchemaTypes[];
564+
} else {
565+
this.missingRefs[this.currentUid].push({
566+
tree,
567+
data_type,
568+
display_name,
569+
fixStatus: 'Fixed',
570+
ct_uid: this.currentUid,
571+
name: this.currentTitle,
572+
missingRefs: 'Referred Global Field Does not exist',
573+
treeStr: tree.map(({ name }) => name).join(' ➜ '),
574+
});
575+
}
544576
}
545577

578+
if(field.schema && !isEmpty(field.schema)){
579+
field.schema = this.runFixOnSchema(tree, field.schema as ContentTypeSchemaType[]);
580+
}
546581
return refExist ? field : null;
547582
}
548583

@@ -559,7 +594,7 @@ export default class ContentType {
559594
*/
560595
fixModularBlocksReferences(tree: Record<string, unknown>[], blocks: ModularBlockType[]) {
561596
return blocks
562-
.map((block) => {
597+
?.map((block) => {
563598
const { reference_to, schema, title: display_name } = block;
564599
tree = [...tree, { uid: block.uid, name: block.title }];
565600
const refErrorObj = {
@@ -572,7 +607,7 @@ export default class ContentType {
572607
treeStr: tree.map(({ name }) => name).join(' ➜ '),
573608
};
574609

575-
if (!schema) {
610+
if (!schema && this.moduleName === 'content-types') {
576611
this.missingRefs[this.currentUid].push(refErrorObj);
577612

578613
return false;
@@ -581,7 +616,11 @@ export default class ContentType {
581616
// NOTE Global field section
582617
if (reference_to) {
583618
const refExist = find(this.gfSchema, { uid: reference_to });
619+
if (!refExist) {
620+
this.missingRefs[this.currentUid].push(refErrorObj);
584621

622+
return false;
623+
}
585624
if (!refExist) {
586625
this.missingRefs[this.currentUid].push(refErrorObj);
587626

@@ -591,7 +630,7 @@ export default class ContentType {
591630

592631
block.schema = this.runFixOnSchema(tree, block.schema as ContentTypeSchemaType[]);
593632

594-
if (isEmpty(block.schema)) {
633+
if (isEmpty(block.schema) && this.moduleName === 'content-types') {
595634
this.missingRefs[this.currentUid].push({
596635
...refErrorObj,
597636
missingRefs: 'Empty schema found',

0 commit comments

Comments
 (0)