forked from auth0/auth0-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
154 lines (142 loc) · 4.28 KB
/
Gruntfile.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
154
var fs = require('fs');
var path = require('path');
var pkg = require('./package');
var major_version = pkg.version.replace(/\.(\d)*\.(\d)*$/, '');
function node_bin (bin) {
return path.join('node_modules', '.bin', bin);
}
module.exports = function (grunt) {
grunt.initConfig({
connect: {
test: {
options: {
// base: 'test',
hostname: '*',
base: ['.', 'support/development-demo', 'support/development-demo/build', 'build'],
port: 9999
}
},
demo: {
options: {
hostname: '*',
base: ['support/development-demo', 'support/development-demo/build', 'build', '.'],
port: 3000
}
}
},
browserify: {
options: {
browserifyOptions: {
debug: true
},
watch: true,
// Convert absolute sourcemap filepaths to relative ones using mold-source-map.
postBundleCB: function(err, src, cb) {
if (err) { return cb(err); }
var through = require('through');
var stream = through().pause().queue(src).end();
var buffer = '';
stream.pipe(require('mold-source-map').transformSourcesRelativeTo(__dirname)).pipe(through(function(chunk) {
buffer += chunk.toString();
}, function() {
cb(err, buffer);
}));
stream.resume();
}
},
debug: {
files: {
'build/auth0-metrics.js': ['standalone.js']
}
},
},
less: {
demo: {
files: {
'support/development-demo/build/index.css': 'support/development-demo/index.less'
}
}
},
copy: {
demo: {
files: {
'support/development-demo/auth0-metrics.min.js': 'build/auth0-metrics.min.js',
'support/development-demo/auth0-metrics.js': 'build/auth0-metrics.js'
}
}
},
exec: {
'uglify': {
cmd: node_bin('uglifyjs') + ' build/auth0-metrics.js -b beautify=false,ascii_only=true > build/auth0-metrics.min.js',
stdout: true,
stderr: true
},
'uglify-loader': {
cmd: node_bin('uglifyjs') + ' build/auth0-metrics-loader.js -b beautify=false,ascii_only=true > build/auth0-metrics-loader.min.js',
stdout: true,
stderr: true
},
'test-inception': {
cmd: node_bin('mocha') + ' ./test/support/characters-inception.test.js',
stdout: true,
stderr: true
},
'test-integration': {
cmd: node_bin('zuul') + ' -- test/*.js',
stdout: true,
stderr: true
},
'test-phantom': {
cmd: node_bin('zuul') + ' --ui mocha-bdd --disable-tunnel --phantom 9999 -- test/*.js',
stdout: true,
stderr: true
},
cdn: {
cmd: node_bin('ccu'),
stdout: true,
stderr: true
}
},
clean: {
js: ['release/', 'build/', 'support/development-demo/auth0-metrics.js']
},
watch: {
js: {
files: ['build/auth0-metrics.js'],
tasks: [],
options: {
livereload: true
},
},
demo: {
files: ['support/development-demo/*'],
tasks: ['less:demo'],
options: {
livereload: true
},
}
},
jsdoc: {
dist : {
src: 'index.js',
options: {
destination: 'build',
template : "support/loader",
query: "majorFileName=metrics-" + major_version
}
}
}
});
// Loading dependencies
for (var key in grunt.file.readJSON('package.json').devDependencies) {
if (key !== 'grunt' && key.indexOf('grunt') === 0) { grunt.loadNpmTasks(key); }
}
grunt.registerTask('js', ['clean:js', 'browserify:debug', 'exec:uglify']);
grunt.registerTask('loader', ['jsdoc', 'exec:uglify-loader']);
grunt.registerTask('build', ['js', 'loader']);
grunt.registerTask('demo', ['less:demo', 'connect:demo', 'build', 'watch']);
grunt.registerTask('dev', ['connect:test', 'build', 'watch']);
grunt.registerTask('integration', ['exec:test-inception', 'exec:test-integration']);
grunt.registerTask('phantom', ['build', 'exec:test-inception', 'exec:test-phantom']);
grunt.registerTask('cdn', ['build', 'exec:cdn']);
};