-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·55 lines (45 loc) · 1.34 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
#!/usr/bin/env node
let commander = require('commander'),
download = require('download-github-repo'),
shell = require('shelljs'),
color = require('colors');
const url = 'https://twitter.github.com/bootstrap/assets/bootstrap.zip';
commander.version('1.0.0')
.command("new <name>")
.description('Creates a new project with a given name.')
.action((name) => {
let dir = `./${name}`;
info(`Creating ${name} application.`);
download('ivyjs/application', dir, (err) => {
if (err) {
error(err);
return;
}
success(`Application ${name} created!`);
installApplication(name);
});
});
commander.parse(process.argv);
if (!commander.args.length) commander.help();
function installApplication(name) {
shell.cd(name);
info('Installing dependencies.');
shell.exec('npm install');
success('Installation done.');
copyEnvFiles();
}
function copyEnvFiles() {
info('Creating environment file.');
shell.cp('.env.example', '.env');
success('Environment file created.');
success('All done! Make something great!'.underline);
}
function info(message) {
console.log(message.yellow);
}
function success(message) {
console.log(message.green);
}
function error(message) {
console.error(message.red);
}