@pernod-ricard-global-cms/cbl-component-library
Advanced tools
Comparing version
{ | ||
"key": "group_627b6cb7e4043", | ||
"title": "Fields: Image-basic", | ||
"title": "Fields: Images - basic", | ||
"fields": [ | ||
@@ -5,0 +5,0 @@ { |
@@ -40,6 +40,7 @@ { | ||
"choices": { | ||
"__full": "Full", | ||
"__short": "Short" | ||
"__original": "Original", | ||
"__16x9": "Wide (16\/9)", | ||
"__16x6": "Short (16\/6)" | ||
}, | ||
"default_value": "__full", | ||
"default_value": "__original", | ||
"allow_null": 0, | ||
@@ -53,5 +54,38 @@ "multiple": 0, | ||
{ | ||
"key": "field_627e4d282ff59", | ||
"label": "Desktop image - original", | ||
"name": "desktop_image", | ||
"type": "image", | ||
"instructions": "", | ||
"required": 0, | ||
"conditional_logic": [ | ||
[ | ||
{ | ||
"field": "field_626efdd827159", | ||
"operator": "==", | ||
"value": "__original" | ||
} | ||
] | ||
], | ||
"wrapper": { | ||
"width": "", | ||
"class": "", | ||
"id": "" | ||
}, | ||
"wpml_cf_preferences": 3, | ||
"return_format": "array", | ||
"preview_size": "medium", | ||
"library": "all", | ||
"min_width": "", | ||
"min_height": "", | ||
"min_size": "", | ||
"max_width": "", | ||
"max_height": "", | ||
"max_size": "", | ||
"mime_types": "" | ||
}, | ||
{ | ||
"key": "field_626efef5266e8", | ||
"label": "Image 16x9", | ||
"name": "desktop_image", | ||
"name": "desktop_image_16x9", | ||
"type": "image_aspect_ratio_crop", | ||
@@ -65,3 +99,3 @@ "instructions": "", | ||
"operator": "==", | ||
"value": "__full" | ||
"value": "__16x9" | ||
} | ||
@@ -93,3 +127,3 @@ ] | ||
"label": "Image 16x6", | ||
"name": "desktop_image_short", | ||
"name": "desktop_image_16x6", | ||
"type": "image_aspect_ratio_crop", | ||
@@ -103,3 +137,3 @@ "instructions": "", | ||
"operator": "==", | ||
"value": "__short" | ||
"value": "__16x6" | ||
} | ||
@@ -143,6 +177,7 @@ ] | ||
"choices": { | ||
"__tall": "Tall", | ||
"__short": "Short" | ||
"__original": "Original", | ||
"__9x16": "Tall (9\/16)", | ||
"__4x3": "Short (4\/3)" | ||
}, | ||
"default_value": "__tall", | ||
"default_value": "__original", | ||
"allow_null": 0, | ||
@@ -156,5 +191,38 @@ "multiple": 0, | ||
{ | ||
"key": "field_627e4d512ff5a", | ||
"label": "Mobile image - original", | ||
"name": "mobile_image", | ||
"type": "image", | ||
"instructions": "", | ||
"required": 0, | ||
"conditional_logic": [ | ||
[ | ||
{ | ||
"field": "field_626efe7f2715a", | ||
"operator": "==", | ||
"value": "__original" | ||
} | ||
] | ||
], | ||
"wrapper": { | ||
"width": "", | ||
"class": "", | ||
"id": "" | ||
}, | ||
"wpml_cf_preferences": 3, | ||
"return_format": "array", | ||
"preview_size": "medium", | ||
"library": "all", | ||
"min_width": "", | ||
"min_height": "", | ||
"min_size": "", | ||
"max_width": "", | ||
"max_height": "", | ||
"max_size": "", | ||
"mime_types": "" | ||
}, | ||
{ | ||
"key": "field_6258b0407076f", | ||
"label": "Image 9x16", | ||
"name": "mobile_image", | ||
"name": "mobile_image_9x16", | ||
"type": "image_aspect_ratio_crop", | ||
@@ -168,3 +236,3 @@ "instructions": "", | ||
"operator": "==", | ||
"value": "__tall" | ||
"value": "__9x16" | ||
} | ||
@@ -196,3 +264,3 @@ ] | ||
"label": "Image 4x3", | ||
"name": "mobile_image_short", | ||
"name": "mobile_image_4x3", | ||
"type": "image_aspect_ratio_crop", | ||
@@ -206,3 +274,3 @@ "instructions": "", | ||
"operator": "==", | ||
"value": "__short" | ||
"value": "__4x3" | ||
} | ||
@@ -236,7 +304,2 @@ ] | ||
"param": "block", | ||
"operator": "==", | ||
"value": "all" | ||
}, | ||
{ | ||
"param": "block", | ||
"operator": "!=", | ||
@@ -256,3 +319,3 @@ "value": "all" | ||
"show_in_rest": 0, | ||
"modified": 1651487999 | ||
"modified": 1652446136 | ||
} |
@@ -40,6 +40,17 @@ const fs = require('fs'); | ||
const componentName = process.argv[2]; | ||
const dynamicEntryPointsAcfJson = glob | ||
.sync('./web/wp-content/themes/global-theme/acf-json/*.json') | ||
.map((path) => { | ||
const assetKey = path.replace( | ||
'./web/wp-content/themes/global-theme/acf-json/', | ||
'' | ||
); | ||
return assetKey; | ||
}); | ||
const componentName = process.argv[2]?.toLocaleLowerCase(); | ||
if (!componentName) { | ||
console.log( | ||
'\x1b[35m', | ||
'Hmmm that failed.. Did you forget to include the component name?' | ||
@@ -49,10 +60,37 @@ ); | ||
} | ||
if (dynamicEntryPointsJs.indexOf(componentName) !== -1) { | ||
console.log( | ||
`It looks like you already have a block called ${componentName}. If you want to overwrite it with the latest version then try "yarn upgrade-component ${componentName}"` | ||
); | ||
process.exit(); | ||
let componentType = 'block'; | ||
if (componentName.split('-')[0] === 'fields') { | ||
componentType = 'fields'; | ||
} | ||
let componentAcf = glob | ||
.sync(`${libraryPath}/components/${componentName}/*.json`) | ||
.map((path) => { | ||
const filename = path.replace( | ||
`${libraryPath}/components/${componentName}/`, | ||
'' | ||
); | ||
return filename; | ||
})[0]; | ||
if (componentType === 'fields') { | ||
if (dynamicEntryPointsAcfJson.indexOf(componentAcf) !== -1) { | ||
console.log( | ||
'\x1b[33m', | ||
`Oh oh! It looks like you already have a field group called "${componentName}". If you want to overwrite it with the latest version then try "yarn update-component ${componentName}"` | ||
); | ||
process.exit(); | ||
} | ||
} else { | ||
if (dynamicEntryPointsJs.indexOf(componentName) !== -1) { | ||
console.log( | ||
'\x1b[33m', | ||
`Oh oh! It looks like you already have a block called ${componentName}. If you want to overwrite it with the latest version then try "yarn update-component ${componentName}"` | ||
); | ||
process.exit(); | ||
} | ||
} | ||
console.log( | ||
'\x1b[32m', | ||
`👑 👑 👑 Hurrah! You installed a component called ${componentName} 👑 👑 👑` | ||
@@ -59,0 +97,0 @@ ); |
{ | ||
"name": "@pernod-ricard-global-cms/cbl-component-library", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "Component library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,2 +44,3 @@ const fs = require('fs'); | ||
console.log( | ||
'\x1b[35m', | ||
'Hmmm that failed.. Did you forget to include the component name?' | ||
@@ -50,6 +51,12 @@ ); | ||
if (dynamicEntryPointsJs.indexOf(componentName) !== -1) { | ||
console.log(`...Found existing version to upgrade ${componentName}..."`); | ||
console.log( | ||
'\x1b[32m', | ||
`...Found existing version to upgrade ${componentName}..."` | ||
); | ||
} | ||
console.log(`👑 👑 👑 Hurrah! You upgraded ${componentName} 👑 👑 👑`); | ||
console.log( | ||
'\x1b[32m', | ||
`👑 👑 👑 Hurrah! You upgraded ${componentName} 👑 👑 👑` | ||
); | ||
@@ -56,0 +63,0 @@ if ( |
45664
8.37%1299
8.79%