@strapi/generators 0.0.0-next.fb3a0b82484ce466b1efb1b28f16fc8ef73aba4a → 0.0.0-next.fb92031f3d90f3d2a2d191ba65725b6c8e329a5d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -3
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plopfile.d.ts +2 -1
- package/dist/plopfile.d.ts.map +1 -0
- package/dist/plopfile.js +24 -26
- package/dist/plopfile.js.map +1 -1
- package/dist/plopfile.mjs +25 -0
- package/dist/plopfile.mjs.map +1 -0
- package/dist/plops/api.d.ts +2 -1
- package/dist/plops/api.d.ts.map +1 -0
- package/dist/plops/api.js +33 -31
- package/dist/plops/api.js.map +1 -1
- package/dist/plops/api.mjs +79 -0
- package/dist/plops/api.mjs.map +1 -0
- package/dist/plops/content-type.d.ts +2 -1
- package/dist/plops/content-type.d.ts.map +1 -0
- package/dist/plops/content-type.js +74 -82
- package/dist/plops/content-type.js.map +1 -1
- package/dist/plops/content-type.mjs +148 -0
- package/dist/plops/content-type.mjs.map +1 -0
- package/dist/plops/controller.d.ts +2 -1
- package/dist/plops/controller.d.ts.map +1 -0
- package/dist/plops/controller.js +20 -20
- package/dist/plops/controller.js.map +1 -1
- package/dist/plops/controller.mjs +38 -0
- package/dist/plops/controller.mjs.map +1 -0
- package/dist/plops/middleware.d.ts +2 -1
- package/dist/plops/middleware.d.ts.map +1 -0
- package/dist/plops/middleware.js +22 -20
- package/dist/plops/middleware.js.map +1 -1
- package/dist/plops/middleware.mjs +40 -0
- package/dist/plops/middleware.mjs.map +1 -0
- package/dist/plops/migration.d.ts +2 -1
- package/dist/plops/migration.d.ts.map +1 -0
- package/dist/plops/migration.js +19 -19
- package/dist/plops/migration.js.map +1 -1
- package/dist/plops/migration.mjs +33 -0
- package/dist/plops/migration.mjs.map +1 -0
- package/dist/plops/policy.d.ts +2 -1
- package/dist/plops/policy.d.ts.map +1 -0
- package/dist/plops/policy.js +22 -20
- package/dist/plops/policy.js.map +1 -1
- package/dist/plops/policy.mjs +40 -0
- package/dist/plops/policy.mjs.map +1 -0
- package/dist/plops/prompts/bootstrap-api-prompts.d.ts +1 -0
- package/dist/plops/prompts/bootstrap-api-prompts.d.ts.map +1 -0
- package/dist/plops/prompts/bootstrap-api-prompts.js +7 -6
- package/dist/plops/prompts/bootstrap-api-prompts.js.map +1 -1
- package/dist/plops/prompts/bootstrap-api-prompts.mjs +11 -0
- package/dist/plops/prompts/bootstrap-api-prompts.mjs.map +1 -0
- package/dist/plops/prompts/ct-names-prompts.d.ts +1 -0
- package/dist/plops/prompts/ct-names-prompts.d.ts.map +1 -0
- package/dist/plops/prompts/ct-names-prompts.js +19 -43
- package/dist/plops/prompts/ct-names-prompts.js.map +1 -1
- package/dist/plops/prompts/ct-names-prompts.mjs +42 -0
- package/dist/plops/prompts/ct-names-prompts.mjs.map +1 -0
- package/dist/plops/prompts/get-attributes-prompts.d.ts +1 -0
- package/dist/plops/prompts/get-attributes-prompts.d.ts.map +1 -0
- package/dist/plops/prompts/get-attributes-prompts.js +36 -30
- package/dist/plops/prompts/get-attributes-prompts.js.map +1 -1
- package/dist/plops/prompts/get-attributes-prompts.mjs +99 -0
- package/dist/plops/prompts/get-attributes-prompts.mjs.map +1 -0
- package/dist/plops/prompts/get-destination-prompts.d.ts +1 -0
- package/dist/plops/prompts/get-destination-prompts.d.ts.map +1 -0
- package/dist/plops/prompts/get-destination-prompts.js +47 -41
- package/dist/plops/prompts/get-destination-prompts.js.map +1 -1
- package/dist/plops/prompts/get-destination-prompts.mjs +76 -0
- package/dist/plops/prompts/get-destination-prompts.mjs.map +1 -0
- package/dist/plops/prompts/kind-prompts.d.ts +1 -0
- package/dist/plops/prompts/kind-prompts.d.ts.map +1 -0
- package/dist/plops/prompts/kind-prompts.js +17 -12
- package/dist/plops/prompts/kind-prompts.js.map +1 -1
- package/dist/plops/prompts/kind-prompts.mjs +24 -0
- package/dist/plops/prompts/kind-prompts.mjs.map +1 -0
- package/dist/plops/service.d.ts +2 -1
- package/dist/plops/service.d.ts.map +1 -0
- package/dist/plops/service.js +19 -19
- package/dist/plops/service.js.map +1 -1
- package/dist/plops/service.mjs +36 -0
- package/dist/plops/service.mjs.map +1 -0
- package/dist/plops/utils/get-file-path.d.ts +2 -1
- package/dist/plops/utils/get-file-path.d.ts.map +1 -0
- package/dist/plops/utils/get-file-path.js +7 -5
- package/dist/plops/utils/get-file-path.js.map +1 -1
- package/dist/plops/utils/get-file-path.mjs +15 -0
- package/dist/plops/utils/get-file-path.mjs.map +1 -0
- package/dist/plops/utils/get-formatted-date.d.ts +1 -0
- package/dist/plops/utils/get-formatted-date.d.ts.map +1 -0
- package/dist/plops/utils/get-formatted-date.js +8 -9
- package/dist/plops/utils/get-formatted-date.js.map +1 -1
- package/dist/plops/utils/get-formatted-date.mjs +6 -0
- package/dist/plops/utils/get-formatted-date.mjs.map +1 -0
- package/dist/plops/utils/validate-attribute-input.d.ts +1 -0
- package/dist/plops/utils/validate-attribute-input.d.ts.map +1 -0
- package/dist/plops/utils/validate-attribute-input.js +7 -5
- package/dist/plops/utils/validate-attribute-input.js.map +1 -1
- package/dist/plops/utils/validate-attribute-input.mjs +10 -0
- package/dist/plops/utils/validate-attribute-input.mjs.map +1 -0
- package/dist/plops/utils/validate-file-name-input.d.ts +1 -0
- package/dist/plops/utils/validate-file-name-input.d.ts.map +1 -0
- package/dist/plops/utils/validate-file-name-input.js +7 -5
- package/dist/plops/utils/validate-file-name-input.js.map +1 -1
- package/dist/plops/utils/validate-file-name-input.mjs +10 -0
- package/dist/plops/utils/validate-file-name-input.mjs.map +1 -0
- package/dist/plops/utils/validate-input.d.ts +1 -0
- package/dist/plops/utils/validate-input.d.ts.map +1 -0
- package/dist/plops/utils/validate-input.js +7 -5
- package/dist/plops/utils/validate-input.js.map +1 -1
- package/dist/plops/utils/validate-input.mjs +10 -0
- package/dist/plops/utils/validate-input.mjs.map +1 -0
- package/dist/templates/js/content-type.schema.json.hbs +0 -1
- package/dist/templates/ts/content-type.schema.json.hbs +0 -1
- package/dist/templates/ts/middleware.ts.hbs +2 -2
- package/package.json +20 -16
- package/dist/files/js/plugin/.editorconfig +0 -7
- package/dist/files/js/plugin/.gitattributes +0 -103
- package/dist/files/js/plugin/admin/src/components/Initializer/index.js +0 -26
- package/dist/files/js/plugin/admin/src/components/PluginIcon/index.js +0 -12
- package/dist/files/js/plugin/admin/src/index.js +0 -63
- package/dist/files/js/plugin/admin/src/pages/App/index.js +0 -25
- package/dist/files/js/plugin/admin/src/pages/HomePage/index.js +0 -20
- package/dist/files/js/plugin/admin/src/pluginId.js +0 -5
- package/dist/files/js/plugin/admin/src/translations/en.json +0 -1
- package/dist/files/js/plugin/admin/src/translations/fr.json +0 -1
- package/dist/files/js/plugin/admin/src/utils/getTrad.js +0 -5
- package/dist/files/js/plugin/server/bootstrap.js +0 -5
- package/dist/files/js/plugin/server/config/index.js +0 -6
- package/dist/files/js/plugin/server/content-types/index.js +0 -3
- package/dist/files/js/plugin/server/controllers/index.js +0 -7
- package/dist/files/js/plugin/server/controllers/my-controller.js.hbs +0 -10
- package/dist/files/js/plugin/server/destroy.js +0 -5
- package/dist/files/js/plugin/server/index.js +0 -25
- package/dist/files/js/plugin/server/middlewares/index.js +0 -3
- package/dist/files/js/plugin/server/policies/index.js +0 -3
- package/dist/files/js/plugin/server/register.js +0 -5
- package/dist/files/js/plugin/server/routes/index.js +0 -10
- package/dist/files/js/plugin/server/services/index.js +0 -7
- package/dist/files/js/plugin/server/services/my-service.js +0 -7
- package/dist/files/js/plugin/strapi-admin.js +0 -3
- package/dist/files/js/plugin/strapi-server.js +0 -3
- package/dist/files/ts/plugin/.editorconfig +0 -7
- package/dist/files/ts/plugin/.gitattributes +0 -103
- package/dist/files/ts/plugin/admin/src/components/Initializer/index.tsx +0 -24
- package/dist/files/ts/plugin/admin/src/components/PluginIcon/index.tsx +0 -12
- package/dist/files/ts/plugin/admin/src/index.tsx +0 -67
- package/dist/files/ts/plugin/admin/src/pages/App/index.tsx +0 -25
- package/dist/files/ts/plugin/admin/src/pages/HomePage/index.tsx +0 -19
- package/dist/files/ts/plugin/admin/src/pluginId.ts +0 -5
- package/dist/files/ts/plugin/admin/src/translations/en.json +0 -1
- package/dist/files/ts/plugin/admin/src/translations/fr.json +0 -1
- package/dist/files/ts/plugin/admin/src/utils/getTrad.ts +0 -5
- package/dist/files/ts/plugin/custom.d.ts +0 -5
- package/dist/files/ts/plugin/server/bootstrap.ts +0 -5
- package/dist/files/ts/plugin/server/config/index.ts +0 -4
- package/dist/files/ts/plugin/server/content-types/index.ts +0 -1
- package/dist/files/ts/plugin/server/controllers/index.ts +0 -5
- package/dist/files/ts/plugin/server/controllers/my-controller.ts.hbs +0 -10
- package/dist/files/ts/plugin/server/destroy.ts +0 -5
- package/dist/files/ts/plugin/server/index.ts +0 -23
- package/dist/files/ts/plugin/server/middlewares/index.ts +0 -1
- package/dist/files/ts/plugin/server/policies/index.ts +0 -1
- package/dist/files/ts/plugin/server/register.ts +0 -5
- package/dist/files/ts/plugin/server/routes/index.ts +0 -10
- package/dist/files/ts/plugin/server/services/index.ts +0 -5
- package/dist/files/ts/plugin/server/services/my-service.ts +0 -7
- package/dist/files/ts/plugin/strapi-admin.js +0 -3
- package/dist/files/ts/plugin/strapi-server.js +0 -3
- package/dist/files/ts/plugin/tsconfig.json +0 -20
- package/dist/files/ts/plugin/tsconfig.server.json +0 -25
- package/dist/plops/plugin.d.ts +0 -3
- package/dist/plops/plugin.js +0 -107
- package/dist/plops/plugin.js.map +0 -1
- package/dist/plops/prompts/draft-and-publish-prompts.d.ts +0 -3
- package/dist/plops/prompts/draft-and-publish-prompts.js +0 -12
- package/dist/plops/prompts/draft-and-publish-prompts.js.map +0 -1
- package/dist/templates/js/README.md.hbs +0 -3
- package/dist/templates/js/plugin-package.json.hbs +0 -42
- package/dist/templates/ts/README.md.hbs +0 -3
- package/dist/templates/ts/plugin-package.json.hbs +0 -51
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-attributes-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAkCxD,QAAA,MAAM,oBAAoB,EAAE,sBAyE3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const validate_attribute_input_1 = __importDefault(require("../utils/validate-attribute-input"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var validateAttributeInput = require('../utils/validate-attribute-input.js');
|
|
4
|
+
|
|
7
5
|
const DEFAULT_TYPES = [
|
|
8
6
|
// advanced types
|
|
9
7
|
'media',
|
|
@@ -23,59 +21,67 @@ const DEFAULT_TYPES = [
|
|
|
23
21
|
'time',
|
|
24
22
|
'datetime',
|
|
25
23
|
'timestamp',
|
|
26
|
-
'boolean'
|
|
24
|
+
'boolean'
|
|
27
25
|
];
|
|
28
|
-
const getAttributesPrompts = async (inquirer)
|
|
26
|
+
const getAttributesPrompts = async (inquirer)=>{
|
|
29
27
|
const { addAttributes } = await inquirer.prompt([
|
|
30
28
|
{
|
|
31
29
|
type: 'confirm',
|
|
32
30
|
name: 'addAttributes',
|
|
33
|
-
message: 'Do you want to add attributes?'
|
|
34
|
-
}
|
|
31
|
+
message: 'Do you want to add attributes?'
|
|
32
|
+
}
|
|
35
33
|
]);
|
|
36
34
|
const attributes = [];
|
|
37
35
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const createNewAttributes = async (inquirer) => {
|
|
36
|
+
* @param {import('inquirer').Inquirer} inquirer
|
|
37
|
+
* @returns {Promise<void>}
|
|
38
|
+
*/ const createNewAttributes = async (inquirer)=>{
|
|
42
39
|
const answers = await inquirer.prompt([
|
|
43
40
|
{
|
|
44
41
|
type: 'input',
|
|
45
42
|
name: 'attributeName',
|
|
46
43
|
message: 'Name of attribute',
|
|
47
|
-
validate: (input)
|
|
44
|
+
validate: (input)=>validateAttributeInput(input)
|
|
48
45
|
},
|
|
49
46
|
{
|
|
50
47
|
type: 'list',
|
|
51
48
|
name: 'attributeType',
|
|
52
49
|
message: 'What type of attribute',
|
|
53
50
|
pageSize: DEFAULT_TYPES.length,
|
|
54
|
-
choices: DEFAULT_TYPES.map((type)
|
|
55
|
-
return {
|
|
56
|
-
|
|
51
|
+
choices: DEFAULT_TYPES.map((type)=>{
|
|
52
|
+
return {
|
|
53
|
+
name: type,
|
|
54
|
+
value: type
|
|
55
|
+
};
|
|
56
|
+
})
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
when: (answers)
|
|
59
|
+
when: (answers)=>answers.attributeType === 'enumeration',
|
|
60
60
|
type: 'input',
|
|
61
61
|
name: 'enum',
|
|
62
|
-
message: 'Add values separated by a comma'
|
|
62
|
+
message: 'Add values separated by a comma'
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
when: (answers)
|
|
65
|
+
when: (answers)=>answers.attributeType === 'media',
|
|
66
66
|
type: 'list',
|
|
67
67
|
name: 'multiple',
|
|
68
68
|
message: 'Choose media type',
|
|
69
69
|
choices: [
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
{
|
|
71
|
+
name: 'Multiple',
|
|
72
|
+
value: true
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'Single',
|
|
76
|
+
value: false
|
|
77
|
+
}
|
|
78
|
+
]
|
|
73
79
|
},
|
|
74
80
|
{
|
|
75
81
|
type: 'confirm',
|
|
76
82
|
name: 'addAttributes',
|
|
77
|
-
message: 'Do you want to add another attribute?'
|
|
78
|
-
}
|
|
83
|
+
message: 'Do you want to add another attribute?'
|
|
84
|
+
}
|
|
79
85
|
]);
|
|
80
86
|
attributes.push(answers);
|
|
81
87
|
if (!answers.addAttributes) {
|
|
@@ -85,11 +91,11 @@ const getAttributesPrompts = async (inquirer) => {
|
|
|
85
91
|
};
|
|
86
92
|
if (addAttributes) {
|
|
87
93
|
await createNewAttributes(inquirer);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
94
|
+
} else {
|
|
90
95
|
console.warn(`You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`);
|
|
91
96
|
}
|
|
92
97
|
return attributes;
|
|
93
98
|
};
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
|
|
100
|
+
module.exports = getAttributesPrompts;
|
|
101
|
+
//# sourceMappingURL=get-attributes-prompts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-attributes-prompts.js","
|
|
1
|
+
{"version":3,"file":"get-attributes-prompts.js","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"sourcesContent":["import type { DynamicPromptsFunction } from 'node-plop';\n\nimport validateAttributeInput from '../utils/validate-attribute-input';\n\ninterface AttributeAnswer {\n attributeName: string;\n attributeType: typeof DEFAULT_TYPES;\n enum?: string;\n multiple?: boolean;\n}\n\nconst DEFAULT_TYPES = [\n // advanced types\n 'media',\n\n // scalar types\n 'string',\n 'text',\n 'richtext',\n 'json',\n 'enumeration',\n 'password',\n 'email',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n] as const;\n\nconst getAttributesPrompts: DynamicPromptsFunction = async (inquirer) => {\n const { addAttributes } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add attributes?',\n },\n ]);\n\n const attributes: Array<AttributeAnswer> = [];\n\n /**\n * @param {import('inquirer').Inquirer} inquirer\n * @returns {Promise<void>}\n */\n const createNewAttributes = async (inquirer: Parameters<DynamicPromptsFunction>[0]) => {\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'attributeName',\n message: 'Name of attribute',\n validate: (input: string) => validateAttributeInput(input),\n },\n {\n type: 'list',\n name: 'attributeType',\n message: 'What type of attribute',\n pageSize: DEFAULT_TYPES.length,\n choices: DEFAULT_TYPES.map((type) => {\n return { name: type, value: type };\n }),\n },\n {\n when: (answers) => answers.attributeType === 'enumeration',\n type: 'input',\n name: 'enum',\n message: 'Add values separated by a comma',\n },\n {\n when: (answers) => answers.attributeType === 'media',\n type: 'list',\n name: 'multiple',\n message: 'Choose media type',\n choices: [\n { name: 'Multiple', value: true },\n { name: 'Single', value: false },\n ],\n },\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add another attribute?',\n },\n ]);\n\n attributes.push(answers);\n\n if (!answers.addAttributes) {\n return;\n }\n\n await createNewAttributes(inquirer);\n };\n\n if (addAttributes) {\n await createNewAttributes(inquirer);\n } else {\n console.warn(\n `You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`\n );\n }\n\n return attributes;\n};\n\nexport default getAttributesPrompts;\n"],"names":["DEFAULT_TYPES","getAttributesPrompts","inquirer","addAttributes","prompt","type","name","message","attributes","createNewAttributes","answers","validate","input","validateAttributeInput","pageSize","length","choices","map","value","when","attributeType","push","console","warn"],"mappings":";;;;AAWA,MAAMA,aAAgB,GAAA;;AAEpB,IAAA,OAAA;;AAGA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;AACA,IAAA,aAAA;AACA,IAAA,UAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,uBAA+C,OAAOC,QAAAA,GAAAA;AAC1D,IA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A;wBAAEZ,IAAM,EAAA,QAAA;wBAAUY,KAAO,EAAA;AAAM;AAChC;AACH,aAAA;AACA,YAAA;gBACEb,IAAM,EAAA,SAAA;gBACNC,IAAM,EAAA,eAAA;gBACNC,OAAS,EAAA;AACX;AACD,SAAA,CAAA;AAEDC,QAAAA,UAAAA,CAAWa,IAAI,CAACX,OAAAA,CAAAA;QAEhB,IAAI,CAACA,OAAQP,CAAAA,aAAa,EAAE;AAC1B,YAAA;AACF;AAEA,QAAA,MAAMM,mBAAoBP,CAAAA,QAAAA,CAAAA;AAC5B,KAAA;AAEA,IAAA,IAAIC,aAAe,EAAA;AACjB,QAAA,MAAMM,mBAAoBP,CAAAA,QAAAA,CAAAA;KACrB,MAAA;AACLoB,QAAAA,OAAAA,CAAQC,IAAI,CACV,CAAC,qHAAqH,CAAC,CAAA;AAE3H;IAEA,OAAOf,UAAAA;AACT;;;;"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import validateAttributeInput from '../utils/validate-attribute-input.mjs';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_TYPES = [
|
|
4
|
+
// advanced types
|
|
5
|
+
'media',
|
|
6
|
+
// scalar types
|
|
7
|
+
'string',
|
|
8
|
+
'text',
|
|
9
|
+
'richtext',
|
|
10
|
+
'json',
|
|
11
|
+
'enumeration',
|
|
12
|
+
'password',
|
|
13
|
+
'email',
|
|
14
|
+
'integer',
|
|
15
|
+
'biginteger',
|
|
16
|
+
'float',
|
|
17
|
+
'decimal',
|
|
18
|
+
'date',
|
|
19
|
+
'time',
|
|
20
|
+
'datetime',
|
|
21
|
+
'timestamp',
|
|
22
|
+
'boolean'
|
|
23
|
+
];
|
|
24
|
+
const getAttributesPrompts = async (inquirer)=>{
|
|
25
|
+
const { addAttributes } = await inquirer.prompt([
|
|
26
|
+
{
|
|
27
|
+
type: 'confirm',
|
|
28
|
+
name: 'addAttributes',
|
|
29
|
+
message: 'Do you want to add attributes?'
|
|
30
|
+
}
|
|
31
|
+
]);
|
|
32
|
+
const attributes = [];
|
|
33
|
+
/**
|
|
34
|
+
* @param {import('inquirer').Inquirer} inquirer
|
|
35
|
+
* @returns {Promise<void>}
|
|
36
|
+
*/ const createNewAttributes = async (inquirer)=>{
|
|
37
|
+
const answers = await inquirer.prompt([
|
|
38
|
+
{
|
|
39
|
+
type: 'input',
|
|
40
|
+
name: 'attributeName',
|
|
41
|
+
message: 'Name of attribute',
|
|
42
|
+
validate: (input)=>validateAttributeInput(input)
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'list',
|
|
46
|
+
name: 'attributeType',
|
|
47
|
+
message: 'What type of attribute',
|
|
48
|
+
pageSize: DEFAULT_TYPES.length,
|
|
49
|
+
choices: DEFAULT_TYPES.map((type)=>{
|
|
50
|
+
return {
|
|
51
|
+
name: type,
|
|
52
|
+
value: type
|
|
53
|
+
};
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
when: (answers)=>answers.attributeType === 'enumeration',
|
|
58
|
+
type: 'input',
|
|
59
|
+
name: 'enum',
|
|
60
|
+
message: 'Add values separated by a comma'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
when: (answers)=>answers.attributeType === 'media',
|
|
64
|
+
type: 'list',
|
|
65
|
+
name: 'multiple',
|
|
66
|
+
message: 'Choose media type',
|
|
67
|
+
choices: [
|
|
68
|
+
{
|
|
69
|
+
name: 'Multiple',
|
|
70
|
+
value: true
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'Single',
|
|
74
|
+
value: false
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'confirm',
|
|
80
|
+
name: 'addAttributes',
|
|
81
|
+
message: 'Do you want to add another attribute?'
|
|
82
|
+
}
|
|
83
|
+
]);
|
|
84
|
+
attributes.push(answers);
|
|
85
|
+
if (!answers.addAttributes) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
await createNewAttributes(inquirer);
|
|
89
|
+
};
|
|
90
|
+
if (addAttributes) {
|
|
91
|
+
await createNewAttributes(inquirer);
|
|
92
|
+
} else {
|
|
93
|
+
console.warn(`You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`);
|
|
94
|
+
}
|
|
95
|
+
return attributes;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { getAttributesPrompts as default };
|
|
99
|
+
//# sourceMappingURL=get-attributes-prompts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-attributes-prompts.mjs","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"sourcesContent":["import type { DynamicPromptsFunction } from 'node-plop';\n\nimport validateAttributeInput from '../utils/validate-attribute-input';\n\ninterface AttributeAnswer {\n attributeName: string;\n attributeType: typeof DEFAULT_TYPES;\n enum?: string;\n multiple?: boolean;\n}\n\nconst DEFAULT_TYPES = [\n // advanced types\n 'media',\n\n // scalar types\n 'string',\n 'text',\n 'richtext',\n 'json',\n 'enumeration',\n 'password',\n 'email',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n] as const;\n\nconst getAttributesPrompts: DynamicPromptsFunction = async (inquirer) => {\n const { addAttributes } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add attributes?',\n },\n ]);\n\n const attributes: Array<AttributeAnswer> = [];\n\n /**\n * @param {import('inquirer').Inquirer} inquirer\n * @returns {Promise<void>}\n */\n const createNewAttributes = async (inquirer: Parameters<DynamicPromptsFunction>[0]) => {\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'attributeName',\n message: 'Name of attribute',\n validate: (input: string) => validateAttributeInput(input),\n },\n {\n type: 'list',\n name: 'attributeType',\n message: 'What type of attribute',\n pageSize: DEFAULT_TYPES.length,\n choices: DEFAULT_TYPES.map((type) => {\n return { name: type, value: type };\n }),\n },\n {\n when: (answers) => answers.attributeType === 'enumeration',\n type: 'input',\n name: 'enum',\n message: 'Add values separated by a comma',\n },\n {\n when: (answers) => answers.attributeType === 'media',\n type: 'list',\n name: 'multiple',\n message: 'Choose media type',\n choices: [\n { name: 'Multiple', value: true },\n { name: 'Single', value: false },\n ],\n },\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add another attribute?',\n },\n ]);\n\n attributes.push(answers);\n\n if (!answers.addAttributes) {\n return;\n }\n\n await createNewAttributes(inquirer);\n };\n\n if (addAttributes) {\n await createNewAttributes(inquirer);\n } else {\n console.warn(\n `You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`\n );\n }\n\n return attributes;\n};\n\nexport default getAttributesPrompts;\n"],"names":["DEFAULT_TYPES","getAttributesPrompts","inquirer","addAttributes","prompt","type","name","message","attributes","createNewAttributes","answers","validate","input","validateAttributeInput","pageSize","length","choices","map","value","when","attributeType","push","console","warn"],"mappings":";;AAWA,MAAMA,aAAgB,GAAA;;AAEpB,IAAA,OAAA;;AAGA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;AACA,IAAA,aAAA;AACA,IAAA,UAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,uBAA+C,OAAOC,QAAAA,GAAAA;AAC1D,IAAA,MAAM,EAAEC,aAAa,EAAE,GAAG,MAAMD,QAAAA,CAASE,MAAM,CAAC;AAC9C,QAAA;YACEC,IAAM,EAAA,SAAA;YACNC,IAAM,EAAA,eAAA;YACNC,OAAS,EAAA;AACX;AACD,KAAA,CAAA;AAED,IAAA,MAAMC,aAAqC,EAAE;AAE7C;;;MAIA,MAAMC,sBAAsB,OAAOP,QAAAA,GAAAA;AACjC,QAAA,MAAMQ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AAE;AAC1B,YAAA;AACF;AAEA,QAAA,MAAMM,mBAAoBP,CAAAA,QAAAA,CAAAA;AAC5B,KAAA;AAEA,IAAA,IAAIC,aAAe,EAAA;AACjB,QAAA,MAAMM,mBAAoBP,CAAAA,QAAAA,CAAAA;KACrB,MAAA;AACLoB,QAAAA,OAAAA,CAAQC,IAAI,CACV,CAAC,qHAAqH,CAAC,CAAA;AAE3H;IAEA,OAAOf,UAAAA;AACT;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-destination-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;iCAGtC,MAAM,YACJ,MAAM;;MAEf,MAAM,cAAc,CAAC;AAJxB,wBA6EE"}
|
|
@@ -1,72 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
exports.default = (action, basePath, { rootFolder = false } = {}) => {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var fs = require('fs-extra');
|
|
5
|
+
|
|
6
|
+
var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
|
|
9
7
|
return [
|
|
10
8
|
{
|
|
11
9
|
type: 'list',
|
|
12
10
|
name: 'destination',
|
|
13
11
|
message: `Where do you want to add this ${action}?`,
|
|
14
12
|
choices: [
|
|
15
|
-
...
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
...rootFolder ? [
|
|
14
|
+
{
|
|
15
|
+
name: `Add ${action} to root of project`,
|
|
16
|
+
value: 'root'
|
|
17
|
+
}
|
|
18
|
+
] : [
|
|
19
|
+
{
|
|
20
|
+
name: `Add ${action} to new API`,
|
|
21
|
+
value: 'new'
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
{
|
|
25
|
+
name: `Add ${action} to an existing API`,
|
|
26
|
+
value: 'api'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: `Add ${action} to an existing plugin`,
|
|
30
|
+
value: 'plugin'
|
|
31
|
+
}
|
|
32
|
+
]
|
|
31
33
|
},
|
|
32
34
|
{
|
|
33
|
-
when: (answers)
|
|
35
|
+
when: (answers)=>answers.destination === 'api',
|
|
34
36
|
type: 'list',
|
|
35
37
|
message: 'Which API is this for?',
|
|
36
38
|
name: 'api',
|
|
37
|
-
async choices() {
|
|
38
|
-
const apiPath =
|
|
39
|
-
const exists = await
|
|
39
|
+
async choices () {
|
|
40
|
+
const apiPath = path.join(basePath, 'api');
|
|
41
|
+
const exists = await fs.pathExists(apiPath);
|
|
40
42
|
if (!exists) {
|
|
41
43
|
throw Error('Couldn\'t find an "api" directory');
|
|
42
44
|
}
|
|
43
|
-
const apiDir = await
|
|
44
|
-
|
|
45
|
+
const apiDir = await fs.readdir(apiPath, {
|
|
46
|
+
withFileTypes: true
|
|
47
|
+
});
|
|
48
|
+
const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
|
|
45
49
|
if (apiDirContent.length === 0) {
|
|
46
50
|
throw Error('The "api" directory is empty');
|
|
47
51
|
}
|
|
48
52
|
return apiDirContent;
|
|
49
|
-
}
|
|
53
|
+
}
|
|
50
54
|
},
|
|
51
55
|
{
|
|
52
|
-
when: (answers)
|
|
56
|
+
when: (answers)=>answers.destination === 'plugin',
|
|
53
57
|
type: 'list',
|
|
54
58
|
message: 'Which plugin is this for?',
|
|
55
59
|
name: 'plugin',
|
|
56
|
-
async choices() {
|
|
57
|
-
const pluginsPath =
|
|
58
|
-
const exists = await
|
|
60
|
+
async choices () {
|
|
61
|
+
const pluginsPath = path.join(basePath, 'plugins');
|
|
62
|
+
const exists = await fs.pathExists(pluginsPath);
|
|
59
63
|
if (!exists) {
|
|
60
64
|
throw Error('Couldn\'t find a "plugins" directory');
|
|
61
65
|
}
|
|
62
|
-
const pluginsDir = await
|
|
63
|
-
const pluginsDirContent = pluginsDir.filter((api)
|
|
66
|
+
const pluginsDir = await fs.readdir(pluginsPath);
|
|
67
|
+
const pluginsDirContent = pluginsDir.filter((api)=>fs.lstatSync(path.join(pluginsPath, api)).isDirectory());
|
|
64
68
|
if (pluginsDirContent.length === 0) {
|
|
65
69
|
throw Error('The "plugins" directory is empty');
|
|
66
70
|
}
|
|
67
71
|
return pluginsDirContent;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
70
74
|
];
|
|
71
|
-
};
|
|
72
|
-
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
module.exports = getDestinationPrompts;
|
|
78
|
+
//# sourceMappingURL=get-destination-prompts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-destination-prompts.js","
|
|
1
|
+
{"version":3,"file":"get-destination-prompts.js","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"sourcesContent":["import { join } from 'path';\nimport fs from 'fs-extra';\n\nimport type { PromptQuestion } from 'node-plop';\n\nexport default (\n action: string,\n basePath: string,\n { rootFolder = false } = {}\n): Array<PromptQuestion> => {\n return [\n {\n type: 'list',\n name: 'destination',\n message: `Where do you want to add this ${action}?`,\n choices: [\n ...(rootFolder\n ? [\n {\n name: `Add ${action} to root of project`,\n value: 'root',\n },\n ]\n : [\n {\n name: `Add ${action} to new API`,\n value: 'new',\n },\n ]),\n { name: `Add ${action} to an existing API`, value: 'api' },\n { name: `Add ${action} to an existing plugin`, value: 'plugin' },\n ],\n },\n {\n when: (answers) => answers.destination === 'api',\n type: 'list',\n message: 'Which API is this for?',\n name: 'api',\n async choices() {\n const apiPath = join(basePath, 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find an \"api\" directory');\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.length === 0) {\n throw Error('The \"api\" directory is empty');\n }\n\n return apiDirContent;\n },\n },\n {\n when: (answers) => answers.destination === 'plugin',\n type: 'list',\n message: 'Which plugin is this for?',\n name: 'plugin',\n async choices() {\n const pluginsPath = join(basePath, 'plugins');\n const exists = await fs.pathExists(pluginsPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find a \"plugins\" directory');\n }\n\n const pluginsDir = await fs.readdir(pluginsPath);\n const pluginsDirContent = pluginsDir.filter((api) =>\n fs.lstatSync(join(pluginsPath, api)).isDirectory()\n );\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ];\n};\n"],"names":["action","basePath","rootFolder","type","name","message","choices","value","when","answers","destination","apiPath","join","exists","fs","pathExists","Error","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","length","pluginsPath","pluginsDir","pluginsDirContent","api","lstatSync"],"mappings":";;;;;AAKA,4BAAe,CAAA,CACbA,MAAAA,EACAC,QACA,EAAA,EAAEC,aAAa,KAAK,EAAE,GAAG,EAAE,GAAA;IAE3B,OAAO;AACL,QAAA;YACEC,IAAM,EAAA,MAAA;YACNC,IAAM,EAAA,aAAA;AACNC,YAAAA,OAAAA,EAAS,CAAC,8BAA8B,EAAEL,MAAAA,CAAO,CAAC,CAAC;YACnDM,OAAS,EAAA;mBACHJ,UACA,GAAA;AACE,oBAAA;AACEE,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;wBACxCO,KAAO,EAAA;AACT;iBACD,GACD;AACE,oBAAA;AACEH,wBAAAA,IAAAA,EAAM,CAA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IAAM,EAAA,MAAA;YACNE,OAAS,EAAA,2BAAA;YACTD,IAAM,EAAA,QAAA;YACN,MAAME,OAAAA,CAAAA,GAAAA;gBACJ,MAAMmB,WAAAA,GAAcb,UAAKX,QAAU,EAAA,SAAA,CAAA;AACnC,gBAAA,MAAMY,MAAS,GAAA,MAAMC,EAAGC,CAAAA,UAAU,CAACU,WAAAA,CAAAA;AAEnC,gBAAA,IAAI,CAACZ,MAAQ,EAAA;AACX,oBAAA,MAAMG,KAAM,CAAA,sCAAA,CAAA;AACd;AAEA,gBAAA,MAAMU,UAAa,GAAA,MAAMZ,EAAGI,CAAAA,OAAO,CAACO,WAAAA,CAAAA;AACpC,gBAAA,MAAME,iBAAoBD,GAAAA,UAAAA,CAAWL,MAAM,CAAC,CAACO,GAAAA,GAC3Cd,EAAGe,CAAAA,SAAS,CAACjB,SAAAA,CAAKa,WAAaG,EAAAA,GAAAA,CAAAA,CAAAA,CAAML,WAAW,EAAA,CAAA;gBAGlD,IAAII,iBAAAA,CAAkBH,MAAM,KAAK,CAAG,EAAA;AAClC,oBAAA,MAAMR,KAAM,CAAA,kCAAA,CAAA;AACd;gBAEA,OAAOW,iBAAAA;AACT;AACF;AACD,KAAA;AACH,CAAA;;;;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
|
|
4
|
+
var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
type: 'list',
|
|
8
|
+
name: 'destination',
|
|
9
|
+
message: `Where do you want to add this ${action}?`,
|
|
10
|
+
choices: [
|
|
11
|
+
...rootFolder ? [
|
|
12
|
+
{
|
|
13
|
+
name: `Add ${action} to root of project`,
|
|
14
|
+
value: 'root'
|
|
15
|
+
}
|
|
16
|
+
] : [
|
|
17
|
+
{
|
|
18
|
+
name: `Add ${action} to new API`,
|
|
19
|
+
value: 'new'
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
{
|
|
23
|
+
name: `Add ${action} to an existing API`,
|
|
24
|
+
value: 'api'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: `Add ${action} to an existing plugin`,
|
|
28
|
+
value: 'plugin'
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
when: (answers)=>answers.destination === 'api',
|
|
34
|
+
type: 'list',
|
|
35
|
+
message: 'Which API is this for?',
|
|
36
|
+
name: 'api',
|
|
37
|
+
async choices () {
|
|
38
|
+
const apiPath = join(basePath, 'api');
|
|
39
|
+
const exists = await fs.pathExists(apiPath);
|
|
40
|
+
if (!exists) {
|
|
41
|
+
throw Error('Couldn\'t find an "api" directory');
|
|
42
|
+
}
|
|
43
|
+
const apiDir = await fs.readdir(apiPath, {
|
|
44
|
+
withFileTypes: true
|
|
45
|
+
});
|
|
46
|
+
const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
|
|
47
|
+
if (apiDirContent.length === 0) {
|
|
48
|
+
throw Error('The "api" directory is empty');
|
|
49
|
+
}
|
|
50
|
+
return apiDirContent;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
when: (answers)=>answers.destination === 'plugin',
|
|
55
|
+
type: 'list',
|
|
56
|
+
message: 'Which plugin is this for?',
|
|
57
|
+
name: 'plugin',
|
|
58
|
+
async choices () {
|
|
59
|
+
const pluginsPath = join(basePath, 'plugins');
|
|
60
|
+
const exists = await fs.pathExists(pluginsPath);
|
|
61
|
+
if (!exists) {
|
|
62
|
+
throw Error('Couldn\'t find a "plugins" directory');
|
|
63
|
+
}
|
|
64
|
+
const pluginsDir = await fs.readdir(pluginsPath);
|
|
65
|
+
const pluginsDirContent = pluginsDir.filter((api)=>fs.lstatSync(join(pluginsPath, api)).isDirectory());
|
|
66
|
+
if (pluginsDirContent.length === 0) {
|
|
67
|
+
throw Error('The "plugins" directory is empty');
|
|
68
|
+
}
|
|
69
|
+
return pluginsDirContent;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export { getDestinationPrompts as default };
|
|
76
|
+
//# sourceMappingURL=get-destination-prompts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-destination-prompts.mjs","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"sourcesContent":["import { join } from 'path';\nimport fs from 'fs-extra';\n\nimport type { PromptQuestion } from 'node-plop';\n\nexport default (\n action: string,\n basePath: string,\n { rootFolder = false } = {}\n): Array<PromptQuestion> => {\n return [\n {\n type: 'list',\n name: 'destination',\n message: `Where do you want to add this ${action}?`,\n choices: [\n ...(rootFolder\n ? [\n {\n name: `Add ${action} to root of project`,\n value: 'root',\n },\n ]\n : [\n {\n name: `Add ${action} to new API`,\n value: 'new',\n },\n ]),\n { name: `Add ${action} to an existing API`, value: 'api' },\n { name: `Add ${action} to an existing plugin`, value: 'plugin' },\n ],\n },\n {\n when: (answers) => answers.destination === 'api',\n type: 'list',\n message: 'Which API is this for?',\n name: 'api',\n async choices() {\n const apiPath = join(basePath, 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find an \"api\" directory');\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.length === 0) {\n throw Error('The \"api\" directory is empty');\n }\n\n return apiDirContent;\n },\n },\n {\n when: (answers) => answers.destination === 'plugin',\n type: 'list',\n message: 'Which plugin is this for?',\n name: 'plugin',\n async choices() {\n const pluginsPath = join(basePath, 'plugins');\n const exists = await fs.pathExists(pluginsPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find a \"plugins\" directory');\n }\n\n const pluginsDir = await fs.readdir(pluginsPath);\n const pluginsDirContent = pluginsDir.filter((api) =>\n fs.lstatSync(join(pluginsPath, api)).isDirectory()\n );\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ];\n};\n"],"names":["action","basePath","rootFolder","type","name","message","choices","value","when","answers","destination","apiPath","join","exists","fs","pathExists","Error","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","length","pluginsPath","pluginsDir","pluginsDirContent","api","lstatSync"],"mappings":";;;AAKA,4BAAe,CAAA,CACbA,MAAAA,EACAC,QACA,EAAA,EAAEC,aAAa,KAAK,EAAE,GAAG,EAAE,GAAA;IAE3B,OAAO;AACL,QAAA;YACEC,IAAM,EAAA,MAAA;YACNC,IAAM,EAAA,aAAA;AACNC,YAAAA,OAAAA,EAAS,CAAC,8BAA8B,EAAEL,MAAAA,CAAO,CAAC,CAAC;YACnDM,OAAS,EAAA;mBACHJ,UACA,GAAA;AACE,oBAAA;AACEE,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;wBACxCO,KAAO,EAAA;AACT;iBACD,GACD;AACE,oBAAA;AACEH,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,WAAW,CAAC;wBAChCO,KAAO,EAAA;AACT;AACD,iBAAA;AACL,gBAAA;AAAEH,oBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;oBAAEO,KAAO,EAAA;AAAM,iBAAA;AACzD,gBAAA;AAAEH,oBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,sBAAsB,CAAC;oBAAEO,KAAO,EAAA;AAAS;AAChE;AACH,SAAA;AACA,QAAA;AACEC,YAAAA,IAAAA,EAAM,CAACC,OAAAA,GAAYA,OAAQC,CAAAA,WAAW,KAAK,KAAA;YAC3CP,IAAM,EAAA,MAAA;YACNE,OAAS,EAAA,wBAAA;YACTD,IAAM,EAAA,KAAA;YACN,MAAME,OAAAA,CAA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jB,IAAAA,CAAKa,WAAaG,EAAAA,GAAAA,CAAAA,CAAAA,CAAML,WAAW,EAAA,CAAA;gBAGlD,IAAII,iBAAAA,CAAkBH,MAAM,KAAK,CAAG,EAAA;AAClC,oBAAA,MAAMR,KAAM,CAAA,kCAAA,CAAA;AACd;gBAEA,OAAOW,iBAAAA;AACT;AACF;AACD,KAAA;AACH,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/kind-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIhD,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,cAAc,CAYpC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const validate_input_1 = __importDefault(require("../utils/validate-input"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var validateInput = require('../utils/validate-input.js');
|
|
4
|
+
|
|
7
5
|
const questions = [
|
|
8
6
|
{
|
|
9
7
|
type: 'list',
|
|
@@ -11,11 +9,18 @@ const questions = [
|
|
|
11
9
|
message: 'Please choose the model type',
|
|
12
10
|
default: 'collectionType',
|
|
13
11
|
choices: [
|
|
14
|
-
{
|
|
15
|
-
|
|
12
|
+
{
|
|
13
|
+
name: 'Collection Type',
|
|
14
|
+
value: 'collectionType'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'Single Type',
|
|
18
|
+
value: 'singleType'
|
|
19
|
+
}
|
|
16
20
|
],
|
|
17
|
-
validate: (input)
|
|
18
|
-
}
|
|
21
|
+
validate: (input)=>validateInput(input)
|
|
22
|
+
}
|
|
19
23
|
];
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
|
|
25
|
+
module.exports = questions;
|
|
26
|
+
//# sourceMappingURL=kind-prompts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kind-prompts.js","
|
|
1
|
+
{"version":3,"file":"kind-prompts.js","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["import type { PromptQuestion } from 'node-plop';\n\nimport validateInput from '../utils/validate-input';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'list',\n name: 'kind',\n message: 'Please choose the model type',\n default: 'collectionType',\n choices: [\n { name: 'Collection Type', value: 'collectionType' },\n { name: 'Single Type', value: 'singleType' },\n ],\n validate: (input: string) => validateInput(input),\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","message","default","choices","value","validate","input","validateInput"],"mappings":";;;;AAIA,MAAMA,SAAmC,GAAA;AACvC,IAAA;QACEC,IAAM,EAAA,MAAA;QACNC,IAAM,EAAA,MAAA;QACNC,OAAS,EAAA,8BAAA;QACTC,OAAS,EAAA,gBAAA;QACTC,OAAS,EAAA;AACP,YAAA;gBAAEH,IAAM,EAAA,iBAAA;gBAAmBI,KAAO,EAAA;AAAiB,aAAA;AACnD,YAAA;gBAAEJ,IAAM,EAAA,aAAA;gBAAeI,KAAO,EAAA;AAAa;AAC5C,SAAA;QACDC,QAAU,EAAA,CAACC,QAAkBC,aAAcD,CAAAA,KAAAA;AAC7C;AACD;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import validateInput from '../utils/validate-input.mjs';
|
|
2
|
+
|
|
3
|
+
const questions = [
|
|
4
|
+
{
|
|
5
|
+
type: 'list',
|
|
6
|
+
name: 'kind',
|
|
7
|
+
message: 'Please choose the model type',
|
|
8
|
+
default: 'collectionType',
|
|
9
|
+
choices: [
|
|
10
|
+
{
|
|
11
|
+
name: 'Collection Type',
|
|
12
|
+
value: 'collectionType'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'Single Type',
|
|
16
|
+
value: 'singleType'
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
validate: (input)=>validateInput(input)
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export { questions as default };
|
|
24
|
+
//# sourceMappingURL=kind-prompts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kind-prompts.mjs","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["import type { PromptQuestion } from 'node-plop';\n\nimport validateInput from '../utils/validate-input';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'list',\n name: 'kind',\n message: 'Please choose the model type',\n default: 'collectionType',\n choices: [\n { name: 'Collection Type', value: 'collectionType' },\n { name: 'Single Type', value: 'singleType' },\n ],\n validate: (input: string) => validateInput(input),\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","message","default","choices","value","validate","input","validateInput"],"mappings":";;AAIA,MAAMA,SAAmC,GAAA;AACvC,IAAA;QACEC,IAAM,EAAA,MAAA;QACNC,IAAM,EAAA,MAAA;QACNC,OAAS,EAAA,8BAAA;QACTC,OAAS,EAAA,gBAAA;QACTC,OAAS,EAAA;AACP,YAAA;gBAAEH,IAAM,EAAA,iBAAA;gBAAmBI,KAAO,EAAA;AAAiB,aAAA;AACnD,YAAA;gBAAEJ,IAAM,EAAA,aAAA;gBAAeI,KAAO,EAAA;AAAa;AAC5C,SAAA;QACDC,QAAU,EAAA,CAACC,QAAkBC,aAAcD,CAAAA,KAAAA;AAC7C;AACD;;;;"}
|
package/dist/plops/service.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/plops/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAMlB,WAAW;AAAjC,wBA8BE"}
|