Storyblok Command Line Interface
Storyblok provides an official CLI for quickly scaffolding ambitious web projects.
Installation
npm i storyblok -g
Commands
Login
Sign into your account via the following command:
storyblok login
Logout
Sign out of your account with the following command:
storyblok logout
if you encounter a 404 by executing any Storyblok CLI commands, logout & login again will help.
Select
Use select
to kickstart a boilerplate, fieldtype, or theme.
storyblok select
After running the command, you will be prompted to name your new project, and select the type of project it will be:
Type | Description |
---|---|
Theme | This will prompt you to select pre-rendered themes that Storyblok has made. After selecting a theme, you will be prompted to type in your space ID so that the project can be tied to a space on Storyblok. Then, it will ask you for your domain URL and theme token. Finally, it will git-clone the repository for you with all your information pre-populated. |
Boilerplate | This will bring up a selection of boilerplates that can be used with your coding language of choice: JavaScript (Node.js and Vue.js), Python (Django), Ruby (Sinatra), and PHP (Silex). Then, the GitHub repo for the boilerplate of choice will be cloned. After, you will be prompted to type in your space ID so that the project can be tied to a space on Storyblok. |
Fieldtype | This will automatically git-clone our fieldtype repo. |
Download your space's components schema as json
The following command allows you to save your components schemas somewhere save (git, svn) and also allows you to migrate components between different spaces. Download your components json:
storyblok pull-components --space <SPACE_ID>
Use your Space ID to access this feature.
To access your space id go to {1} Settings, then {2} Space. Your {3} Space ID should be displayed.
)
Push your components file to your/another space
To push your downloaded components schema to another space you can execute the following command. Make sure to pass the right path/url of your components file you've downloaded as last parameter:
storyblok push-components --space <DEST_SPACE_ID> {{path/url}}
sync
You can sync components, folder, roles, datasources or stories between spaces.
storyblok sync --type <COMMAND> --source <SPACE_ID> --target <SPACE_ID>
Options | Description |
---|---|
type | describe the command type to execute. Can be folders, components, stories, datasources or roles. It's possible pass multiple types separated by comma (,). |
source | the source space to use to sync |
target | the target space to use to sync |
region | your space region (default: eu). If your space was created under the US region, you should use us instead. |
Examples
Please note that it is currently not possible to use the CLI to synchronize information between spaces in different regions.
/* Sync components from `00001` space to `00002` space */
storyblok sync --type components --source 00001 --target 00002
/* Sync components and stories from `00001` space to `00002` space */
storyblok sync --type components,stories --source 00001 --target 00002
You can sync multiple spaces! Tutorial: Setting Up Multiple Spaces with Storyblok CLI
quickstart
Create a space in Storyblok and select the boilerplate to use
storyblok quickstart
spaces
List all the spaces of the currently logged-in account
storyblok spaces
import
Imports flat content from .csv
, .xml
and .json
files coming from other systems.
The attributes path and title are required.
storyblok import --file <FILE_NAME> --type <TYPE_OF_CONTENT> --folder <FOLDER_ID> --delimiter <DELIMITER_TO_CSV_FILES> --space <SPACE_ID>
Options | Description |
---|---|
file | name of the file |
type | name of the content type you want to use for the import |
space | ID number of your space |
delimiter (optional) | delimiter of the .cvs files, only necessary if you are uploading a csv file (Default value is ; ) |
folder (optional) | id of the folder where you want to store the content in Storyblok |
help
For global help
storyblok --help
For command help
storyblok sync --help
version
To check your current version of the Storyblok CLI
storyblok -V
/* or --version */
Migrations
generate-migration
Create a migration file (with the name change_<COMPONENT>_<FIELD>.js
) inside the migrations folder.
storyblok generate-migration --space <SPACE_ID> --component <COMPONENT_NAME> --field <FIELD>
Options | Description |
---|---|
space | the space of where the component is |
component | component name |
field | name of field |
run-migration
Execute a specific migration file.
storyblok run-migration --space <SPACE_ID> --component <COMPONENT_NAME> --field <FIELD> --dryrun
You can provide the publish parameter to publish content after saving.
Example:
storyblok run-migration --publish published --space 1234 --component article --field image
Option | Description |
---|---|
space | the space ID number you get from the space settings area |
component | component name |
field | name of field |
dryrun | when passed as an argument, does not perform the migration |
publish (optional) | publish the content when update
|
publish-languages (optional) | publish specific languages. You can publish more than one language at a time by separating the languages by a comma ( ,). |
rollback-migration
The rollback-migration command gives the ability to undo changes made from the execution of the last run-migrations command.
storyblok rollback-migration --space 1234 --component Product --field title
The rollback-migration
command will only work if there where changes done with run-migrations. Therefore running run-migrations command with the --dryrun
flag will NOT create a rollback file.
Option | Description |
---|---|
space | the space ID number you get from the space settings area |
component | component name |
field | name of field |