sable 0.5.10 → 0.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,6 @@
1
1
  # Sable
2
2
 
3
- [![CircleCI](https://circleci.com/gh/kei-ito/sable.svg?style=svg)](https://circleci.com/gh/kei-ito/sable)
4
- [![Build Status](https://travis-ci.com/kei-ito/sable.svg?branch=master)](https://travis-ci.com/kei-ito/sable)
5
- [![Build status](https://ci.appveyor.com/api/projects/status/github/kei-ito/sable?branch=master&svg=true)](https://ci.appveyor.com/project/kei-ito/sable/branch/master)
3
+ [![test](https://github.com/kei-ito/sable/actions/workflows/test.yml/badge.svg)](https://github.com/kei-ito/sable/actions/workflows/test.yml)
6
4
  [![codecov](https://codecov.io/gh/kei-ito/sable/branch/master/graph/badge.svg)](https://codecov.io/gh/kei-ito/sable)
7
5
 
8
6
  Starts a server for development.
package/bin/sable CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  const console = require('console');
3
- const program = require('commander');
3
+ const {Command} = require('commander');
4
4
  const {startServer} = require('..');
5
5
  const packageJSON = require('../package.json');
6
6
 
7
- program
7
+ const program = new Command()
8
8
  .version(packageJSON.version)
9
9
  .description('Starts a HTTP server for development')
10
10
  .usage('[options] <documentRoot ...>')
@@ -18,7 +18,10 @@ if (program.noWatch) {
18
18
  program.watch = false;
19
19
  }
20
20
 
21
- startServer(program)
21
+ startServer({
22
+ ...program.opts(),
23
+ documentRoot: 0 < program.args.length ? program.args : [process.cwd()],
24
+ })
22
25
  .catch((error) => {
23
26
  console.error(error);
24
27
  process.exit(1);
package/lib/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as http from 'http';
2
2
  import * as connect from 'connect';
3
3
  import * as staticLivereload from 'middleware-static-livereload';
4
4
  export { LogLevel } from 'middleware-static-livereload';
5
- export interface SableOptions extends staticLivereload.IOptions {
5
+ export interface SableOptions extends staticLivereload.Options {
6
6
  port?: number;
7
7
  host?: string;
8
8
  middlewares?: Array<connect.HandleFunction>;
package/lib/index.js CHANGED
@@ -13,7 +13,7 @@ const startServer = async (options = {}) => {
13
13
  }
14
14
  app.use(staticLivereload.middleware(options));
15
15
  const server = http.createServer(app);
16
- await new Promise((resolve, reject) => {
16
+ return await new Promise((resolve, reject) => {
17
17
  server.once('listening', () => {
18
18
  const addressInfo = server.address();
19
19
  if (addressInfo && typeof addressInfo === 'object') {
@@ -25,19 +25,17 @@ const startServer = async (options = {}) => {
25
25
  resolve(server);
26
26
  });
27
27
  const listen = (port, host) => {
28
- server
29
- .once('error', (error) => {
28
+ server.once('error', (error) => {
30
29
  if (error.code === 'EADDRINUSE') {
31
30
  listen(port + 1, host);
32
31
  }
33
32
  else {
34
33
  reject(error);
35
34
  }
36
- })
37
- .listen(port, host);
35
+ });
36
+ server.listen(port, host);
38
37
  };
39
38
  listen(options.port || 4000, options.host);
40
39
  });
41
- return server;
42
40
  };
43
41
  exports.startServer = startServer;
package/package.json CHANGED
@@ -1,25 +1,35 @@
1
1
  {
2
2
  "name": "sable",
3
- "version": "0.5.10",
3
+ "version": "0.5.14",
4
4
  "description": "Starts a server and a file watcher",
5
5
  "author": {
6
6
  "name": "Kei Ito",
7
7
  "email": "kei.itof@gmail.com",
8
- "url": "https://github.com/kei-ito"
8
+ "url": "https://github.com/gjbkz"
9
9
  },
10
10
  "license": "Apache-2.0",
11
11
  "engines": {
12
- "node": ">=8"
12
+ "node": ">=12"
13
13
  },
14
- "repository": "kei-ito/sable",
14
+ "repository": "https://github.com/gjbkz/sable",
15
15
  "main": "./lib/index.js",
16
16
  "bin": {
17
17
  "sable": "./bin/sable"
18
18
  },
19
+ "files": [
20
+ "lib"
21
+ ],
22
+ "scripts": {
23
+ "lint": "eslint --ext .ts src",
24
+ "build": "tsc --project tsconfig.build.json",
25
+ "test": "ava",
26
+ "version": "run-s version:changelog version:add",
27
+ "version:changelog": "npx @nlib/changelog --output CHANGELOG.md",
28
+ "version:add": "git add ."
29
+ },
19
30
  "dependencies": {
20
- "@types/connect": "3.4.34",
21
- "commander": "6.2.1",
31
+ "commander": "8.3.0",
22
32
  "connect": "3.7.0",
23
- "middleware-static-livereload": "1.2.17"
33
+ "middleware-static-livereload": "1.2.21"
24
34
  }
25
35
  }
package/CHANGELOG.md DELETED
@@ -1,202 +0,0 @@
1
- # Changelog
2
-
3
- ## v0.5.10 (2020-12-20)
4
-
5
- ### Dependency Upgrades
6
-
7
- - upgrade dependencies (#229) (be5fbaf)
8
-
9
-
10
- ## v0.5.9 (2020-06-26)
11
-
12
-
13
- ## v0.5.8 (2020-06-22)
14
-
15
-
16
- ## v0.5.7 (2019-12-09)
17
-
18
-
19
- ## v0.5.6 (2019-12-09)
20
-
21
-
22
- ## v0.5.5 (2019-12-08)
23
-
24
-
25
- ## v0.5.4 (2019-11-15)
26
-
27
-
28
- ## v0.5.3 (2019-08-23)
29
-
30
- ### Code Refactoring
31
-
32
- - fix an eslint error (b5dd2ec)
33
-
34
-
35
- ## v0.5.2 (2019-06-27)
36
-
37
- ### Features
38
-
39
- - add middlewares (30874fb)
40
-
41
-
42
- ## v0.5.1 (2019-06-27)
43
-
44
- ### Features
45
-
46
- - support all options (8a6abf7)
47
-
48
- ### Documentation
49
-
50
- - update README (bab63ee)
51
-
52
-
53
- ## v0.5.0 (2019-06-11)
54
-
55
- ### Features
56
-
57
- - use connect (#42) (95c2e9a)
58
-
59
- ### Documentation
60
-
61
- - update README (7eda663)
62
- - change some badges (e21ef1e)
63
-
64
-
65
- ## v0.4.6 (2018-11-28)
66
-
67
-
68
- ## v0.4.5 (2018-10-19)
69
-
70
-
71
- ## v0.4.4 (2018-10-18)
72
-
73
-
74
- ## v0.4.3 (2018-08-22)
75
-
76
-
77
- ## v0.4.2 (2018-08-22)
78
-
79
-
80
- ## v0.4.1 (2018-08-16)
81
-
82
-
83
- ## v0.4.0 (2018-08-09)
84
-
85
-
86
- ## v0.3.1 (2018-07-18)
87
-
88
-
89
- ## v0.3.0 (2018-07-18)
90
-
91
-
92
- ## v0.2.15 (2018-04-03)
93
-
94
-
95
- ## v0.2.14 (2018-03-15)
96
-
97
-
98
- ## v0.2.13 (2018-01-22)
99
-
100
-
101
- ## v0.2.12 (2018-01-22)
102
-
103
-
104
- ## v0.2.11 (2018-01-09)
105
-
106
-
107
- ## v0.2.10 (2017-12-27)
108
-
109
-
110
- ## v0.2.9 (2017-12-22)
111
-
112
-
113
- ## v0.2.8 (2017-12-22)
114
-
115
-
116
- ## v0.2.7 (2017-12-22)
117
-
118
-
119
- ## v0.2.6 (2017-12-22)
120
-
121
-
122
- ## v0.2.5 (2017-12-22)
123
-
124
-
125
- ## v0.2.4 (2017-12-21)
126
-
127
-
128
- ## v0.2.3 (2017-12-12)
129
-
130
-
131
- ## v0.2.2 (2017-12-07)
132
-
133
-
134
- ## v0.2.1 (2017-12-07)
135
-
136
-
137
- ## v0.2.0 (2017-12-06)
138
-
139
-
140
- ## v0.1.7 (2017-07-28)
141
-
142
-
143
- ## v0.1.6 (2017-06-30)
144
-
145
-
146
- ## v0.1.5 (2017-06-30)
147
-
148
-
149
- ## v0.1.4 (2017-06-30)
150
-
151
-
152
- ## v0.1.3 (2017-06-15)
153
-
154
-
155
- ## v0.1.2 (2017-05-24)
156
-
157
-
158
- ## v0.1.1 (2017-05-24)
159
-
160
-
161
- ## v0.1.0 (2017-05-06)
162
-
163
-
164
- ## v0.0.21 (2017-04-12)
165
-
166
-
167
- ## v0.0.20 (2017-03-30)
168
-
169
-
170
- ## v0.0.19 (2017-03-27)
171
-
172
-
173
- ## v0.0.18 (2017-03-27)
174
-
175
-
176
- ## v0.0.17 (2017-03-23)
177
-
178
-
179
- ## v0.0.16 (2017-03-23)
180
-
181
-
182
- ## v0.0.15 (2017-03-23)
183
-
184
-
185
- ## v0.0.14 (2017-03-23)
186
-
187
-
188
- ## v0.0.13 (2017-03-23)
189
-
190
-
191
- ## v0.0.12 (2017-03-22)
192
-
193
-
194
- ## v0.0.11 (2017-03-16)
195
-
196
-
197
- ## v0.0.10 (2017-03-15)
198
-
199
-
200
- ## v0.0.9 (2017-03-15)
201
-
202
-
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,mCAAmC;AACnC,iEAAiE;AACjE,6EAAsD;AAA9C,wHAAA,QAAQ,OAAA;AAsBT,MAAM,WAAW,GAAG,KAAK,EAC5B,UAAwB,EAAE,EACN,EAAE;IACtB,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,KAAK,MAAM,UAAU,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE;QAClD,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;KACvB;IACD,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;YAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YACrC,IAAI,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;gBAChD,MAAM,EAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAC,GAAG,WAAW,CAAC;gBAC5C,MAAM,UAAU,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;gBACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBAC9F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,QAAQ,GAAG,UAAU,IAAI,CAAC,CAAC;aAC7D;YACD,OAAO,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,IAAa,EAAE,EAAE;YAC3C,MAAM;iBACL,IAAI,CAAC,OAAO,EAAE,CAAC,KAA6B,EAAE,EAAE;gBAC7C,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;oBAC7B,MAAM,CAAC,IAAI,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;iBAC1B;qBAAM;oBACH,MAAM,CAAC,KAAK,CAAC,CAAC;iBACjB;YACL,CAAC,CAAC;iBACD,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAlCW,QAAA,WAAW,eAkCtB"}
package/src/index.ts DELETED
@@ -1,60 +0,0 @@
1
- import * as http from 'http';
2
- import * as connect from 'connect';
3
- import * as staticLivereload from 'middleware-static-livereload';
4
- export {LogLevel} from 'middleware-static-livereload';
5
-
6
- export interface SableOptions extends staticLivereload.IOptions {
7
- /**
8
- * The first argument of server.listen()
9
- * https://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback
10
- * @default 4000
11
- */
12
- port?: number,
13
- /**
14
- * The second argument of server.listen()
15
- * https://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback
16
- * @default undefined
17
- */
18
- host?: string,
19
- /**
20
- * A list of middlewares.
21
- * @default []
22
- */
23
- middlewares?: Array<connect.HandleFunction>,
24
- }
25
-
26
- export const startServer = async (
27
- options: SableOptions = {},
28
- ): Promise<http.Server> => {
29
- const app = connect();
30
- for (const middleware of (options.middlewares || [])) {
31
- app.use(middleware);
32
- }
33
- app.use(staticLivereload.middleware(options));
34
- const server = http.createServer(app);
35
- await new Promise<http.Server>((resolve, reject) => {
36
- server.once('listening', () => {
37
- const addressInfo = server.address();
38
- if (addressInfo && typeof addressInfo === 'object') {
39
- const {address, family, port} = addressInfo;
40
- const portSuffix = port === 80 ? '' : `:${port}`;
41
- const hostname = options.host || (portSuffix && family === 'IPv6' ? `[${address}]` : address);
42
- process.stdout.write(`http://${hostname}${portSuffix}\n`);
43
- }
44
- resolve(server);
45
- });
46
- const listen = (port: number, host?: string) => {
47
- server
48
- .once('error', (error: Error & {code: string}) => {
49
- if (error.code === 'EADDRINUSE') {
50
- listen(port + 1, host);
51
- } else {
52
- reject(error);
53
- }
54
- })
55
- .listen(port, host);
56
- };
57
- listen(options.port || 4000, options.host);
58
- });
59
- return server;
60
- };