Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Merge 8ed5485 into 524e204
Browse files Browse the repository at this point in the history
  • Loading branch information
bochaco committed Apr 2, 2019
2 parents 524e204 + 8ed5485 commit 77afab3
Show file tree
Hide file tree
Showing 4 changed files with 339 additions and 340 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist: trusty
os:
- linux
- osx
- windows
language: node_js
node_js:
- '10.0.0'
Expand Down
84 changes: 84 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
module.exports = function(grunt) {

grunt.initConfig({
download: {
'safe_app-mock': {
url: 'https://s3.eu-west-2.amazonaws.com/safe-client-libs/',
version: '0.9.1',
ext: 'x64.zip'
},
'system_uri': {
url: 'https://s3.eu-west-2.amazonaws.com/system-uri/',
version: 'v0.4.0',
ext: 'x64.zip'
}
}
});

grunt.task.registerMultiTask('download', 'Log stuff.', function() {
let os;
switch (process.platform) {
case 'linux':
os = 'linux';
break;
case 'win32':
os = 'win';
break;
case 'darwin':
os = 'osx';
break;
}

let url = this.data.url + this.target + '-' + this.data.version + '-' + os + '-' + this.data.ext;
grunt.log.writeln('Downloading native lib for platform ' + os + ', ' + this.target + ' version ' + this.data.version + ' from: ' + url);

const path = require('path');
const https = require('https');
const fs = require('fs');

let done = this.async();

https.get(url, (res) => {
if (res.statusCode !== 200) {
grunt.log.warn('Got response code ' + res.statusCode + ' while trying to copy ' + url);
}

//grunt.file.mkdir(path.dirname('download'));
let zipFilePath = this.target + '.zip';
const wstream = fs.createWriteStream(zipFilePath);

res.on('data', function(chunk) {
grunt.log.write('+');
wstream.write(chunk);
});

res.on('end', function () {
grunt.log.writeln('Copying....');
wstream.end();
grunt.log.writeln('Copied ');

var extract = require('extract-zip')
let outputPath = path.resolve(__dirname, 'src/native/mock');
grunt.log.writeln(outputPath);
extract(zipFilePath, { dir: outputPath }, function (err) {
if (err) {
grunt.fail.warn('Got error: ' + err);
done(false);
}
done();
})

});

res.on('error', function (e) {
grunt.fail.warn('Got error: ' + e.message);
done(false);
});

}).on('error', (e) => {
grunt.fail.warn('Got error: ' + e.message);
});


});
};
50 changes: 3 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"lint": "eslint src test",
"fix-lint": "eslint --fix src test",
"postinstall": "download_deps --package package.json",
"postinstall": "grunt download",
"docs": "rimraf docs/ && jsdoc -c jsdoc.json",
"test": "cross-env NODE_ENV=test mocha --recursive",
"test-coverage": "cross-env NODE_ENV=test istanbul cover _mocha --report lcovonly -- -R spec --recursive test",
Expand Down Expand Up @@ -40,9 +40,10 @@
"dependencies": {
"cids": "bochaco/js-cid#temp-use-bochaco-multicodec",
"cross-env": "5.1.3",
"deps_downloader": "https://s3.eu-west-2.amazonaws.com/deps-downloader/deps_downloader-0.3.0.tgz",
"enum": "^2.3.0",
"extract-zip": "^1.6.7",
"ffi": "^2.3.0",
"grunt": "^1.0.4",
"mime": "^2.0.3",
"multihashes": "^0.4.14",
"rdflib": "^0.19.1",
Expand All @@ -65,50 +66,5 @@
"mocha-lcov-reporter": "^1.3.0",
"rimraf": "^2.6.2",
"should": "^11.1.2"
},
"download_deps": {
"system_uri": {
"mirror": "https://s3.eu-west-2.amazonaws.com/system-uri",
"version": "v0.4.0",
"targetDir": "src/native/prod",
"filePattern": "^.*\\.(dll|so|dylib)$",
"filename": "system_uri"
},
"safe_app": {
"mirror": "https://s3.eu-west-2.amazonaws.com/safe-client-libs",
"version": "0.9.1",
"targetDir": "src/native/prod",
"filename": "safe_app",
"filePattern": "^.*\\.(dll|so|dylib)$",
"force": true
},
"ENV": {
"dev": {
"safe_app": {
"targetDir": "src/native/mock",
"filename": "safe_app-mock",
"override": false
},
"system_uri": {
"targetDir": "src/native/mock",
"override": false
}
},
"mobile_prod": {
"system_uri": {
"disabled": true
}
},
"mobile_dev": {
"system_uri": {
"disabled": true
},
"safe_app": {
"targetDir": "src/native/mock",
"filename": "safe_app-mock",
"override": false
}
}
}
}
}

0 comments on commit 77afab3

Please sign in to comment.