-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.js
105 lines (90 loc) · 3.54 KB
/
install.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
99
100
101
102
103
104
105
var prompt = require('prompt'),
fs = require('fs'),
prompt = require('prompt'),
exec = require('child_process').exec,
shell = require('shelljs'),
encryption = require('./encryption');
/**
*
* Check for installed required software
* Warn about sudo issues: give links
*
*/
if (!shell.which('grunt')) {
prompt.logger.error('You need to install grunt-cli globally :: http://gruntjs.com/getting-started');
prompt.logger.warn('If you get access errors, you need to set the proper permissions on your node_modules folder =>');
prompt.logger.info(' http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo');
return;
}
if (!shell.which('bower')) {
prompt.logger.error('You need to install bower globally :: http://bower.io/');
prompt.logger.warn('If you get access errors, you need to set the proper permissions on your node_modules folder =>');
prompt.logger.info(' http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo');
return;
}
var schema = {
properties: {
username: {
required: true,
description: 'Please enter your JIRA username (not email address)'
},
password: {
hidden: true,
description: 'Please enter your JIRA password (password is encrypted)'
},
url: {
pattern: /.+\/$/,
message: 'JIRA url must have trailing slash ("/")',
required: true,
description: 'Please enter your JIRA url (include the trailing slash ("http://jiraurl.com/")'
}
}
}
prompt.logger.info('Starting install...\n');
prompt.get(schema, function (err, result) {
// check for data dir, if not found build files/folders
if (!shell.test('-d', 'data')) {
prompt.logger.info('Creating `data` directory');
shell.mkdir('data');
prompt.logger.info('Creating `data/stats.json` file');
fs.writeFileSync('data/stats.json', JSON.stringify({
jira: {}
}));
prompt.logger.info('Creating `data/user.json` file');
fs.writeFileSync('data/user.json', JSON.stringify({
id: 1,
allowBrowserNotifications: false,
allowVoiceNotifications: false,
allowVoiceCommands: false,
notificationDuration: 10,
backupDuration: 60,
screenCaptureDuration: 10,
allowScreenCapture: false,
screenCaptureStartTime: '9:00 AM',
screenCaptureEndTime: '5:00 PM',
hoursPerWorkWeek: 30
}));
prompt.logger.info('Creating `data/jira.json` file');
fs.writeFileSync('data/jira.json', JSON.stringify({
id: 1,
username: result.username,
password: encryption.encrypt(result.password),
jiraUrl: result.url,
hasLoginCreds: true,
isVisible: false
}));
prompt.logger.info('Creating `data/captures.json` file');
fs.writeFileSync('data/captures.json', JSON.stringify([]));
}
// check for static/img/screens dir, if not found build files/folders
if (!shell.test('-d', 'static/img/screens')) {
prompt.logger.info('Creating `static/img/screens/full` directory');
shell.mkdir('-p', 'static/img/screens/full');
prompt.logger.info('Creating `static/img/screens/thumbs` directory');
shell.mkdir('static/img/screens/thumbs');
}
prompt.logger.info('bower install \n');
shell.exec('bower install');
prompt.logger.info('grunt build \n');
shell.exec('grunt build');
});