Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ fileignoreconfig:
- filename: packages/contentstack/package.json
checksum: 9b0fdd100effcdbb5ee3809f7f102bfd11c88dd76e49db5103434f3aa29473dd
- filename: pnpm-lock.yaml
checksum: 85b652e6a8d386a7209294e67f91a570dbf9f96be396995d44cf4dbb54d073a4
checksum: d1ac3746440f92fdf23f07fcbe3266ee7ac5ad5ce1b7d16108b593b352e5e719
- filename: package-lock.json
checksum: c1556f7d4bcc426e0b821961b922a465c9f1cf8ef38e858e8beeeb591356746b
checksum: cbb0db266f55fac87a85c72371a7791cf16a7d4dc6d2165826e2fcc8c50aa967
- filename: packages/contentstack-audit/src/audit-base-command.ts
checksum: 4544ad2869041340969c66500268c61f969e2ad907891c9a62b94fdae47134de
- filename: packages/contentstack-migrate-rte/test/commands/json-migration.test.js
Expand Down
570 changes: 286 additions & 284 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
"dependencies": {
"@colors/colors": "^1.6.0",
"@contentstack/cli-cm-export": "~1.16.1",
"@contentstack/cli-cm-export": "~1.16.2",
"@contentstack/cli-cm-import": "~1.22.0",
"@contentstack/cli-command": "~1.5.0",
"@contentstack/cli-utilities": "~1.11.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-export",
"description": "Contentstack CLI plugin to export content from stack",
"version": "1.16.1",
"version": "1.16.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class GlobalFieldsExport extends BaseClass {
asc: string;
skip?: number;
limit?: number;
include_global_field_schema?: boolean;
};
private globalFieldsConfig: {
dirName?: string;
Expand All @@ -34,6 +35,7 @@ export default class GlobalFieldsExport extends BaseClass {
asc: 'updated_at',
include_count: true,
limit: this.globalFieldsConfig.limit,
include_global_field_schema: true
};
this.globalFieldsDirPath = path.resolve(
sanitizePath(exportConfig.data),
Expand Down
138 changes: 70 additions & 68 deletions packages/contentstack-import/src/utils/content-type-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,78 +86,80 @@ export const removeReferenceFields = async function (
flag = { supressed: false },
stackAPIClient: any,
): Promise<boolean | void> {
for (let i = 0; i < schema.length; i++) {
if (schema[i].data_type === 'group') {
await removeReferenceFields(schema[i].schema, flag, stackAPIClient);
} else if (schema[i].data_type === 'blocks') {
for (var block in schema[i].blocks) {
await removeReferenceFields(schema[i].blocks[block].schema, flag, stackAPIClient);
}
} else if (schema[i].data_type === 'reference') {
flag.supressed = true;
// Check if content-type exists
// If exists, then no change should be required.
let isContentTypeError = false;
for (let j = 0; j < schema[i].reference_to.length; j++) {
try {
await stackAPIClient.contentType(schema[i].reference_to[j]).fetch();
} catch (error) {
// Else warn and modify the schema object.
isContentTypeError = true;
console.warn(`Content-type ${schema[i].reference_to[j]} does not exist. Removing the field from schema`);
if (schema?.length) {
for (let i = 0; i < schema.length; i++) {
if (schema[i].data_type === 'group') {
await removeReferenceFields(schema[i].schema, flag, stackAPIClient);
} else if (schema[i].data_type === 'blocks') {
for (var block in schema[i].blocks) {
await removeReferenceFields(schema[i].blocks[block].schema, flag, stackAPIClient);
}
}
if (isContentTypeError) {
schema.splice(i, 1);
--i;
if (schema.length < 1) {
schema.push({
data_type: 'text',
display_name: 'dummyTest',
uid: 'dummy_test',
field_metadata: {
description: '',
default_value: '',
version: 3,
},
format: '',
error_messages: {
} else if (schema[i].data_type === 'reference') {
flag.supressed = true;
// Check if content-type exists
// If exists, then no change should be required.
let isContentTypeError = false;
for (let j = 0; j < schema[i].reference_to.length; j++) {
try {
await stackAPIClient.contentType(schema[i].reference_to[j]).fetch();
} catch (error) {
// Else warn and modify the schema object.
isContentTypeError = true;
console.warn(`Content-type ${schema[i].reference_to[j]} does not exist. Removing the field from schema`);
}
}
if (isContentTypeError) {
schema.splice(i, 1);
--i;
if (schema.length < 1) {
schema.push({
data_type: 'text',
display_name: 'dummyTest',
uid: 'dummy_test',
field_metadata: {
description: '',
default_value: '',
version: 3,
},
format: '',
},
multiple: false,
mandatory: false,
unique: false,
non_localizable: false,
});
error_messages: {
format: '',
},
multiple: false,
mandatory: false,
unique: false,
non_localizable: false,
});
}
}
} else if (
// handling entry references in json rte
schema[i].data_type === 'json' &&
schema[i].field_metadata.allow_json_rte &&
schema[i].field_metadata.embed_entry &&
schema[i].reference_to.length > 1
) {
flag.supressed = true;
schema[i].reference_to = ['sys_assets'];
} else if (
// handling entry references in json rte
schema[i].data_type === 'json' &&
schema[i]?.field_metadata?.rich_text_type &&
schema[i]?.field_metadata?.embed_entry &&
schema[i]?.reference_to?.length > 1
) {
flag.supressed = true;
schema[i].reference_to = ['sys_assets'];
} else if (
// handling entry references in rte
schema[i].data_type === 'text' &&
schema[i]?.field_metadata?.rich_text_type &&
schema[i]?.field_metadata?.embed_entry &&
schema[i]?.reference_to?.length >= 1
) {
flag.supressed = true;
schema[i].reference_to = ['sys_assets'];
}
} else if (
// handling entry references in json rte
schema[i].data_type === 'json' &&
schema[i].field_metadata.allow_json_rte &&
schema[i].field_metadata.embed_entry &&
schema[i].reference_to.length > 1
) {
flag.supressed = true;
schema[i].reference_to = ['sys_assets'];
} else if (
// handling entry references in json rte
schema[i].data_type === 'json' &&
schema[i]?.field_metadata?.rich_text_type &&
schema[i]?.field_metadata?.embed_entry &&
schema[i]?.reference_to?.length > 1
) {
flag.supressed = true;
schema[i].reference_to = ['sys_assets'];
} else if (
// handling entry references in rte
schema[i].data_type === 'text' &&
schema[i]?.field_metadata?.rich_text_type &&
schema[i]?.field_metadata?.embed_entry &&
schema[i]?.reference_to?.length >= 1
) {
flag.supressed = true;
schema[i].reference_to = ['sys_assets'];
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@contentstack/cli-cm-branches": "~1.4.2",
"@contentstack/cli-cm-bulk-publish": "~1.8.0",
"@contentstack/cli-cm-clone": "~1.14.1",
"@contentstack/cli-cm-export": "~1.16.1",
"@contentstack/cli-cm-export": "~1.16.2",
"@contentstack/cli-cm-export-to-csv": "~1.8.1",
"@contentstack/cli-cm-import": "~1.22.0",
"@contentstack/cli-cm-import-setup": "1.2.0",
Expand Down
Loading
Loading