Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<Tabs groupId="yarn-npm">
<TabItem value="yarn" label="Yarn">
Expand Down
25 changes: 25 additions & 0 deletions docusaurus/docs/cms/plugins-development/plugin-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
35 changes: 35 additions & 0 deletions docusaurus/docs/cms/plugins-development/server-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

<Tabs groupId="js-ts">
Expand Down Expand Up @@ -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:**

<Tabs groupdId="js-ts">
Expand Down Expand Up @@ -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:**

<Tabs groupdId="js-ts">
Expand Down Expand Up @@ -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:**

<Tabs groupdId="js-ts">
Expand Down Expand Up @@ -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:**

<Tabs groupId="js-ts">
Expand Down