Skip to content

Commit 26a6bd4

Browse files
authored
add strapi:generate template command (#308)
1 parent 6efa647 commit 26a6bd4

File tree

2 files changed

+40
-6
lines changed
  • docs/developer-docs/latest

2 files changed

+40
-6
lines changed

docs/developer-docs/latest/developer-resources/cli/CLI.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,20 @@ strapi generate:plugin <name>
345345

346346
Please refer to the [local plugins](/developer-docs/latest/development/local-plugins-customization.md) section to know more.
347347

348+
## strapi generate:template
349+
350+
Create a template from the current strapi project
351+
352+
```bash
353+
strapi generate:template <path>
354+
```
355+
356+
- **strapi generate:template &#60;path&#62;**<br/>
357+
Generates a Strapi template at `<path>`
358+
359+
Example: `strapi generate:template ../strapi-template-name` will copy the required files and folders to a `template` directory inside `../strapi-template-name`
360+
361+
348362
## strapi install
349363

350364
Install a plugin in the project.

docs/developer-docs/latest/setup-deployment-guides/installation/templates.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,29 @@ To create a Strapi template, you need to publish a public GitHub repository that
7676

7777
First, a template's only concern should be to adapt Strapi to a use case. It should not deal with environment-specific configs, like databases, or upload and email providers. This is to make sure that templates stay maintainable, and to avoid conflicts with other CLI options like `--quickstart`.
7878

79-
Second, a template must follow the following file structure.
79+
Second, a template must follow the file structure detailed below.
80+
81+
You can create this file structure by hand or generate it via the [CLI](/documentation/developer-docs/latest/developer-resources/cli/CLI.html#strapi-generate-template)
82+
83+
:::: tabs
84+
85+
::: tab yarn
86+
87+
```bash
88+
yarn strapi generate:template <path>
89+
```
90+
91+
:::
92+
93+
::: tab npx
94+
95+
```bash
96+
npx strapi generate:template <path>
97+
```
98+
99+
:::
100+
101+
::::
80102

81103
### File structure
82104

@@ -133,9 +155,7 @@ After reading the above rules, follow these steps to create your template:
133155

134156
1. Create a standard Strapi app with `create-strapi-app`, using the `--quickstart` option.
135157
2. Customize your app to match the needs of your use case.
136-
3. Outside of Strapi, create a new directory for your template.
137-
4. Create a `template.json` file in your template directory.
158+
3. Generate your template using the [CLI](/documentation/developer-docs/latest/developer-resources/cli/CLI.html#strapi-generate-template) by running `strapi generate:template <path>`
159+
4. Navigate to this path to see your generated template
138160
5. If you have modified your app's `package.json`, include these changes (and _only_ these changes) in `template.json` in a `package` property. Otherwise, leave it as an empty object.
139-
6. Create a `/template` subdirectory.
140-
7. Think of all the files you have modified in your app, and copy them to the `/template` directory
141-
8. Publish the root template project on GitHub. Make sure that the repository is public, and that the code is on the `master` branch.
161+
6. Publish the root template project on GitHub. Make sure that the repository is public, and that the code is on the `master` branch.

0 commit comments

Comments
 (0)