@greenberry/datocms-migration-utils
A collection of utils to help with the development of DatoCMS migration files.
Installation
yarn add @greenberry/datocms-migration-utils -D
API
Each field creator method need 3 arguments a working DatoCMS SiteClient, field options and the modelId you want to attach the field to.
await createFieldMethod(client, options, modelId);
Field Options
createBoolean
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
createColor
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
presetColors | [#000] | β |
enableAlpha | Boolean | β |
createCTA
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
createDate
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
dateRange | {min: 'ISO-8601', max: 'ISO-8601'} | β |
createDateTime
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
dateRange | {min: 'ISO-8601', max: 'ISO-8601'} | β |
createEnum
label | String | β
|
apiKey | String | β
|
options | [String] | β
|
defaultValue | String | β |
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
createImage
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
createLink
label | String | β
|
apiKey | String | β
|
items | [ItemType ID] | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
unique | Boolean | β |
createLinks
label | String | β
|
apiKey | String | β
|
items | [ItemType ID] | β
|
size | { min: Number, max: Number } | β |
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
createModularContent
label | String | β
|
apiKey | String | β
|
blockIds | [ItemType ID] | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
createNumber
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
createSEO
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
createSingleLine
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
heading | Boolean | β |
createSlug
label | String | β
|
apiKey | String | β
|
titleField | Field | β
|
prefix | String | β |
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
createTextArea
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
createWysiwyg
label | String | β
|
apiKey | String | β
|
hint | String | β |
localized | Boolean | β |
required | Boolean | β |
toolbar | Array | β |
updateModularContent
label | String | β
|
apiKey | String | β
|
localized | Boolean | β |
hint | String | β |
blockIds | [ItemType ID] | β
|
uploadFile
Color formatting
DatoCMS only accepts a specific format when filling colors. That is why we added a util to format hex values in a shape acceptable by DatoCMS.
const color = formatColor('#000000');
console.log(color);
formatColor also accepts a second argument to specify the alpha of the color, this works in the same way as CSS opacity.
const color = formatColor('#000000', 0.8);
console.log(color);