prismic-cli Technical Reference

Introduction

A Node CLI for developing JavaScript apps with Prismic. Includes utilities for Slice Machine.

Dependencies and requirements

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

Installation

Install globally via the command line:

  • npm
  • Yarn
Copy
npm i -g prismic-cli
Copy
yarn add -global prismic-cli

If you get a permissions error, you can try again with sudo:

  • npm
  • Yarn
Copy
sudo npm i -g prismic-cli
Copy
sudo yarn add -global prismic-cli

Usage

Basic commands

prismic

Display Prismic CLI help.

prismic new

Create a new Prismic repo.

prismic theme <theme-url>

Create a new Prismic repo, download project files (GIT repo or ZIP file) from a URL, clone project, and add new repo URL to project config.

prismic signup

Create a Prismic account.

prismic login

Log in to a Prismic account.

prismic logout

Log out of Prismic.

Basic options

--conf <conf-folder>

Used with theme. Specify the configuration file.

--ignore-conf

Used with theme. Ignore the configuration file.

Slice Machine commands

prismic sm

Display Prismic Slice Machine help.

prismic sm --ls

List all the slices from libraries and the local files.

prismic sm --setup

In the root folder of a supported framework (Nuxt.js and Next.js as of January, 2021), adds dependencies for Slice Machine and Slice Builder, creates a repo in Prismic, and adds Slice Machine configuration to project.

prismic sm --boostrap

Bootstrap a project with Slice Machine from an existing configuration.

prismic sm --create-slice

Create a new Slice component in your file system and a corresponding Slice in your Prismic repo.

prismic sm --add-storybook

Create a Storybook at the root of your project and configure it to display your local Slices.

prismic sm --develop

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

prismic sm --pull

Pull slices from Prismic.

Slice Machine options

--no-prismic

Used with --setup, skips the creation of a Prismic repo.

--local-path

Used with --setup, specifies a local Slice directory.

--framework

Used with --create-slice or --add-storybook, specify the framework. Currently accepts next and nuxt.

--library
# or
--lib

Used with --setup. Specify an external Slice library to include. Uses vue-essential-slices by default.

Examples

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

$ prismic theme https://github.com/prismicio/nodejs-sdk
# Create a project from a zip file with a new prismic repository.

$ prismic sm --setup
# Setup a nuxt.js project with SliceMachine.

$ prismic sm --setup --lib vue-essential-slices --local-path ./slices
# Setup an existing Nuxt.js project with slicemachine.

$ prismic sm --ls
# List all the slices.

$ prismic sm --create-slice
# Setup a slice

$ prismic sm --pull
# Pull slices from Prismic