Extension management with the Contentful CLI
These commands will help you manage extensions in Contentful.
Requirements
- A (free) Contentful account
- Locally installed contentful-cli
- Authenticated with contentful-cli
List available commands and their description
contentful extension --helpCreate a new extension
contentful extension create --space-id xxx --id test --name "Test Extension" --field-types Symbol --src https://new.extensionCreate an extension using srcdoc with automatically assigned ID and two field types:
contentful extension create --space-id xxx --field-types Symbol --field-types Text --srcdoc ./bundle.htmlWhen using the srcdoc property, an extension is considered internally hosted. A file being pointed by the srcdoc property will be loaded and uploaded as a string to Contentful. All local dependencies have to be manually inlined into the file. The command line tool does not take care of link resolving and inlining of referenced local resources. The maximum size of a file used with the srcdoc property is 512kB.
Create an extension using ./extension.json descriptor file and provide installation parameter:
Examples of
extension.jsonfiles and extensions in general can be found here.
contentful extension create --space-id xxx --installation-parameters '{"devMode": true}'Get a list of all available extensions
Lists all available extensions from a space.
contentful extension list --space-id xxxThe output should look similar to this:
┌────────────────┬──────────────┬──────────────┐
│ Extension Name │ Extension ID │ Version      │
├────────────────┼──────────────┼──────────────┤
│ Test           │ test         │ 3            │
└────────────────┴──────────────┴──────────────┘Delete an extension
Deletes an extension from a space.
contentful extension delete --space-id xxx --id testThe output should look similar to this:
Successfully deleted extension with ID testGet an extension
Prints information about the requested extension.
contentful extension get --space-id xxx --id testThe output should look similar to this:
┌─────────────┬───────────────────────────┐
│ Property    │ Value                     │
├─────────────┼───────────────────────────┤
│ ID          │ test                      │
├─────────────┼───────────────────────────┤
│ Name        │ Test Extension            │
├─────────────┼───────────────────────────┤
│ Field types │ Symbol                    │
├─────────────┼───────────────────────────┤
│ Src         │ https://awesome.extension │
├─────────────┼───────────────────────────┤
│ Version     │ 1                         │
└─────────────┴───────────────────────────┘Update an extension
Update an extension without providing its current version:
contentful extension update --space-id xxx --id test --name "Test Extension" --field-types Symbol --src https://new.extension --forceUpdate an extension using srcdoc and two field types:
contentful extension update --space-id xxx --id test --field-types Symbol --field-types Text --srcdoc ./bundle.html --version 2Update an extension using ./extension.json descriptor file and provide installation parameter:
contentful extension update --space-id xxx --installation-parameters '{"devMode": true}' --forceNext steps
Not what you’re looking for? Try our FAQ.