sable 0.5.16 → 0.5.18
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.
- package/README.md +24 -12
- package/cjs/cli.cjs +3 -3
- package/esm/cli.mjs +3 -3
- package/package.json +7 -6
- package/types/index.d.ts +5 -1
package/README.md
CHANGED
|
@@ -3,7 +3,17 @@
|
|
|
3
3
|
[](https://github.com/kei-ito/sable/actions/workflows/test.yml)
|
|
4
4
|
[](https://codecov.io/gh/kei-ito/sable)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
An HTTP development server that serves static files and reloads the browser when files change. If the configured port is already in use, sable automatically tries the next one, so multiple projects can run side by side without any configuration changes.
|
|
7
|
+
|
|
8
|
+
## Quick start
|
|
9
|
+
|
|
10
|
+
No installation required. Run the following command to serve the current directory:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
npx sable .
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The server URL is printed to stdout once it is ready. Edit any file in the directory and the browser reloads automatically.
|
|
7
17
|
|
|
8
18
|
## Install
|
|
9
19
|
|
|
@@ -15,17 +25,19 @@ npm install sable --save-dev
|
|
|
15
25
|
|
|
16
26
|
```
|
|
17
27
|
$ sable -h
|
|
18
|
-
Usage: sable [options]
|
|
28
|
+
Usage: sable [options] [documentRoot...]
|
|
19
29
|
|
|
20
|
-
Starts
|
|
30
|
+
Starts an HTTP development server
|
|
21
31
|
|
|
22
32
|
Options:
|
|
23
|
-
-V, --version
|
|
24
|
-
-p, --port <n>
|
|
25
|
-
-h, --host <s>
|
|
26
|
-
--
|
|
27
|
-
|
|
28
|
-
-
|
|
33
|
+
-V, --version Output the version number
|
|
34
|
+
-p, --port <n> Port number for HTTP/HTTPS (default: 4000)
|
|
35
|
+
-h, --host <s> Host name to bind
|
|
36
|
+
-v, --verbose Enable verbose logging
|
|
37
|
+
--noWatch Set the watch option to false
|
|
38
|
+
-i, --index <s> Value for the index option (default: index.html)
|
|
39
|
+
[documentRoot...] Directories that contain files to be served
|
|
40
|
+
-h, --help Output usage information
|
|
29
41
|
```
|
|
30
42
|
|
|
31
43
|
## Javascript API
|
|
@@ -38,11 +50,11 @@ startServer({/* options */})
|
|
|
38
50
|
|
|
39
51
|
### Options
|
|
40
52
|
|
|
41
|
-
`startServer` supports all
|
|
42
|
-
|
|
53
|
+
`startServer` supports all options from [middleware-static-livereload], plus
|
|
54
|
+
`port`, `host`, and `middlewares`.
|
|
43
55
|
|
|
44
56
|
```javascript
|
|
45
|
-
interface SableOptions extends
|
|
57
|
+
interface SableOptions extends Partial<MiddlewareOptions> {
|
|
46
58
|
/**
|
|
47
59
|
* The first argument of server.listen()
|
|
48
60
|
* https://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback
|
package/cjs/cli.cjs
CHANGED
|
@@ -74,11 +74,11 @@ if (!packageJsonPath) {
|
|
|
74
74
|
throw new Error("Unable to resolve path to package.json");
|
|
75
75
|
}
|
|
76
76
|
var { version } = JSON.parse((0, import_node_fs.readFileSync)(packageJsonPath, "utf8"));
|
|
77
|
-
var program = new import_commander.Command().version(version).description("Starts
|
|
77
|
+
var program = new import_commander.Command().version(version).description("Starts an HTTP development server").option(
|
|
78
78
|
"-p, --port <n>",
|
|
79
|
-
"
|
|
79
|
+
"Port number for HTTP/HTTPS (default: 4000)",
|
|
80
80
|
Number.parseInt
|
|
81
|
-
).option("-h, --host <s>", "
|
|
81
|
+
).option("-h, --host <s>", "Host name to bind").option("-v, --verbose", "Enable verbose logging").option("--noWatch", "Set the watch option to false").option("-i, --index <s>", "Value for the index option (default: index.html)").argument("[documentRoot...]", "Directories that contain files to be served");
|
|
82
82
|
program.parse();
|
|
83
83
|
var {
|
|
84
84
|
noWatch,
|
package/esm/cli.mjs
CHANGED
|
@@ -50,11 +50,11 @@ if (!packageJsonPath) {
|
|
|
50
50
|
throw new Error("Unable to resolve path to package.json");
|
|
51
51
|
}
|
|
52
52
|
var { version } = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
53
|
-
var program = new Command().version(version).description("Starts
|
|
53
|
+
var program = new Command().version(version).description("Starts an HTTP development server").option(
|
|
54
54
|
"-p, --port <n>",
|
|
55
|
-
"
|
|
55
|
+
"Port number for HTTP/HTTPS (default: 4000)",
|
|
56
56
|
Number.parseInt
|
|
57
|
-
).option("-h, --host <s>", "
|
|
57
|
+
).option("-h, --host <s>", "Host name to bind").option("-v, --verbose", "Enable verbose logging").option("--noWatch", "Set the watch option to false").option("-i, --index <s>", "Value for the index option (default: index.html)").argument("[documentRoot...]", "Directories that contain files to be served");
|
|
58
58
|
program.parse();
|
|
59
59
|
var {
|
|
60
60
|
noWatch,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sable",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.18",
|
|
4
|
+
"description": "HTTP development server with file watching",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Kei Ito",
|
|
7
7
|
"email": "kei.itof@gmail.com",
|
|
@@ -30,18 +30,19 @@
|
|
|
30
30
|
"types"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"lint": "npx @biomejs/biome
|
|
33
|
+
"lint": "npx @biomejs/biome check",
|
|
34
|
+
"format": "npx @biomejs/biome format --write",
|
|
34
35
|
"build": "run-s build:*",
|
|
35
36
|
"build:typedef": "tsc --project tsconfig.typedef.json",
|
|
36
37
|
"build:code": "node build.ts",
|
|
37
38
|
"test": "node --test test/index.mjs",
|
|
38
|
-
"version": "run-s version:changelog version:add",
|
|
39
|
+
"version": "run-s version:changelog format version:add",
|
|
39
40
|
"version:changelog": "npx @nlib/changelog --output CHANGELOG.md",
|
|
40
41
|
"version:add": "git add ."
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"commander": "14.0.
|
|
44
|
+
"commander": "14.0.2",
|
|
44
45
|
"connect": "3.7.0",
|
|
45
|
-
"middleware-static-livereload": "1.
|
|
46
|
+
"middleware-static-livereload": "1.5.2"
|
|
46
47
|
}
|
|
47
48
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import * as http from "node:http";
|
|
2
|
-
import { type HandleFunction } from "connect";
|
|
3
2
|
import * as staticLivereload from "middleware-static-livereload";
|
|
4
3
|
export { LogLevel } from "middleware-static-livereload";
|
|
4
|
+
type NextFunction = (err?: unknown) => void;
|
|
5
|
+
export type SimpleHandleFunction = (req: http.IncomingMessage, res: http.ServerResponse) => void;
|
|
6
|
+
export type NextHandleFunction = (req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
|
|
7
|
+
export type ErrorHandleFunction = (err: unknown, req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
|
|
8
|
+
export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
|
|
5
9
|
export interface SableOptions extends Partial<staticLivereload.MiddlewareOptions> {
|
|
6
10
|
port?: number;
|
|
7
11
|
host?: string;
|