From b62f221b8b24aa23a2c8f16553c53be82b548cce Mon Sep 17 00:00:00 2001 From: Pierre Wizla Date: Thu, 28 Oct 2021 22:52:54 +0200 Subject: [PATCH 1/3] Add the new interactive `strapi generate` + all the `:list` commands --- .../latest/developer-resources/cli/CLI.md | 179 ++++-------------- .../backend-customization/models.md | 2 +- .../latest/development/plugins-development.md | 5 +- docs/developer-docs/latest/plugins/graphql.md | 2 +- 4 files changed, 41 insertions(+), 147 deletions(-) diff --git a/docs/developer-docs/latest/developer-resources/cli/CLI.md b/docs/developer-docs/latest/developer-resources/cli/CLI.md index 1105655de7..4543c45a94 100644 --- a/docs/developer-docs/latest/developer-resources/cli/CLI.md +++ b/docs/developer-docs/latest/developer-resources/cli/CLI.md @@ -183,182 +183,75 @@ strapi admin:reset-user-password --email=chef@strapi.io --password=Gourmet1234 | -p, --password | string | New password for the user | | -h, --help | | display help for command | -## strapi generate:api +## strapi generate -Scaffold a complete API with its configurations, controller, model and service. +Run a fully interactive CLI to generate APIs, [controllers](/developer-docs/latest/development/backend-customization/controllers.md), [content-types](/developer-docs/latest/development/backend-customization/models.md), [plugins](/developer-docs/latest/development/plugins-development.md#creating-a-plugin), [policies](/developer-docs/latest/development/backend-customization/policies.md), [middlewares](/developer-docs/latest/development/backend-customization/middlewares.md) and [services](/developer-docs/latest/development/backend-customization/services.md). -```bash -strapi generate:api [] - -options: [--plugin ] +```sh +strapi generate ``` -- **strapi generate:api <name>**
- Generates an API called **<name>** in the `./api` folder at the root of your project. - -- **strapi generate:api <name> --draft-and-publish=true**
- Generates an API called **<name>** in the `./api` folder at the root of your project and enabled the draft/publish feature. - -- **strapi generate:api <name> <attribute:type>**
- Generates an API called **<name>** in the `./api` folder at the root of your project. The model will already contain an attribute called **<attribute>** with the type property set to **<type>**. - - Example: `strapi generate:api product name:string description:text price:integer` - -- **strapi generate:api <name> --plugin <plugin>**
- Generates an API called **<name>** in the `./plugins/` folder. - - Example: `strapi generate:api product --plugin content-manager` - -::: tip TIPS -* The filename will be kebab-cased. -* When you create a new API using the CLI, a model is automatically created. -::: - -## strapi generate:controller +## strapi generate:template -Create a new controller. +Create a template from the current strapi project ```bash -strapi generate:controller - -options: [--api |--plugin ] +strapi generate:template ``` -- **strapi generate:controller <name>**
- Generates an empty controller called **<name>** in the `./api//controllers` folder. - - Example: `strapi generate:controller category` will create the controller at `./api/category/controllers/Category.js`. - -- **strapi generate:controller <name> --api <api>**
- Generates an empty controller called **<name>** in the `./api//controllers` folder. - - Example: `strapi generate:controller category --api product` will create the controller at `./api/product/controllers/Category.js`. - -- **strapi generate:controller <name> --plugin <plugin>**
- Generates an empty controller called **<name>** in the `./plugins//controllers` folder. - -::: tip -The first letter of the filename will be uppercase. -::: +- **strapi generate:template <path>**
+ Generates a Strapi template at `` -## strapi generate:model + Example: `strapi generate:template ../strapi-template-name` will copy the required files and folders to a `template` directory inside `../strapi-template-name` -Create a new model. +## strapi routes:list -```bash -strapi generate:model [] +Display a list of all the available routes. -options: [--api |--plugin |--draft-and-publish ] +```sh +strapi routes:list ``` -- **strapi generate:model <name>**
- Generates an empty model called **<name>** in the `./api//models` folder. It will create two files. - The first one will be **<name>.js** which contains your lifecycle callbacks and another **<name>.settings.json** that will list your attributes and options. - - Example: `strapi generate:model category` will create these two files `./api/category/models/Category.js` and `./api/category/models/Category.settings.json`. - -- **strapi generate:model <name> <attribute:type>**
- Generates an empty model called **<name>** in the `./api//models` folder. The file **<name>.settings.json** will already contain a list of attribute with their associated **<type>**. - - Example: `strapi generate:model category name:string description:text` will create these two files `./api/category/models/Category.js` and `./api/category/models/Category.settings.json`. This last file will contain two attributes `name` with the type `string` and `description` with type `text`. - -- **strapi generate:model <name> --api <api>**
- Generates an empty model called **<name>** in the `./api//models` folder. - - Example: `strapi generate:model category --api product` will create these two files: - - - `./api/product/models/Category.js` - - `./api/product/models/Category.settings.json`. - -* **strapi generate:model <name> --plugin <plugin>**
- Generates an empty model called **<name>** in the `./plugins//models` folder. - -* **strapi generate:model <name> --draft-and-publish=true**
- Generates an empty model called **<name>** in the `./plugins//models` folder with the draft/publish feature enabled +## strapi policies:list -::: tip -The first letter of the filename will be uppercase. -::: - -## strapi generate:service - -Create a new service. - -```bash -strapi generate:service +Display a list of all the registered policies. -options: [--api |--plugin ] +```sh +strapi policies:list ``` -- **strapi generate:service <name>**
- Generates an empty service called **<name>** in the `./api//services` folder. - - Example: `strapi generate:service category` will create the service at `./api/category/services/Category.js`. - -- **strapi generate:service <name> --api <api>**
- Generates an empty service called **<name>** in the `./api//services` folder. - - Example: `strapi generate:service category --api product` will create the service at `./api/product/services/Category.js`. +## strapi middlewares:list -- **strapi generate:service <name> --plugin <plugin>**
- Generates an empty service called **<name>** in the `./plugins//services` folder. +Display a list of all the registered middlewares. -::: tip -The first letter of the filename will be uppercase. -::: - -## strapi generate:policy - -Create a new policy. - -```bash -strapi generate:policy - -options: [--api |--plugin ] +```sh +strapi middlewares:list ``` -- **strapi generate:policy <name>**
- Generates an empty policy called **<name>** in the `./config/policies` folder. - - Example: `strapi generate:policy isAuthenticated` will create the policy at `./config/policies/isAuthenticated.js`. - -- **strapi generate:policy <name> --api <api>**
- Generates an empty policy called **<name>** in the `./api//config/policies` folder. This policy will be scoped and only accessible by the **<api>** routes. +## strapi content-types:list - Example: `strapi generate:policy isAuthenticated --api product` will create the policy at `./api/product/config/policies/isAuthenticated.js`. +Display a list of all the existing content-types. -- **strapi generate:policy <name> --plugin <plugin>**
- Generates an empty policy called **<name>** in the `./plugins//config/policies` folder. This policy will be scoped and accessible only by the **<plugin>** routes. - -## strapi generate:plugin - -Create a new plugin skeleton. - -```bash -strapi generate:plugin +```sh +strapi content-types:list ``` -- **strapi generate:plugin <name>**
- Generates an empty plugin called **<name>** in the `./plugins` folder. - - Example: `strapi generate:plugin user` will create the plugin at `./plugins/user`. - -Please refer to the [plugins development](/developer-docs/latest/development/plugins-development.md) section to know more. - -## strapi generate:template + +## strapi hooks:list -Create a template from the current strapi project +Display a list of all the available hooks. -```bash -strapi generate:template +```sh +strapi hooks:list ``` -- **strapi generate:template <path>**
- Generates a Strapi template at `` - - Example: `strapi generate:template ../strapi-template-name` will copy the required files and folders to a `template` directory inside `../strapi-template-name` +## strapi services:list +Display a list of all the registered services. +```sh +strapi services:list +``` ## strapi install Install a plugin in the project. diff --git a/docs/developer-docs/latest/development/backend-customization/models.md b/docs/developer-docs/latest/development/backend-customization/models.md index 832add5f7d..c782cab04c 100644 --- a/docs/developer-docs/latest/development/backend-customization/models.md +++ b/docs/developer-docs/latest/development/backend-customization/models.md @@ -26,7 +26,7 @@ Content-types and components models are created and stored differently. Content-types in Strapi can be created: - with the [Content-Types Builder in the admin panel](/user-docs/latest/content-types-builder/introduction-to-content-types-builder.md), -- or with [Strapi's CLI `generate:model`](/developer-docs/latest/developer-resources/cli/CLI.md#strapi-generate-model) command. +- or with [Strapi's interactive CLI `strapi generate`](/developer-docs/latest/developer-resources/cli/CLI.md#strapi-generate) command. Creating a content-type with either method generates 2 files: diff --git a/docs/developer-docs/latest/development/plugins-development.md b/docs/developer-docs/latest/development/plugins-development.md index f05966bba0..78c65529fd 100644 --- a/docs/developer-docs/latest/development/plugins-development.md +++ b/docs/developer-docs/latest/development/plugins-development.md @@ -17,8 +17,9 @@ To create a plugin, use Strapi CLI tools: 1. (_Optional_) If you don't already have an existing project, create a new development project with `strapi new myDevelopmentProject`. 2. Start the project with `cd myDevelopmentProject && strapi develop`. -3. In a new terminal window, [create a new plugin](/developer-docs/latest/developer-resources/cli/CLI.md#strapi-generate-plugin) with `cd /path/to/myDevelopmentProject && strapi generate:plugin my-plugin` -4. Enable the plugin by adding it to the [plugins configurations](/developer-docs/latest/setup-deployment-guides/configurations/optional/plugins.md) file: +3. In a new terminal window, run `cd /path/to/myDevelopmentProject && strapi generate` to launch the interactive `strapi generate` CLI. +4. Choose "plugin" from the list, press Enter, and give the plugin a name. +5. Enable the plugin by adding it to the [plugins configurations](/developer-docs/latest/setup-deployment-guides/configurations/optional/plugins.md) file: ```js // path: /path/to/myDevelopmentProject/config/plugins.js diff --git a/docs/developer-docs/latest/plugins/graphql.md b/docs/developer-docs/latest/plugins/graphql.md index 60ec4e2412..45b7340f15 100644 --- a/docs/developer-docs/latest/plugins/graphql.md +++ b/docs/developer-docs/latest/plugins/graphql.md @@ -75,7 +75,7 @@ To simplify and automate the build of the GraphQL schema, we introduced the Shad **Example:** -If you've generated an API called `Restaurant` using the CLI `strapi generate:api restaurant` or the administration panel, your model looks like this: +If you've generated an API called `Restaurant` using [the interactive `strapi generate` CLI](/developer-docs/latest/developer-resources/cli/CLI.md#strapi-generate) or the administration panel, your model looks like this: ```json // path: ./src/api/[api-name]/content-types/restaurant/schema.json From 8ba15aea3f87c62448e4e09d0294c0220a5e49c5 Mon Sep 17 00:00:00 2001 From: Pierre Wizla Date: Thu, 28 Oct 2021 23:11:57 +0200 Subject: [PATCH 2/3] Add strapi watch-admin --- .../developer-docs/latest/developer-resources/cli/CLI.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/developer-docs/latest/developer-resources/cli/CLI.md b/docs/developer-docs/latest/developer-resources/cli/CLI.md index 4543c45a94..277cfafead 100644 --- a/docs/developer-docs/latest/developer-resources/cli/CLI.md +++ b/docs/developer-docs/latest/developer-resources/cli/CLI.md @@ -95,6 +95,15 @@ options: [--no-optimization] - **strapi build --no-optimization**
Builds the administration panel without minimizing the assets. The build duration is faster. +## strapi watch-admin + +Starts the admin server. Strapi should already be running with `strapi develop`. + +```sh +strapi watch-admin +options: [--browser ] +``` + ## strapi configuration:dump **Alias**: `config:dump` From 91853d5ff0a3379a73256719646e7b50b96ff74c Mon Sep 17 00:00:00 2001 From: Pierre Wizla Date: Thu, 28 Oct 2021 23:12:16 +0200 Subject: [PATCH 3/3] Add links to docs entries for :list commands --- .../latest/developer-resources/cli/CLI.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/developer-docs/latest/developer-resources/cli/CLI.md b/docs/developer-docs/latest/developer-resources/cli/CLI.md index 277cfafead..86b8900c9d 100644 --- a/docs/developer-docs/latest/developer-resources/cli/CLI.md +++ b/docs/developer-docs/latest/developer-resources/cli/CLI.md @@ -215,7 +215,7 @@ strapi generate:template ## strapi routes:list -Display a list of all the available routes. +Display a list of all the available [routes](/developer-docs/latest/development/backend-customization/routes.md). ```sh strapi routes:list @@ -223,7 +223,7 @@ strapi routes:list ## strapi policies:list -Display a list of all the registered policies. +Display a list of all the registered [policies](/developer-docs/latest/development/backend-customization/policies.md). ```sh strapi policies:list @@ -231,7 +231,7 @@ strapi policies:list ## strapi middlewares:list -Display a list of all the registered middlewares. +Display a list of all the registered [middlewares](/developer-docs/latest/development/backend-customization/middlewares.md). ```sh strapi middlewares:list @@ -239,7 +239,7 @@ strapi middlewares:list ## strapi content-types:list -Display a list of all the existing content-types. +Display a list of all the existing [content-types](/developer-docs/latest/development/backend-customization/models.md). ```sh strapi content-types:list @@ -256,11 +256,12 @@ strapi hooks:list ## strapi services:list -Display a list of all the registered services. +Display a list of all the registered [services](/developer-docs/latest/development/backend-customization/services.md). ```sh strapi services:list ``` + ## strapi install Install a plugin in the project.