prismic-cli - v4

Introduction

A Node CLI for developing JavaScript apps with Prismic.

Dependencies and requirements

Runs on Node.js, and requires npm or yarn for installation.

Installation

Install globally via the command line:

  • npm
  • Yarn
npm
Copy
npm install -global prismic-cli
Yarn
Copy
yarn global add prismic-cli

Usage

Basic commands

Prepend the prismic reserved identifier words before each theme command.

prismic

The reserved identifier word before each CLI command.

prismic list

List all the available project template generators.

prismic signup

Create a new Prismic account.

prismic login

Log in to your Prismic account.

prismic logout

Log out of your Prismic account.

prismic whoami

Shows the email of the current user.

prismic new

Create a project with a new Prismic repository.

prismic theme

Create a project from a ZIP file or a GitHub repository with a new Prismic repository.

Slice Machine commands

Prepend the prismic slicemachine, or prismic sm reserved identifier words before each Slice Machine command option.

prismic sm
prismic slicemachine 

Display all the available command help options for Slice Machine.

prismic sm --setup

Set up a Slice Machine environment in an already existing project. In the root folder of a supported framework (Nuxt.js and Next.js as of January, 2021), it will add dependencies for Slice Machine and the Slice Builder. Then, it creates a repository in Prismic.

prismic sm --add-storybook

Install Storybook at the root of your Slice Machine project. It will configure it automatically to display your local slices.

prismic sm --develop

Launch the Slice Builder locally. Storybook must already be running.

prismic sm --create-slice

Create a new slice component in your file system and a corresponding slice in your Prismic repository.

prismic sm --list

List all the slices from libraries and the local files.

prismic sm --bootstrap

Bootstrap a project with Slice Machine from an existing configuration.

prismic sm --sliceName [slice-name]

The name of the slice in the library.

Common options

These options work with prismic new, prismic theme, and prismic sm --setup.

--help

Show the available command options.

--domain [repo-name]

Create a new Prismic repository. For example, your-repo-name creates the URL https://your-repo-name.prismic.io.

--folder [folder-name]

Name a new local project folder. Use it to create a new Prismic repository and select a technology.

--template [template-url]

Install a project from a Prismic template.

--force

Overwrite local files.

--skip-install

Prevent running install command after generating project.

prismic new options

Prepend the prismic theme reserved identifier words before each theme command option.

--template

Prismic template for the project.

prismic sm --setup options

--framework [next||nuxt]

Select any of the supported frameworks (Nuxt.js and Next.js as of January, 2021).

--library

The name of the slice library.

prismic theme options

Prepend the prismic theme reserved identifier words before each theme command option.

Creates a project from a ZIP file or GitHub repository. Then uploads the theme’s custom types to a new Prismic repository. Add a [theme-url] with a path to the hosted ZIP file or GitHub Repository.

--conf [configuration-path]

Path to the Prismic configuration file containing your repository’s API endpoint. Default: prismic-configuration.js.

This file should include the project’s client configuration, with the API endpoint set to 'https://your-repo-name.cdn.prismic.io/api/v2'.

When launching the theme, the command will replace any instances of the string your-repo-name with the name of the newly created repository. However, the theme can also contain a prismic-theme.json file, which contains a replaceRepositoryName property (e.g { "replaceRepositoryName": "my-repo-name" } ). This allows you to include a default repository to demo the theme.

--theme-url [theme-url]

HTTPS path to a ZIP file or a GitHub repository.

--customTypes [custom-types]

Path to the custom types directory in the project. Default: custom_types.

The directory must contain a JSON file for each custom type and an index.json file listing the custom types.

The index.json file should contain an array of objects, where each object has the following properties: { "id": "home", "name": "Home", "repeatable": false, "value": "home.json" }. The value is the path to the JSON file for the type.

The JSON file for each type should contain the JSON from the Legacy Type Builder.

Your project can contain up to 20 types.

prismic signup and prismic login options

--email [account-email]

The email of the Prismic account.

--password [account-password]

The password of the Prismic account.

--port [port-name]

Port to start the local login server. Default: [5555]

--oauthaccesstoken [oauth-access-token]

Use this for the prismic login command to add the oauth access token.

Examples

Copy
prismic new
# Create a project with a new prismic repository.

prismic --help
# Show all available help options for the Prismic CLI

prismic signup
# Create a new Prismic account. It'll ask you to add your email and a unique password.

prismic sm --setup
# Setup a nuxt.js or next.js project with Slice Machine.

prismic theme --theme-url https://github.com/prismicio/gatsby-js-sample
# Create a project from a ZIP file with a new prismic repository.

prismic sm --develop
# Run the Slice Builder locally to start creating the content modeling for your slice machine repository.

prismic sm --add-storybook
# Install Storybook in your Slice Machine project to visualize your slices and variations locally.

prismic sm --ls
# List all the slices.

prismic sm --create-slice
# Setup a slice

Was this article helpful?
Not really
Yes, Thanks

Can't find what you're looking for? Spot an error in the documentation? Get in touch with us on our Community Forum or using the feedback form above.