2019-06-20 15:45:14 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module dependencies
|
|
|
|
*/
|
|
|
|
|
2019-10-14 16:14:34 +02:00
|
|
|
const { trackUsage } = require('./utils/usage');
|
2021-11-23 14:53:00 +01:00
|
|
|
const checkInstallPath = require('./utils/check-install-path');
|
2019-06-20 16:38:15 +02:00
|
|
|
const createCLIDatabaseProject = require('./create-cli-db-project');
|
2022-03-07 11:09:26 +01:00
|
|
|
const createCustomizedProject = require('./create-customized-project');
|
2019-06-20 16:38:15 +02:00
|
|
|
const createQuickStartProject = require('./create-quickstart-project');
|
2019-06-20 15:45:14 +02:00
|
|
|
|
2022-08-08 23:33:39 +02:00
|
|
|
module.exports = async (scope) => {
|
2019-06-20 15:45:14 +02:00
|
|
|
const hasDatabaseConfig = Boolean(scope.database);
|
|
|
|
|
|
|
|
// check rootPath is empty
|
2021-11-23 14:53:00 +01:00
|
|
|
checkInstallPath(scope.rootPath);
|
2019-06-20 15:45:14 +02:00
|
|
|
|
2019-10-14 16:14:34 +02:00
|
|
|
await trackUsage({ event: 'willCreateProject', scope });
|
|
|
|
|
2019-06-20 15:45:14 +02:00
|
|
|
// if database config is provided don't test the connection and create the project directly
|
|
|
|
if (hasDatabaseConfig) {
|
2019-06-20 16:38:15 +02:00
|
|
|
return createCLIDatabaseProject(scope);
|
2019-06-20 15:45:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// if cli quickstart create project with default sqlite options
|
|
|
|
if (scope.quick === true) {
|
|
|
|
return createQuickStartProject(scope);
|
|
|
|
}
|
2019-06-20 16:38:15 +02:00
|
|
|
// create a project with full list of questions
|
2022-03-07 11:09:26 +01:00
|
|
|
return createCustomizedProject(scope);
|
2019-06-20 15:45:14 +02:00
|
|
|
};
|