Skip to content

Commit 0dc54b1

Browse files
committed
udpated schema json to indvidual content type files
1 parent 4fad3c6 commit 0dc54b1

11 files changed

Lines changed: 298 additions & 380 deletions

File tree

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fileignoreconfig:
1515
- filename: pnpm-lock.yaml
1616
checksum: 454f794a75f7d972451575ac5d7d208f691acd776fd01fe9f0d3277ae1142d10
1717
- filename: package-lock.json
18-
checksum: 6585e1ce86e49a60e3593d926180e0bf4e151f9ff989d44841410eee2fab59a4
18+
checksum: 232dc3c29b538cc900979dbcddbede259430cefc2212da775c5aa8fc2739dcea
1919
- filename: packages/contentstack-export/test/unit/export/modules/taxonomies.test.ts
2020
checksum: f6175a8e89fb9dde4b0ff269d65a9e42c4374ef7efb1b828e54e2ebd7c4379fa
2121
- filename: packages/contentstack-export/test/unit/export/modules/workflows.test.ts

package-lock.json

Lines changed: 236 additions & 343 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: 13 additions & 11 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/2.0.0-beta.1 darwin-arm64 node-v24.12.0
22+
@contentstack/cli-audit/2.0.0-beta.2 darwin-arm64 node-v22.13.1
2323
$ csdx --help [COMMAND]
2424
USAGE
2525
$ csdx COMMAND
@@ -41,13 +41,14 @@ Perform audits and find possible errors in the exported Contentstack data
4141
```
4242
USAGE
4343
$ csdx cm:stacks:audit [-c <value>] [-d <value>] [--show-console-output] [--report-path <value>] [--modules
44-
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules...] [--columns <value>]
45-
[--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
44+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules|composable-studio...]
45+
[--columns <value>] [--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output
46+
csv|json|yaml]
4647
4748
FLAGS
4849
--modules=<option>... Provide the list of modules to be audited
49-
<options:
50-
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules>
50+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-ru
51+
les|composable-studio>
5152
--report-path=<value> Path to store the audit reports
5253
5354
COMMON FLAGS
@@ -89,18 +90,19 @@ Perform audits and fix possible errors in the exported Contentstack data.
8990
```
9091
USAGE
9192
$ csdx cm:stacks:audit:fix [-c <value>] [-d <value>] [--show-console-output] [--report-path <value>] [--modules
92-
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules...] [--copy-path <value>
93-
--copy-dir] [--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types...] [--columns
94-
<value>] [--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
93+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules|composable-studio...]
94+
[--copy-path <value> --copy-dir] [--fix-only
95+
reference|global_field|json:rte|json:extension|blocks|group|content_types...] [--columns <value>] [--sort <value>]
96+
[--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]
9597
9698
FLAGS
9799
--copy-dir Create backup from the original data.
98100
--copy-path=<value> Provide the path to backup the copied data
99101
--fix-only=<option>... Provide the list of fix options
100102
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
101103
--modules=<option>... Provide the list of modules to be audited
102-
<options:
103-
content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules>
104+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-r
105+
ules|composable-studio>
104106
--report-path=<value> Path to store the audit reports
105107
106108
COMMON FLAGS
@@ -155,5 +157,5 @@ DESCRIPTION
155157
Display help for csdx.
156158
```
157159

158-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.36/src/commands/help.ts)_
160+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.37/src/commands/help.ts)_
159161
<!-- commandsstop -->

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { v4 as uuid } from 'uuid';
55
import isEmpty from 'lodash/isEmpty';
66
import { join, resolve } from 'path';
77
import cloneDeep from 'lodash/cloneDeep';
8-
import { cliux, sanitizePath, TableFlags, TableHeader, log, configHandler, CLIProgressManager, clearProgressModuleSetting } from '@contentstack/cli-utilities';
8+
import { cliux, sanitizePath, TableFlags, TableHeader, log, configHandler, CLIProgressManager, clearProgressModuleSetting, readContentTypeSchemas } from '@contentstack/cli-utilities';
99
import { createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'fs';
1010
import config from './config';
1111
import { print } from './util/log';
@@ -480,10 +480,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
480480
* `gfSchema`. The values of these properties are the parsed JSON data from two different files.
481481
*/
482482
getCtAndGfSchema() {
483-
const ctPath = join(
483+
const ctDirPath = join(
484484
this.sharedConfig.basePath,
485485
this.sharedConfig.moduleConfig['content-types'].dirName,
486-
this.sharedConfig.moduleConfig['content-types'].fileName,
487486
);
488487
const gfPath = join(
489488
this.sharedConfig.basePath,
@@ -492,7 +491,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
492491
);
493492

494493
const gfSchema = existsSync(gfPath) ? (JSON.parse(readFileSync(gfPath, 'utf8')) as ContentTypeStruct[]) : [];
495-
const ctSchema = existsSync(ctPath) ? (JSON.parse(readFileSync(ctPath, 'utf8')) as ContentTypeStruct[]) : [];
494+
const ctSchema = readContentTypeSchemas(ctDirPath) as ContentTypeStruct[];
496495

497496
return { ctSchema, gfSchema };
498497
}

packages/contentstack-audit/src/config/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const config = {
1818
moduleConfig: {
1919
'content-types': {
2020
name: 'content type',
21-
fileName: 'schema.json',
21+
fileName: 'schema.json', // Not used - reads from individual files
2222
dirName: 'content_types',
2323
},
2424
'global-fields': {

packages/contentstack-export/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export
4848
$ csdx COMMAND
4949
running command...
5050
$ csdx (--version)
51-
@contentstack/cli-cm-export/2.0.0-beta.5 darwin-arm64 node-v24.12.0
51+
@contentstack/cli-cm-export/2.0.0-beta.6 darwin-arm64 node-v22.13.1
5252
$ csdx --help [COMMAND]
5353
USAGE
5454
$ csdx COMMAND

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,5 @@ export default class ContentTypesExport extends BaseClass {
155155
await executeTask(contentTypes, writeWithProgress.bind(this), {
156156
concurrency: this.exportConfig.writeConcurrency,
157157
});
158-
159-
const schemaFilePath = path.join(this.contentTypesDirPath, 'schema.json');
160-
log.debug(`Writing aggregate schema to: ${schemaFilePath}`, this.exportConfig.context);
161-
162-
return fsUtil.writeFile(schemaFilePath, contentTypes);
163158
}
164159
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import { ContentstackClient, FsUtility, handleAndLogError, messageHandler, log } from '@contentstack/cli-utilities';
2+
import { ContentstackClient, FsUtility, handleAndLogError, messageHandler, log, readContentTypeSchemas } from '@contentstack/cli-utilities';
33
import { Export, ExportProjects } from '@contentstack/cli-variants';
44
import { sanitizePath } from '@contentstack/cli-utilities';
55

@@ -30,7 +30,7 @@ export default class EntriesExport extends BaseClass {
3030
private variantEntries!: any;
3131
private entriesDirPath: string;
3232
private localesFilePath: string;
33-
private schemaFilePath: string;
33+
private contentTypesDirPath: string;
3434
private entriesFileHelper: FsUtility;
3535
private projectInstance: ExportProjects;
3636
public exportVariantEntry: boolean = false;
@@ -51,11 +51,10 @@ export default class EntriesExport extends BaseClass {
5151
sanitizePath(exportConfig.modules.locales.dirName),
5252
sanitizePath(exportConfig.modules.locales.fileName),
5353
);
54-
this.schemaFilePath = path.resolve(
54+
this.contentTypesDirPath = path.resolve(
5555
sanitizePath(exportConfig.exportDir),
5656
sanitizePath(exportConfig.branchName || ''),
5757
sanitizePath(exportConfig.modules.content_types.dirName),
58-
'schema.json',
5958
);
6059
this.projectInstance = new ExportProjects(this.exportConfig);
6160
this.exportConfig.context.module = MODULE_CONTEXTS.ENTRIES;
@@ -70,7 +69,7 @@ export default class EntriesExport extends BaseClass {
7069
const [locales, contentTypes, entryRequestOptions, totalEntriesCount, variantInfo] =
7170
await this.withLoadingSpinner('ENTRIES: Analyzing content structure and entries...', async () => {
7271
const locales = fsUtil.readFile(this.localesFilePath) as Array<Record<string, unknown>>;
73-
const contentTypes = fsUtil.readFile(this.schemaFilePath) as Array<Record<string, unknown>>;
72+
const contentTypes = readContentTypeSchemas(this.contentTypesDirPath);
7473

7574
if (!Array.isArray(locales) || locales?.length === 0) {
7675
log.debug(`No locales found in ${this.localesFilePath}`, this.exportConfig.context);
@@ -83,7 +82,7 @@ export default class EntriesExport extends BaseClass {
8382
return [locales, contentTypes, [], 0, null];
8483
}
8584
log.debug(
86-
`Loaded ${contentTypes?.length} content types from ${this.schemaFilePath}`,
85+
`Loaded ${contentTypes?.length} content types from individual files in ${this.contentTypesDirPath}`,
8786
this.exportConfig.context,
8887
);
8988

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import * as path from 'path';
99
import { find, cloneDeep, map } from 'lodash';
10-
import { sanitizePath, log, handleAndLogError } from '@contentstack/cli-utilities';
10+
import { sanitizePath, log, handleAndLogError, readContentTypeSchemas } from '@contentstack/cli-utilities';
1111
import { ImportConfig, ModuleClassParams } from '../../types';
1212
import BaseClass, { ApiOptions } from './base-class';
1313
import { updateFieldRules } from '../../utils/content-type-helper';
@@ -475,7 +475,7 @@ export default class ContentTypesImport extends BaseClass {
475475
const [cts, gfs, pendingGfs, pendingExt] = await this.withLoadingSpinner(
476476
'CONTENT TYPES: Analyzing import data...',
477477
async () => {
478-
const cts = fsUtil.readFile(path.join(this.cTsFolderPath, 'schema.json'));
478+
const cts = readContentTypeSchemas(this.cTsFolderPath);
479479
const gfs = fsUtil.readFile(path.resolve(this.gFsFolderPath, this.gFsConfig.fileName));
480480
const pendingGfs = fsUtil.readFile(this.gFsPendingPath);
481481
const pendingExt = fsUtil.readFile(this.extPendingPath);

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import * as path from 'path';
88
import { writeFileSync } from 'fs';
99
import { isEmpty, values, cloneDeep, find, indexOf, forEach, remove } from 'lodash';
10-
import { FsUtility, sanitizePath, log, handleAndLogError } from '@contentstack/cli-utilities';
10+
import { FsUtility, sanitizePath, log, handleAndLogError, readContentTypeSchemas } from '@contentstack/cli-utilities';
1111
import {
1212
fsUtil,
1313
lookupExtension,
@@ -231,7 +231,8 @@ export default class EntriesImport extends BaseClass {
231231
return this.withLoadingSpinner('ENTRIES: Analyzing import data...', async () => {
232232
log.debug('Loading content types for entry analysis', this.importConfig.context);
233233

234-
this.cTs = fsUtil.readFile(path.join(this.cTsPath, 'schema.json')) as Record<string, unknown>[];
234+
this.cTs = readContentTypeSchemas(this.cTsPath);
235+
235236
if (!this.cTs || isEmpty(this.cTs)) {
236237
return [0, 0, 0, 0, 0];
237238
}
@@ -1205,10 +1206,8 @@ export default class EntriesImport extends BaseClass {
12051206
for (let cTUid of cTsWithFieldRules) {
12061207
log.debug(`Processing field rules for content type: ${cTUid}`, this.importConfig.context);
12071208

1208-
const cTs: Record<string, any>[] = fsUtil.readFile(path.join(this.cTsPath, 'schema.json')) as Record<
1209-
string,
1210-
unknown
1211-
>[];
1209+
// Read content types from individual files
1210+
const cTs = readContentTypeSchemas(this.cTsPath);
12121211
const contentType: any = find(cTs, { uid: cTUid });
12131212

12141213
if (contentType.field_rules) {

0 commit comments

Comments
 (0)