-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathindex.js
executable file
·71 lines (66 loc) · 1.65 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env node
/**
* strapi-tool-strapi-tool-dockerize
* Add docker support for a Strapi Project
*
* @author Simen Daehlin <https://dehlin.dev>
*/
const { cli, init, log, quickStart, reset } = require(`./cli`);
const questions = require(`./core/questions`);
const {
detectProjectType,
detectPackageManager,
detectStrapiProject,
goodbye,
detectDownloadsAndStars,
config,
createStrapiProject,
detectDockerFiles
} = require(`./utils`);
const {
appendEnv,
createEnv,
installDependecies,
createDockerComposeFiles,
createDockerFiles
} = require(`./core`);
const input = cli.input;
const flags = cli.flags;
const { clear, debug } = flags;
const path = require(`path`);
const { setConfig } = require(`./utils/config`);
const process = require(`process`);
(async () => {
init({ clear });
input.includes(`help`) && cli.showHelp(0);
debug && log(flags);
const useQuickStart = input.includes(`new`) ? quickStart(flags) : false;
try {
await detectDownloadsAndStars();
await detectProjectType();
await detectPackageManager();
if (!(await detectStrapiProject())) {
const projectPath = await createStrapiProject();
process.chdir(projectPath);
setConfig({ outDir: path.join(process.cwd()) });
}
if (input.includes(`reset`)) {
await reset();
goodbye();
return;
}
const askQuestions = useQuickStart ? false : await questions();
if (askQuestions || config.dockerCompose) {
await detectDockerFiles();
await createDockerComposeFiles();
await appendEnv();
await createEnv();
await installDependecies();
}
await detectDockerFiles();
await createDockerFiles();
goodbye();
} catch (error) {
goodbye(false);
}
})();