Add draft/publish to CLI

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2020-07-28 12:14:52 +02:00 committed by Pierre Noël
parent 3b3ea84685
commit 7ec435b36e
5 changed files with 12 additions and 4 deletions

View File

@ -162,6 +162,9 @@ options: [--plugin <name>]
- **strapi generate:api &#60;name&#62;**<br/>
Generates an API called **&#60;name&#62;** in the `./api` folder at the root of your project.
- **strapi generate:api --draft-and-publish=true**<br/>
Generates an API called **&#60;name&#62;** in the `./api` folder at the root of your project and enabled the draft/publish feature.
- **strapi generate:api &#60;name&#62; &#60;attribute:type&#62;**<br/>
Generates an API called **&#60;name&#62;** in the `./api` folder at the root of your project. The model will already contain an attribute called **&#60;attribute&#62;** with the type property set to **&#60;type&#62;**.
@ -210,7 +213,7 @@ Create a new model.
```bash
strapi generate:model <name> [<attribute:type>]
options: [--api <name>|--plugin <name>]
options: [--api <name>|--plugin <name>|--draft-and-publish <boolean>]
```
- **strapi generate:model &#60;name&#62;**<br/>
@ -235,6 +238,9 @@ options: [--api <name>|--plugin <name>]
* **strapi generate:model &#60;name&#62; --plugin &#60;plugin&#62;**<br/>
Generates an empty model called **&#60;name&#62;** in the `./plugins/<plugin>/models` folder.
* **strapi generate:model &#60;name&#62; --draft-and-publish=true**<br/>
Generates an empty model called **&#60;name&#62;** in the `./plugins/<plugin>/models` folder with the draft/publish feature enabled
::: tip
The first letter of the filename will be uppercase.
:::

View File

@ -128,7 +128,7 @@ module.exports = (scope, cb) => {
description: scope.description,
},
options: {
draftAndPublish: false,
draftAndPublish: scope.args.draftAndPublish === 'true',
increments: true,
timestamps: true,
comment: '',

View File

@ -129,7 +129,7 @@ module.exports = (scope, cb) => {
description: scope.description,
},
options: {
draftAndPublish: false,
draftAndPublish: scope.args.draftAndPublish === 'true',
timestamps: true,
increments: true,
comment: '',

View File

@ -185,7 +185,7 @@ module.exports = function createComponentBuilder() {
.set('kind', infos.kind || contentType.schema.kind)
.set(['info', 'name'], infos.name)
.set(['info', 'description'], infos.description)
.setSchemaOption(['draftAndPublish'], infos.draftAndPublish)
.setSchemaOption(['draftAndPublish'], infos.draftAndPublish || false)
.setAttributes(this.convertAttributes(newAttributes));
return contentType;

View File

@ -137,6 +137,7 @@ program
.option('-p, --plugin <api>', 'Name of the local plugin')
.option('-e, --extend <api>', 'Name of the plugin to extend')
.option('-c, --connection <connection>', 'The name of the connection to use')
.option('--draft-and-publish <value>', 'Enable draft/publish', false)
.description('generate a basic API')
.action((id, attributes, cliArguments) => {
cliArguments.attributes = attributes;
@ -158,6 +159,7 @@ program
.option('-a, --api <api>', 'API name to generate a sub API')
.option('-p, --plugin <api>', 'plugin name')
.option('-c, --connection <connection>', 'The name of the connection to use')
.option('--draft-and-publish <value>', 'Enable draft/publish', false)
.description('generate a model for an API')
.action((id, attributes, cliArguments) => {
cliArguments.attributes = attributes;