From 55c4e32ec2c3237d00d15e640892daf02ff83925 Mon Sep 17 00:00:00 2001 From: Presidenten Date: Wed, 30 Oct 2013 11:28:39 +0100 Subject: [PATCH] Fixed proxy problems --- Gruntfile.js | 53 ++++++++++++++++++++++++++++++++++++++++++++-------- README.md | 3 ++- bower.json | 2 +- package.json | 7 ++++--- 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 310d613..5a329c7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -27,19 +27,13 @@ module.exports = function ( grunt ) { requirejs: false, forceExit: true }, - curl: { - long: { - src: 'http://bower.herokuapp.com/packages', - dest: 'git_repositories/all_bower_packages.json' - } - }, clean: { - all: 'git_repositories' + all: 'git_repositories/all_bower_packages.json' } }); grunt.registerTask('test', ['jshint', 'jasmine_node']); - grunt.registerTask('sync', ['clean', 'curl', 'sync_db']); + grunt.registerTask('sync', ['clean', 'get_bower_packages', 'sync_db']); grunt.registerTask('default', ['test', 'sync']); grunt.registerTask('init_db', 'Sync database to Bower official registry', function(){ @@ -51,6 +45,49 @@ module.exports = function ( grunt ) { }); }); + grunt.registerTask('get_bower_packages', 'Get official bower packages', function(){ + var fs = require('fs'); + var request = require('request'); + var progress = require('request-progress'); + var util = require('util'); + var done = this.async(); + var url = 'http://bower.herokuapp.com/packages'; + + if(!fs.existsSync('git_repositories')){ + fs.mkdir('git_repositories'); + } + + //request = request.defaults({'proxy':'http://:'}); + + var total = ''; + progress(request(url), { + throttle: 1000, + delay: 500 + }) + .on('progress', function (state) { + util.print('Receiving ' + state.received + ' of ' + state.total + + ' bytes. ' + state.percent + '% done.\r'); + total = state.total; + }) + .on('error', function (err) { + console.log('Could not read '+ url +' - ' + err); + }) + .pipe(fs.createWriteStream('git_repositories/all_bower_packages.json')) + .on('error', function (err) { + console.log('Could not save git_repositories/all_bower_packages.json - ' + err); + }) + .on('close', function (err) { + if(total !== ''){ + util.print('Receiving ' + total + ' of ' + total + + ' bytes. 100 % done.\r'); + } + else { + util.print('100 % done.\r'); + } + done(); + }); + }); + grunt.registerTask('sync_db', 'Sync database to Bower official registry', function(){ var done = this.async(); var bowerDB = grunt.file.readJSON('git_repositories/all_bower_packages.json'); diff --git a/README.md b/README.md index 7e76a0a..7d55dff 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,14 @@ Install node dependencies Install bower dependencies + git config --global http.sslVerify false bower install ### Setup database and server If you have a proxy you need to add it to these to files on line 2: - nano +2 Gruntfile.js + nano +62 Gruntfile.js nano +2 templates/.bowerrc Run tests and sync with official Bower repository diff --git a/bower.json b/bower.json index 41432c7..8de4aa6 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "bowers-nest", "main": "bowers-nest.js", - "version": "1.0.0", + "version": "1.0.1", "homepage": "https://github.com/presidenten/bowers-nest", "authors": [ "Johan Hernefeldt" diff --git a/package.json b/package.json index bc6240e..fbbf412 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bowers-nest", - "version": "1.0.0", + "version": "1.0.1", "description": "A Bower registry written for node and express with SQLite3", "main": "server.js", "scripts": { @@ -30,8 +30,9 @@ "supertest": "~0.8.0", "jasmine-node": "~1.11.0", "grunt-jasmine-node": "~0.1.0", - "grunt-curl": "~1.1.1", "grunt-contrib-clean": "~0.5.0", - "grunt-text-replace": "~0.3.8" + "grunt-text-replace": "~0.3.8", + "request": "~2.27.0", + "request-progress": "~0.3.1" } }