@faststore/cli
Advanced tools
Comparing version 2.0.21-alpha.0 to 2.0.22-alpha.0
@@ -6,2 +6,11 @@ # Change Log | ||
## [2.0.22-alpha.0](https://github.com/vtex/faststore/compare/v2.0.21-alpha.0...v2.0.22-alpha.0) (2022-12-19) | ||
### Bug Fixes | ||
* cli cms merge ([#1565](https://github.com/vtex/faststore/issues/1565)) ([2e5bd93](https://github.com/vtex/faststore/commit/2e5bd93c0ee5f1b6ab3afa39a2eae79c5ebea210)) | ||
## [2.0.21-alpha.0](https://github.com/vtex/faststore/compare/v2.0.20-alpha.0...v2.0.21-alpha.0) (2022-12-19) | ||
@@ -8,0 +17,0 @@ |
@@ -40,9 +40,11 @@ "use strict"; | ||
function copyUserSrcToCustomizations() { | ||
try { | ||
(0, fs_extra_1.copySync)(directory_1.userSrcDir, directory_1.tmpCustomizationsDir); | ||
console.log(`${chalk_1.default.green('success')} - Custom files copied`); | ||
if ((0, fs_extra_1.existsSync)(directory_1.userSrcDir) && (0, fs_extra_1.readdirSync)(directory_1.userSrcDir).length > 0) { | ||
try { | ||
(0, fs_extra_1.copySync)(directory_1.userSrcDir, directory_1.tmpCustomizationsDir); | ||
console.log(`${chalk_1.default.green('success')} - Custom files copied`); | ||
} | ||
catch (err) { | ||
console.error(`${chalk_1.default.red('error')} - ${err}`); | ||
} | ||
} | ||
catch (err) { | ||
console.error(`${chalk_1.default.red('error')} - ${err}`); | ||
} | ||
} | ||
@@ -74,14 +76,20 @@ async function copyTheme() { | ||
function mergeCMSFile(fileName) { | ||
const coreContentTypes = (0, fs_extra_1.readFileSync)(`${directory_1.coreCMSDir}/${fileName}`, 'utf8'); | ||
const customContentTypes = (0, fs_extra_1.readFileSync)(`${directory_1.userCMSDir}/${fileName}`, 'utf8'); | ||
const coreContentTypesJSON = JSON.parse(coreContentTypes); | ||
const customContentTypesJSON = JSON.parse(customContentTypes); | ||
const mergeContentTypes = [...coreContentTypesJSON, ...customContentTypesJSON]; | ||
try { | ||
(0, fs_extra_1.writeFileSync)(`${directory_1.tmpCMSDir}/${fileName}`, JSON.stringify(mergeContentTypes)); | ||
console.log(`${chalk_1.default.green('success')} - CMS file ${chalk_1.default.dim(fileName)} created`); | ||
// TODO: create a validation when has the cms files but doesn't have a component for then | ||
if ((0, fs_extra_1.existsSync)(directory_1.userCMSDir) && (0, fs_extra_1.readdirSync)(directory_1.userCMSDir).length > 0) { | ||
const coreContentTypes = (0, fs_extra_1.readFileSync)(`${directory_1.coreCMSDir}/${fileName}`, 'utf8'); | ||
const customContentTypes = (0, fs_extra_1.readFileSync)(`${directory_1.userCMSDir}/${fileName}`, 'utf8'); | ||
const coreContentTypesJSON = JSON.parse(coreContentTypes); | ||
const customContentTypesJSON = JSON.parse(customContentTypes); | ||
const mergeContentTypes = [ | ||
...coreContentTypesJSON, | ||
...customContentTypesJSON, | ||
]; | ||
try { | ||
(0, fs_extra_1.writeFileSync)(`${directory_1.tmpCMSDir}/${fileName}`, JSON.stringify(mergeContentTypes)); | ||
console.log(`${chalk_1.default.green('success')} - CMS file ${chalk_1.default.dim(fileName)} created`); | ||
} | ||
catch (err) { | ||
console.error(`${chalk_1.default.red('error')} - ${err}`); | ||
} | ||
} | ||
catch (err) { | ||
console.error(`${chalk_1.default.red('error')} - ${err}`); | ||
} | ||
} | ||
@@ -104,9 +112,2 @@ function generateStoreConfigFile(content) { | ||
function mergeCMSFiles() { | ||
try { | ||
(0, fs_extra_1.mkdirsSync)(`${directory_1.tmpDir}/cms`); | ||
console.log(`${chalk_1.default.green('success')} - CMS folder created`); | ||
} | ||
catch (err) { | ||
console.error(`${chalk_1.default.red('error')} - ${err}`); | ||
} | ||
mergeCMSFile('content-types.json'); | ||
@@ -113,0 +114,0 @@ mergeCMSFile('sections.json'); |
{ | ||
"name": "@faststore/cli", | ||
"version": "2.0.21-alpha.0", | ||
"version": "2.0.22-alpha.0", | ||
"description": "FastStore CLI", | ||
@@ -71,3 +71,3 @@ "author": "Emerson Laurentino @emersonlaurentino", | ||
"types": "dist/index.d.ts", | ||
"gitHead": "1fbde68a07972b420c37512a9def58ef5ca883c7" | ||
"gitHead": "54f1b21ac99d8a5e6e85ecc049c44a00b77ff9ef" | ||
} |
Sorry, the diff of this file is not supported yet
33539
359