From 7c80d0d6e1af842ab1b2ed85189791edc9c8602b Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 21:40:57 +0200 Subject: [PATCH] Warn if current is not the last version (#1161) fix https://github.com/ethereum/remix-project/issues/938 --- libs/remixd/package.json | 4 +++- libs/remixd/src/bin/remixd.ts | 16 ++++++++++++++++ package-lock.json | 20 ++++++-------------- package.json | 3 ++- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/libs/remixd/package.json b/libs/remixd/package.json index 607b0a7ff2..6bbfed0109 100644 --- a/libs/remixd/package.json +++ b/libs/remixd/package.json @@ -44,7 +44,9 @@ "commander": "^2.20.3", "fs-extra": "^3.0.1", "isbinaryfile": "^3.0.2", - "ws": "^7.3.0" + "ws": "^7.3.0", + "latest-version": "^5.1.0", + "semver": "^6.3.0" }, "python": { "execPath": "python3", diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index ae240a8cdf..5b7076fd0d 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.ts @@ -1,4 +1,6 @@ #!/usr/bin/env node +import latestVersion from 'latest-version' +import * as semver from 'semver' import WebSocket from '../websocket' import * as servicesList from '../serviceList' import * as WS from 'ws' // eslint-disable-line @@ -8,6 +10,18 @@ import * as fs from 'fs-extra' import * as path from 'path' import * as program from 'commander' +async function warnLatestVersion () { + const latest = await latestVersion('@remix-project/remixd') + const pjson = require('../package.json') + if (semver.eq(latest, pjson.version)) { + console.log('\x1b[32m%s\x1b[0m', `[INFO] you are using the latest version ${latest}`) + } else if (semver.gt(latest, pjson.version)) { + console.log('\x1b[33m%s\x1b[0m', `[WARN] latest version of remixd is ${latest}, you are using ${pjson.version}`) + console.log('\x1b[33m%s\x1b[0m', '[WARN] please update using the following command:') + console.log('\x1b[33m%s\x1b[0m', '[WARN] npm install @remix-project/remixd -g') + } +} + const services = { git: (readOnly: boolean) => new servicesList.GitClient(readOnly), folder: (readOnly: boolean) => new servicesList.Sharedfolder(readOnly) @@ -40,6 +54,8 @@ function startService (service: S, callback: (ws: WS }).parse(process.argv) // eslint-disable-next-line + await warnLatestVersion() + if (!program.remixIde) { console.log('\x1b[33m%s\x1b[0m', '[WARN] You can only connect to remixd from one of the supported origins.') } else { diff --git a/package-lock.json b/package-lock.json index b2c38f3b0f..4f92e09fa8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15178,8 +15178,7 @@ "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "dev": true + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" }, "deep-is": { "version": "0.1.3", @@ -21217,8 +21216,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "dev": true + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, "init-package-json": { "version": "1.10.3", @@ -24668,7 +24666,6 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz", "integrity": "sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA==", - "dev": true, "requires": { "package-json": "^6.3.0" } @@ -33827,7 +33824,6 @@ "version": "6.5.0", "resolved": "https://registry.npmjs.org/package-json/-/package-json-6.5.0.tgz", "integrity": "sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==", - "dev": true, "requires": { "got": "^9.6.0", "registry-auth-token": "^4.0.0", @@ -35709,7 +35705,6 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "dev": true, "requires": { "deep-extend": "^0.6.0", "ini": "~1.3.0", @@ -36217,10 +36212,9 @@ } }, "registry-auth-token": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.0.tgz", - "integrity": "sha512-P+lWzPrsgfN+UEpDS3U8AQKg/UjZX6mQSJueZj3EK+vNESoqBSpBUD3gmu4sF9lOsjXWjF11dQKUqemf3veq1w==", - "dev": true, + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.1.tgz", + "integrity": "sha512-6gkSb4U6aWJB4SF2ZvLb76yCBjcvufXBqvvEx1HbmKPkutswjW1xNVRY0+daljIYRbogN7O0etYSlbiaEQyMyw==", "requires": { "rc": "^1.2.8" } @@ -36229,7 +36223,6 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-5.1.0.tgz", "integrity": "sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw==", - "dev": true, "requires": { "rc": "^1.2.8" } @@ -39088,8 +39081,7 @@ "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "strong-log-transformer": { "version": "2.1.0", diff --git a/package.json b/package.json index bd2a0e8aa6..2587e3bfbf 100644 --- a/package.json +++ b/package.json @@ -159,6 +159,7 @@ "isbinaryfile": "^3.0.2", "jquery": "^3.3.1", "jszip": "^3.6.0", + "latest-version": "^5.1.0", "merge": "^1.2.0", "npm-install-version": "^6.0.2", "react": "16.13.1", @@ -273,7 +274,7 @@ "request": "^2.83.0", "rimraf": "^2.6.1", "selenium-standalone": "^6.17.0", - "semver": "^6.1.2", + "semver": "^6.3.0", "solc": "0.7.4", "swarmgw": "^0.3.1", "tap-spec": "^5.0.0",