@hocuspocus/cli 3.1.3 → 3.1.4
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/package.json +26 -26
- package/src/index.js +53 -47
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
"name": "@hocuspocus/cli",
|
|
3
|
+
"description": "a CLI tool to start a local Hocuspocus server",
|
|
4
|
+
"version": "3.1.4",
|
|
5
|
+
"homepage": "https://hocuspocus.dev",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"hocuspocus",
|
|
8
|
+
"yjs",
|
|
9
|
+
"yjs-websocket"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"bin": {
|
|
14
|
+
"hocuspocus": "./src/index.js",
|
|
15
|
+
"@hocuspocus/cli": "./src/index.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"src"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@hocuspocus/extension-logger": "^3.1.4",
|
|
22
|
+
"@hocuspocus/extension-sqlite": "^3.1.4",
|
|
23
|
+
"@hocuspocus/extension-webhook": "^3.1.4",
|
|
24
|
+
"@hocuspocus/server": "^3.1.4",
|
|
25
|
+
"meow": "^13.0.0"
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d"
|
|
28
28
|
}
|
package/src/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
3
|
+
import { Logger } from "@hocuspocus/extension-logger";
|
|
4
|
+
import { SQLite } from "@hocuspocus/extension-sqlite";
|
|
5
|
+
import { Webhook } from "@hocuspocus/extension-webhook";
|
|
6
|
+
import { Server } from "@hocuspocus/server";
|
|
7
|
+
import meow from "meow";
|
|
8
8
|
|
|
9
|
-
export const cli = meow(
|
|
9
|
+
export const cli = meow(
|
|
10
|
+
`
|
|
10
11
|
Usage
|
|
11
12
|
$ hocuspocus [options]
|
|
12
13
|
|
|
@@ -21,52 +22,57 @@ export const cli = meow(`
|
|
|
21
22
|
$ hocuspocus --webhook http://localhost/webhooks/hocuspocus
|
|
22
23
|
$ hocuspocus --sqlite
|
|
23
24
|
$ hocuspocus --sqlite database/default.sqlite
|
|
24
|
-
`,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
25
|
+
`,
|
|
26
|
+
{
|
|
27
|
+
importMeta: import.meta,
|
|
28
|
+
flags: {
|
|
29
|
+
port: {
|
|
30
|
+
type: "string",
|
|
31
|
+
shortFlag: "p",
|
|
32
|
+
default: "1234",
|
|
33
|
+
},
|
|
34
|
+
webhook: {
|
|
35
|
+
type: "string",
|
|
36
|
+
shortFlag: "w",
|
|
37
|
+
default: "",
|
|
38
|
+
},
|
|
39
|
+
sqlite: {
|
|
40
|
+
type: "string",
|
|
41
|
+
shortFlag: "s",
|
|
42
|
+
default: "",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
);
|
|
44
47
|
|
|
45
48
|
export const getConfiguredWebhookExtension = () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
49
|
+
return cli.flags.webhook
|
|
50
|
+
? new Webhook({
|
|
51
|
+
url: cli.flags.webhook,
|
|
52
|
+
})
|
|
53
|
+
: undefined;
|
|
54
|
+
};
|
|
50
55
|
|
|
51
56
|
export const getConfiguredSQLiteExtension = () => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
if (cli.flags.sqlite) {
|
|
58
|
+
return new SQLite({
|
|
59
|
+
database: cli.flags.sqlite,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (process.argv.includes("--sqlite")) {
|
|
63
|
+
return new SQLite();
|
|
64
|
+
}
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
}
|
|
66
|
+
return undefined;
|
|
67
|
+
};
|
|
62
68
|
|
|
63
69
|
const server = new Server({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})
|
|
70
|
+
port: Number.parseInt(cli.flags.port, 10),
|
|
71
|
+
extensions: [
|
|
72
|
+
new Logger(),
|
|
73
|
+
getConfiguredWebhookExtension(),
|
|
74
|
+
getConfiguredSQLiteExtension(),
|
|
75
|
+
].filter((extension) => extension),
|
|
76
|
+
});
|
|
71
77
|
|
|
72
|
-
server.listen()
|
|
78
|
+
server.listen();
|