support to download specified versions of web3
This commit is contained in:
parent
263fdb6d8b
commit
31ecaf0837
|
@ -1,6 +1,7 @@
|
|||
var fs = require('./fs.js');
|
||||
var Plugins = require('./plugins.js');
|
||||
var utils = require('../utils/utils.js');
|
||||
var npm = require('../pipeline/npm.js');
|
||||
|
||||
// TODO: add wrapper for fs so it can also work in the browser
|
||||
// can work with both read and save
|
||||
|
@ -248,6 +249,13 @@ Config.prototype.loadFiles = function(files) {
|
|||
|
||||
readFiles.push({filename: 'embark.js', content: fs.readFileSync(fs.embarkPath("js/build/embark.bundle.js")).toString(), path: fs.embarkPath("js/build/embark.bundle.js")});
|
||||
}
|
||||
if (file.indexOf("web3-") == 0) {
|
||||
let web3Version = file.split('web3-')[1].split(".js")[0];
|
||||
npm.getPackageVersion('web3', web3Version, function(web3Content) {
|
||||
self.logger.error('downloaded web3');
|
||||
readFiles.push({filename: file, content: web3Content, path: fs.embarkPath("js/web3.js")});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// get plugins
|
||||
|
@ -280,6 +288,8 @@ Config.prototype.loadFiles = function(files) {
|
|||
originalFiles.filter(function(file) {
|
||||
if (file === 'embark.js') {
|
||||
return;
|
||||
} else if (file.indexOf("web3-") === 0) {
|
||||
return;
|
||||
} else if (file === 'abi.js') {
|
||||
readFiles.push({filename: file, content: "", path: file});
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
let utils = require('../utils/utils.js');
|
||||
|
||||
module.exports = {
|
||||
// TODO: need to refactor to make it truly generalistic, perhaps by
|
||||
// downloading the tarball itself
|
||||
getPackageVersion: function(packageName, version, callback) {
|
||||
let npmRegistry = "http://registry.npmjs.org/" + packageName + "/" + version;
|
||||
|
||||
utils.httpGet(npmRegistry, function (res) {
|
||||
|
||||
let body = '';
|
||||
res.on('data', function (d) {
|
||||
body += d;
|
||||
});
|
||||
res.on('end', function () {
|
||||
let registryJSON = JSON.parse(body);
|
||||
let gitHash = registryJSON.gitHead;
|
||||
let repo = registryJSON.homepage.split("github.com/")[1];
|
||||
|
||||
let gitUrl = "http://raw.githubusercontent.com/" + repo + "/" + gitHash + "/dist/" + packageName + ".js"
|
||||
utils.httpGet(gitUrl, function (res2) {
|
||||
let body = '';
|
||||
res2.on('data', function (d) {
|
||||
body += d;
|
||||
});
|
||||
res2.on('end', function () {
|
||||
callback(body);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
let path = require('path');
|
||||
let globule = require('globule');
|
||||
let merge = require('merge');
|
||||
let http = require('http');
|
||||
let http = require('follow-redirects').http;
|
||||
let shelljs = require('shelljs');
|
||||
|
||||
function joinPath() {
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
"commander": "^2.8.1",
|
||||
"ethereumjs-testrpc": "3.9.2",
|
||||
"finalhandler": "^0.5.0",
|
||||
"follow-redirects": "^1.2.4",
|
||||
"fs-extra": "^2.0.0",
|
||||
"globule": "^1.1.0",
|
||||
"merge": "^1.2.0",
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
"js/mytoken.js": ["$MyToken", "app/js/token_test.js"],
|
||||
"index.html": "app/index.html",
|
||||
"test.html": "app/test.html",
|
||||
"test2.html": "app/test2.html"
|
||||
"test2.html": "app/test2.html",
|
||||
"js/myweb3.js": "web3-0.18.js"
|
||||
},
|
||||
"buildDir": "dist/",
|
||||
"config": "config/",
|
||||
|
|
Loading…
Reference in New Issue