2021-06-02 14:55:33 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const inquirer = require('inquirer');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string|null} projectName - The name/path of project
|
|
|
|
* @param {string|null} template - The Github repo of the template
|
|
|
|
* @returns Object containting prompt answers
|
|
|
|
*/
|
2022-02-28 13:40:13 -05:00
|
|
|
module.exports = async function promptUser(projectName, program, hasDatabaseOptions) {
|
|
|
|
const questions = await getPromptQuestions(projectName, program, hasDatabaseOptions);
|
2021-11-16 15:36:38 +01:00
|
|
|
return inquirer.prompt(questions);
|
2021-06-02 14:55:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-09-24 14:49:41 +02:00
|
|
|
* @param {string|null} projectName - The name of the project
|
|
|
|
* @param {string|null} template - The template the project should use
|
2021-06-02 14:55:33 +02:00
|
|
|
* @returns Array of prompt question objects
|
|
|
|
*/
|
2022-02-28 13:40:13 -05:00
|
|
|
async function getPromptQuestions(projectName, program, hasDatabaseOptions) {
|
2021-06-02 14:55:33 +02:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
type: 'input',
|
|
|
|
default: 'my-strapi-project',
|
|
|
|
name: 'directory',
|
|
|
|
message: 'What would you like to name your project?',
|
|
|
|
when: !projectName,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'list',
|
|
|
|
name: 'quick',
|
|
|
|
message: 'Choose your installation type',
|
2022-02-28 13:40:13 -05:00
|
|
|
when: !program.quickstart && !hasDatabaseOptions,
|
2021-06-02 14:55:33 +02:00
|
|
|
choices: [
|
|
|
|
{
|
|
|
|
name: 'Quickstart (recommended)',
|
|
|
|
value: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Custom (manual settings)',
|
|
|
|
value: false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|