mirror of https://github.com/embarklabs/embark.git
fix support for 1.0 versions of web3
This commit is contained in:
parent
f41702634f
commit
a78d8b00bf
|
@ -29,7 +29,7 @@ class SolcW {
|
|||
solcProcess.send({action: 'loadCompiler', solcLocation: 'solc'});
|
||||
} else {
|
||||
let npm = new Npm({logger: this.logger});
|
||||
npm.getPackageVersion('solc', this.solcVersion, false, function(location) {
|
||||
npm.getPackageVersion('solc', this.solcVersion, false, false, function(location) {
|
||||
let requirePath = path.join(process.env.PWD, location);
|
||||
solcProcess.send({action: 'loadCompiler', solcLocation: requirePath});
|
||||
});
|
||||
|
|
|
@ -257,7 +257,7 @@ Config.prototype.loadFiles = function(files) {
|
|||
//readFiles.push(new File({filename: 'web3-' + web3Version + '.js', type: 'custom', resolver: function(callback) {
|
||||
readFiles.push(new File({filename: 'web3.js', type: 'custom', resolver: function(callback) {
|
||||
let npm = new Npm({logger: self.logger});
|
||||
npm.getPackageVersion('web3', web3Version, 'dist/web3.js', function(web3Content) {
|
||||
npm.getPackageVersion('web3', web3Version, 'dist/web3.min.js', true, function(web3Content) {
|
||||
callback(web3Content);
|
||||
});
|
||||
}}));
|
||||
|
|
|
@ -12,7 +12,8 @@ class Npm {
|
|||
this.logger = options.logger;
|
||||
}
|
||||
|
||||
getPackageVersion(packageName, version, returnContent, callback) {
|
||||
// TODO: callback should accept an error
|
||||
getPackageVersion(packageName, version, returnContent, getFromGit, callback) {
|
||||
let self = this;
|
||||
let npmRegistry = "https://registry.npmjs.org/" + packageName + "/" + version;
|
||||
|
||||
|
@ -25,6 +26,7 @@ class Npm {
|
|||
res.on('end', function () {
|
||||
let registryJSON = JSON.parse(body);
|
||||
|
||||
console.log(JSON.stringify(registryJSON));
|
||||
let tarball = registryJSON.dist.tarball;
|
||||
|
||||
var download = function(url, dest, cb) {
|
||||
|
@ -40,35 +42,70 @@ class Npm {
|
|||
});
|
||||
};
|
||||
|
||||
let packageDirectory = './.embark/versions/' + packageName + '/' + version + '/';
|
||||
if (getFromGit) {
|
||||
let repoName = registryJSON.repository.url.replace("git+https://github.com/", "").replace(".git","");
|
||||
let gitHead = registryJSON.gitHead;
|
||||
let fileLocation = "https://raw.githubusercontent.com/" + repoName + "/" + gitHead + "/dist/web3.min.js";
|
||||
|
||||
if (fs.existsSync(packageDirectory + "/downloaded_package.tgz")) {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + returnContent;
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
let packageDirectory = './.embark/versions/' + packageName + '/' + version + '/';
|
||||
if (fs.existsSync(packageDirectory + "/" + packageName + ".js")) {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + packageName + ".js";
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
}
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
fs.mkdirpSync(packageDirectory);
|
||||
self.logger.info("downloading " + packageName + " " + version + "....");
|
||||
|
||||
download(tarball, packageDirectory + "/" + packageName + ".js", function() {
|
||||
o_fs.createReadStream(packageDirectory + "/" + packageName + ".js").pipe(
|
||||
tar.x({
|
||||
strip: 1,
|
||||
C: packageDirectory
|
||||
}).on('end', function() {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + packageName + ".js";
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
fs.mkdirpSync(packageDirectory);
|
||||
self.logger.info("downloading " + packageName + " " + version + "....");
|
||||
|
||||
download(tarball, packageDirectory + "/downloaded_package.tgz", function() {
|
||||
o_fs.createReadStream(packageDirectory + '/downloaded_package.tgz').pipe(
|
||||
tar.x({
|
||||
strip: 1,
|
||||
C: packageDirectory
|
||||
}).on('end', function() {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + returnContent;
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
let packageDirectory = './.embark/versions/' + packageName + '/' + version + '/';
|
||||
if (fs.existsSync(packageDirectory + "/downloaded_package.tgz")) {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + returnContent;
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
}
|
||||
} else {
|
||||
fs.mkdirpSync(packageDirectory);
|
||||
self.logger.info("downloading " + packageName + " " + version + "....");
|
||||
|
||||
download(tarball, packageDirectory + "/downloaded_package.tgz", function() {
|
||||
o_fs.createReadStream(packageDirectory + '/downloaded_package.tgz').pipe(
|
||||
tar.x({
|
||||
strip: 1,
|
||||
C: packageDirectory
|
||||
}).on('end', function() {
|
||||
if (returnContent) {
|
||||
let distFile = packageDirectory + returnContent;
|
||||
callback(fs.readFileSync(distFile).toString());
|
||||
} else {
|
||||
callback(packageDirectory);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"default": {
|
||||
"versions": {
|
||||
"web3.js": "0.20.0",
|
||||
"web3.js": "1.0.0-beta.18",
|
||||
"solc": "0.4.11"
|
||||
},
|
||||
"deployment": {
|
||||
|
|
Loading…
Reference in New Issue