Skip to content

Commit

Permalink
Fixed proxy problems
Browse files Browse the repository at this point in the history
  • Loading branch information
presidenten committed Oct 30, 2013
1 parent fcc103b commit 55c4e32
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 13 deletions.
53 changes: 45 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -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://<proxy-ip>:<proxy-port>'});

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');
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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"
}
}

0 comments on commit 55c4e32

Please sign in to comment.