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
77 changes: 41 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/contentstack-auth/src/commands/auth/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export default class LoginCommand extends BaseCommand<typeof LoginCommand> {
}
} catch (error) {
let errorMessage = formatError(error) || 'Something went wrong while logging. Please try again.';
if (typeof errorMessage === 'object' && Object.keys(errorMessage)?.length === 0) {
console.log(error);
}
this.logger.error('login failed', errorMessage);
cliux.error('CLI_AUTH_LOGIN_FAILED');
cliux.error(errorMessage);
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-branches",
"description": "Contentstack CLI plugin to do branches operations",
"version": "1.1.3",
"version": "1.2.0",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
79 changes: 45 additions & 34 deletions packages/contentstack-branches/src/utils/entry-create-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ export function entryCreateScript(contentType) {
findAssetIdsFromJsonRte(entry, schema);
parent.pop();
}
if (
schema[i].data_type === 'json' &&
schema[i].field_metadata.extension &&
schema[i].field_metadata.is_asset
) {
fetchAssetFromFileFields(parent,schema[i],entry);
}
if (
schema[i].data_type === 'text' &&
schema[i].field_metadata &&
Expand All @@ -121,43 +128,47 @@ export function entryCreateScript(contentType) {
parent.pop();
}
if (schema[i].data_type === 'file') {
parent.push(schema[i].uid);
let updatedEntry = entry;
for (let i = 0; i < parent.length; i++) {
updatedEntry = updatedEntry[parent[i]];
}
const imgDetails = updatedEntry;
if (schema[i].multiple) {
if (imgDetails && imgDetails.length) {
imgDetails.forEach((img) => {
const obj = {
uid: img.uid,
parent_uid: img.parent_uid,
description: img.description,
title: img.title,
filename: img.filename,
url: img.url,
};
cAssetDetails.push(obj);
});
}
} else {
if (imgDetails) {
const obj = {
uid: imgDetails.uid,
parent_uid: imgDetails.parent_uid,
description: imgDetails.description,
title: imgDetails.title,
filename: imgDetails.filename,
url: imgDetails.url,
};
cAssetDetails.push(obj);
}
}
parent.pop();
fetchAssetFromFileFields(parent,schema[i],entry);
}
}
};

function fetchAssetFromFileFields (parent, schema, entry) {
parent.push(schema.uid);
let updatedEntry = entry;
for (let i = 0; i < parent.length; i++) {
updatedEntry = updatedEntry[parent[i]];
}
const imgDetails = updatedEntry;
if (schema.multiple) {
if (imgDetails && imgDetails.length) {
imgDetails.forEach((img) => {
const obj = {
uid: img.uid,
parent_uid: img.parent_uid,
description: img.description,
title: img.title,
filename: img.filename,
url: img.url,
};
assetDetails.push(obj);
});
}
} else {
if (imgDetails) {
const obj = {
uid: imgDetails.uid,
parent_uid: imgDetails.parent_uid,
description: imgDetails.description,
title: imgDetails.title,
filename: imgDetails.filename,
url: imgDetails.url,
};
assetDetails.push(obj);
}
}
parent.pop();
}

function findAssetIdsFromHtmlRte(entryObj, ctSchema) {
const regex = /<img asset_uid=\\"([^"]+)\\"/g;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ export function entryCreateUpdateScript(contentType) {
findAssetIdsFromJsonRte(entry, schema);
parent.pop();
}

if (
schema[i].data_type === 'json' &&
schema[i].field_metadata.extension &&
schema[i].field_metadata.is_asset
) {
fetchAssetFromFileFields(parent,schema[i],entry);
}

if (
schema[i].data_type === 'text' &&
schema[i].field_metadata &&
Expand All @@ -143,44 +152,47 @@ export function entryCreateUpdateScript(contentType) {
parent.pop();
}
if (schema[i].data_type === 'file') {
parent.push(schema[i].uid);
let updatedEntry = entry;
for (let i = 0; i < parent.length; i++) {
updatedEntry = updatedEntry[parent[i]];
}
const imgDetails = updatedEntry;
if (schema[i].multiple) {
if (imgDetails && imgDetails.length) {
imgDetails.forEach((img) => {
const obj = {
uid: img.uid,
parent_uid: img.parent_uid,
description: img.description,
title: img.title,
filename: img.filename,
url: img.url,
};
assetDetails.push(obj);
});
}
} else {
if (imgDetails) {
const obj = {
uid: imgDetails.uid,
parent_uid: imgDetails.parent_uid,
description: imgDetails.description,
title: imgDetails.title,
filename: imgDetails.filename,
url: imgDetails.url,
};
assetDetails.push(obj);
}
}
parent.pop();
fetchAssetFromFileFields(parent,schema[i],entry);
}
}
};

function fetchAssetFromFileFields (parent, schema, entry) {
parent.push(schema.uid);
let updatedEntry = entry;
for (let i = 0; i < parent.length; i++) {
updatedEntry = updatedEntry[parent[i]];
}
const imgDetails = updatedEntry;
if (schema.multiple) {
if (imgDetails && imgDetails.length) {
imgDetails.forEach((img) => {
const obj = {
uid: img.uid,
parent_uid: img.parent_uid,
description: img.description,
title: img.title,
filename: img.filename,
url: img.url,
};
assetDetails.push(obj);
});
}
} else {
if (imgDetails) {
const obj = {
uid: imgDetails.uid,
parent_uid: imgDetails.parent_uid,
description: imgDetails.description,
title: imgDetails.title,
filename: imgDetails.filename,
url: imgDetails.url,
};
assetDetails.push(obj);
}
}
parent.pop();
}
function findAssetIdsFromHtmlRte(entryObj, ctSchema) {
const regex = /<img asset_uid=\\"([^"]+)\\"/g;
let match;
Expand Down
Loading