Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/CS-41107 #1019

Merged
merged 12 commits into from
Sep 4, 2023
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
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: pnpm/[email protected]
with:
version: 7
- uses: actions/setup-node@v3.7.0
- uses: actions/setup-node@v1
with:
node-version: '18.x'
cache: 'pnpm'
Expand Down Expand Up @@ -249,6 +249,10 @@ jobs:
if: ${{env.release_releaseAll == 'true' || env.release_plugins_core == 'true'}}
working-directory: ./packages/contentstack
run: npm install
- name: Compiling core
if: ${{ steps.core-installation.conclusion == 'success' }}
working-directory: ./packages/contentstack
run: npm run prepack
- name: Publishing core
id: publish-core
uses: JS-DevTools/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

22 changes: 16 additions & 6 deletions packages/contentstack-branches/src/utils/entry-create-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export function entryCreateScript(contentType) {
return path.split('[').reduce((o, key) => o && o[key.replace(/\]$/, '')], obj);
}
function updateValueByPath(obj, path, newValue, type, index) {
function updateValueByPath(obj, path, newValue, type, fileIndex) {
path.split('[').reduce((o, key, index, arr) => {
if (index === arr.length - 1) {
if (type === 'file') {
o[key.replace(/]$/, '')][index] = newValue;
o[key.replace(/]$/, '')][fileIndex] = newValue;
} else {
o[key.replace(/]$/, '')][0].uid = newValue;
}
Expand Down Expand Up @@ -81,7 +81,7 @@ export function entryCreateScript(contentType) {
for (const i in schema) {
const currentPath = path ? path + '[' + schema[i].uid : schema[i].uid;
if (schema[i].data_type === 'group' || schema[i].data_type === 'global_field') {
findAssets(schema[i].schema, entry, refPath, currentPath);
findAssets(schema[i].schema, entry, refPath, currentPath + '[0]');
} else if (schema[i].data_type === 'blocks') {
for (const block in schema[i].blocks) {
{
Expand Down Expand Up @@ -386,6 +386,14 @@ export function entryCreateScript(contentType) {
assetUrlMapper[asset.url] = res && res.url;
}
};
function handleErrorMsg(err) {
if (err?.errorMessage) {
console.log(err.errorMessage);
} else if (err?.message) {
console.log(err.message);
}
}
const createEntryTask = () => {
return {
Expand Down Expand Up @@ -469,10 +477,12 @@ export function entryCreateScript(contentType) {
let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails }).catch(error => {
throw error;
});
if (flag.references) {
await updateReferences(entryDetails, createdEntry, references);
if(createdEntry){
if (flag.references) {
await updateReferences(entryDetails, createdEntry, references);
}
await updateEntry(createdEntry, entryDetails);
}
await updateEntry(createdEntry, entryDetails);
});
} catch (error) {
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export function entryCreateUpdateScript(contentType) {
return path.split('[').reduce((o, key) => o && o[key.replace(/\]$/, '')], obj);
}

function updateValueByPath(obj, path, newValue, type, index) {
function updateValueByPath(obj, path, newValue, type, fileIndex) {
path.split('[').reduce((o, key, index, arr) => {
if (index === arr.length - 1) {
if (type === 'file') {
o[key.replace(/]$/, '')][index] = newValue;
o[key.replace(/]$/, '')][fileIndex] = newValue;
} else {
o[key.replace(/]$/, '')][0].uid = newValue;
}
Expand Down Expand Up @@ -103,7 +103,7 @@ export function entryCreateUpdateScript(contentType) {
for (const i in schema) {
const currentPath = path ? path + '[' + schema[i].uid : schema[i].uid;
if (schema[i].data_type === 'group' || schema[i].data_type === 'global_field') {
findAssets(schema[i].schema, entry, refPath, currentPath);
findAssets(schema[i].schema, entry, refPath, currentPath + '[0]');
} else if (schema[i].data_type === 'blocks') {
for (const block in schema[i].blocks) {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export function entryUpdateScript(contentType) {
return path.split('[').reduce((o, key) => o && o[key.replace(/\]$/, '')], obj);
}

function updateValueByPath(obj, path, newValue, type, index) {
function updateValueByPath(obj, path, newValue, type, fileIndex) {
path.split('[').reduce((o, key, index, arr) => {
if (index === arr.length - 1) {
if (type === 'file') {
o[key.replace(/]$/, '')][index] = newValue;
o[key.replace(/]$/, '')][fileIndex] = newValue;
} else {
o[key.replace(/]$/, '')][0].uid = newValue;
}
Expand Down Expand Up @@ -103,7 +103,7 @@ export function entryUpdateScript(contentType) {
for (const i in schema) {
const currentPath = path ? path + '[' + schema[i].uid : schema[i].uid;
if (schema[i].data_type === 'group' || schema[i].data_type === 'global_field') {
findAssets(schema[i].schema, entry, refPath, currentPath);
findAssets(schema[i].schema, entry, refPath, currentPath + '[0]');
} else if (schema[i].data_type === 'blocks') {
for (const block in schema[i].blocks) {
{
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.8.2",
"version": "1.8.3",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run"
Expand Down