diff --git a/docs/v3.x/cli/CLI.md b/docs/v3.x/cli/CLI.md index 4e5e74f19e..f4079722e4 100644 --- a/docs/v3.x/cli/CLI.md +++ b/docs/v3.x/cli/CLI.md @@ -162,6 +162,9 @@ options: [--plugin ] - **strapi generate:api <name>**
Generates an API called **<name>** in the `./api` folder at the root of your project. +- **strapi generate:api --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>**. @@ -210,7 +213,7 @@ Create a new model. ```bash strapi generate:model [] -options: [--api |--plugin ] +options: [--api |--plugin |--draft-and-publish ] ``` - **strapi generate:model <name>**
@@ -235,6 +238,9 @@ options: [--api |--plugin ] * **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 + ::: tip The first letter of the filename will be uppercase. ::: diff --git a/packages/strapi-generate-api/lib/before.js b/packages/strapi-generate-api/lib/before.js index 1acb548207..529647375c 100644 --- a/packages/strapi-generate-api/lib/before.js +++ b/packages/strapi-generate-api/lib/before.js @@ -128,7 +128,7 @@ module.exports = (scope, cb) => { description: scope.description, }, options: { - draftAndPublish: false, + draftAndPublish: scope.args.draftAndPublish === 'true', increments: true, timestamps: true, comment: '', diff --git a/packages/strapi-generate-model/lib/before.js b/packages/strapi-generate-model/lib/before.js index e935db0c26..a581ea9b4d 100644 --- a/packages/strapi-generate-model/lib/before.js +++ b/packages/strapi-generate-model/lib/before.js @@ -129,7 +129,7 @@ module.exports = (scope, cb) => { description: scope.description, }, options: { - draftAndPublish: false, + draftAndPublish: scope.args.draftAndPublish === 'true', timestamps: true, increments: true, comment: '', diff --git a/packages/strapi-plugin-content-type-builder/services/schema-builder/content-type-builder.js b/packages/strapi-plugin-content-type-builder/services/schema-builder/content-type-builder.js index 99044a6958..a9b6d35113 100644 --- a/packages/strapi-plugin-content-type-builder/services/schema-builder/content-type-builder.js +++ b/packages/strapi-plugin-content-type-builder/services/schema-builder/content-type-builder.js @@ -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; diff --git a/packages/strapi/bin/strapi.js b/packages/strapi/bin/strapi.js index d4fd839a9d..8a30a239a0 100755 --- a/packages/strapi/bin/strapi.js +++ b/packages/strapi/bin/strapi.js @@ -137,6 +137,7 @@ program .option('-p, --plugin ', 'Name of the local plugin') .option('-e, --extend ', 'Name of the plugin to extend') .option('-c, --connection ', 'The name of the connection to use') + .option('--draft-and-publish ', '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 name to generate a sub API') .option('-p, --plugin ', 'plugin name') .option('-c, --connection ', 'The name of the connection to use') + .option('--draft-and-publish ', 'Enable draft/publish', false) .description('generate a model for an API') .action((id, attributes, cliArguments) => { cliArguments.attributes = attributes;