remove remove one or more components from a pubsweet app
...
...
@@ -111,13 +122,13 @@ For any command, you can see detailed usage help by running `pubsweet help cmd`,
```bash
pubsweet help new
pubsweet help run
pubsweet help start
[...etc]
```
### 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.
The `new` subcommand generates a template PubSweet app for you to work from. This includes dependencies, boilerplate code and configuration, and a set of initial components.
To generate an app, just provide the name:
...
...
@@ -125,116 +136,97 @@ 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:
```bash
pubsweet new myappname \
--username someuser \
--email some@email.com \
--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.
`pubsweet` will clone the template app from GitLab (pubsweet-starter) into a subdirectory with the name you supplied, and run `yarn install` to install the app's dependencies.
To start your app:
### Setting up the database (`pubsweet setupdb`)
**either** use the `run` command from the app directory:
Run the `setupdb` subcommand within your app directory to create the database for your app.
```bash
cd myappname
pubsweet run
pubsweet setupdb
```
**or** provide the app path to the `run` command:
This will generate a database for the current `NODE_ENV` (defaulting to 'production'). You can also create a database for the 'dev' environment by passing `--dev`.
```bash
pubsweet run path/to/myapp
pubsweet setupdb --dev
```
### Adding and removing components (`pubsweet add`)
Components add pages, actions, and behaviors to pubsweet. There are many we've
bundled by default, and you can create your own. To read more about components,
[read the documentation](TODO!).
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`:
```bash
pubsweet add users-manager
```
$ pubsweet setupdb
info: Generating PubSweet app database at api/db/production
error: Database already exists
error: If you want to overwrite the database, use --clobber
Find all available components by typing:
```bash
pubsweet components
$ pubsweet setupdb --clobber
info: Generating PubSweet app database at api/db/production
info: Database already exists
info: Overwriting existing database due to --clobber flag
info: Aetting up the database
question:><Admin username><
[...etc]
```
To remove a component, simply type `remove` with one or more components:
The command will prompt you with a series of questions to customise your app. If you prefer to provide the answers in the initial command, you can do that instead:
```bash
pubsweet remove users-manager,teams-manager
pubsweet setupdb
--username someuser \
--email some@email.com \
--password correct-horse-battery-staple \
--collection Articles
```
### Setting up the database (`pubsweet setupdb`)
### Running your app (`pubsweet start`)
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:
Use the `start` subcommand within your app directory to start your app. It takes care of transpilation, module bundling and process management (using `forever`).
```bash
pubsweet setupdb ./path/to/app/dir
cd myappname
pubsweet start
```
By default this will generate a **production** database only. To generate a **dev** database, run the command with `--dev`:
### Adding and removing components (`pubsweet add`, `pubsweet remove`)
```bash
pubsweet setupdb --dev ./path/to/app/dir
```
Components add pages, actions, and behaviors to pubsweet. There are many we have bundled by default, and you can create your own. To learn more about components,
[read the documentation](TODO!).
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`:
Run `add` or `remove` within your app directory, followed by one or more components, to add and remove components. These subcommands use `yarn` to add or remove the components and updates the configuration for your app accordingly.
```
$ 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]
```bash
cd myappname
pubsweet add users-manager items-manager
pubsweet remove users-manager items-manager
```
As with `pubsweet new`, you can skip any or all of the interactive prompts by providing the user details with command-line flags:
Find all available components by typing:
```bash
pubsweet setupdb ./path/to/app/dir \
--username someuser \
--email some@email.com \
--password correct-horse-battery-staple \
--collection Articles
pubsweet components
```
### Adding a user to the database (`pubsweet adduser`)
You can add a user to an existing database:
Run `adduser` within your app directory to add a user to an existing database:
```bash
pubsweet adduser ./path/to/app/dir
cd myappname
pubsweet adduser
```
You can optionally make that user an admin:
```bash
pubsweet adduser --admin ./path/to/app/dir
pubsweet adduser --admin
```
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:
As with `pubsweet setupdb`, you can skip any or all of the interactive prompts by providing the user details with command-line flags:
Note that integration tests found in the file `./tests/integration.js` will run tests against the globally installed `pubsweet` binary. You can replace the globally installed `pubsweet` with the current repository by running `yarn link`. No tests outside this file require the globally installed binary.
# Credits
`pubsweet-cli` is part of the PubSweet ecosystem.
...
...
@@ -254,5 +250,3 @@ PubSweet is part of the [Collaborative Knowledge Foundation](https://coko.founda