Skip to content

Commit 0cf4d7c

Browse files
authored
Decrease install size (#396)
* Remove chalk and upgrade arg * Add engines key to package.json * Remove handling of below node 8 * Revert "Remove handling of below node 8" This reverts commit f41de4c. * Revert "Revert "Remove handling of below node 8"" This reverts commit af254a0. * Remove test for below node 8
1 parent 85d7bd6 commit 0cf4d7c

File tree

6 files changed

+33
-65
lines changed

6 files changed

+33
-65
lines changed

bin/micro.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const {existsSync} = require('fs');
66

77
// Packages
88
const arg = require('arg');
9-
const chalk = require('chalk');
109

1110
// Utilities
1211
const serve = require('../lib');
@@ -37,46 +36,46 @@ const args = arg({
3736
// When `-h` or `--help` are used, print out
3837
// the usage information
3938
if (args['--help']) {
40-
console.error(chalk`
41-
{bold.cyan micro} - Asynchronous HTTP microservices
39+
console.error(`
40+
micro - Asynchronous HTTP microservices
4241
43-
{bold USAGE}
42+
USAGE
4443
45-
{bold $} {cyan micro} --help
46-
{bold $} {cyan micro} --version
47-
{bold $} {cyan micro} [-l {underline listen_uri} [-l ...]] [{underline entry_point.js}]
44+
$ micro --help
45+
$ micro --version
46+
$ micro [-l listen_uri [-l ...]] [entry_point.js]
4847
49-
By default {cyan micro} will listen on {bold 0.0.0.0:3000} and will look first
50-
for the {bold "main"} property in package.json and subsequently for {bold index.js}
51-
as the default {underline entry_point}.
48+
By default micro will listen on 0.0.0.0:3000 and will look first
49+
for the "main" property in package.json and subsequently for index.js
50+
as the default entry_point.
5251
53-
Specifying a single {bold --listen} argument will overwrite the default, not supplement it.
52+
Specifying a single --listen argument will overwrite the default, not supplement it.
5453
55-
{bold OPTIONS}
54+
OPTIONS
5655
5756
--help shows this help message
5857
5958
-v, --version displays the current version of micro
6059
61-
-l, --listen {underline listen_uri} specify a URI endpoint on which to listen (see below) -
60+
-l, --listen listen_uri specify a URI endpoint on which to listen (see below) -
6261
more than one may be specified to listen in multiple places
6362
64-
{bold ENDPOINTS}
63+
ENDPOINTS
6564
66-
Listen endpoints (specified by the {bold --listen} or {bold -l} options above) instruct {cyan micro}
65+
Listen endpoints (specified by the --listen or -l options above) instruct micro
6766
to listen on one or more interfaces/ports, UNIX domain sockets, or Windows named pipes.
6867
6968
For TCP (traditional host/port) endpoints:
7069
71-
{bold $} {cyan micro} -l tcp://{underline hostname}:{underline 1234}
70+
$ micro -l tcp://hostname:1234
7271
7372
For UNIX domain socket endpoints:
7473
75-
{bold $} {cyan micro} -l unix:{underline /path/to/socket.sock}
74+
$ micro -l unix:/path/to/socket.sock
7675
7776
For Windows named pipe endpoints:
7877
79-
{bold $} {cyan micro} -l pipe:\\\\.\\pipe\\{underline PipeName}
78+
$ micro -l pipe:\\\\.\\pipe\\PipeName
8079
`);
8180
process.exit(2);
8281
}

errors/old-node-version.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/handler.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@ module.exports = async file => {
1212
}
1313
} catch (err) {
1414
logError(`Error when importing ${file}: ${err.stack}`, 'invalid-entry');
15-
16-
if (
17-
err instanceof SyntaxError &&
18-
/\s+async\s+/.test(err.stack) &&
19-
Number(process.versions.node.split('.')[0]) < 8
20-
) {
21-
logError(
22-
'In order for `async` & `await` to work, you need to use at least Node.js 8!',
23-
'old-node-version'
24-
);
25-
}
26-
2715
process.exit(1);
2816
}
2917

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"bin": {
1616
"micro": "./bin/micro.js"
1717
},
18+
"engines": {
19+
"node": ">= 8.0.0"
20+
},
1821
"repository": "zeit/micro",
1922
"keywords": [
2023
"micro",
@@ -40,8 +43,7 @@
4043
"then-sleep": "1.0.1"
4144
},
4245
"dependencies": {
43-
"arg": "2.0.0",
44-
"chalk": "2.4.0",
46+
"arg": "4.1.0",
4547
"content-type": "1.0.4",
4648
"is-stream": "1.1.0",
4749
"raw-body": "2.3.2"

test/handler.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,3 @@ test('process.exit when handling and inexisting file', async t => {
5050
await t.throws(promise);
5151
t.is(process.exit.getCall(0).args[0], 1);
5252
});
53-
54-
test('log and process.exit when node version is below 8', async t => {
55-
// Stub process.versions.node.split()
56-
sinon.stub(String.prototype, 'split').callsFake(() => '7');
57-
const logErrorSpy = sinon.spy();
58-
handle.__set__('logError', logErrorSpy);
59-
const file = path.resolve('test/fixtures/syntax-error');
60-
const promise = handle(file);
61-
await t.throws(promise);
62-
t.is(logErrorSpy.callCount, 2);
63-
t.is(process.exit.getCall(0).args[0], 1);
64-
});

yarn.lock

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@ are-we-there-yet@~1.1.2:
185185
delegates "^1.0.0"
186186
readable-stream "^2.0.6"
187187

188-
arg@2.0.0:
189-
version "2.0.0"
190-
resolved "https://registry.yarnpkg.com/arg/-/arg-2.0.0.tgz#c06e7ff69ab05b3a4a03ebe0407fac4cba657545"
188+
arg@4.1.0:
189+
version "4.1.0"
190+
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.0.tgz#583c518199419e0037abb74062c37f8519e575f0"
191+
integrity sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg==
191192

192193
arg@^1.0.0:
193194
version "1.0.1"
@@ -887,14 +888,6 @@ center-align@^0.1.1:
887888
align-text "^0.1.3"
888889
lazy-cache "^1.0.3"
889890

890-
chalk@2.4.0, chalk@^2.0.0, chalk@^2.3.0:
891-
version "2.4.0"
892-
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52"
893-
dependencies:
894-
ansi-styles "^3.2.1"
895-
escape-string-regexp "^1.0.5"
896-
supports-color "^5.3.0"
897-
898891
chalk@^0.4.0:
899892
version "0.4.0"
900893
resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f"
@@ -913,6 +906,14 @@ chalk@^1.1.3:
913906
strip-ansi "^3.0.0"
914907
supports-color "^2.0.0"
915908

909+
chalk@^2.0.0, chalk@^2.3.0:
910+
version "2.4.0"
911+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52"
912+
dependencies:
913+
ansi-styles "^3.2.1"
914+
escape-string-regexp "^1.0.5"
915+
supports-color "^5.3.0"
916+
916917
chalk@^2.0.1, chalk@^2.1.0:
917918
version "2.3.2"
918919
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65"

0 commit comments

Comments
 (0)