-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
50 lines (39 loc) · 1.37 KB
/
index.ts
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
#! /usr/bin/env node
import { Argument, Command, Option } from 'commander';
import packageJson from './package.json';
import chalk from 'chalk';
import { copyRemoteTemplate, copyToProject, initDatabase, installProject } from './helpers/utils';
import Output from "./helpers/output";
const program = new Command();
program.version(packageJson.version, '-v, --version');
program.usage(
`${chalk.blue('project-directory')} [options]`
);
// Arguments
program.addArgument(
new Argument('<project-directory>', 'specify path for create-burdy-app').argOptional().default('create-burdy-app')
);
// Options
program.addOption(
new Option('-d, --docker <type>', 'default docker file to be included with the set-up')
.default('mariadb')
.choices(['mariadb', 'postgres', 'mysql'])
);
program.addOption(
new Option('-t, --template <template>', 'use one of burdy starter templates ex. "next-blog"')
.default(null)
)
program.parse(process.argv);
(async () => {
const projectDirectory = program.processedArgs[0];
const dockerConfig = program.opts<any>().docker;
const template = program.opts<any>().template;
if (template) {
await copyRemoteTemplate(projectDirectory, template);
} else {
await copyToProject(projectDirectory, dockerConfig)
}
await installProject(projectDirectory);
await initDatabase(projectDirectory);
Output.nextSteps(projectDirectory);
})();