two-stroke 5.2.7 → 5.3.0
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/bin/bulk.mjs +45 -0
- package/package.json +3 -1
package/bin/bulk.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
import { promises as fs } from "fs";
|
|
5
|
+
import { cmd } from "../src/cmd.mjs";
|
|
6
|
+
import mime from "mime";
|
|
7
|
+
|
|
8
|
+
const entryOrRest = process.argv[2];
|
|
9
|
+
const entry = process.argv[3];
|
|
10
|
+
|
|
11
|
+
const ents = await fs.readdir("dist", { withFileTypes: true, recursive: true });
|
|
12
|
+
const files = await Promise.all(
|
|
13
|
+
ents
|
|
14
|
+
.filter((ent) => ent.isFile())
|
|
15
|
+
.filter((ent) =>
|
|
16
|
+
entryOrRest == "entry" ? ent.name === entry : ent.name !== entry,
|
|
17
|
+
)
|
|
18
|
+
.map((ent) => {
|
|
19
|
+
const type = mime.getType(`${ent.parentPath}/${ent.name}`);
|
|
20
|
+
const key = `${ent.parentPath.substring(4)}/${ent.name}`;
|
|
21
|
+
return (async () => ({
|
|
22
|
+
key: ent.name === entry ? `${process.env.DOMAIN}${key}` : key,
|
|
23
|
+
value: (await fs.readFile(`${ent.parentPath}/${ent.name}`)).toString(
|
|
24
|
+
"base64",
|
|
25
|
+
),
|
|
26
|
+
base64: true,
|
|
27
|
+
metadata: {
|
|
28
|
+
"Content-Type":
|
|
29
|
+
type === "text/html"
|
|
30
|
+
? "text/html;charset=utf-8"
|
|
31
|
+
: type === "text/javascript"
|
|
32
|
+
? "text/javascript;charset=utf-8"
|
|
33
|
+
: type,
|
|
34
|
+
"Cache-Control":
|
|
35
|
+
ent.name === entry ? "nocache" : "max-age=31536000, immutable",
|
|
36
|
+
},
|
|
37
|
+
}))();
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
fs.writeFileSync(`dist/bulk_${process.argv[2]}.json`, files);
|
|
42
|
+
|
|
43
|
+
cmd(
|
|
44
|
+
`wrangler kv bulk put dist/bulk_${process.argv[2]}.json --remote --namespace-id ${process.env.NAMESPACE}`,
|
|
45
|
+
);
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bin": {
|
|
3
|
+
"bulk": "./bin/bulk.mjs",
|
|
3
4
|
"deploy": "./bin/deploy.mjs",
|
|
4
5
|
"dev": "./bin/dev.mjs",
|
|
5
6
|
"format": "./bin/format.mjs",
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
"eslint-config-typescript": "^3.0.0",
|
|
21
22
|
"jose": "^6.0.12",
|
|
22
23
|
"jwk-subtle": "^1.0.7",
|
|
24
|
+
"mime": "^4.0.7",
|
|
23
25
|
"miniflare": "^4.20250712.1",
|
|
24
26
|
"openapi-fetch": "^0.14.0",
|
|
25
27
|
"openapi-typescript": "^7.8.0",
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
"name": "two-stroke",
|
|
50
52
|
"packageManager": "yarn@4.6.0",
|
|
51
53
|
"type": "module",
|
|
52
|
-
"version": "5.
|
|
54
|
+
"version": "5.3.0",
|
|
53
55
|
"devDependencies": {
|
|
54
56
|
"@types/eslint": "^9.6.1",
|
|
55
57
|
"eslint": "^9.31.0",
|