command-line tools for managing PubSweet apps
- Getting started with PubSweet CLI
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/pubsweet-server||an extensible backend API that runs on the server|
|pubsweet/pubsweet-client||an extensible frontend app that runs in the browser|
|pubsweet/pubsweet-components||pluggable extensions for server and/or client|
|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 (
Usage: pubsweet [options] [command] Commands: 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] Options: -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 [...etc]
Generating an app (
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 email@example.com \ --password correct-horse-battery-staple \ --collection Articles
Running your app (
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
pubsweet run path/to/myapp
Setting up the database (
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
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
$ 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>< [...etc]
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 firstname.lastname@example.org \ --password correct-horse-battery-staple \ --collection Articles
Adding a user to the database (
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
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 email@example.com \ --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.