diff --git a/bin/micro.js b/bin/micro.js index f4e54022..45799595 100755 --- a/bin/micro.js +++ b/bin/micro.js @@ -6,7 +6,6 @@ const {existsSync} = require('fs'); // Packages const arg = require('arg'); -const chalk = require('chalk'); // Utilities const serve = require('../lib'); @@ -37,46 +36,46 @@ const args = arg({ // When `-h` or `--help` are used, print out // the usage information if (args['--help']) { - console.error(chalk` - {bold.cyan micro} - Asynchronous HTTP microservices + console.error(` + micro - Asynchronous HTTP microservices - {bold USAGE} + USAGE - {bold $} {cyan micro} --help - {bold $} {cyan micro} --version - {bold $} {cyan micro} [-l {underline listen_uri} [-l ...]] [{underline entry_point.js}] + $ micro --help + $ micro --version + $ micro [-l listen_uri [-l ...]] [entry_point.js] - By default {cyan micro} will listen on {bold 0.0.0.0:3000} and will look first - for the {bold "main"} property in package.json and subsequently for {bold index.js} - as the default {underline entry_point}. + By default micro will listen on 0.0.0.0:3000 and will look first + for the "main" property in package.json and subsequently for index.js + as the default entry_point. - Specifying a single {bold --listen} argument will overwrite the default, not supplement it. + Specifying a single --listen argument will overwrite the default, not supplement it. - {bold OPTIONS} + OPTIONS --help shows this help message -v, --version displays the current version of micro - -l, --listen {underline listen_uri} specify a URI endpoint on which to listen (see below) - + -l, --listen listen_uri specify a URI endpoint on which to listen (see below) - more than one may be specified to listen in multiple places - {bold ENDPOINTS} + ENDPOINTS - Listen endpoints (specified by the {bold --listen} or {bold -l} options above) instruct {cyan micro} + Listen endpoints (specified by the --listen or -l options above) instruct micro to listen on one or more interfaces/ports, UNIX domain sockets, or Windows named pipes. For TCP (traditional host/port) endpoints: - {bold $} {cyan micro} -l tcp://{underline hostname}:{underline 1234} + $ micro -l tcp://hostname:1234 For UNIX domain socket endpoints: - {bold $} {cyan micro} -l unix:{underline /path/to/socket.sock} + $ micro -l unix:/path/to/socket.sock For Windows named pipe endpoints: - {bold $} {cyan micro} -l pipe:\\\\.\\pipe\\{underline PipeName} + $ micro -l pipe:\\\\.\\pipe\\PipeName `); process.exit(2); } diff --git a/errors/old-node-version.md b/errors/old-node-version.md deleted file mode 100644 index d919ef34..00000000 --- a/errors/old-node-version.md +++ /dev/null @@ -1,10 +0,0 @@ -# Old Node Version - -#### Why This Error Occurred - -In order to execute code that contains the `async` or `await` keywords, you need to have at least version 8.0.0 of [Node.js](https://nodejs.org/en/) installed on the device that runs `micro`. If that's not the case, you will see this error. - -#### Possible Ways to Fix It - -- Ensure that at least version 8.0.0 of [Node.js](https://nodejs.org/en/) is installed -- [Transpile](https://github.com/zeit/micro#transpilation) the code of your microservice diff --git a/lib/handler.js b/lib/handler.js index 94bdf342..4b8fd1c1 100644 --- a/lib/handler.js +++ b/lib/handler.js @@ -12,18 +12,6 @@ module.exports = async file => { } } catch (err) { logError(`Error when importing ${file}: ${err.stack}`, 'invalid-entry'); - - if ( - err instanceof SyntaxError && - /\s+async\s+/.test(err.stack) && - Number(process.versions.node.split('.')[0]) < 8 - ) { - logError( - 'In order for `async` & `await` to work, you need to use at least Node.js 8!', - 'old-node-version' - ); - } - process.exit(1); } diff --git a/package.json b/package.json index a0370693..cd9f952f 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,9 @@ "bin": { "micro": "./bin/micro.js" }, + "engines": { + "node": ">= 8.0.0" + }, "repository": "zeit/micro", "keywords": [ "micro", @@ -40,8 +43,7 @@ "then-sleep": "1.0.1" }, "dependencies": { - "arg": "2.0.0", - "chalk": "2.4.0", + "arg": "4.1.0", "content-type": "1.0.4", "is-stream": "1.1.0", "raw-body": "2.3.2" diff --git a/test/handler.js b/test/handler.js index d32b1750..28bcbd18 100644 --- a/test/handler.js +++ b/test/handler.js @@ -50,15 +50,3 @@ test('process.exit when handling and inexisting file', async t => { await t.throws(promise); t.is(process.exit.getCall(0).args[0], 1); }); - -test('log and process.exit when node version is below 8', async t => { - // Stub process.versions.node.split() - sinon.stub(String.prototype, 'split').callsFake(() => '7'); - const logErrorSpy = sinon.spy(); - handle.__set__('logError', logErrorSpy); - const file = path.resolve('test/fixtures/syntax-error'); - const promise = handle(file); - await t.throws(promise); - t.is(logErrorSpy.callCount, 2); - t.is(process.exit.getCall(0).args[0], 1); -}); diff --git a/yarn.lock b/yarn.lock index 65876162..b0351e11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -185,9 +185,10 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" -arg@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/arg/-/arg-2.0.0.tgz#c06e7ff69ab05b3a4a03ebe0407fac4cba657545" +arg@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0" + integrity sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg== arg@^1.0.0: version "1.0.1" @@ -887,14 +888,6 @@ center-align@^0.1.1: align-text "^0.1.3" lazy-cache "^1.0.3" -chalk@2.4.0, chalk@^2.0.0, chalk@^2.3.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52" - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - chalk@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f" @@ -913,6 +906,14 @@ chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" +chalk@^2.0.0, chalk@^2.3.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52" + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + chalk@^2.0.1, chalk@^2.1.0: version "2.3.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65"