diff --git a/docusaurus/docs/cms/plugins-development/admin-panel-api.md b/docusaurus/docs/cms/plugins-development/admin-panel-api.md index 779f082484..8fa91b5958 100644 --- a/docusaurus/docs/cms/plugins-development/admin-panel-api.md +++ b/docusaurus/docs/cms/plugins-development/admin-panel-api.md @@ -41,7 +41,7 @@ The Admin Panel API includes: - and several [specific APIs](#available-actions) for your plugin to interact with the admin panel. :::note -The whole code for the admin panel part of your plugin could live in the `/strapi-admin.js|ts` or `/admin/src/index.js|ts` file. However, it's recommended to split the code into different folders, just like the [structure](/cms/plugins-development/plugin-structure) created by the `strapi generate plugin` CLI generator command. +The whole code for the admin panel part of your plugin could live in the `/strapi-admin.js|ts` or `/admin/src/index.js|ts` file. However, it's recommended to split the code into different folders, just like the [structure](/cms/plugins-development/plugin-structure) created by the `npx @strapi/sdk-plugin init` CLI generator command. ::: ## Entry file diff --git a/docusaurus/docs/cms/plugins-development/guides/store-and-access-data.md b/docusaurus/docs/cms/plugins-development/guides/store-and-access-data.md index 48593324be..a391e6cf53 100644 --- a/docusaurus/docs/cms/plugins-development/guides/store-and-access-data.md +++ b/docusaurus/docs/cms/plugins-development/guides/store-and-access-data.md @@ -21,7 +21,7 @@ To store data with a Strapi [plugin](/cms/plugins-development/developing-plugins ## Create a content-type for your plugin -To create a content-type with the CLI generator, run the following command in a terminal within the `server/src/` directory of your plugin: +To create a content-type with the CLI generator, run the following command in a terminal within the root of your Strapi project: diff --git a/docusaurus/docs/cms/plugins-development/plugin-sdk.md b/docusaurus/docs/cms/plugins-development/plugin-sdk.md index 9b8ea97e1c..b8c24ed996 100644 --- a/docusaurus/docs/cms/plugins-development/plugin-sdk.md +++ b/docusaurus/docs/cms/plugins-development/plugin-sdk.md @@ -76,6 +76,31 @@ strapi-plugin watch | `-d, --debug` | - | Enable debugging mode with verbose logs | false | | `--silent` | - | Do not log anything | false | +## strapi-plugin generate + +Generate APIs, [controllers](/cms/backend-customization/controllers), [content-types](/cms/backend-customization/models), [policies](/cms/backend-customization/policies), [middlewares](/cms/backend-customization/middlewares) and [services](/cms/backend-customization/services) for your plugin. + +```bash +strapi-plugin generate +``` + +| Option | Type | Description | Default | +| ------------- | :--: | --------------------------------------- | ------- | +| `-d, --debug` | - | Enable debugging mode with verbose logs | false | +| `--silent` | - | Do not log anything | false | + +The command displays an interactive menu with the following options: + +- **api** - Generate a new API with controller and service +- **controller** - Generate a new controller +- **content-type** - Generate a new content type with schema +- **policy** - Generate a new policy +- **middleware** - Generate a new middleware +- **service** - Generate a new service + +The generator detects TypeScript or JavaScript automatically and creates files with the correct extension (`.ts` or `.js`). +Generated files include commented examples. Singular and plural names must be different and use kebab-case format. + ## strapi-plugin verify Verify the output of the plugin before publishing it. diff --git a/docusaurus/docs/cms/plugins-development/server-api.md b/docusaurus/docs/cms/plugins-development/server-api.md index df6a24bcb6..5d913f59b7 100644 --- a/docusaurus/docs/cms/plugins-development/server-api.md +++ b/docusaurus/docs/cms/plugins-development/server-api.md @@ -250,6 +250,13 @@ An object with the [content-types](/cms/backend-customization/models) the plugin Content-Types keys in the `contentTypes` object should re-use the `singularName` defined in the [`info`](/cms/backend-customization/models#model-information) key of the schema. ::: +:::tip +You can scaffold a content-type by using the [generate command](/cms/plugins-development/plugin-sdk#strapi-plugin-generate) inside the root of your plugin: +```bash +strapi-plugin generate content-type +``` +::: + **Example:** @@ -527,6 +534,13 @@ An object with the [controllers](/cms/backend-customization/controllers) the plu **Type**: `Object` +:::tip +You can scaffold a controller by using the [generate command](/cms/plugins-development/plugin-sdk#strapi-plugin-generate) inside the root of your plugin: +```bash +strapi-plugin generate controller +``` +::: + **Example:** @@ -629,6 +643,13 @@ Services should be functions taking `strapi` as a parameter. **Type**: `Object` +:::tip +You can scaffold a service by using the [generate command](/cms/plugins-development/plugin-sdk#strapi-plugin-generate) inside the root of your plugin: +```bash +strapi-plugin generate service +``` +::: + **Example:** @@ -725,6 +746,13 @@ An object with the [policies](/cms/backend-customization/policies) the plugin pr **Type**: `Object` +:::tip +You can scaffold a policy by using the [generate command](/cms/plugins-development/plugin-sdk#strapi-plugin-generate) inside the root of your plugin: +```bash +strapi-plugin generate policy +``` +::: + **Example:** @@ -817,6 +845,13 @@ An object with the [middlewares](/cms/configurations/middlewares) the plugin pro **Type**: `Object` +:::tip +You can scaffold a middleware by using the [generate command](/cms/plugins-development/plugin-sdk#strapi-plugin-generate) inside the root of your plugin: +```bash +strapi-plugin generate middleware +``` +::: + **Example:**