### Quickstart Storyblok Space Creation
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Initiates the process of creating a new space in Storyblok and selecting a boilerplate. This is a basic setup command.
```sh
storyblok quickstart
```
--------------------------------
### Install Storyblok CLI
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Installs the Storyblok CLI globally using npm. Requires Node.js version 18.0.0 or higher.
```sh
$ npm i storyblok -g
```
--------------------------------
### Install Storyblok Markdown to Richtext Converter
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Installs the global package required to convert Markdown or HTML fields to Storyblok's Richtext format. This is a prerequisite for the migration script.
```sh
npm install storyblok-markdown-richtext -g
```
--------------------------------
### View Storyblok CLI Version
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Displays the currently installed version of the Storyblok CLI.
```sh
storyblok -V
```
```sh
storyblok --version
```
--------------------------------
### Generate TypeScript Typedefs - Multiple Sources
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Example of generating TypeScript type definitions by combining multiple component JSON source files.
```sh
# Generate typedefs for multiple components sources
$ storyblok generate-typescript-typedefs --sourceFilePaths ./fooComponent-12345.json,./barComponent-12345.json
```
--------------------------------
### CSV Import File Format
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Example structure for a CSV file for Storyblok content import. The first row specifies attribute names, and values are separated by semicolons.
```csv
path;title;text;image;category
this-is-my-title;This is my title;"Lorem ipsum dolor sit amet";https://a.storyblok.com/f/51376/x/1502f01431/corporate-website.svg;press
```
--------------------------------
### XML Import File Format
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Example structure for an XML file intended for content import into Storyblok. It defines the root element and row structure for content entries.
```xml
this-is-my-titleThis is my titleLorem ipsum dolor sit amethttps://a.storyblok.com/f/51376/x/1502f01431/corporate-website.svgpress
```
--------------------------------
### Custom Field Types Parser Example
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
A JavaScript function example that parses Storyblok Custom Field Types into JSON Schema nodes. This is used when the `customFieldTypesParserPath` option is provided.
```js
export default function (key, obj) {
switch (obj.field_type) {
case 'my-custom-field-type-name':
return {
[key]: {
type: 'object',
properties: {
color: { type: 'string' }
},
required: ['color']
}
}
default:
return {}
}
}
```
--------------------------------
### JSON Import File Format
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Example structure for a JSON file for Storyblok content import. It's an array of objects, where each object represents a content entry with its attributes.
```json
[
{
"path": "this-is-my-title",
"title": "This is my title",
"text": "Lorem ipsum dolor sit amet",
"image": "https://a.storyblok.com/f/51376/x/1502f01431/corporate-website.svg",
"category": "press"
}
]
```
--------------------------------
### Generate TypeScript Typedefs - Custom JSONSchemaToTS Options
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Example of providing custom options to the underlying `json-schema-to-typescript` library via a JSON configuration file.
```sh
# Provide customized options for the JSON-schema-to-typescript lib
$ storyblok generate-typescript-typedefs --sourceFilePaths ./components.12345.json --JSONSchemaToTSOptionsPath ./PathToJSONFileWithCustomOptions.json
```
--------------------------------
### Generate TypeScript Typedefs - Custom Destination
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Example of specifying a custom file path for the generated TypeScript type definition file.
```sh
# Custom path for the typedefs file
$ storyblok generate-typescript-typedefs --sourceFilePaths ./components.12345.json --destinationFilePath ./types/my-custom-type-file.d.ts
```
--------------------------------
### Generate TypeScript Typedefs - Single Source
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Example of generating TypeScript type definitions for Storyblok components from a single JSON source file.
```sh
# Generate typedefs for the components retrieved for the space `12345` via the `storyblok pull-components` command
$ storyblok generate-typescript-typedefs --sourceFilePaths ./components.12345.json
```
--------------------------------
### Get Current User in Storyblok CLI
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Retrieves information about the currently logged-in user in the Storyblok CLI.
```sh
$ storyblok user
```
--------------------------------
### Update Image Field During Migration (Storyblok CLI)
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Example of a migration script to update image field URLs. It replaces a specific domain in image URLs within the 'product' component.
```js
module.exports = function (block) {
block.image = block.image.replace('a.storyblok.com', 'my-custom-domain.com')
}
```
--------------------------------
### Generate TypeScript Typedefs - Custom Field Types Parser
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Example of specifying a custom JavaScript file to parse Storyblok Custom Field Types into JSON Schema definitions.
```sh
# Provide a custom field types parser
$ storyblok generate-typescript-typedefs --sourceFilePaths ./components.12345.json --customFieldTypesParserPath ./customFieldTypesParser.js
```
--------------------------------
### Select Storyblok Project Boilerplate
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Initiates the scaffolding process for a new Storyblok project, fieldtype, or theme.
```sh
$ storyblok select
```
--------------------------------
### Storyblok CLI Command Help
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Provides detailed help specific to a particular command, such as 'sync', outlining its options and usage.
```sh
storyblok sync --help
```
--------------------------------
### Storyblok CLI Global Help
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Displays comprehensive help information for all available Storyblok CLI commands and their general usage.
```sh
storyblok --help
```
--------------------------------
### Run Content Migration with Publishing Options (Storyblok CLI)
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Executes a content migration and optionally publishes the updated content. Supports publishing all, published, or published-with-changes, and allows specifying languages.
```sh
# you can use the --dryrun option to not execute the updates
$ storyblok run-migration --space 00000 --component product --field price
```
```sh
$ storyblok run-migration --space 00000 --component product --field price --publish all
```
```sh
# to update only one language
$ storyblok run-migration --space 00000 --component product --field price --publish all --publish-languages=de
# to update more than one language
$ storyblok run-migration --space 00000 --component product --field price --publish all --publish-languages=de,pt
```
--------------------------------
### Push Components using URL or Path
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Command to push components to a Storyblok space. It accepts a URL or a local file path (single or multiple comma-separated files) as the source for component definitions. The `--space` option is required to specify the target space ID.
```shell
$ storyblok push-components https://raw.githubusercontent.com/storyblok/nuxtdoc/master/seed.components.json --space 67819
```
```shell
$ storyblok push-components ./components.json --space 67819
```
```shell
$ storyblok push-components ./page.json,../grid.json,./feature.json --space 67819
```
```shell
$ storyblok push-components https://raw.githubusercontent.com/storyblok/nuxtdoc/master/seed.components.json --presets-source https://url-to-your-presets-file.json --space 67819
```
```shell
$ storyblok push-components ./components.json --presets-source ./presets.json --space 67819
```
--------------------------------
### Run Content Migration with Dry-Run Option (Storyblok CLI)
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Executes a content migration and allows a dry-run to preview changes without applying them. Requires space, component, and field IDs.
```sh
$ storyblok run-migration --space 00000 --component product --field price --dryrun
```
--------------------------------
### Download Storyblok Components Schema
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Downloads the component schema for a specified Storyblok space. Options include saving components and presets separately, specifying a path, custom filenames, and resolving datasources for option fields.
```sh
$ storyblok pull-components --space # Will save files like components-1234.json
```
```sh
$ storyblok pull-components --space --separate-files --prefix-presets-names --file-name production # Will save files like feature-production.json grid-production.json
```
```sh
$ storyblok pull-components --space --resolve-datasources # Will resolve datasources for single/multiple option field
```
--------------------------------
### Push Storyblok Components
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Pushes component files to a specified Storyblok space. Requires the source of the components, the target space ID, and optionally the presets source.
```sh
$ storyblok push-components --space --presets-source
```
--------------------------------
### List All Spaces
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Retrieves and displays a list of all spaces associated with the currently logged-in Storyblok account.
```sh
storyblok spaces
```
--------------------------------
### Run Migration
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Executes a specific migration file. Supports a `--dryrun` option to prevent actual changes and a `--publish` option to control content publishing (all, published, published-with-changes). Can also publish specific languages.
```sh
storyblok run-migration --space --component --field --dryrun
```
```sh
storyblok run-migration --publish published --space 1234 --component article --field image
```
--------------------------------
### Login to Storyblok CLI
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Logs into the Storyblok CLI using either email and password or a personal access token. Requires specifying the region.
```sh
$ storyblok login
```
```sh
$ storyblok login --token --region eu
```
--------------------------------
### Download Storyblok Languages Schema
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Downloads the language schema for a specified Storyblok space as a JSON file. Requires the space ID.
```sh
$ storyblok pull-languages --space
```
--------------------------------
### Generate Migration File
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Creates a new migration file in the 'migrations' folder. The filename is generated based on the component and field name. Requires space ID, component name, and field name as parameters.
```sh
storyblok generate-migration --space --component --field
```
--------------------------------
### Sync Data Between Spaces
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Command to synchronize various data types (components, folders, roles, datasources, stories) between Storyblok spaces. It allows specifying source and target space IDs, filtering by name prefixes, and applying complex filters based on keys, operations, and values. The `--components-full-sync` option ensures complete component object overrides during synchronization.
```shell
$ storyblok sync --type --source --target
```
```shell
# Sync components from `00001` space to `00002` space
$ storyblok sync --type components --source 00001 --target 00002
```
```shell
# Sync components and stories from `00001` space to `00002` space
$ storyblok sync --type components,stories --source 00001 --target 00002
```
```shell
# Sync only stories that starts with `myStartsWithString` from `00001` space to `00002` space
$ storyblok sync --type stories --source 00001 --target 00002 --starts-with myStartsWithString
```
```shell
# Sync only stories with a category field like `reference` from `00001` space to `00002` space
$ storyblok sync --type stories --source 00001 --target 00002 --filter --keys category --operations like --values reference
```
--------------------------------
### Import Content from File
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Imports content into Storyblok from various file formats (.csv, .xml, .json). Requires specifying the file name, content type, and space ID. Optional parameters include delimiter for CSV files and a target folder ID.
```sh
storyblok import --file --type --folder --delimiter --space
```
--------------------------------
### Generate Content Migration File with Storyblok CLI
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Generates a Javascript migration file for a specified component and field within a Storyblok space. Outputs a migration file (e.g., change_product_price.js) in the 'migrations' folder.
```sh
# creating a migration file to product component to update the price
$ storyblok generate-migration --space 00000 --component product --field price
```
--------------------------------
### Sync Content with Filters
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Synchronizes content between two spaces based on specified filters. It allows filtering by keys with specific operations (like, not_like) and values. Dependencies include the Storyblok CLI.
```sh
storyblok sync --type stories --source 00001 --target 00002 --filter --keys category,name --operations like,not_like --values reference,demo
```
--------------------------------
### Rollback Migration
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Undoes the changes made by the last `run-migrations` command execution. It requires the space, component, and field details. Does not work if `run-migrations` was used with `--dryrun`.
```sh
storyblok rollback-migration --space 1234 --component Product --field title
```
--------------------------------
### Generate TypeScript Type Definitions for Storyblok Components
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Generates TypeScript type definition files from Storyblok component JSON schemas. This command helps in integrating Storyblok components with TypeScript projects.
```sh
$ storyblok generate-typescript-typedefs
--sourceFilePaths
--destinationFilePath
--typeNamesPrefix
--typeNamesSuffix
--JSONSchemaToTSOptionsPath
--customFieldTypesParserPath
```
--------------------------------
### Delete Components (with options)
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Command to delete components from a Storyblok space based on local JSON definitions. It supports deleting components present in the JSON or, with the `--reverse` flag, deleting components not present in the JSON. The `--dryrun` option allows previewing changes without execution.
```shell
storyblok delete-components --space
```
```shell
$ storyblok delete-components ./components.json --space 67819
```
```shell
$ storyblok delete-components ./components.json --space 67819 --reverse
```
```shell
$ storyblok delete-components ./components.json --space 67819 --reverse --dryrun
```
--------------------------------
### Content Migration Function Structure (Javascript)
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Defines the structure of a Javascript migration function. The function receives a 'block' object representing the content to be modified.
```js
// here, 'subtitle' is the name of the field defined when you execute the generate command
module.exports = function (block) {
// Example to change a string to boolean
// block.subtitle = !!(block.subtitle)
// Example to transfer content from other field
// block.subtitle = block.other_field
}
```
--------------------------------
### Transform Markdown to Richtext in Storyblok Migration
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Applies the Markdown to Richtext conversion within a Storyblok migration script. It takes a string field containing Markdown and replaces it with a Richtext-formatted object.
```js
var richtextConverter = require('/usr/local/lib/node_modules/storyblok-markdown-richtext')
module.exports = function (block) {
if (typeof block.intro == 'string') {
block.intro = richtextConverter.markdownToRichtext(block.intro)
}
}
```
--------------------------------
### Delete Datasources with Storyblok CLI
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Commands to delete datasources within a Storyblok space. Supports filtering by slug or name. Requires SPACE_ID.
```sh
$ storyblok delete-datasources --space-id # Will delete all datasources
```
```sh
$ storyblok delete-datasources --space-id --by-slug global-translations # Will only delete datasources where the slug starts with global-translations
```
--------------------------------
### Logout from Storyblok CLI
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Logs out the currently authenticated user from the Storyblok CLI.
```sh
$ storyblok logout
```
--------------------------------
### Delete Single Component
Source: https://github.com/storyblok/storyblok-cli/blob/main/README.md
Command to delete a specific component from a Storyblok space. Requires the component name or ID and the target space ID.
```shell
storyblok delete-component --space
```
```shell
storyblok delete-component 111111 --space 67819
```
```shell
storyblok delete-component teaser --space 67819
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.