mirror of
https://github.com/strapi/strapi.git
synced 2025-09-18 21:08:54 +00:00
add attributes
This commit is contained in:
parent
92a12ce1e3
commit
b9c5595aea
27
packages/generators/generate/custom-prompt.js
Normal file
27
packages/generators/generate/custom-prompt.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const inquirer = require('inquirer');
|
||||||
|
|
||||||
|
const getAttributes = async (attributes = []) => {
|
||||||
|
const prompts = [
|
||||||
|
{
|
||||||
|
type: 'input',
|
||||||
|
name: 'inputValue',
|
||||||
|
message: 'Enter some input: ',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'confirm',
|
||||||
|
name: 'again',
|
||||||
|
message: 'Enter another input? ',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const { again, ...answers } = await inquirer.prompt(prompts);
|
||||||
|
|
||||||
|
const newInputs = [...attributes, answers];
|
||||||
|
return again ? getAttributes(newInputs) : newInputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = getAttributes;
|
@ -6,6 +6,8 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs-extra": "10.0.0",
|
"fs-extra": "10.0.0",
|
||||||
|
"inquirer": "8.1.2",
|
||||||
|
"inquirer-recursive": "0.0.7",
|
||||||
"node-plop": "0.26.2",
|
"node-plop": "0.26.2",
|
||||||
"plop": "2.7.4",
|
"plop": "2.7.4",
|
||||||
"pluralize": "8.0.0"
|
"pluralize": "8.0.0"
|
||||||
|
@ -173,6 +173,7 @@ module.exports = function(plop) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
plop.setPrompt('recursive', require('inquirer-recursive'));
|
||||||
// Model generator
|
// Model generator
|
||||||
plop.setGenerator('model', {
|
plop.setGenerator('model', {
|
||||||
description: 'Generate a model for an API',
|
description: 'Generate a model for an API',
|
||||||
@ -192,6 +193,10 @@ module.exports = function(plop) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
...getDestinationPrompts('model'),
|
...getDestinationPrompts('model'),
|
||||||
|
{
|
||||||
|
type: 'addAttributes',
|
||||||
|
name: 'attributes',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
name: 'useDraftAndPublish',
|
name: 'useDraftAndPublish',
|
||||||
@ -216,6 +221,9 @@ module.exports = function(plop) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { prompts } = plop.inquirer.prompt;
|
||||||
|
console.log(prompts);
|
||||||
|
|
||||||
// Plugin generator
|
// Plugin generator
|
||||||
plop.setGenerator('plugin', {
|
plop.setGenerator('plugin', {
|
||||||
description: 'Generate a basic plugin',
|
description: 'Generate a basic plugin',
|
||||||
|
37
yarn.lock
37
yarn.lock
@ -11159,6 +11159,14 @@ init-package-json@^1.10.3:
|
|||||||
validate-npm-package-license "^3.0.1"
|
validate-npm-package-license "^3.0.1"
|
||||||
validate-npm-package-name "^3.0.0"
|
validate-npm-package-name "^3.0.0"
|
||||||
|
|
||||||
|
inquirer-recursive@0.0.7:
|
||||||
|
version "0.0.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/inquirer-recursive/-/inquirer-recursive-0.0.7.tgz#09f65757e3ee10273d8c6b97e36663484741dba5"
|
||||||
|
integrity sha512-z15FD5N3GrzXM7OwEijm/9FbZzUiQUJQxrtUM0mOy3KeKshp3v/FhjspM8E3a9IgG6sYlN619lHpAdupn90ikQ==
|
||||||
|
dependencies:
|
||||||
|
inquirer "^7.3.3"
|
||||||
|
lodash "^4.17.20"
|
||||||
|
|
||||||
inquirer@8.1.0:
|
inquirer@8.1.0:
|
||||||
version "8.1.0"
|
version "8.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-8.1.0.tgz#68ce5ce5376cf0e89765c993d8b7c1e62e184d69"
|
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-8.1.0.tgz#68ce5ce5376cf0e89765c993d8b7c1e62e184d69"
|
||||||
@ -11179,6 +11187,26 @@ inquirer@8.1.0:
|
|||||||
strip-ansi "^6.0.0"
|
strip-ansi "^6.0.0"
|
||||||
through "^2.3.6"
|
through "^2.3.6"
|
||||||
|
|
||||||
|
inquirer@8.1.2:
|
||||||
|
version "8.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-8.1.2.tgz#65b204d2cd7fb63400edd925dfe428bafd422e3d"
|
||||||
|
integrity sha512-DHLKJwLPNgkfwNmsuEUKSejJFbkv0FMO9SMiQbjI3n5NQuCrSIBqP66ggqyz2a6t2qEolKrMjhQ3+W/xXgUQ+Q==
|
||||||
|
dependencies:
|
||||||
|
ansi-escapes "^4.2.1"
|
||||||
|
chalk "^4.1.1"
|
||||||
|
cli-cursor "^3.1.0"
|
||||||
|
cli-width "^3.0.0"
|
||||||
|
external-editor "^3.0.3"
|
||||||
|
figures "^3.0.0"
|
||||||
|
lodash "^4.17.21"
|
||||||
|
mute-stream "0.0.8"
|
||||||
|
ora "^5.3.0"
|
||||||
|
run-async "^2.4.0"
|
||||||
|
rxjs "^7.2.0"
|
||||||
|
string-width "^4.1.0"
|
||||||
|
strip-ansi "^6.0.0"
|
||||||
|
through "^2.3.6"
|
||||||
|
|
||||||
inquirer@^6.2.0, inquirer@^6.2.1, inquirer@^6.3.1:
|
inquirer@^6.2.0, inquirer@^6.2.1, inquirer@^6.3.1:
|
||||||
version "6.5.2"
|
version "6.5.2"
|
||||||
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.2.tgz#ad50942375d036d327ff528c08bd5fab089928ca"
|
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.2.tgz#ad50942375d036d327ff528c08bd5fab089928ca"
|
||||||
@ -11198,7 +11226,7 @@ inquirer@^6.2.0, inquirer@^6.2.1, inquirer@^6.3.1:
|
|||||||
strip-ansi "^5.1.0"
|
strip-ansi "^5.1.0"
|
||||||
through "^2.3.6"
|
through "^2.3.6"
|
||||||
|
|
||||||
inquirer@^7.1.0:
|
inquirer@^7.1.0, inquirer@^7.3.3:
|
||||||
version "7.3.3"
|
version "7.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003"
|
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003"
|
||||||
integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==
|
integrity sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==
|
||||||
@ -18254,6 +18282,13 @@ rxjs@^6.4.0, rxjs@^6.6.0, rxjs@^6.6.6, rxjs@^6.6.7:
|
|||||||
dependencies:
|
dependencies:
|
||||||
tslib "^1.9.0"
|
tslib "^1.9.0"
|
||||||
|
|
||||||
|
rxjs@^7.2.0:
|
||||||
|
version "7.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.3.0.tgz#39fe4f3461dc1e50be1475b2b85a0a88c1e938c6"
|
||||||
|
integrity sha512-p2yuGIg9S1epc3vrjKf6iVb3RCaAYjYskkO+jHIaV0IjOPlJop4UnodOoFb2xeNwlguqLYvGw1b1McillYb5Gw==
|
||||||
|
dependencies:
|
||||||
|
tslib "~2.1.0"
|
||||||
|
|
||||||
safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
|
safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
|
||||||
version "5.1.2"
|
version "5.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
|
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user