-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
246 lines (224 loc) · 6.52 KB
/
Gruntfile.js
File metadata and controls
246 lines (224 loc) · 6.52 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
// Generated on 2014-09-10 using generator-socketio 0.0.3
'use strict';
var moment = require('moment');
var LIVERELOAD_PORT = 35729;
var RUNNING_PORT = 4443; // <- if you change this, you need to change in public/js/app.js and recompile
var RUNNING_CERT_PATH = 'server.crt';
var RUNNING_KEY_PATH = 'server.key';
var RUNNING_ADMIN_NAME = 'admin';
var RUNNING_CLOSED_TASK_DELAY = 60*1000;
var RUNNING_SESSION_SECRET = 'change_me';
var RUNNING_DB_CONNECTION_STRING = 'mongodb://127.0.0.1:27017/sthack';
var RUNNING_SESSION_KEY = 'sthackSession';
var RUNNING_ADMIN_PATH = '/admin_poney';
var RUNNING_NODE_ENV = 'production';
var RUNNING_TITLE = 'Sthack';
var RUNNING_BASE_SCORE = 50;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.loadNpmTasks('grunt-jasmine-node');
grunt.initConfig({
cssmin: {
target: {
files: {
'public/css/style.min.css': 'static/css/style.css',
'public/css/reset.min.css': 'static/css/reset.css'
}
}
},
//this is currently turned off, since jquery KILLS it
jshint: {
options: {
curly: true,
eqeqeq: false,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
},
files:{
src:['static/js/*.js', 'server.js', 'src/**/*.js']
}
},
uglify: {
options: {
mangle: false
},
my_target: {
files: {
'public/js/client.min.js': ['static/js/button.js', 'static/js/console.js', 'static/js/client.js'],
'public/js/rules.min.js': ['static/js/button.js', 'static/js/rules.js'],
'public/js/scoreboard.min.js': ['static/js/console.js', 'static/js/scoreboard.js'],
'public/js/admin.min.js': ['static/js/console.js', 'static/js/admin.js']
}
}
},
jasmine_node: {
options: {
forceExit: true,
match: '.',
matchall: false,
extensions: 'js',
specNameMatcher: 'spec'
},
all: ['spec/']
},
// Watch Config
watch: {
src:{
files: ['views/**/*'],
options: {
livereload: true
},
},
scripts: {
files: [
'static/js/**/*.js',
],
tasks:['uglify']
},
css: {
files: [
'static/css/**/*.css',
],
tasks:['cssmin']
},
},
// connect: {
// options: {
// port: RUNNING_PORT,//variable at top of this file
// // change this to '0.0.0.0' to access the server from outside
// hostname: 'localhost'
// },
// livereload: {
// options: {
// middleware: function (connect) {
// return [
// lrSnippet,
// mountFolder(connect, '.')
// ];
// }
// }
// }
// },
nodemon:{
dev: {
options: {
file: 'server.js',
//args: ['dev'],
//nodeArgs: ['--debug'],
ignoredFiles: ['node_modules/**'],
//watchedExtensions: ['js'],
watchedFolders: ['src'],
//delayTime: 1,
legacyWatch: true,
env: {
PORT : RUNNING_PORT,
CERT_PATH : RUNNING_CERT_PATH,
KEY_PATH : RUNNING_KEY_PATH,
ADMIN_NAME : RUNNING_ADMIN_NAME,
CLOSED_TASK_DELAY : RUNNING_CLOSED_TASK_DELAY,
SESSION_SECRET : RUNNING_SESSION_SECRET,
DB_CONNECTION_STRING: RUNNING_DB_CONNECTION_STRING,
SESSION_KEY : RUNNING_SESSION_KEY,
ADMIN_PATH : RUNNING_ADMIN_PATH,
TITLE : RUNNING_TITLE,
BASE_SCORE : RUNNING_BASE_SCORE,
NODE_ENV : RUNNING_NODE_ENV
},
cwd: __dirname
}
}
},
// run 'watch' and 'nodemon' indefinitely, together
// 'launch' will just kick it off, and won't stay running
concurrent: {
target: {
tasks: ['nodemon', 'watch', 'wait'],
options: {
logConcurrentOutput: true
}
}
},
wait:{
options: {
delay: 1000
},
pause:{
options:{
before:function(options){
console.log('pausing %dms before launching page', options.delay);
},
after : function() {
console.log('pause end, heading to page (using default browser)');
}
}
}
},
compress: {
main: {
options: {
mode: 'tgz',
archive: 'dist/sthack-interface-neo.tar.gz'
},
files: [
{src: ['public/**', 'server.js', 'src/**', 'views/**', 'package.json']}
]
}
},
secret: grunt.file.readJSON('sshProduction.json'),
sshexec: {
extract: {
command: '<%= secret.extractcmd %>',
options: {
host: '<%= secret.host %>',
username: '<%= secret.username %>',
password: '<%= secret.password %>'
}
},
restart: {
command: '<%= secret.restartcmd %>',
options: {
host: '<%= secret.host %>',
username: '<%= secret.username %>',
password: '<%= secret.password %>'
}
},
start: {
command: '<%= secret.startcmd %>',
options: {
host: '<%= secret.host %>',
username: '<%= secret.username %>',
password: '<%= secret.password %>'
}
}
},
sftp: {
upload: {
files: {
"./": "dist/**"
},
options: {
path: '<%= secret.path %>',
host: '<%= secret.host %>',
username: '<%= secret.username %>',
password: '<%= secret.password %>',
showProgress: true,
srcBasePath: "dist/"
}
}
}
});
//grunt.registerTask('server', ['build', 'connect:livereload', 'open', 'watch']);
grunt.registerTask('build', ['cssmin', 'uglify']);
grunt.registerTask('validate', ['jshint']);
grunt.registerTask('test', ['jasmine_node'])
grunt.registerTask('deploy', ['build', 'compress', 'sftp:upload', 'sshexec:extract', 'sshexec:restart']);
grunt.registerTask('default', ['build', 'concurrent']);
};