Skip to content

Commit 0bf7d25

Browse files
committed
Build/grunt: First draft for cdn tasks. Hashing works fine, zip file doesn't quite match the intended structure.
1 parent 34f8134 commit 0bf7d25

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

grunt.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ allI18nFiles.forEach(minFile);
3737
// TODO move core to the front, theme to the end, exclude all and base
3838
var cssFiles = file.expand('themes/base/*.css');
3939

40+
var cdnFiles = [
41+
'AUTHORS.txt',
42+
'GPL-LICENSE.txt',
43+
'MIT-LICENSE.txt',
44+
'dist/i18n/jquery-ui-i18n.js',
45+
'dist/i18n/jquery-ui-i18n.min.js',
46+
'ui/i18n/jquery.ui.datepicker-*.js',
47+
'dist/ui/i18n/jquery.ui.datepicker-*.min.js',
48+
'dist/ui/jquery-ui.js',
49+
'dist/ui/minified/jquery-ui.min.js',
50+
'themes/base/images/*.png',
51+
'dist/themes/base/jquery-ui.css',
52+
'themes/base/jquery.ui.*.css',
53+
'dist/themes/base/minified/*.css',
54+
'version.txt'
55+
];
56+
4057
config.init({
4158
pkg: '<json:package.json>',
4259
meta: {
@@ -70,8 +87,15 @@ config.init({
7087
'tests/**/*'
7188
],
7289
dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip'
90+
},
91+
cdn: {
92+
src: cdnFiles,
93+
dest: 'dist/<%= pkg.name %>-<%= pkg.version %>-cdn.zip'
7394
}
7495
},
96+
md5: {
97+
'dist/MANIFEST': cdnFiles
98+
},
7599
qunit: {
76100
files: file.expand('tests/unit/**/*.html').filter(function(file) {
77101
// disabling everything that doesn't (quite) work with PhantomJS for now
@@ -139,5 +163,17 @@ task.registerBasicTask( 'css_min', 'Minify CSS files with Sqwish.', function( da
139163
task.helper( 'min_max_info', min, max );
140164
});
141165

166+
task.registerBasicTask('md5', 'Create list of md5 hashes for CDN uploads', function(data) {
167+
var crypto = require('crypto');
168+
var hashes = [];
169+
file.expand(data.src).forEach(function(fileName) {
170+
var hash = crypto.createHash('md5');
171+
hash.update(file.read(fileName));
172+
hashes.push(fileName + ' ' + hash.digest('hex'));
173+
});
174+
file.write(data.dest, hashes.join('\n') + '\n');
175+
});
176+
142177
task.registerTask('default', 'lint qunit');
143-
task.registerTask('release', 'concat min zip');
178+
task.registerTask('release', 'concat min zip:dist');
179+
task.registerTask('release_cdn', 'concat min md5 zip:cdn');

0 commit comments

Comments
 (0)