sable 0.5.17 → 0.5.19
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 +28 -12
- package/cjs/cli.cjs +20 -4
- package/esm/cli.mjs +20 -4
- package/package.json +7 -6
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,23 @@ 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
|
+
-F, --fileOperations Enable all file operations (upload, delete, text upload)
|
|
40
|
+
--allowFileUpload Enable file upload
|
|
41
|
+
--allowDelete Enable file deletion
|
|
42
|
+
--allowTextUpload Enable text upload
|
|
43
|
+
[documentRoot...] Directories that contain files to be served
|
|
44
|
+
-h, --help Output usage information
|
|
29
45
|
```
|
|
30
46
|
|
|
31
47
|
## Javascript API
|
|
@@ -38,11 +54,11 @@ startServer({/* options */})
|
|
|
38
54
|
|
|
39
55
|
### Options
|
|
40
56
|
|
|
41
|
-
`startServer` supports all
|
|
42
|
-
|
|
57
|
+
`startServer` supports all options from [middleware-static-livereload], plus
|
|
58
|
+
`port`, `host`, and `middlewares`.
|
|
43
59
|
|
|
44
60
|
```javascript
|
|
45
|
-
interface SableOptions extends
|
|
61
|
+
interface SableOptions extends Partial<MiddlewareOptions> {
|
|
46
62
|
/**
|
|
47
63
|
* The first argument of server.listen()
|
|
48
64
|
* https://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback
|
package/cjs/cli.cjs
CHANGED
|
@@ -74,18 +74,25 @@ 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)").option(
|
|
82
|
+
"-F, --fileOperations",
|
|
83
|
+
"Enable all file operations (upload, delete, text upload)"
|
|
84
|
+
).option("--allowFileUpload", "Enable file upload").option("--allowDelete", "Enable file deletion").option("--allowTextUpload", "Enable text upload").argument("[documentRoot...]", "Directories that contain files to be served");
|
|
82
85
|
program.parse();
|
|
83
86
|
var {
|
|
84
87
|
noWatch,
|
|
85
88
|
port,
|
|
86
89
|
host,
|
|
87
90
|
verbose = false,
|
|
88
|
-
index
|
|
91
|
+
index,
|
|
92
|
+
fileOperations,
|
|
93
|
+
allowFileUpload,
|
|
94
|
+
allowDelete,
|
|
95
|
+
allowTextUpload
|
|
89
96
|
} = program.opts();
|
|
90
97
|
var documentRoot = program.args;
|
|
91
98
|
if (documentRoot.length === 0) {
|
|
@@ -111,6 +118,15 @@ if (Array.isArray(index)) {
|
|
|
111
118
|
} else if (index) {
|
|
112
119
|
options.index = index;
|
|
113
120
|
}
|
|
121
|
+
if (fileOperations) {
|
|
122
|
+
options.fileOperations = true;
|
|
123
|
+
} else if (allowFileUpload || allowDelete || allowTextUpload) {
|
|
124
|
+
options.fileOperations = {
|
|
125
|
+
allowFileUpload,
|
|
126
|
+
allowDelete,
|
|
127
|
+
allowTextUpload
|
|
128
|
+
};
|
|
129
|
+
}
|
|
114
130
|
startServer(options).catch((error) => {
|
|
115
131
|
console.error(error);
|
|
116
132
|
process.exit(1);
|
package/esm/cli.mjs
CHANGED
|
@@ -50,18 +50,25 @@ 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)").option(
|
|
58
|
+
"-F, --fileOperations",
|
|
59
|
+
"Enable all file operations (upload, delete, text upload)"
|
|
60
|
+
).option("--allowFileUpload", "Enable file upload").option("--allowDelete", "Enable file deletion").option("--allowTextUpload", "Enable text upload").argument("[documentRoot...]", "Directories that contain files to be served");
|
|
58
61
|
program.parse();
|
|
59
62
|
var {
|
|
60
63
|
noWatch,
|
|
61
64
|
port,
|
|
62
65
|
host,
|
|
63
66
|
verbose = false,
|
|
64
|
-
index
|
|
67
|
+
index,
|
|
68
|
+
fileOperations,
|
|
69
|
+
allowFileUpload,
|
|
70
|
+
allowDelete,
|
|
71
|
+
allowTextUpload
|
|
65
72
|
} = program.opts();
|
|
66
73
|
var documentRoot = program.args;
|
|
67
74
|
if (documentRoot.length === 0) {
|
|
@@ -87,6 +94,15 @@ if (Array.isArray(index)) {
|
|
|
87
94
|
} else if (index) {
|
|
88
95
|
options.index = index;
|
|
89
96
|
}
|
|
97
|
+
if (fileOperations) {
|
|
98
|
+
options.fileOperations = true;
|
|
99
|
+
} else if (allowFileUpload || allowDelete || allowTextUpload) {
|
|
100
|
+
options.fileOperations = {
|
|
101
|
+
allowFileUpload,
|
|
102
|
+
allowDelete,
|
|
103
|
+
allowTextUpload
|
|
104
|
+
};
|
|
105
|
+
}
|
|
90
106
|
startServer(options).catch((error) => {
|
|
91
107
|
console.error(error);
|
|
92
108
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sable",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.19",
|
|
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.3",
|
|
44
45
|
"connect": "3.7.0",
|
|
45
|
-
"middleware-static-livereload": "1.
|
|
46
|
+
"middleware-static-livereload": "1.5.3"
|
|
46
47
|
}
|
|
47
48
|
}
|