From 410390a9ae98548c58306b1d24406b83e19855f2 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Thu, 22 Jun 2017 18:58:09 +0200 Subject: [PATCH 1/2] Remove Buffer polyfill, require Node v6+, and print warnings in older versions --- CHANGELOG.md | 4 ++++ build/app.js | 8 ++++++-- lib/app.coffee | 7 ++++++- package.json | 5 ++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86f0d562..8835fea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## Fixed + +- **Breaking** Remove Buffer polyfill, require Node v6+, and print warnings in older versions + ## [5.11.1] - 2017-06-22 ## Added diff --git a/build/app.js b/build/app.js index 435fbaa8..a09f3385 100644 --- a/build/app.js +++ b/build/app.js @@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -var Promise, Raven, _, actions, capitano, capitanoExecuteAsync, errors, events, globalTunnel, plugins, proxy, resin, settings, update; +var Promise, Raven, _, actions, capitano, capitanoExecuteAsync, errors, events, globalTunnel, plugins, proxy, resin, settings, update, validNodeVersions; Raven = require('raven'); @@ -36,7 +36,11 @@ Raven.setContext({ } }); -require('buffer-v6-polyfill'); +validNodeVersions = require('../package.json').engines.node; + +if (!require('semver').satisfies(process.version, validNodeVersions)) { + console.warn("Warning: this version of Node does not match the requirements of this package. This package expects " + validNodeVersions + ", but you're using " + process.version + ". This may cause unexpected behaviour."); +} globalTunnel = require('global-tunnel-ng'); diff --git a/lib/app.coffee b/lib/app.coffee index 29dd98a1..751b455d 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -27,7 +27,12 @@ Raven.setContext args: process.argv node_version: process.version -require('buffer-v6-polyfill') +validNodeVersions = require('../package.json').engines.node +if not require('semver').satisfies(process.version, validNodeVersions) + console.warn("Warning: this version of Node does not match the requirements of this package. + This package expects #{validNodeVersions}, but you're using #{process.version}. + This may cause unexpected behaviour.") + # Doing this before requiring any other modules, # including the 'resin-sdk', to prevent any module from reading the http proxy config diff --git a/package.json b/package.json index 3542772b..be41197a 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,9 @@ ], "author": "Juan Cruz Viotti ", "license": "Apache-2.0", + "engines": { + "node": ">=6.0" + }, "devDependencies": { "ent": "^2.2.0", "gulp": "^3.9.0", @@ -40,7 +43,6 @@ "babel-register": "^6.16.3", "bash": "0.0.1", "bluebird": "^3.3.3", - "buffer-v6-polyfill": "^1.0.3", "capitano": "^1.7.0", "chalk": "^1.1.3", "coffee-script": "^1.12.6", @@ -86,6 +88,7 @@ "resin-sync": "^7.0.0", "rimraf": "^2.4.3", "rindle": "^1.0.0", + "semver": "^5.3.0", "stream-to-promise": "^2.2.0", "tmp": "0.0.31", "umount": "^1.1.6", From 6182e7c98aeb9602f96066a071f908d4d00862b2 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Mon, 26 Jun 2017 13:24:54 +0200 Subject: [PATCH 2/2] Make Node warning a multi-line string --- build/app.js | 2 +- lib/app.coffee | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build/app.js b/build/app.js index a09f3385..cd1f389a 100644 --- a/build/app.js +++ b/build/app.js @@ -39,7 +39,7 @@ Raven.setContext({ validNodeVersions = require('../package.json').engines.node; if (!require('semver').satisfies(process.version, validNodeVersions)) { - console.warn("Warning: this version of Node does not match the requirements of this package. This package expects " + validNodeVersions + ", but you're using " + process.version + ". This may cause unexpected behaviour."); + console.warn("Warning: this version of Node does not match the requirements of this package.\nThis package expects " + validNodeVersions + ", but you're using " + process.version + ".\nThis may cause unexpected behaviour."); } globalTunnel = require('global-tunnel-ng'); diff --git a/lib/app.coffee b/lib/app.coffee index 751b455d..37088315 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -29,9 +29,11 @@ Raven.setContext validNodeVersions = require('../package.json').engines.node if not require('semver').satisfies(process.version, validNodeVersions) - console.warn("Warning: this version of Node does not match the requirements of this package. + console.warn """ + Warning: this version of Node does not match the requirements of this package. This package expects #{validNodeVersions}, but you're using #{process.version}. - This may cause unexpected behaviour.") + This may cause unexpected behaviour. + """ # Doing this before requiring any other modules,