1 | 'use strict';
|
2 |
|
3 | const execa = require('execa');
|
4 |
|
5 | const { trackUsage, captureStderr } = require('./utils/usage');
|
6 | const defaultConfigs = require('./utils/db-configs.js');
|
7 | const clientDependencies = require('./utils/db-client-dependencies.js');
|
8 | const createProject = require('./create-project');
|
9 |
|
10 | module.exports = async function createQuickStartProject(scope) {
|
11 | console.log('Creating a quickstart project.');
|
12 | await trackUsage({ event: 'didChooseQuickstart', scope });
|
13 |
|
14 |
|
15 | const client = 'sqlite';
|
16 | const configuration = {
|
17 | client,
|
18 | connection: defaultConfigs[client],
|
19 | dependencies: clientDependencies({ scope, client }),
|
20 | };
|
21 |
|
22 | await createProject(scope, configuration);
|
23 |
|
24 | if (scope.runQuickstartApp !== true) return;
|
25 |
|
26 | try {
|
27 | await trackUsage({ event: 'willBuildAdmin', scope });
|
28 |
|
29 | await execa('npm', ['run', 'build', '--', '--no-optimization'], {
|
30 | stdio: 'inherit',
|
31 | cwd: scope.rootPath,
|
32 | env: {
|
33 | FORCE_COLOR: 1,
|
34 | },
|
35 | });
|
36 |
|
37 | await trackUsage({ event: 'didBuildAdmin', scope });
|
38 | } catch (error) {
|
39 | await trackUsage({
|
40 | event: 'didNotBuildAdmin',
|
41 | scope,
|
42 | error,
|
43 | });
|
44 |
|
45 | await captureStderr('didNotBuildAdmin', error);
|
46 | process.exit(1);
|
47 | }
|
48 |
|
49 | console.log(`Running your Strapi application.`);
|
50 |
|
51 | try {
|
52 | await trackUsage({ event: 'willStartServer', scope });
|
53 |
|
54 | await execa('npm', ['run', 'develop'], {
|
55 | stdio: 'inherit',
|
56 | cwd: scope.rootPath,
|
57 | env: {
|
58 | FORCE_COLOR: 1,
|
59 | },
|
60 | });
|
61 | } catch (error) {
|
62 | await trackUsage({
|
63 | event: 'didNotStartServer',
|
64 | scope,
|
65 | error,
|
66 | });
|
67 |
|
68 | await captureStderr('didNotStartServer', error);
|
69 | process.exit(1);
|
70 | }
|
71 | };
|