Gathering detailed insights and metrics for contentful-migration
Gathering detailed insights and metrics for contentful-migration
Gathering detailed insights and metrics for contentful-migration
Gathering detailed insights and metrics for contentful-migration
contentful-smart-migration
Contentful migration enhancement for projects that need to have a migration be used across multiple environments
contentful
Client for Contentful's Content Delivery API
contentful-cli
Contentful CLI tool
contentful-management
Client for Contentful's Content Management API
npm install contentful-migration
61.6
Supply Chain
96.2
Quality
93.8
Maintenance
100
Vulnerability
98.6
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
328 Stars
1,149 Commits
150 Forks
60 Watching
21 Branches
277 Contributors
Updated on 14 Nov 2024
Minified
Minified + Gzipped
TypeScript (64.85%)
JavaScript (35.14%)
Shell (0.01%)
Cumulative downloads
Total Downloads
Last day
4.9%
17,168
Compared to previous day
Last week
-5.8%
87,286
Compared to previous week
Last month
9.2%
424,140
Compared to previous month
Last year
6.9%
4,146,323
Compared to previous year
17
44
Describe and execute changes to your content model and transform entry content.
What is Contentful?
Contentful provides content infrastructure for digital teams to power websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship their products faster.
migration
context
createField(id[, opts])
: FieldeditField(id[, opts])
: FielddeleteField(id)
: voidchangeFieldId (currentId, newId)
: voidmoveField (id)
: MovableFieldchangeFieldControl (fieldId, widgetNamespace, widgetId[, settings])
: voidresetFieldControl (fieldId)
: voidcopyFieldControl (sourceFieldId, destinationFieldId)
: voidaddSidebarWidget (widgetNamespace, widgetId[, settings, insertBeforeWidgetId])
: voidupdateSidebarWidget (widgetNamespace, widgetId, settings)
: voidremoveSidebarWidget (widgetNamespace, widgetId)
: voidresetSidebarToDefault ()
: voidconfigureEntryEditor (widgetNamespace, widgetId[, settings])
: voidconfigureEntryEditors (EntryEditor[])
: voidresetEntryEditorToDefault ()
: voidcreateEditorLayout ()
: EditorLayouteditEditorLayout ()
: EditorLayoutdeleteEditorLayout ()
: void1npm install contentful-migration
We moved the CLI version of this tool into our Contentful CLI. This allows our users to use and install only one single CLI tool to get the full Contentful experience.
Please have a look at the Contentful CLI migration command documentation to learn more about how to use this as command line tool.
1const { runMigration } = require('contentful-migration') 2const options = { 3 filePath: '<migration-file-path>', 4 spaceId: '<space-id>', 5 accessToken: '<access-token>' 6} 7runMigration(options) 8 .then(() => console.log('Migration Done!')) 9 .catch((e) => console.error(e))
In your migration description file, export a function that accepts the migration
object as its argument. For example:
1module.exports = function (migration, context) { 2 const dog = migration.createContentType('dog') 3 const name = dog.createField('name') 4 name.type('Symbol').required(true) 5}
You can also pass the function directly. For example:
1const { runMigration } = require('contentful-migration') 2 3function migrationFunction(migration, context) { 4 const dog = migration.createContentType('dog') 5 const name = dog.createField('name') 6 name.type('Symbol').required(true) 7} 8 9const options = { 10 migrationFunction, 11 spaceId: '<space-id>', 12 accessToken: '<access-token>' 13} 14 15runMigration(options) 16 .then(() => console.log('Migration Done!')) 17 .catch((e) => console.error(e))
Name | Default | Type | Description | Required |
---|---|---|---|---|
filePath | string | The path to the migration file | if migrationFunction is not supplied | |
migrationFunction | function | Specify the migration function directly. See the expected signature. | if filePath is not supplied | |
spaceId | string | ID of the space to run the migration script on | true | |
environmentId | 'master' | string | ID of the environment within the space to run the | false |
accessToken | string | The access token to use | true | |
yes | false | boolean | Skips any confirmation before applying the migration,script | false |
retryLimit | 5 | number | Number of retries before failure (every subsequent retry will increase the timeout to the previous retry by about 1.5 seconds) | false |
requestBatchSize | 100 | number | Limit for every single request | false |
headers | object | Additional headers to attach to the requests | false |
All methods described below can be used in two flavors:
The chained approach:
1const author = migration 2 .createContentType('author') 3 .name('Author') 4 .description('Author of blog posts or pages')
The object approach:
1const author = migration.createContentType('author', { 2 name: 'Author', 3 description: 'Author of blog posts or pages' 4})
While both approaches work, it is recommended to use the chained approach since validation errors will display context information whenever an error is detected, along with a line number. The object notation will lead the validation error to only show the line where the object is described, whereas the chained notation will show precisely where the error is located.
migration
The main interface for creating and editing content types and tags.
createContentType(id[, opts])
: ContentTypeCreates a content type with provided id
and returns a reference to the newly created content type.
id : string
– The ID of the content type.
opts : Object
– Content type definition, with the following options:
name : string
– Name of the content type.description : string
– Description of the content type.displayField : string
– ID of the field to use as the display field for the content type. This is referred to as the "Entry title" in the web application.editContentType(id[, opts])
: ContentTypeEdits an existing content type of provided id
and returns a reference to the content type.
Uses the same options as createContentType
.
deleteContentType(id)
Deletes the content type with the provided id and returns undefined
. Note that the content type must not have any entries.
transformEntries(config)
For the given content type, transforms all its entries according to the user-provided transformEntryForLocale
function. For each entry, the CLI will call this function once per locale in the space, passing in the from
fields and the locale as arguments.
The transform function is expected to return an object with the desired target fields. If it returns undefined
, this entry locale will be left untouched.
config : Object
– Content transformation definition, with the following properties:
contentType : string
(required) – Content type IDfrom : array
(required) – Array of the source field IDsto : array
(required) – Array of the target field IDstransformEntryForLocale : function (fields, locale, {id}): object
(required) – Transformation function to be applied.
fields
is an object containing each of the from
fields. Each field will contain their current localized values (i.e. fields == {myField: {'en-US': 'my field value'}}
)locale
one of the locales in the space being transformedid
id of the current entry in scopeto
. Their values will be written to the respective entry fields for the current locale (i.e. {nameField: 'myNewValue'}
). If it returns undefined
, this the values for this locale on the entry will be left untouched.shouldPublish : bool | 'preserve'
(optional) – Flag that specifies publishing of target entries, preserve
will keep current states of the source entries (default 'preserve'
)transformEntries
Example1migration.transformEntries({ 2 contentType: 'newsArticle', 3 from: ['author', 'authorCity'], 4 to: ['byline'], 5 transformEntryForLocale: function (fromFields, currentLocale, { id }) { 6 if (currentLocale === 'de-DE') { 7 return 8 } 9 const newByline = `${fromFields.author[currentLocale]} ${fromFields.authorCity[currentLocale]}` 10 return { byline: newByline } 11 } 12})
For the complete version, please refer to this example.
deriveLinkedEntries(config)
For each entry of the given content type (source entry), derives a new entry and sets up a reference to it on the source entry. The content of the new entry is generated by the user-provided deriveEntryForLocale
function.
For each source entry, this function will be called as many times as there are locales in the space. Each time, it will be called with the from
fields and one of the locales as arguments.
The derive function is expected to return an object with the desired target fields. If it returns undefined
, the new entry will have no values for the current locale.
config : Object
– Entry derivation definition, with the following properties:
contentType : string
(required) – Source content type ID
derivedContentType : string
(required) – Target content type ID
from : array
(required) – Array of the source field IDs
toReferenceField : string
(required) – ID of the field on the source content type in which to insert the reference
derivedFields : array
(required) – Array of the field IDs on the target content type
identityKey: function (fields): string
(required) - Called once per source entry. Returns the ID used for the derived entry, which is also used for de-duplication so that multiple source entries can link to the same derived entry.
fields
is an object containing each of the from
fields. Each field will contain their current localized values (i.e. fields == {myField: {'en-US': 'my field value'}}
)deriveEntryForLocale : function (fields, locale, {id}): object
(required) – Function that generates the field values for the derived entry.
fields
is an object containing each of the from
fields. Each field will contain their current localized values (i.e. fields == {myField: {'en-US': 'my field value'}}
)locale
one of the locales in the space being transformedid
id of the current entry in scopeThe return value must be an object with the same keys as specified in derivedFields
. Their values will be written to the respective new entry fields for the current locale (i.e. {nameField: 'myNewValue'}
)
shouldPublish : bool|'preserve'
(optional) – If true, both the source and the derived entries will be published. If false, both will remain in draft state. If preserve, will keep current states of the source entries (default true
)
deriveLinkedEntries(config)
Example1migration.deriveLinkedEntries({ 2 contentType: 'dog', 3 derivedContentType: 'owner', 4 from: ['owner'], 5 toReferenceField: 'ownerRef', 6 derivedFields: ['firstName', 'lastName'], 7 identityKey: async (fromFields) => { 8 return fromFields.owner['en-US'].toLowerCase().replace(' ', '-') 9 }, 10 shouldPublish: true, 11 deriveEntryForLocale: async (inputFields, locale, { id }) => { 12 if (locale !== 'en-US') { 13 return 14 } 15 const [firstName, lastName] = inputFields.owner[locale].split(' ') 16 return { 17 firstName, 18 lastName 19 } 20 } 21})
For the complete version of this migration, please refer to this example.
transformEntriesToType(config)
For the given (source) content type, transforms all its entries according to the user-provided transformEntryForLocale
function into a new entry of a specific different (target) content type. For each entry, the CLI will call the function transformEntryForLocale
once per locale in the space, passing in the from
fields and the locale as arguments. The transform function is expected to return an object with the desired target fields. If it returns undefined
, this entry locale will be left untouched.
config : Object
– Content transformation definition, with the following properties:
sourceContentType : string
(required) – Content type ID of source entries
targetContentType : string
(required) – Targeted Content type ID
from : array
(optional) – Array of the source field IDs, returns complete list of fields if not configured
identityKey: function (fields): string
(required) - Function to create a new entry ID for the target entry
shouldPublish : bool | 'preserve'
(optional) – Flag that specifies publishing of target entries, preserve
will keep current states of the source entries (default false
)
updateReferences : bool
(optional) – Flag that specifies if linking entries should be updated with target entries (default false
). Note that this flag does not support Rich Text Fields references.
removeOldEntries : bool
(optional) – Flag that specifies if source entries should be deleted (default false
)
transformEntryForLocale : function (fields, locale, {id}): object
(required) – Transformation function to be applied.
fields
is an object containing each of the from
fields. Each field will contain their current localized values (i.e. fields == {myField: {'en-US': 'my field value'}}
)locale
one of the locales in the space being transformedid
id of the current entry in scopeThe return value must be an object with the same keys as specified in the targetContentType
. Their values will be written to the respective entry fields for the current locale (i.e. {nameField: 'myNewValue'}
). If it returns undefined
, the values for this locale on the entry will be left untouched.
transformEntriesToType
Example1const MurmurHash3 = require('imurmurhash') 2 3migration.transformEntriesToType({ 4 sourceContentType: 'dog', 5 targetContentType: 'copycat', 6 from: ['woofs'], 7 shouldPublish: false, 8 updateReferences: false, 9 removeOldEntries: false, 10 identityKey: function (fields) { 11 const value = fields.woofs['en-US'].toString() 12 return MurmurHash3(value).result().toString() 13 }, 14 transformEntryForLocale: function (fromFields, currentLocale, { id }) { 15 return { 16 woofs: `copy - ${fromFields.woofs[currentLocale]}` 17 } 18 } 19})
For the complete version of this migration, please refer to this example.
createTag(id[, opts, visibility])
Creates a tag with provided id
and returns a reference to the newly created tag.
id : string
– The ID of the tag.
opts : Object
– Tag definition, with the following options:
name : string
– Name of the tag.visibility : 'private' | 'public'
Tag visibility - defaults to private
.
editTag(id[, opts])
Edits an existing tag of provided id
and returns a reference to the tag.
Uses the same options as createTag
.
deleteTag(id)
Deletes the tag with the provided id and returns undefined
. Note that this deletes the tag even if it is still attached to entries or assets.
setTagsForEntries(config)
For the given content type, updates the tags that are attached to its entries according to the user-provided setTagsForEntry
function. For each entry, the CLI will call this function once, passing in the from
fields, link objects of all tags that already are attached to the entry and link objects of all tags available in the environment. The setTagsForEntry
function is expected to return an array with link objects for all tags that are to be added to the entry. If it returns undefined
, the entry will be left untouched.
config : Object
– Content transformation definition, with the following properties:
contentType : string
(required) – Content type IDfrom : array
(required) – Array of the source field IDssetTagsForEntry : function (entryFields, entryTags, apiTags): array
(required) – Transformation function to be applied. - entryFields
is an object containing each of the from
fields. - entryTags
is an array containing link objects of all tags
already attached to the entry. - apiTags
is an array containing link objects of all tags
available in the environment.setTagsForEntries
Example1migration.createTag('department-sf').name('Department: San Francisco') 2migration.createTag('department-ldn').name('Department: London') 3 4const departmentMapping = { 5 'san-francisco': 'department-sf', 6 london: 'department-ldn' 7} 8 9migration.setTagsForEntries({ 10 contentType: 'news-article', 11 from: ['department'], 12 setTagsForEntry: (entryFields, entryTags, apiTags) => { 13 const departmentField = entryFields.department['en-US'] 14 const newTag = apiTags.find((tag) => tag.sys.id === departmentMapping[departmentField]) 15 16 return [...entryTags, newTag] 17 } 18})
context
There may be cases where you want to use Contentful API features that are not supported by the migration
object. For these cases you have access to the internal configuration of the running migration in a context
object.
1module.exports = async function (migration, { makeRequest, spaceId, accessToken }) { 2 const contentType = await makeRequest({ 3 method: 'GET', 4 url: `/content_types?sys.id[in]=foo` 5 }) 6 7 const anyOtherTool = new AnyOtherTool({ spaceId, accessToken }) 8}
makeRequest(config)
The function used by the migration object to talk to the Contentful Management API. This can be useful if you want to use API features that may not be supported by the migration
object.
config : Object
- Configuration for the request based on the Contentful management SDK
method
: string
– HTTP methodurl
: string
- HTTP endpoint1module.exports = async function (migration, { makeRequest }) { 2 const contentType = await makeRequest({ 3 method: 'GET', 4 url: `/content_types?sys.id[in]=foo` 5 }) 6}
spaceId
: string
The space ID that was set for the current migration.
accessToken
: string
The access token that was set for the current migration.
For a comprehensive guide to content modelling, please refer to this guide.
createField(id[, opts])
: FieldCreates a field with provided id
.
id : string
– The ID of the field.
opts : Object
– Field definition, with the following options:
name : string
(required) – Field name.
type : string
(required) – Field type, amongst the following values:
Symbol
(Short text)Text
(Long text)Integer
Number
Date
Boolean
Object
Location
RichText
Array
(requires items
)Link
(requires linkType
)ResourceLink
(requires allowedResources
)items : Object
(required for type Array
) – Defines the items of an Array field.
Example:
1items: { 2 type: 'Link', 3 linkType: 'Entry', 4 validations: [ 5 { linkContentType: [ 'my-content-type' ] } 6 ] 7}
linkType : string
(required for type Link
) – Type of the referenced entry.
Value must be either Asset
or Entry
.
allowedResources
(required for type ResourceLink
) - Defines which resources can be linked through the field.
required : boolean
– Sets the field as required.
validations : Array
– Validations for the field.
Example:
1validations: [{ in: ['Web', 'iOS', 'Android'] }]
See The CMA documentation for the list of available validations.
localized : boolean
– Sets the field as localized.
disabled : boolean
– Sets the field as disabled, hence not editable by authors.
omitted : boolean
– Sets the field as omitted, hence not sent in response.
deleted : boolean
– Sets the field as deleted. Requires to have been omitted
first.
You may prefer using the deleteField
method.
defaultValue : Object
– Sets the default value for the field.
Example:
1defaultValue: { 2 "en-US": false, 3 "de-DE": true 4}
editField(id[, opts])
: FieldEdits the field of provided id
.
id : string
– The ID of the field to edit.
opts : Object
– Same as createField
listed above.
deleteField(id)
: voidShorthand method to omit a field, publish its content type, and then delete the field. This implies that associated content for the field will be lost.
id : string
– The ID of the field to delete.
changeFieldId (currentId, newId)
: voidChanges the field's ID.
currentId : string
– The current ID of the field.
newId : string
– The new ID for the field.
moveField (id)
: MovableFieldMove the field (position of the field in the web editor)
id: string
- The ID of the field to move
.moveField(id)
returns a movable field type which must be called with a direction function:
.toTheTop()
.toTheBottom()
.beforeField(fieldId)
.afterField(fieldId)
Example:
1module.exports = function (migration) { 2 const food = migration.editContentType('food') 3 4 food.createField('calories').type('Number').name('How many calories does it have?') 5 6 food.createField('sugar').type('Number').name('Amount of sugar') 7 8 food.createField('vegan').type('Boolean').name('Vegan friendly') 9 10 food.createField('producer').type('Symbol').name('Food producer') 11 12 food.createField('gmo').type('Boolean').name('Genetically modified food') 13 14 food.moveField('calories').toTheTop() 15 food.moveField('sugar').toTheBottom() 16 food.moveField('producer').beforeField('vegan') 17 food.moveField('gmo').afterField('vegan') 18}
changeFieldControl (fieldId, widgetNamespace, widgetId[, settings])
: voidChanges control interface of given field's ID.
fieldId : string
– The ID of the field.
widgetNamespace : string
– The namespace of the widget, one of the following values:
builtin
(Standard widget)app
(Custom App)extension
(Custom UI extension)app
(Custom app widget)widgetId : string
– The new widget ID for the field. See the editor interface documentation for a list of available widgets.
settings : Object
– Widget settings and extension instance parameters. Key-value pairs of type (string, number | boolean | string). For builtin widgets, the the following options are available:
helpText : string
– This help text will show up below the field.trueLabel : string
(only for fields of type boolean) – Shows this text next to the radio button that sets this value to true
. Defaults to “Yes”.falseLabel : string
(only for fields of type boolean) – Shows this text next to the radio button that sets this value to false
. Defaults to “No”.stars : number
(only for fields of type rating) – Number of stars to select from. Defaults to 5.format : string
(only for fields of type datePicker) – One of “dateonly”, “time”, “timeZ” (default). Specifies whether to show the clock and/or timezone inputs.ampm : string
(only for fields of type datePicker) – Specifies which type of clock to use. Must be one of the strings “12” or “24” (default).bulkEditing : boolean
(only for fields of type Array) – Specifies whether bulk editing of linked entries is possible.trackingFieldId : string
(only for fields of type slugEditor) – Specifies the ID of the field that will be used to generate the slug value.showCreateEntityAction : boolean
(only for fields of type Link) - specifies whether creation of new entries from the field is enabled.showLinkEntityAction : boolean
(only for fields of type Link) - specifies whether linking to existing entries from the field is enabled.resetFieldControl (fieldId)
: voidfieldId : string
– The ID of the field.
copyFieldControl (sourceFieldId, destinationFieldId)
: voidsourceFieldId : string
– The ID of the field to copy the control setting from.
destinationFieldId : string
– The ID of the field to apply the copied control setting to.
addSidebarWidget (widgetNamespace, widgetId[, settings, insertBeforeWidgetId])
: voidAdds a builtin or custom widget to the sidebar of the content type.
widgetNamespace: string
– The namespace of the widget, one of the following values:
sidebar-builtin
(Standard widget, default)extension
(Custom UI extension)widgetId : string
– The ID of the builtin or extension widget to add.
settings : Object
– Instance settings for the widget. Key-value pairs of type (string, number | boolean | string)
insertBeforeWidgetId : Object
– Insert widget above this widget in the sidebar. If null, the widget will be added to the end.
updateSidebarWidget (widgetNamespace, widgetId, settings)
: voidUpdates the configuration of a widget in the sidebar of the content type.
widgetNamespace: string
– The namespace of the widget, one of the following values:
sidebar-builtin
(Standard widget, default)extension
(Custom UI extension)widgetId : string
– The ID of the builtin or extension widget to add.
settings : Object
– Instance settings for the widget. Key-value pairs of type (string, number | boolean | string)
removeSidebarWidget (widgetNamespace, widgetId)
: voidRemoves a widget from the sidebar of the content type.
widgetNamespace: string
– The namespace of the widget, one of the following values:
sidebar-builtin
(Standard widget, default)extension
(Custom UI extension)widgetId : string
– The ID of the builtin or extension widget to remove.
resetSidebarToDefault ()
: voidResets the sidebar of the content type to default.
configureEntryEditor (widgetNamespace, widgetId[, settings])
: voidSets the entry editor to specified widget.
widgetNamespace: string
– The namespace of the widget.
widgetId : string
– The ID of the builtin or extension widget to add.
settings : Object
– Instance settings for the widget. Key-value pairs of type (string, number | boolean | string). Optional.
configureEntryEditors (EntryEditor[])
: voidAs opposed to configureEntryEditor
which only sets one editor, this sets a list of editors to the current editor interface of a content-type.
Each EntryEditor
has the following properties:
widgetNamespace: string
– The namespace of the widget (i.e: app
, extension
or builtin-editor
).widgetId : string
– The ID of the builtin, extension or app widget to add.settings : Object
– Instance settings for the widget. Key-value pairs of type (string, number | boolean | string). Optional.resetEntryEditorToDefault ()
: voidResets the entry editor of the content type to default.
createEditorLayout ()
: EditorLayoutCreates an empty editor layout for this content type.
editEditorLayout ()
: EditorLayoutEdits the editor layout for this content type.
deleteEditorLayout ()
: voidDeletes the editor layout for this content type.
setAnnotations(AnnotationId[])
Configure the annotations assigned to this content type. See annotations documentation for more details on valid AnnotationId
.
clearAnnotations()
Remove all assigned annotations from this content type
The field object has the same methods as the properties listed in the ContentType.createField
method.
In addition the following methods allow to manage field annotations.
setAnnotations(AnnotationId[])
Configure the annotations assigned to this field. See annotations documentation for more details on valid AnnotationId
.
clearAnnotations()
Remove all assigned annotations from this field.
moveField(id)
: MovableEditorLayoutItemMoves the field with the provided id
.
moveField(id)
returns a movable editor layout item type which must be called with a direction function:
.toTheTopOfFieldGroup(groupId)
groupId
is provided, the field will be moved within its group.toTheBottomOfFieldGroup(groupId)
groupId
is provided, the field will be moved within its group.beforeFieldGroup(groupId)
.afterFieldGroup(groupId)
.beforeField(fieldId)
.afterField(fieldId)
createFieldGroup(id[, opts])
: EditorLayoutFieldGroupCreates a tab with the provided id
.
id : string
– The ID of the group.
opts : Object
– Group settings, with the following options:
name : string
(required) – Group name.deleteFieldGroup (id)
: voidDeletes the group with the provided id
from the editor layout,
moving its contents to the parent if the group to delete is a field set or to the default tab if it’s a tab.
changeFieldGroupId (currentId, newId)
Changes the group’s ID.
currentId : string
– The current ID of the group.
newId : string
– The new ID for the group.
editFieldGroup (id[, opts])
: EditorLayoutFieldGroupcreateFieldGroup (id[, opts])
: EditorLayoutFieldGroupCreates a field set with the provided id
.
id : string
– The ID of the group.
opts : Object
– Group settings, with the following options:
name : string
(required) – Group name.changeFieldGroupControl (id, widgetNamespace, widgetId[, settings])
: voidSets the group control for a field group.
widgetNamespace : string
– The namespace for the group control. Currently allowed: builtin
.
widgetId : string
- The widget ID for the group control. Allowed values: fieldset
, topLevelTab
.
settings : Object
– Field set settings, with the following properties:
helpText : string
– Help text for the field set. Displayed when editing.collapsible : boolean
– Whether the field set can be collapsed when editing.collapsedByDefault : string
– Whether the field set is collapsed when opening the editor.You can learn more from the possible validation errors here.
You can check out the examples to learn more about the migrations DSL. Each example file is prefixed with a sequence number, specifying the order in which you're supposed to run the migrations, as follows:
1const runMigration = require('contentful-migration/built/bin/cli').runMigration 2 3const options = { 4 spaceId: '<space-id>', 5 accessToken: '<access-token>', 6 yes: true 7} 8 9const migrations = async () => { 10 await runMigration({ ...options, ...{ filePath: '01-angry-dog.js' } }) 11 await runMigration({ ...options, ...{ filePath: '02-friendly-dog.js' } }) 12 await runMigration({ ...options, ...{ filePath: '03-long-example.js' } }) 13 await runMigration({ ...options, ...{ filePath: '04-steps-errors.js' } }) 14 await runMigration({ ...options, ...{ filePath: '05-plan-errors.js' } }) 15 await runMigration({ ...options, ...{ filePath: '06-delete-field.js' } }) 16 await runMigration({ ...options, ...{ filePath: '07-display-field.js' } }) 17} 18 19migrations()
You can use Typescript to write your migration files using ts-node
! First npm install --save ts-node typescript
,
then run your migration with ts-node:
1node_modules/.bin/ts-node node_modules/.bin/contentful-migration -s $CONTENTFUL_SPACE_ID -a $CONTENTFUL_MANAGEMENT_TOKEN my_migration.ts
An example Typescript migration:
1import { MigrationFunction } from 'contentful-migration' 2 3// typecast to 'MigrationFunction' to ensure you get type hints in your editor 4export = function (migration, { makeRequest, spaceId, accessToken }) { 5 const dog = migration.createContentType('dog', { 6 name: 'Dog' 7 }) 8 9 const name = dog.createField('name') 10 name.name('Name').type('Symbol').required(true) 11} as MigrationFunction
Here's how it looks inside VS Code:
rawProxy
option to true
.1runMigration({ 2 proxy: 'https://cat:dog@example.com:1234', 3 rawProxy: true, 4 ... 5})
NOCK_RECORD=1
which should automatically update fixturesWe appreciate any help on our repositories. For more details about how to contribute see our CONTRIBUTING.md document.
This repository is published under the MIT license.
We want to provide a safe, inclusive, welcoming, and harassment-free space and experience for all participants, regardless of gender identity and expression, sexual orientation, disability, physical appearance, socioeconomic status, body size, ethnicity, nationality, level of experience, age, religion (or lack thereof), or other identity markers.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
15 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 11/12 approved changesets -- score normalized to 9
Reason
1 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More