diff --git a/docusaurus/docs/dev-docs/cli.md b/docusaurus/docs/dev-docs/cli.md index 893bb32440..5ee00d8b85 100644 --- a/docusaurus/docs/dev-docs/cli.md +++ b/docusaurus/docs/dev-docs/cli.md @@ -52,11 +52,26 @@ Strapi modifies/creates files at runtime and needs to restart when new files are Strapi also adds middlewares to support HMR (Hot Module Replacement) for the administration panel. This allows you to customize the administration panel without having to restart the application or run a separate server. -```shell -strapi develop + + + +```bash +yarn strapi develop +options: [--no-build |--no-watch-admin |--browser |--debug |--silent] +``` + + + + + +```bash +npm run strapi develop options: [--no-build |--no-watch-admin |--browser |--debug |--silent] ``` + + + - **strapi develop --open**
Starts your application with auto-reloading enabled & open your default browser with the administration panel running. - **strapi develop --no-watch-admin**
@@ -79,14 +94,46 @@ Start a Strapi application with auto-reloading disabled. This command is to run a Strapi application without restarts and file writes, primarily for use in production. Certain features such as the Content-type Builder are disabled in the `strapi start` mode because they require application restarts. The `start` command can be prefaced with [environment variables](/dev-docs/configurations/environment#strapi) to customize the application start. + + + +```bash +yarn strapi start +``` + + + + + +```bash +npm run strapi start +``` + + + + ## strapi build Builds your admin panel. + + + +```bash +yarn strapi build +``` + + + + + ```bash -strapi build +npm run strapi build ``` + + + | Option | Type | Description | | ------------------- | :--: | -------------------------------------------------------- | | `-d, --debug` | - | Enable debugging mode with verbose logs (default: false) | @@ -100,22 +147,90 @@ strapi build Logs in to Strapi Cloud (see [Cloud CLI](/cloud/cli/cloud-cli#strapi-login) documentation). + + + +```bash +yarn strapi login +``` + + + + + +```bash +npm run strapi login +``` + + + + ## strapi logout Logs out from Strapi Cloud (see [Cloud CLI](/cloud/cli/cloud-cli#strapi-logout) documentation). + + + +```bash +yarn strapi logout +``` + + + + + +```bash +npm run strapi logout +``` + + + + ## strapi deploy Deploys to Strapi Cloud (see [Cloud CLI](/cloud/cli/cloud-cli#strapi-deploy) documentation). + + + +```bash +yarn strapi deploy +``` + + + + + +```bash +npm run strapi deploy +``` + + + + ## strapi export [Exports your project data](/dev-docs/data-management). The default settings create a `.tar` file, compressed using `gzip` and encrypted using `aes-128-ecb`. + + + +```bash +yarn strapi export +``` + + + + + ```bash -strapi export +npm run strapi export ``` + + + The exported file is automatically named using the format `export_YYYYMMDDHHMMSS` with the current date and timestamp. Alternately, you can specify the filename using the `-f` or `--file` flag. The following table provides all of the available options as command line flags: | Option | Type | Description | @@ -130,22 +245,54 @@ The exported file is automatically named using the format `export_YYYYMMDDHHMMSS **Examples** + + + ```bash title="Examples of strapi export:" # export your data with the default options and the filename myData, which results in a file named myData.tar.gz.enc. -strapi export -f myData +yarn strapi export -f myData # export your data without encryption. -strapi export --no-encrypt +yarn strapi export --no-encrypt ``` + + + + +```bash title="Examples of strapi export:" +# export your data with the default options and the filename myData, which results in a file named myData.tar.gz.enc. +npm run strapi export -- -f myData + +# export your data without encryption. +npm run strapi export -- --no-encrypt +``` + + + + ## strapi import [Imports data](/dev-docs/data-management) into your project. The imported data must originate from another Strapi application. You must pass the `--file` option to specify the filename and location for the import action. + + + +```bash +yarn strapi import +``` + + + + + ```bash -strapi import +npm run strapi import ``` + + + | Option | Type | Description | | -------------- | ------ | ------------------------------------------------------------------------- | | `-k,` `--key` | string | Provide the encryption key in the command instead of a subsequent prompt. | @@ -154,12 +301,26 @@ strapi import **Examples** + + + ```bash title="Example of strapi import:" +# import your data with the default parameters and pass an encryption key: +yarn strapi import -f your-filepath-and-filename --key my-key +``` + + + + +```bash title="Example of strapi import:" # import your data with the default parameters and pass an encryption key: -strapi import -f your-filepath-and-filename --key my-key +npm run strapi import -- -f your-filepath-and-filename --key my-key ``` + + + ## strapi transfer [Transfers data](/dev-docs/data-management/transfer) between 2 Strapi instances. This command is primarily intended for use between a local instance and a remote instance or 2 remote instances. The `transfer` command requires a Transfer token, which is generated in the destination instance Admin panel. See the [User Guide](/user-docs/settings/transfer-tokens) for detailed documentation on creating Transfer tokens. @@ -185,10 +346,24 @@ Either `--to` or `--from` is required, but it's not currently allowed to enter b **Example** + + + ```bash -strapi transfer --to http://example.com/admin --to-token my-transfer-token +yarn strapi transfer --to http://example.com/admin --to-token my-transfer-token ``` + + + + +```bash +npm run strapi transfer -- --to http://example.com/admin --to-token my-transfer-token +``` + + + + ## strapi report Prints out debug information useful for debugging and required when reporting an issue. @@ -201,18 +376,32 @@ Prints out debug information useful for debugging and required when reporting an **Examples** -To include the project UUID and dependencies in the output: + + ```bash -strapi report --uuid --dependencies +# To include the project UUID and dependencies in the output: +yarn strapi report --uuid --dependencies + +# To log everything, use the --all option: +yarn strapi report --all ``` -To log everything, use the `--all` option: + + + ```bash -strapi report --all +# To include the project UUID and dependencies in the output: +npm run strapi report -- --uuid --dependencies + +# To log everything, use the --all option: +npm run strapi report -- --all ``` + + + ## strapi configuration:dump **Alias**: `config:dump` @@ -221,18 +410,55 @@ Dumps configurations to a file or stdout to help you migrate to production. The dump format will be a JSON array. + + + +```bash title="strapi configuration:dump" +yarn strapi configuration:dump + +Options: + -f, --file Output file, default output is stdout + -p, --pretty Format the output JSON with indentation and line breaks (default: false) +``` + + + + + ```bash title="strapi configuration:dump" +npm run strapi configuration:dump Options: -f, --file Output file, default output is stdout -p, --pretty Format the output JSON with indentation and line breaks (default: false) ``` + + + **Examples** -- `strapi configuration:dump -f dump.json` -- `strapi config:dump --file dump.json` -- `strapi config:dump > dump.json` + + + +```bash +yarn strapi configuration:dump -f dump.json +yarn strapi config:dump --file dump.json +yarn strapi config:dump > dump.json +``` + + + + + +```bash +npm run strapi configuration:dump -- -f dump.json +npm run strapi config:dump -- --file dump.json +npm run strapi config:dump > dump.json +``` + + + All these examples are equivalent. @@ -243,7 +469,6 @@ In case of doubt, you should avoid committing the dump file into a versioning sy - Copy the file directly to the environment you want and run the restore command there. - Put the file in a secure location and download it at deploy time with the right credentials. - Encrypt the file before committing and decrypt it when running the restore command. - ::: ## strapi configuration:restore @@ -254,20 +479,55 @@ Restores a configuration dump into your application. The input format must be a JSON array. + + + +```bash +yarn strapi configuration:restore + +Options: + -f, --file Input file, default input is stdin + -s, --strategy Strategy name, one of: "replace", "merge", "keep". Defaults to: "replace" +``` + + + + + ```bash -strapi configuration:restore +npm run strapi configuration:restore Options: -f, --file Input file, default input is stdin -s, --strategy Strategy name, one of: "replace", "merge", "keep". Defaults to: "replace" ``` + + + **Examples** -- `strapi configuration:restore -f dump.json` -- `strapi config:restore --file dump.json -s replace` -- `cat dump.json | strapi config:restore` -- `strapi config:restore < dump.json` + + + +```bash +yarn strapi configuration:restore -f dump.json +yarn strapi config:restore --file dump.json -s replace +yarn strapi config:restore < dump.json +``` + + + + + +```bash +npm run strapi configuration:restore -- -f dump.json +npm run strapi config:restore -- --file dump.json -s replace +npm run strapi config:restore < dump.json +``` + + + All these examples are equivalent. @@ -291,11 +551,24 @@ Administrator's first name, last name, email, and password can be: **Example** + + + ```bash +yarn strapi admin:create-user --firstname=Kai --lastname=Doe --email=chef@strapi.io --password=Gourmet1234 +``` + + -strapi admin:create-user --firstname=Kai --lastname=Doe --email=chef@strapi.io --password=Gourmet1234 + + +```bash +npm run strapi admin:create-user -- --firstname=Kai --lastname=Doe --email=chef@strapi.io --password=Gourmet1234 ``` + + + **Options** | Option | Type | Description | Required | @@ -315,11 +588,24 @@ You can pass the email and new password as options or set them interactively if **Example** + + + ```bash +yarn strapi admin:reset-user-password --email=chef@strapi.io --password=Gourmet1234 +``` + + -strapi admin:reset-user-password --email=chef@strapi.io --password=Gourmet1234 + + +```bash +npm run strapi admin:reset-user-password -- --email=chef@strapi.io --password=Gourmet1234 ``` + + + **Options** | Option | Type | Description | @@ -332,18 +618,46 @@ strapi admin:reset-user-password --email=chef@strapi.io --password=Gourmet1234 Run a fully interactive CLI to generate APIs, [controllers](/dev-docs/backend-customization/controllers), [content-types](/dev-docs/backend-customization/models), [plugins](/dev-docs/plugins/development/create-a-plugin), [policies](/dev-docs/backend-customization/policies), [middlewares](/dev-docs/backend-customization/middlewares) and [services](/dev-docs/backend-customization/services), and [migrations](/dev-docs/database-migrations). + + + ```bash -strapi generate +yarn strapi generate ``` + + + + +```bash +npm run strapi generate +``` + + + + ## strapi templates:generate Create a template from the current Strapi project. + + + +```bash +yarn strapi templates:generate +``` + + + + + ```bash -strapi templates:generate +npm run strapi templates:generate ``` + + + - **strapi templates:generate <path>**
Generates a Strapi template at `` @@ -353,10 +667,24 @@ strapi templates:generate Generate [TypeScript](/dev-docs/typescript) typings for the project schemas. + + + +```bash +yarn strapi ts:generate-types +``` + + + + + ```bash -strapi ts:generate-types +npm run strapi ts:generate-types ``` + + + - **strapi ts:generate-types --debug**
Generate typings with the debug mode enabled, displaying a detailed table of the generated schemas. - **strapi ts:generate-types --silent** or **strapi ts:generate-types -s**
@@ -372,95 +700,263 @@ Strapi requires the project types to be generated in the `types` directory for t Display a list of all the available [routes](/dev-docs/backend-customization/routes). + + + +```bash +yarn strapi routes:list +``` + + + + + ```bash -strapi routes:list +npm run strapi routes:list ``` + + + ## strapi policies:list Display a list of all the registered [policies](/dev-docs/backend-customization/policies). + + + +```bash +yarn strapi policies:list +``` + + + + + ```bash -strapi policies:list +npm run strapi policies:list ``` + + + ## strapi middlewares:list Display a list of all the registered [middlewares](/dev-docs/backend-customization/middlewares). + + + +```bash +yarn strapi middlewares:list +``` + + + + + ```bash -strapi middlewares:list +npm run strapi middlewares:list ``` + + + ## strapi content-types:list Display a list of all the existing [content-types](/dev-docs/backend-customization/models). + + + +```bash +yarn strapi content-types:list +``` + + + + + ```bash -strapi content-types:list +npm run strapi content-types:list ``` + + + ## strapi hooks:list Display a list of all the available hooks. + + + +```bash +yarn strapi hooks:list +``` + + + + + ```bash -strapi hooks:list +npm run strapi hooks:list ``` + + + ## strapi controllers:list Display a list of all the registered [controllers](/dev-docs/backend-customization/controllers). + + + ```bash -strapi controllers:list +yarn strapi controllers:list ``` + + + + +```bash +npm run strapi controllers:list +``` + + + + ## strapi services:list Display a list of all the registered [services](/dev-docs/backend-customization/services). + + + +```bash +yarn strapi services:list +``` + + + + + ```bash -strapi services:list +npm run strapi services:list ``` + + + ## strapi telemetry:disable Disable data collection for the project (see [Usage Information](/dev-docs/usage-information)). + + + +```bash +yarn strapi telemetry:disable +``` + + + + + ```bash -strapi telemetry:disable +npm run strapi telemetry:disable ``` + + + ## strapi telemetry:enable Re-enable data collection for the project after it was disabled (see [Usage Information](/dev-docs/usage-information)). + + + +```bash +yarn strapi telemetry:enable +``` + + + + + ```bash -strapi telemetry:enable +npm run strapi telemetry:enable ``` + + + ## strapi console Start the server and eval commands in your application in real time. + + + +```bash +yarn strapi console +``` + + + + + ```bash -strapi console +npm run strapi console ``` + + + ## strapi version Print the currently installed Strapi version. It will output the current globally installed version if this command is strapi is installed globally, or the current version of Strapi within a Strapi project if the command is run from a given folder containing a Strapi project. + + + +```bash +yarn strapi version +``` + + + + + ```bash -strapi version +npm run strapi version ``` + + + ## strapi help List CLI commands. + + + +```bash +yarn strapi help +``` + + + + + ```bash -strapi help +npm run strapi help ``` + + +