@nomadmystic/wordpress-scaffold-cli
Version:
This project is created to speed up WordPress development
100 lines (99 loc) • 2.8 kB
JavaScript
import { getInternalConfig } from '../utils/get-config.js';
import { scaffoldInternal } from '../scaffold/common/scaffold-internal.js';
import getCommonOptions from "./common-options.js";
let projectOptions = [
{
type: 'confirm',
name: 'databaseSetup',
message: 'Have you setup your database and user for this site?',
default: false,
},
{
type: 'input',
name: 'databaseName',
message: 'What is the DB name for the site?',
default: '',
when(answers) {
return answers.databaseSetup;
},
validate(value) {
if (value !== '') {
return true;
}
return 'Please enter a database name.';
},
},
{
type: 'password',
name: 'databasePassword',
message: 'What is the DB password for the site?',
default: '',
when(answers) {
return answers.databaseSetup;
},
validate(value) {
if (value !== '') {
return true;
}
return 'Please enter a database password.';
},
},
{
type: 'input',
name: 'databaseUsername',
message: 'What is the DB username for the site?',
default: '',
when(answers) {
return answers.databaseSetup;
},
validate(value) {
if (value !== '') {
return true;
}
return 'Please enter a database username.';
},
},
{
type: 'input',
name: 'siteTitle',
message: 'What is the title for the site?',
default: 'Example Site',
},
{
type: 'input',
name: 'siteAdminUser',
message: 'What is the admin username for the site?',
default: 'example@example.com',
},
{
type: 'input',
name: 'adminEmail',
message: 'What is the admin email for the site?',
default: 'example@example.com',
},
{
type: 'password',
name: 'siteAdminPassword',
message: 'What is the admin user\'s password for the site?',
default: '',
validate(value) {
if (value !== '') {
return true;
}
return 'Please enter your admin user\'s password.';
},
},
];
const getProjectOptions = async () => {
try {
await scaffoldInternal();
let jsonFileParsed = await getInternalConfig('project/project-config.json');
const commonOptions = await getCommonOptions(jsonFileParsed);
projectOptions = projectOptions.concat(commonOptions);
return projectOptions;
}
catch (err) {
console.error(err);
}
};
export default getProjectOptions;