This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
grunt.js
153 lines (131 loc) · 4.51 KB
/
grunt.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
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
/*global module:true */
module.exports = function(grunt) {
var read = grunt.file.read,
port = require('./utils/gruntConfig').port,
rjsDefine = require('./utils/rjsDefine');
// Register task for mapping out test files
require('./utils/grunt-test-files')(grunt);
// Project configuration.
grunt.initConfig({
// Package meta data
pkg: '<json:package.json>',
meta: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> Ensighten;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
// Download public resources
curl: {
'src/public/js/jquery.js': 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js',
'src/public/js/require.js': 'https://raw.github.com/jrburke/requirejs/master/require.js',
'src/public/js/socket.io.js': 'https://raw.github.com/LearnBoost/socket.io-client/master/dist/socket.io.js',
'src/public/js/Sauron.js': 'https://raw.github.com/Ensighten/Sauron/master/dist/Sauron.require.js',
'src/public/js/Builder.js': 'https://raw.github.com/Ensighten/Builder/master/dist/Builder.require.jquery.js'
},
// Add require.js paths to files (src -> stage)
replace: {
'socket.io': rjsDefine('socket.io'),
Sauron: rjsDefine('Sauron'),
Builder: rjsDefine('Builder'),
mvc: rjsDefine('mvc'),
text: rjsDefine({file: 'text', singleQuotes: true}),
PrimalClay: rjsDefine('PrimalClay'),
BaseController: rjsDefine({module: 'BaseController', file: '../../controllers/BaseController'}),
HtmlController: rjsDefine({module: 'HtmlController', file: '../../controllers/HtmlController'}),
CrudModel: rjsDefine({module: 'CrudModel', file: '../../models/CrudModel'}),
SocketModel: rjsDefine({module: 'SocketModel', file: '../../models/SocketModel'})
},
// Concatenate and minify repository
concat: {
halo: {
src: [
// Banner, require, and jquery first
'<banner:meta.banner>', 'src/public/js/require.js', 'src/public/js/jquery.js',
// Then socket.io
// Socket.io uses anonymous define
'stage/public/js/socket.io.js',
// Then Sauron.require, Builder.require.jquery
'stage/public/js/Sauron.js', 'stage/public/js/Builder.js',
// Then text and mvc
'stage/public/js/text.js', 'stage/public/js/mvc.js',
// Then PrimalClay
'stage/public/js/PrimalClay.js',
// Then controllers
'stage/controllers/BaseController.js', 'stage/controllers/HtmlController.js',
// Then models
'stage/models/CrudModel.js', 'stage/models/SocketModel.js'
],
dest: 'dist/halo.js'
}
},
min: {
halo: {
src: '<config:concat.halo.src>',
dest: 'dist/halo.min.js'
}
},
// Testing
qunit: {
// TODO: Get directive working inline
// files: '<test-files:Halo/*.html:Halo/*.js>'
files: grunt.task.directive('<test-files:test/*.html:test/Halo_test*.js>')
},
server: {
port: port,
base: '.'
},
// Linting
lint: {
files: [
'grunt.js',
'src/{controllers,models}/**/*.js',
'public/js/{Builder,Sauron,mvc}.js',
'test/*.js'
]
},
// Watch files
watch: {
files: ['<config:lint.files>', '<config:qunit.files>'],
tasks: 'build-only test-only'
},
// Test options
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
// newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
'$': true,
'jQuery': true,
'require': true,
'define': true
}
},
uglify: {}
});
// Load in grunt-curl
grunt.loadNpmTasks('grunt-curl');
// Load in requirejs bindings
grunt.loadNpmTasks('grunt-text-replace');
// Alias qunit as test
grunt.registerTask('test', 'server test-only');
grunt.registerTask('test-only', 'qunit');
// Alias update as curl
grunt.registerTask('update', 'curl');
// By default, build and watch
grunt.registerTask('default', 'build watch');
// Set up up build task
grunt.registerTask('build', 'build-only test');
grunt.registerTask('build-only', 'lint replace concat min');
};