From c46a2067f8295845581ec31ccafd279c1fe1d1fb Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Mon, 28 Aug 2023 16:25:35 +0530 Subject: [PATCH 1/4] fix: group file upload issue --- .../src/utils/entry-create-script.ts | 26 ++++++++++++------- .../src/utils/entry-create-update-script.ts | 6 ++--- .../src/utils/entry-update-script.ts | 6 ++--- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/packages/contentstack-branches/src/utils/entry-create-script.ts b/packages/contentstack-branches/src/utils/entry-create-script.ts index 5739966094..e4c7209f38 100644 --- a/packages/contentstack-branches/src/utils/entry-create-script.ts +++ b/packages/contentstack-branches/src/utils/entry-create-script.ts @@ -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; } @@ -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) { { @@ -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 { @@ -466,13 +474,13 @@ export function entryCreateScript(contentType) { compareFilteredProperties.length !== 0 && compareFilteredProperties.forEach(async (entryDetails) => { entryDetails = updateAssetDetailsInEntries(entryDetails); - let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails }).catch(error => { - throw error; - }); - if (flag.references) { - await updateReferences(entryDetails, createdEntry, references); + let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails }).catch(error => throw error;); + if(createdEntry){ + if (flag.references) { + await updateReferences(entryDetails, createdEntry, references); + } + await updateEntry(createdEntry, entryDetails); } - await updateEntry(createdEntry, entryDetails); }); } catch (error) { throw error; diff --git a/packages/contentstack-branches/src/utils/entry-create-update-script.ts b/packages/contentstack-branches/src/utils/entry-create-update-script.ts index 64b188d925..9926436dba 100644 --- a/packages/contentstack-branches/src/utils/entry-create-update-script.ts +++ b/packages/contentstack-branches/src/utils/entry-create-update-script.ts @@ -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; } @@ -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) { { diff --git a/packages/contentstack-branches/src/utils/entry-update-script.ts b/packages/contentstack-branches/src/utils/entry-update-script.ts index 0e085db968..1ee65bff4a 100644 --- a/packages/contentstack-branches/src/utils/entry-update-script.ts +++ b/packages/contentstack-branches/src/utils/entry-update-script.ts @@ -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; } @@ -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) { { From 42f28db906e8b145fe5982eebea3ebab2acb657b Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Mon, 28 Aug 2023 16:42:37 +0530 Subject: [PATCH 2/4] fix: entry create issue --- .../contentstack-branches/src/utils/entry-create-script.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/contentstack-branches/src/utils/entry-create-script.ts b/packages/contentstack-branches/src/utils/entry-create-script.ts index e4c7209f38..682ffb8b0f 100644 --- a/packages/contentstack-branches/src/utils/entry-create-script.ts +++ b/packages/contentstack-branches/src/utils/entry-create-script.ts @@ -474,7 +474,9 @@ export function entryCreateScript(contentType) { compareFilteredProperties.length !== 0 && compareFilteredProperties.forEach(async (entryDetails) => { entryDetails = updateAssetDetailsInEntries(entryDetails); - let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails }).catch(error => throw error;); + let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails }).catch(error => { + throw error; + }); if(createdEntry){ if (flag.references) { await updateReferences(entryDetails, createdEntry, references); From 2568f8e84916974155d2907051cafaa4dd9c9919 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 29 Aug 2023 19:14:22 +0530 Subject: [PATCH 3/4] Fixed Release Workflow --- .github/workflows/release.yml | 2 +- package-lock.json | 2 +- packages/contentstack/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e45cf7549..9eba725091 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: - uses: pnpm/action-setup@v2.2.4 with: version: 7 - - uses: actions/setup-node@v3.7.0 + - uses: actions/setup-node@v1 with: node-version: '18.x' cache: 'pnpm' diff --git a/package-lock.json b/package-lock.json index 4eb63ff6ff..a1ecc18b1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20298,7 +20298,7 @@ }, "packages/contentstack": { "name": "@contentstack/cli", - "version": "1.8.2", + "version": "1.8.3", "license": "MIT", "dependencies": { "@contentstack/cli-auth": "~1.3.12", diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 14e61aab08..397f8d18b3 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -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" From 889cc16343ed17672fed6f1acdeedc68f430cf0b Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Tue, 29 Aug 2023 20:24:53 +0530 Subject: [PATCH 4/4] fix: added compile phase for core module --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9eba725091..5fb673798b 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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/npm-publish@v2.2.1