-
Notifications
You must be signed in to change notification settings - Fork 498
Add solcjs-get #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add solcjs-get #227
Conversation
chevdor
commented
Jun 19, 2018
|
@axic you were asking for this one |
axic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shares a lot of code with downloadCurrentVersion.js. The common code should be pulled into helpers.
Alternatively, this should just replace downloadCurrentVersion.js.
|
It replaces |
In the PR it doesn't do that yet. I can look into fixing it if you don't have time (which I understand, given how long it took to get into reviewing the PR). |
|
I admit I lost the history of this one... |
|
Hello, coud this PR be reviewed and either merged or closed ? |
|
Can you explain the benefit over |
Back in 2018 I surely could have 😄 |
|
I think this looks useful. It's at least an improvement over the original script. I rebased it on the latest There are some things that I think get unnecessarily removed. I'll point them out in review. BTW, the diff is much better if you look at the individual commits. In the combined diff github does not detect that the file was actually just renamed. |
| var hash = '0x' + keccak256(fs.readFileSync(outputName, { encoding: 'binary' })); | ||
| if (expectedHash !== hash) { | ||
| console.log('Hash mismatch: ' + expectedHash + ' vs ' + hash); | ||
| process.exit(1); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new script removes the code responsible for verifying checksums of downloaded binaries. I don't think it's a good thing. I'd keep that code.
| var expectedFile = list.builds.filter(function (entry) { return entry.path === releaseFileName; })[0]; | ||
| if (!expectedFile) { | ||
| console.log('Version list is invalid or corrupted?'); | ||
| process.exit(1); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is gone too in the new version.
| process.on('SIGINT', function () { | ||
| console.log('Interrupted, removing file.'); | ||
| fs.unlinkSync(outputName); | ||
| process.exit(1); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to remove a partially downloaded file. I'd keep it.
solcjs-get
Outdated
| var MemoryStream = require('memorystream'); | ||
| var keccak256 = require('js-sha3').keccak256; | ||
| var path = require('path'); | ||
| var compilerDir = 'bin'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add an option to specify this directory (bin could still be the default though).
| .option('list', { | ||
| describe: 'List all the versions', | ||
| type: 'bool' | ||
| }) | ||
| .option('all', { | ||
| describe: 'Download all the versions. Additionnaly, use --nightly to get the nightly builds.', | ||
| type: 'bool' | ||
| }) | ||
| .option('nightly', { | ||
| describe: 'Combined with --all, it adds the nightly to the list', | ||
| type: 'bool' | ||
| }) | ||
| .option('releases', { | ||
| describe: 'Get all the release builds', | ||
| type: 'bool' | ||
| }) | ||
| .option('clean', { | ||
| describe: 'Delete all the compiler in ./bin', | ||
| type: 'bool' | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These options all seem to be mutually exclusive but the script does not print any error if you use more than one. This was pretty confusing when I tried running it for the first time. Using more than one should not be allowed unless it actually does something.
BTW, I think that combining --list with --all/--nightly/--releases might actually be useful. I'd even make --list print only releases by default because the whole list is pretty long.
solcjs-get
Outdated
| if (!requestedVersion){ | ||
| fs.copy(file, 'soljson.js'); // for backward compatibility | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should really be a symlink (at least if the FS supports it).
Actually, this does not seem like something just for backwards compatibility. Can solc-js even use the compiler when it's inside bin/? I think that an option to relink it to another version might be useful because that's basically how the select the compiler version now.
solcjs-get
Outdated
| console.log('Removing all local compilers in ' + compilerDir + ' ...'); | ||
| fs.remove(compilerDir, function (err) { | ||
| if (err) return console.error(err); | ||
|
|
||
| console.log('Success! Cleaned ' + compilerDir); | ||
| process.exit(0); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's a good idea to remove the whole dir. As a user I think I'd expect this to be more intelligent and only remove the binaries (otherwise why even provide an option for something that can be easily done with rm?). I think it would be safer to only remove files matching the valid name regex.
solcjs-get
Outdated
| list = JSON.parse(list).builds; | ||
| for (var i = list.length - 1; i >= 0; i--) { | ||
| var target = list[i].path; | ||
| if (target.indexOf('nightly') > 0 && !argv.nightly) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list contains a releases array. I think that checking if the file name is not in it would be a more future-proof check for a nightly.
solcjs-get
Outdated
| var compilerDir = 'bin'; | ||
|
|
||
| var yargs = require('yargs') | ||
| .usage('Usage: [options| version]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually supposed to work with a version or only with the whole file name?
Something like ./solcjs-get 0.8.6 or ./solcjs-get v0.8.6 does not not say that the file does not exist. The script tries to download it:
Retrieving available version list...
Requested version: v0.8.6
Downloading version v0.8.6
Error downloading file: 404
|
Closing because I don't really have a use for this PR anymore and it is so long ago, I don't even remember the details... |