2019-06-20 16:38:15 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const execa = require('execa');
|
|
|
|
|
2019-10-15 16:21:59 +02:00
|
|
|
const { trackUsage, captureStderr } = require('./utils/usage');
|
2019-06-20 16:38:15 +02:00
|
|
|
const defaultConfigs = require('./utils/db-configs.js');
|
|
|
|
const clientDependencies = require('./utils/db-client-dependencies.js');
|
|
|
|
const createProject = require('./create-project');
|
|
|
|
|
|
|
|
module.exports = async function createQuickStartProject(scope) {
|
|
|
|
console.log('Creating a quickstart project.');
|
|
|
|
await trackUsage({ event: 'didChooseQuickstart', scope });
|
|
|
|
|
|
|
|
// get default sqlite config
|
|
|
|
const client = 'sqlite';
|
|
|
|
const configuration = {
|
|
|
|
client,
|
|
|
|
connection: defaultConfigs[client],
|
2019-07-03 11:20:14 +02:00
|
|
|
dependencies: clientDependencies({ scope, client }),
|
2019-06-20 16:38:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
await createProject(scope, configuration);
|
|
|
|
|
2019-10-14 16:14:34 +02:00
|
|
|
if (scope.runQuickstartApp !== true) return;
|
|
|
|
|
|
|
|
try {
|
|
|
|
await trackUsage({ event: 'willBuildAdmin', scope });
|
|
|
|
|
2019-10-15 18:33:27 +02:00
|
|
|
await execa('npm', ['run', 'build', '--', '--no-optimization'], {
|
2019-10-14 16:14:34 +02:00
|
|
|
stdio: 'inherit',
|
|
|
|
cwd: scope.rootPath,
|
|
|
|
env: {
|
|
|
|
FORCE_COLOR: 1,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
await trackUsage({ event: 'didBuildAdmin', scope });
|
|
|
|
} catch (error) {
|
|
|
|
await trackUsage({
|
|
|
|
event: 'didNotBuildAdmin',
|
|
|
|
scope,
|
2019-10-16 11:37:42 +02:00
|
|
|
error,
|
2019-10-14 16:14:34 +02:00
|
|
|
});
|
|
|
|
|
2019-10-15 16:21:59 +02:00
|
|
|
await captureStderr('didNotBuildAdmin', error);
|
|
|
|
process.exit(1);
|
2019-10-14 16:14:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
console.log(`Running your Strapi application.`);
|
|
|
|
|
|
|
|
try {
|
|
|
|
await trackUsage({ event: 'willStartServer', scope });
|
2019-06-20 16:38:15 +02:00
|
|
|
|
|
|
|
await execa('npm', ['run', 'develop'], {
|
|
|
|
stdio: 'inherit',
|
|
|
|
cwd: scope.rootPath,
|
|
|
|
env: {
|
|
|
|
FORCE_COLOR: 1,
|
|
|
|
},
|
2019-10-08 08:56:51 +02:00
|
|
|
});
|
2019-10-14 16:14:34 +02:00
|
|
|
} catch (error) {
|
|
|
|
await trackUsage({
|
|
|
|
event: 'didNotStartServer',
|
|
|
|
scope,
|
2019-10-16 11:37:42 +02:00
|
|
|
error,
|
2019-10-14 16:14:34 +02:00
|
|
|
});
|
|
|
|
|
2019-10-15 16:21:59 +02:00
|
|
|
await captureStderr('didNotStartServer', error);
|
|
|
|
process.exit(1);
|
2019-06-20 16:38:15 +02:00
|
|
|
}
|
|
|
|
};
|