-
Notifications
You must be signed in to change notification settings - Fork 420
Sort using semver #8
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
|
|
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
|
|
||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||
| lib-cov | ||
|
|
||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
|
|
||
| # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
| .grunt | ||
|
|
||
| # node-waf configuration | ||
| .lock-wscript | ||
|
|
||
| # Compiled binary addons (http://nodejs.org/api/addons.html) | ||
| build/Release | ||
|
|
||
| # Dependency directory | ||
| # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
| node_modules |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| language: node_js | ||
| script: npm run lint && npm run test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "private": true, | ||
| "name": "solc-bin", | ||
| "version": "0.0.0", | ||
| "description": "Current and historical (emscripten) binaries for Solidity", | ||
| "dependencies": { | ||
| "semver": "^5.3.0" | ||
| }, | ||
| "devDependencies": { | ||
| "standard": "^8.4.0" | ||
| }, | ||
| "scripts": { | ||
| "lint": "standard update", | ||
| "update": "./update", | ||
| "test": "git checkout -f && npm run update && git diff" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/ethereum/solc-bin.git" | ||
| }, | ||
| "keywords": [ | ||
| "ethereum", | ||
| "solidity" | ||
| ], | ||
| "author": "", | ||
| "license": "GPL-3.0", | ||
| "bugs": { | ||
| "url": "https://github.com/ethereum/solc-bin/issues" | ||
| }, | ||
| "homepage": "https://github.com/ethereum/solc-bin#readme" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| const fs = require('fs') | ||
| const path = require('path') | ||
| const semver = require('semver') | ||
|
|
||
| // This script updates the index files list.js and list.txt in the bin directory, | ||
| // as well as the soljson-latest.js files. | ||
|
|
@@ -13,10 +14,26 @@ fs.readdir(path.join(__dirname, '/bin'), function (err, files) { | |
| throw err | ||
| } | ||
|
|
||
| function buildVersion (build) { | ||
| var version = build.version | ||
| if (build.prerelease && build.prerelease.length > 0) { | ||
| version += '-' + build.prerelease | ||
| } | ||
| if (build.build && build.build.length > 0) { | ||
| version += '+' + build.build | ||
| } | ||
| return version | ||
| } | ||
|
|
||
| // ascending list (oldest version first) | ||
| const parsedList = files | ||
| .map(function (file) { return file.match(/^soljson-v([0-9.]*)(-([^+]*))?(\+(.*))?.js$/) }) | ||
| .filter(function (version) { return version }) | ||
| .map(function (pars) { return { path: pars[0], version: pars[1], prerelease: pars[3], build: pars[5] } }) | ||
| .sort(function (a, b) { | ||
| // NOTE: a vs. b (the order is important), because we want oldest first in the list | ||
| return semver.compare(buildVersion(a), buildVersion(b)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could just use the semver module to also parse the version string.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, the only downside having semver is that it must be npm installed before running update.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually semver doesn't seem to return the |
||
| }) | ||
|
|
||
| // descending list | ||
| const releases = parsedList | ||
|
|
||
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.
Do we really need to rebuild it again?
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.
Actually if we rebuild it with MM.DD we don't even need semver to do the comparison.