63 lines
1.4 KiB
JavaScript
Raw Normal View History

'use strict';
const inquirer = require('inquirer');
/**
* @param {string|null} projectName - The name/path of project
* @param {string|null} starterUrl - The GitHub repo of the starter
* @returns Object containting prompt answers
*/
module.exports = async function promptUser(projectName, starter, program) {
const mainQuestions = [
{
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',
2021-11-16 15:36:38 +01:00
when: !program.quickstart,
choices: [
{
name: 'Quickstart (recommended)',
value: true,
},
{
name: 'Custom (manual settings)',
value: false,
},
],
},
];
const [mainResponse, starterQuestion] = await Promise.all([
inquirer.prompt(mainQuestions),
getStarterQuestion(),
]);
const starterResponse = await inquirer.prompt({
name: 'starter',
when: !starter,
...starterQuestion,
});
return { ...mainResponse, ...starterResponse };
};
/**
*
* @returns Prompt question object
*/
async function getStarterQuestion() {
2021-11-22 10:37:00 +01:00
// Ask user to manually input his starter
// TODO: find way to suggest the possible v4 starters
return {
2021-11-22 10:37:00 +01:00
type: 'input',
message: 'Please provide the npm package name of the starter you want to use:',
};
}