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

chore(deps): replace the deps_downloader with a grunt task #362

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
sudo: true
dist: trusty
os:
- linux
- osx
matrix:
include:
- os: linux
- os: osx
- os: windows
env:
- YARN_GPG=no # otherwise this starts gpg-agent that never exits

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);
});


});
};
54 changes: 5 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"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",
"publish-coverage": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"test-coverage": "cross-env NODE_ENV=test istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec --recursive test --timeout 6000",
"publish-coverage": "mv ./coverage/lcov.info ./node_modules/coveralls/bin/coveralls.js",
"pre-pack": "npm run lint",
"prepush": "npm run lint && cross-env NODE_ENV=dev npm run test",
"prepublishOnly": "npm run lint && npm run 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
}
}
}
}
}
Loading