Skip to content

Commit

Permalink
Configure download links automatically (ethereum#650)
Browse files Browse the repository at this point in the history
* Configure download links automatically, closes ethereum#249

* Fix indentation

* No need for string interpolation
  • Loading branch information
ryanio authored and alexvansande committed Sep 8, 2017
1 parent be73766 commit 8b1d7de
Show file tree
Hide file tree
Showing 5 changed files with 736 additions and 12 deletions.
49 changes: 43 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ var styles = [
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
http: {
fetch_mist_releases: {
options: {
headers: {
'User-Agent': 'Ethereum.org-Gruntfile'
},
url: 'https://api.github.com/repos/ethereum/mist/releases'
},
dest: 'data/mist_releases.json'
}
},
clean: {
build: ['dist'],
cleanup_js: ['dist/js/*.*', '!dist/js/frontier.*'],
Expand All @@ -33,12 +44,37 @@ module.exports = function(grunt) {
jade: {
build: {
options: {
data: {
debug: false,
pretty: false,
block: {
hash: '<%= pkg.hash %>'
data: function(dest, src) {
var mistReleases = grunt.file.readJSON("data/mist_releases.json")[0]['assets'];
var mistReleaseOSX,
mistReleaseWin64,
mistReleaseWin32;

for (var i = 0; i < mistReleases.length; i++){
var obj = mistReleases[i];
for (var key in obj) {
if (key === 'name') {
if (obj[key].indexOf('macosx') !== -1) {
mistReleaseOSX = obj['browser_download_url'];
} else if (obj[key].indexOf('win64') !== -1) {
mistReleaseWin64 = obj['browser_download_url'];
} else if (obj[key].indexOf('win32') !== -1) {
mistReleaseWin32 = obj['browser_download_url'];
}
}
}
}

return {
debug: false,
pretty: false,
block: {
hash: '<%= pkg.hash %>'
},
mistReleaseOSX: mistReleaseOSX,
mistReleaseWin64: mistReleaseWin64,
mistReleaseWin32: mistReleaseWin32
};
}
},
files: [
Expand Down Expand Up @@ -195,7 +231,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-http');

grunt.registerTask('default', ['clean', 'jade', 'copy', 'cssmin', 'concat:vendor', 'concat:app', 'uglify', 'concat:frontier', 'concat:css', 'clean:cleanup_js', 'clean:cleanup_css']);
grunt.registerTask('default', ['http', 'clean', 'jade', 'copy', 'cssmin', 'concat:vendor', 'concat:app', 'uglify', 'concat:frontier', 'concat:css', 'clean:cleanup_js', 'clean:cleanup_css']);
grunt.registerTask('build', 'default');
};
1 change: 1 addition & 0 deletions data/mist_releases.json

Large diffs are not rendered by default.

Loading

0 comments on commit 8b1d7de

Please sign in to comment.