docs(v2): CLI docs (#1476)

* WiP: CLI docs

* Tweak word choices for CLI docs

- Use the word swizzle directly
- Follow variable convention for shell

* Resolve docs discussion

* Update cli.md
This commit is contained in:
Wei Gao 2019-05-17 14:01:34 +03:00 committed by Endi
parent 89ef4b9c44
commit 0e5cac94cb

View file

@ -3,8 +3,84 @@ id: cli
title: CLI
---
TODO: Add CLI reference here.
Docusaurus provides a set of scripts to help you generate, serve, and deploy your website.
#### References
Once your website is generated, your website package will contain the Docusaurus scripts that you may invoke with your package manager:
- TODO
```json
// package.json
{
// ...
"scripts": {
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy"
}
}
```
## Docusaurus CLI commands
Below is a list of Docusaurus CLI commands and their usages:
<!-- TODO: init docs after the init command is implemented
### `docusaurus init`
The `docusaurus init` command is intended to be used with `docusaurus` installed globally:
```shell
$ yarn global add docusaurus
# or
$ npm install --global docusaurus
```
-->
### `docusaurus start`
Builds and serves the static site with [Webpack Dev Server](https://webpack.js.org/configuration/dev-server).
**options**
|Options|Default|Description|
|-|-|-|
|`--port`|`3000`|Specifies the port of the dev server|
|`--host`|`localhost`|Specifie a host to use. E.g., if you want your server to be accessible externally, you can use `--host 0.0.0.0`|
|`--no-watch`|`false`|<!-- TODO problematic atm --> Disables watching files for hot reload|
|`--hot-only`|`false`|Enables Hot Module Replacement without page refresh as fallback in case of build failures. More information [here](https://webpack.js.org/configuration/dev-server/#devserverhotonly).|
### `docusaurus build`
Compiles your site for production.
**options**
|Options|Default|Description|
|-|-|-|
|`--bundle-analyzer`||Analyze your bundle with [bundle analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer)|
### `docusaurus swizzle`
Swizzle any Docusaurus Theme components with your own component with `docusaurus swizzle`.
```shell
$ docusaurus swizzle <themeName> [componentName] [siteDir]
```
**params**
- `themeName`: name of the theme you are using
- `swizzleComponent`: name of the component to be swizzled
Running the above command will copy the relevant theme files to your site folder. You may then make any changes to it and Docusaurus will use it instead of the one provided from the theme.
To unswizzle a component, simply delete the files of the swizzled component.
<!-- TODO a separate section for swizzle tutorial -->
To learn more about swizzling, check [here](#).
### `docusaurus deploy`
Deploys your site with [GitHub Pages](https://pages.github.com/).