-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
98 lines (69 loc) · 2.04 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env node --harmony
'use strict';
var Promise = require('promise');
var fs = require('fs');
var fse = require('fs-extra');
var figlet = require('figlet');
var chalk = require('chalk');
var supportsColor = require('supports-color');
var inquirer = require('inquirer');
var shell = require("shelljs");
var username,
project;
//Ascii Logo
console.log(
chalk.yellow(
figlet.textSync('Your Sweet Build Tool', {
horizontalLayout: 'full',
font: 'Big Money-sw',
})
)
);
//Callbacks
buildToolLauncherInit(function(data) {
cloneRepo(data);
setTimeout(function() {
installDependenciesThenLaunch(data);
}, 3000);
});
//Init Function
function buildToolLauncherInit(callback) {
var questions = [{
type: "input",
message: 'What is your Bitbucket username? ',
name: "username"
}, {
type: "input",
message: 'What is the name of your project?',
name: "project"
}, {
type: 'confirm',
name: 'doublecheck',
message: 'Is this correct? (just hit enter for YES)',
default: true
}];
//Allow cofirmation to reset installation
function makeSure() {
inquirer.prompt(questions).then(function(data) {
if (data.doublecheck) {
return callback(data);
} else {
makeSure();
}
});
} makeSure();
}
//Clone Repo Function
function cloneRepo(data) {
console.log(chalk.cyan.bold('Downloading repo 👍'));
shell.exec("git clone https://" + data.username + "@bitbucket.org/YOUR-URL.git " + data.project);
}
//Installation and Launch Function
function installDependenciesThenLaunch(data) {
var newProject = data.project;
fse.removeSync(newProject + "/.git");
console.log(chalk.cyan.bold('Starting npm install 👍'));
shell.exec('cd ' + newProject + '&& ' + 'npm install --color always');
console.log(chalk.cyan.bold('Starting gulp 👍'));
shell.exec('cd ' + newProject + '&& ' + 'gulp --color');
}