@hocuspocus/cli 3.2.2 → 3.2.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 +7 -6
- package/src/index.js +70 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/cli",
|
|
3
3
|
"description": "a CLI tool to start a local Hocuspocus server",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.4",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"hocuspocus",
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"src"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@hocuspocus/extension-logger": "^3.2.
|
|
22
|
-
"@hocuspocus/extension-
|
|
23
|
-
"@hocuspocus/extension-
|
|
24
|
-
"@hocuspocus/
|
|
25
|
-
"
|
|
21
|
+
"@hocuspocus/extension-logger": "^3.2.4",
|
|
22
|
+
"@hocuspocus/extension-s3": "^3.2.4",
|
|
23
|
+
"@hocuspocus/extension-sqlite": "^3.2.4",
|
|
24
|
+
"@hocuspocus/extension-webhook": "^3.2.4",
|
|
25
|
+
"@hocuspocus/server": "^3.2.4",
|
|
26
|
+
"meow": "^14.0.0"
|
|
26
27
|
},
|
|
27
28
|
"gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d"
|
|
28
29
|
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Logger } from "@hocuspocus/extension-logger";
|
|
4
|
+
import { S3 } from "@hocuspocus/extension-s3";
|
|
4
5
|
import { SQLite } from "@hocuspocus/extension-sqlite";
|
|
5
6
|
import { Webhook } from "@hocuspocus/extension-webhook";
|
|
6
7
|
import { Server } from "@hocuspocus/server";
|
|
@@ -15,6 +16,11 @@ export const cli = meow(
|
|
|
15
16
|
--port=, -p Set the port, defaults to 1234.
|
|
16
17
|
--webhook=, -w Configure a custom webhook.
|
|
17
18
|
--sqlite=, -s Store data in a SQLite database, defaults to :memory:.
|
|
19
|
+
--s3 Store data in S3 or S3-compatible storage.
|
|
20
|
+
--s3-bucket= S3 bucket name (required when using --s3).
|
|
21
|
+
--s3-region= S3 region, defaults to us-east-1.
|
|
22
|
+
--s3-prefix= S3 key prefix for documents.
|
|
23
|
+
--s3-endpoint= S3 endpoint URL (for S3-compatible services like MinIO).
|
|
18
24
|
--version Show the current version number.
|
|
19
25
|
|
|
20
26
|
Examples
|
|
@@ -22,6 +28,14 @@ export const cli = meow(
|
|
|
22
28
|
$ hocuspocus --webhook http://localhost/webhooks/hocuspocus
|
|
23
29
|
$ hocuspocus --sqlite
|
|
24
30
|
$ hocuspocus --sqlite database/default.sqlite
|
|
31
|
+
$ hocuspocus --s3 --s3-bucket my-docs
|
|
32
|
+
$ hocuspocus --s3 --s3-bucket my-docs --s3-region eu-west-1
|
|
33
|
+
$ hocuspocus --s3 --s3-bucket my-docs --s3-endpoint http://localhost:9000
|
|
34
|
+
|
|
35
|
+
Environment Variables (for S3)
|
|
36
|
+
AWS_ACCESS_KEY_ID AWS access key ID
|
|
37
|
+
AWS_SECRET_ACCESS_KEY AWS secret access key
|
|
38
|
+
AWS_REGION AWS region (alternative to --s3-region)
|
|
25
39
|
`,
|
|
26
40
|
{
|
|
27
41
|
importMeta: import.meta,
|
|
@@ -41,6 +55,26 @@ export const cli = meow(
|
|
|
41
55
|
shortFlag: "s",
|
|
42
56
|
default: "",
|
|
43
57
|
},
|
|
58
|
+
s3: {
|
|
59
|
+
type: "boolean",
|
|
60
|
+
default: false,
|
|
61
|
+
},
|
|
62
|
+
s3Bucket: {
|
|
63
|
+
type: "string",
|
|
64
|
+
default: "",
|
|
65
|
+
},
|
|
66
|
+
s3Region: {
|
|
67
|
+
type: "string",
|
|
68
|
+
default: "us-east-1",
|
|
69
|
+
},
|
|
70
|
+
s3Prefix: {
|
|
71
|
+
type: "string",
|
|
72
|
+
default: "",
|
|
73
|
+
},
|
|
74
|
+
s3Endpoint: {
|
|
75
|
+
type: "string",
|
|
76
|
+
default: "",
|
|
77
|
+
},
|
|
44
78
|
},
|
|
45
79
|
},
|
|
46
80
|
);
|
|
@@ -66,12 +100,48 @@ export const getConfiguredSQLiteExtension = () => {
|
|
|
66
100
|
return undefined;
|
|
67
101
|
};
|
|
68
102
|
|
|
103
|
+
export const getConfiguredS3Extension = () => {
|
|
104
|
+
if (!cli.flags.s3) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const bucket = cli.flags.s3Bucket || process.env.S3_BUCKET;
|
|
109
|
+
if (!bucket) {
|
|
110
|
+
console.error("❌ S3 bucket is required. Use --s3-bucket or set S3_BUCKET environment variable.");
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const config = {
|
|
115
|
+
bucket,
|
|
116
|
+
region: cli.flags.s3Region || process.env.AWS_REGION || "us-east-1",
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
if (cli.flags.s3Prefix) {
|
|
120
|
+
config.prefix = cli.flags.s3Prefix;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (cli.flags.s3Endpoint) {
|
|
124
|
+
config.endpoint = cli.flags.s3Endpoint;
|
|
125
|
+
config.forcePathStyle = true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) {
|
|
129
|
+
config.credentials = {
|
|
130
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
131
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return new S3(config);
|
|
136
|
+
};
|
|
137
|
+
|
|
69
138
|
const server = new Server({
|
|
70
139
|
port: Number.parseInt(cli.flags.port, 10),
|
|
71
140
|
extensions: [
|
|
72
141
|
new Logger(),
|
|
73
142
|
getConfiguredWebhookExtension(),
|
|
74
143
|
getConfiguredSQLiteExtension(),
|
|
144
|
+
getConfiguredS3Extension(),
|
|
75
145
|
].filter((extension) => extension),
|
|
76
146
|
});
|
|
77
147
|
|