forked from RallyTechServices/custom-grid-with-deep-export
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGruntfile.js
161 lines (141 loc) · 5.69 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
155
156
157
158
159
160
161
module.exports = function(grunt) {
require('grunt');
var config_file_name = 'config.json';
var auth_file_name = 'auth.json';
var config = { auth: {} };
if ( grunt.file.exists(config_file_name) ) {
config = grunt.file.readJSON('config.json');
config.js_files = grunt.file.expand(['src/javascript/utils/*.js','src/javascript/*.js']);
config.ugly_files = grunt.file.expand(['deploy/app.min.*.js']);
config.css_files = grunt.file.expand( 'src/style/*.css' );
config.checksum = "<!= checksum !>";
config.js_contents = " ";
for (var i=0;i<config.js_files.length;i++) {
grunt.log.writeln( config.js_files[i]);
config.js_contents = config.js_contents + "\n" + grunt.file.read(config.js_files[i]);
}
config.style_contents = "";
for (var i=0;i<config.css_files.length;i++) {
grunt.log.writeln( config.css_files[i]);
config.style_contents = config.style_contents + "\n" + grunt.file.read(config.css_files[i]);
}
config.ugly_contents = "";
for ( var i=0;i<config.ugly_files;i++ ) {
grunt.file.read(config.ugly_files[i]);
}
}
if ( grunt.file.exists(auth_file_name) ) {
// grunt.log.writeln( config.js_contents );
var auth = grunt.file.readJSON(auth_file_name);
config.auth = auth
} else {
grunt.log.writeln("");
grunt.log.writeln("WARNING: Slow tests won't run without an auth.json file");
}
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
mangle: true
},
ugly: {
files: { 'deploy/app.min.js': config.js_files }
}
},
template: {
dev: {
src: 'templates/App-debug-tpl.html',
dest: 'App-debug.html',
engine: 'underscore',
variables: config
},
prod: {
src: 'templates/App-tpl.html',
dest: 'deploy/App.txt',
engine: 'underscore',
variables: config
},
apikey: {
src: 'templates/App-apikey-tpl.html',
dest: 'deploy/ExternalApp.txt',
engine: 'underscore',
variables: config
},
confluence: {
src: 'templates/App-confluence-tpl.html',
dest: 'deploy/ConfluenceApp.txt',
engine: 'underscore',
variables: config
},
ugly: {
src: 'templates/App-ugly-tpl.html',
dest: 'deploy/Ugly.txt',
engine: 'underscore',
variables: config
}
},
jasmine: {
fast: {
src: 'src/**/*.js',
options: {
specs: 'test/fast/*-spec.js',
helpers: 'test/fast/*Helper.js',
template: 'test/fast/custom.tmpl',
templateOptions: config,
keepRunner: true,
junit: {
path: 'test/logs/fast'
}
}
},
slow: {
src: 'src/**/*.js',
options: {
specs: 'test/slow/*-spec.js',
helpers: 'test/slow/*Helper.js',
template: 'test/slow/custom.tmpl',
templateOptions: config,
keepRunner: true,
timeout: 50000,
junit: {
path: 'test/logs/slow'
}
}
}
}
});
grunt.registerTask('setChecksum', 'Make a sloppy checksum', function() {
var fs = require('fs');
var chk = 0x12345678,
i;
var deploy_file = 'deploy/App.txt';
var file = grunt.file.read(deploy_file);
string = file.replace(/var CHECKSUM = .*;/,"");
string = string.replace(/\s/g,""); //Remove all whitespace from the string.
for (i = 0; i < string.length; i++) {
chk += (string.charCodeAt(i) * i);
}
grunt.log.writeln('sloppy checksum: ' + chk);
grunt.log.writeln('length: ' + string.length);
//
grunt.template.addDelimiters('square-brackets','[%','%]');
var output = grunt.template.process(file, { data: { checksum: chk }, delimiters: 'square-brackets' });
grunt.file.write(deploy_file,output);
});
//load
grunt.loadNpmTasks('grunt-templater');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-uglify');
//tasks
grunt.registerTask('default', ['debug','build','ugly','apikey']);
// (uses all the files in src/javascript)
grunt.registerTask('build', "Create the html for deployment",['template:prod','setChecksum']);
//
grunt.registerTask('debug', "Create an html file that can run in its own tab", ['template:dev']);
//
grunt.registerTask('ugly', "Create the ugly html for deployment",['uglify:ugly','template:ugly']);
//
grunt.registerTask('apikey', "Create an html file that can run on another server", ['template:apikey','template:confluence']);
grunt.registerTask('test-fast', "Run tests that don't need to connect to Rally", ['jasmine:fast']);
grunt.registerTask('test-slow', "Run tests that need to connect to Rally", ['jasmine:slow']);
};