PubSweet command line interface

Name Last Update
.gitlab/merge_request_templates Loading commit data...
bin Loading commit data...
cli Loading commit data...
initial-app Loading commit data...
logs Loading commit data...
src Loading commit data...
test Loading commit data...
.eslintrc Loading commit data...
.gitignore Loading commit data...
.gitlab-ci.yml Loading commit data...
CONTRIBUTING Loading commit data... Loading commit data...
package.json Loading commit data...

PubSweet CLI

command-line tools for managing PubSweet apps

PubSweet home MIT license npm build status coverage report code style standard mattermost chat



PubSweet overview

PubSweet allows you to build state-of-the-art publishing platforms.

It's a modular and flexible framework consisting of a server and client that work together, components that can modify or extend the functionality of the server and/or client, and a command-line tool that helps manage PubSweet apps.

PubSweet modules

repository description
pubsweet-server pubsweet/pubsweet-server an extensible backend API that runs on the server
pubsweet-client pubsweet/pubsweet-client an extensible frontend app that runs in the browser
pubsweet-components pubsweet/pubsweet-components pluggable extensions for server and/or client
pubsweet-cli pubsweet/pubsweet-cli a suite of command-line tools for building and managing your platform

Getting started with PubSweet CLI

Getting PubSweet CLI


  • node v7.6+
  • npm v3+ or yarn v0.21+


The PubSweet command-line tools can be installed from npm or yarn:

npm install --global pubsweet


yarn global add pubsweet

Using PubSweet CLI

Displaying the commands (pubsweet or pubsweet help)


Usage: pubsweet [options] [command]


  new         create and set up a new pubsweet app
  run         start a pubsweet app
  setupdb     generate a database for a pubsweet app
  add         add one or more components to a pubsweet app
  adduser     add a user to the database for a pubsweet app
  help [cmd]  display help for [cmd]


  -h, --help     output usage information
  -V, --version  output the version number

For any command, you can see detailed usage help by running pubsweet help cmd, e.g.:

pubsweet help new
pubsweet help run

Generating an app (pubsweet new)

The new subcommand generates a template PubSweet app for you to work from. This includes everything needed to run your publishing platform: dependencies, database setup, boilerplate code and configuration, and a set of initial components.

To generate an app, just provide the name:

pubsweet new myappname

pubsweet will create a subdirectory with the name you supplied, and start generating the app inside. It'll ask you a series of questions to customise your app. If you prefer to provide the answers in the initial command, you can do that instead:

pubsweet new myappname \
  --username someuser \
  --email \
  --password correct-horse-battery-staple \
  --collection Articles

Running your app (pubsweet run)

The run subcommand starts your app. It takes care of transpilation, module bundling and process management.

To start your app:

either use the run command from the app directory:

cd myappname
pubsweet run

or provide the app path to the run command:

pubsweet run path/to/myapp

Setting up the database (pubsweet setupdb)

The setupdb subcommand creates the database for your app. It is usually used when you've cloned the source code of an existing app, or when you want to start over with a fresh database.

To generate a database for an app that doesn't have one yet:

pubsweet setupdb ./path/to/app/dir

By default this will generate a production database only. To generate a dev database, run the command with --dev:

pubsweet setupdb --dev ./path/to/app/dir

If your app already has a database, pubsweet setupdb will not overwrite it by default. You can force it to delete an existing database and overwrite it with a new one using --clobber:

$ pubsweet setupdb ./path/to/app/dir
info: Generating PubSweet app database at path api/db/production
error: Database appears to already exist
error: If you want to overwrite the database, use --clobber
$ pubsweet setupdb --clobber ./path/to/app/dir
info: Generating PubSweet app database at path api/db/production
info: Database appears to already exist
info: Overwriting existing database due to --clobber flag
info: setting up the database
info: building prompt
question:><Admin username><

As with pubsweet new, you can skip any or all of the interactive prompts by providing the user details with command-line flags:

pubsweet setupdb ./path/to/app/dir \
  --username someuser \
  --email \
  --password correct-horse-battery-staple \
  --collection Articles

Adding a user to the database (pubsweet adduser)

You can add a user to an existing database:

pubsweet adduser ./path/to/app/dir

You can optionally make that user an admin:

pubsweet adduser --admin ./path/to/app/dir

As with pubsweet new and pubsweet setupdb, you can skip any or all of the interactive prompts by providing the user details with command-line flags:

pubsweet adduser ./path/to/app/dir \
  --username someuser \
  --email \
  --password correct-horse-battery-staple


Please read our CONTRIBUTING guide.


pubsweet-cli is part of the PubSweet ecosystem.

PubSweet is part of the Collaborative Knowledge Foundation family.