@s-hirano-ist/s-scripts 4.2.0 → 4.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/README.md +8 -0
- package/dist/chunk-4CXH2QIX.js +445 -0
- package/dist/chunk-67LIMNXH.js +36 -0
- package/dist/{chunk-R5EI7JXR.js → chunk-GBQOCN2C.js} +5 -16
- package/dist/chunk-MJYGMGH5.js +382 -0
- package/dist/{chunk-M6LFKOUH.js → chunk-MVYAZJB2.js} +2 -2
- package/dist/chunk-SFKQ2RAP.js +87 -0
- package/dist/cleanup-minio-images.js +65 -84
- package/dist/enrich-books.js +6 -4
- package/dist/fetch-articles.js +5 -23
- package/dist/fetch-books.js +6 -24
- package/dist/fetch-images.js +6 -24
- package/dist/fetch-notes.js +5 -23
- package/dist/find-duplicate-json-articles.js +11 -13
- package/dist/fix-book-frontmatter.js +6 -4
- package/dist/fix-image-formats.js +7 -5
- package/dist/ingest-articles.js +7 -5
- package/dist/ingest-books.js +10 -8
- package/dist/ingest-images.js +7 -5
- package/dist/ingest-notes.js +10 -8
- package/dist/rag/delete-collection.js +5 -30
- package/dist/rag/ingest.js +5 -379
- package/dist/rag/search.js +5 -84
- package/dist/reset-articles.js +6 -21
- package/dist/reset-books.js +6 -21
- package/dist/reset-images.js +6 -21
- package/dist/reset-notes.js +6 -21
- package/dist/revert-articles.js +6 -21
- package/dist/revert-books.js +6 -21
- package/dist/revert-images.js +6 -21
- package/dist/revert-notes.js +6 -21
- package/dist/s-content-format.js +9 -11
- package/dist/update-json-articles.js +19 -41
- package/dist/update-raw-articles.js +14 -37
- package/dist/validate-json-articles.js +8 -5
- package/package.json +6 -4
- package/dist/chunk-7PVU2Z32.js +0 -71
package/dist/reset-notes.js
CHANGED
|
@@ -9,28 +9,22 @@ import {
|
|
|
9
9
|
makeUserId
|
|
10
10
|
} from "./chunk-RLAYINCA.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
cliNotifications,
|
|
13
|
+
runCli
|
|
14
|
+
} from "./chunk-4CXH2QIX.js";
|
|
14
15
|
import "./chunk-JZOR5GA2.js";
|
|
15
16
|
|
|
16
17
|
// src/reset-notes.ts
|
|
17
18
|
async function main() {
|
|
18
19
|
const env = {
|
|
19
20
|
DATABASE_URL: process.env.DATABASE_URL,
|
|
20
|
-
PUSHOVER_URL: process.env.PUSHOVER_URL,
|
|
21
|
-
PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
|
|
22
|
-
PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
|
|
23
21
|
USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
|
|
24
22
|
};
|
|
25
23
|
if (Object.values(env).some((v) => !v)) {
|
|
26
24
|
throw new Error("Required environment variables are not set.");
|
|
27
25
|
}
|
|
28
26
|
const prisma = createPrismaClient(env.DATABASE_URL ?? "");
|
|
29
|
-
const notificationService =
|
|
30
|
-
url: env.PUSHOVER_URL ?? "",
|
|
31
|
-
userKey: env.PUSHOVER_USER_KEY ?? "",
|
|
32
|
-
appToken: env.PUSHOVER_APP_TOKEN ?? ""
|
|
33
|
-
});
|
|
27
|
+
const notificationService = cliNotifications;
|
|
34
28
|
const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
|
|
35
29
|
async function resetNotes() {
|
|
36
30
|
const commandRepository = createNotesCommandRepository(prisma);
|
|
@@ -45,18 +39,9 @@ async function main() {
|
|
|
45
39
|
await resetNotes();
|
|
46
40
|
await notificationService.notifyInfo("reset-notes completed", {
|
|
47
41
|
caller: "reset-notes"
|
|
48
|
-
})
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
|
|
51
|
-
await notificationService.notifyError(`reset-notes failed: ${String(error)}`, {
|
|
52
|
-
caller: "reset-notes"
|
|
53
|
-
}).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
|
|
54
|
-
process.exitCode = 1;
|
|
42
|
+
});
|
|
55
43
|
} finally {
|
|
56
44
|
await prisma.$disconnect();
|
|
57
45
|
}
|
|
58
46
|
}
|
|
59
|
-
main
|
|
60
|
-
console.error(error);
|
|
61
|
-
process.exit(1);
|
|
62
|
-
});
|
|
47
|
+
await runCli("reset-notes", main);
|
package/dist/revert-articles.js
CHANGED
|
@@ -9,28 +9,22 @@ import {
|
|
|
9
9
|
makeUserId
|
|
10
10
|
} from "./chunk-RLAYINCA.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
cliNotifications,
|
|
13
|
+
runCli
|
|
14
|
+
} from "./chunk-4CXH2QIX.js";
|
|
14
15
|
import "./chunk-JZOR5GA2.js";
|
|
15
16
|
|
|
16
17
|
// src/revert-articles.ts
|
|
17
18
|
async function main() {
|
|
18
19
|
const env = {
|
|
19
20
|
DATABASE_URL: process.env.DATABASE_URL,
|
|
20
|
-
PUSHOVER_URL: process.env.PUSHOVER_URL,
|
|
21
|
-
PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
|
|
22
|
-
PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
|
|
23
21
|
USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
|
|
24
22
|
};
|
|
25
23
|
if (Object.values(env).some((v) => !v)) {
|
|
26
24
|
throw new Error("Required environment variables are not set.");
|
|
27
25
|
}
|
|
28
26
|
const prisma = createPrismaClient(env.DATABASE_URL ?? "");
|
|
29
|
-
const notificationService =
|
|
30
|
-
url: env.PUSHOVER_URL ?? "",
|
|
31
|
-
userKey: env.PUSHOVER_USER_KEY ?? "",
|
|
32
|
-
appToken: env.PUSHOVER_APP_TOKEN ?? ""
|
|
33
|
-
});
|
|
27
|
+
const notificationService = cliNotifications;
|
|
34
28
|
const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
|
|
35
29
|
try {
|
|
36
30
|
const commandRepository = createArticlesCommandRepository(prisma);
|
|
@@ -41,18 +35,9 @@ async function main() {
|
|
|
41
35
|
);
|
|
42
36
|
await notificationService.notifyInfo("revert-articles completed", {
|
|
43
37
|
caller: "revert-articles"
|
|
44
|
-
})
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
|
|
47
|
-
await notificationService.notifyError(`revert-articles failed: ${String(error)}`, {
|
|
48
|
-
caller: "revert-articles"
|
|
49
|
-
}).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
|
|
50
|
-
process.exitCode = 1;
|
|
38
|
+
});
|
|
51
39
|
} finally {
|
|
52
40
|
await prisma.$disconnect();
|
|
53
41
|
}
|
|
54
42
|
}
|
|
55
|
-
main
|
|
56
|
-
console.error(error);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
});
|
|
43
|
+
await runCli("revert-articles", main);
|
package/dist/revert-books.js
CHANGED
|
@@ -9,28 +9,22 @@ import {
|
|
|
9
9
|
makeUserId
|
|
10
10
|
} from "./chunk-RLAYINCA.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
cliNotifications,
|
|
13
|
+
runCli
|
|
14
|
+
} from "./chunk-4CXH2QIX.js";
|
|
14
15
|
import "./chunk-JZOR5GA2.js";
|
|
15
16
|
|
|
16
17
|
// src/revert-books.ts
|
|
17
18
|
async function main() {
|
|
18
19
|
const env = {
|
|
19
20
|
DATABASE_URL: process.env.DATABASE_URL,
|
|
20
|
-
PUSHOVER_URL: process.env.PUSHOVER_URL,
|
|
21
|
-
PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
|
|
22
|
-
PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
|
|
23
21
|
USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
|
|
24
22
|
};
|
|
25
23
|
if (Object.values(env).some((v) => !v)) {
|
|
26
24
|
throw new Error("Required environment variables are not set.");
|
|
27
25
|
}
|
|
28
26
|
const prisma = createPrismaClient(env.DATABASE_URL ?? "");
|
|
29
|
-
const notificationService =
|
|
30
|
-
url: env.PUSHOVER_URL ?? "",
|
|
31
|
-
userKey: env.PUSHOVER_USER_KEY ?? "",
|
|
32
|
-
appToken: env.PUSHOVER_APP_TOKEN ?? ""
|
|
33
|
-
});
|
|
27
|
+
const notificationService = cliNotifications;
|
|
34
28
|
const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
|
|
35
29
|
try {
|
|
36
30
|
const commandRepository = createBooksCommandRepository(prisma);
|
|
@@ -41,18 +35,9 @@ async function main() {
|
|
|
41
35
|
);
|
|
42
36
|
await notificationService.notifyInfo("revert-books completed", {
|
|
43
37
|
caller: "revert-books"
|
|
44
|
-
})
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
|
|
47
|
-
await notificationService.notifyError(`revert-books failed: ${String(error)}`, {
|
|
48
|
-
caller: "revert-books"
|
|
49
|
-
}).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
|
|
50
|
-
process.exitCode = 1;
|
|
38
|
+
});
|
|
51
39
|
} finally {
|
|
52
40
|
await prisma.$disconnect();
|
|
53
41
|
}
|
|
54
42
|
}
|
|
55
|
-
main
|
|
56
|
-
console.error(error);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
});
|
|
43
|
+
await runCli("revert-books", main);
|
package/dist/revert-images.js
CHANGED
|
@@ -9,28 +9,22 @@ import {
|
|
|
9
9
|
makeUserId
|
|
10
10
|
} from "./chunk-RLAYINCA.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
cliNotifications,
|
|
13
|
+
runCli
|
|
14
|
+
} from "./chunk-4CXH2QIX.js";
|
|
14
15
|
import "./chunk-JZOR5GA2.js";
|
|
15
16
|
|
|
16
17
|
// src/revert-images.ts
|
|
17
18
|
async function main() {
|
|
18
19
|
const env = {
|
|
19
20
|
DATABASE_URL: process.env.DATABASE_URL,
|
|
20
|
-
PUSHOVER_URL: process.env.PUSHOVER_URL,
|
|
21
|
-
PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
|
|
22
|
-
PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
|
|
23
21
|
USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
|
|
24
22
|
};
|
|
25
23
|
if (Object.values(env).some((v) => !v)) {
|
|
26
24
|
throw new Error("Required environment variables are not set.");
|
|
27
25
|
}
|
|
28
26
|
const prisma = createPrismaClient(env.DATABASE_URL ?? "");
|
|
29
|
-
const notificationService =
|
|
30
|
-
url: env.PUSHOVER_URL ?? "",
|
|
31
|
-
userKey: env.PUSHOVER_USER_KEY ?? "",
|
|
32
|
-
appToken: env.PUSHOVER_APP_TOKEN ?? ""
|
|
33
|
-
});
|
|
27
|
+
const notificationService = cliNotifications;
|
|
34
28
|
const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
|
|
35
29
|
try {
|
|
36
30
|
const commandRepository = createImagesCommandRepository(prisma);
|
|
@@ -41,18 +35,9 @@ async function main() {
|
|
|
41
35
|
);
|
|
42
36
|
await notificationService.notifyInfo("revert-images completed", {
|
|
43
37
|
caller: "revert-images"
|
|
44
|
-
})
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
|
|
47
|
-
await notificationService.notifyError(`revert-images failed: ${String(error)}`, {
|
|
48
|
-
caller: "revert-images"
|
|
49
|
-
}).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
|
|
50
|
-
process.exitCode = 1;
|
|
38
|
+
});
|
|
51
39
|
} finally {
|
|
52
40
|
await prisma.$disconnect();
|
|
53
41
|
}
|
|
54
42
|
}
|
|
55
|
-
main
|
|
56
|
-
console.error(error);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
});
|
|
43
|
+
await runCli("revert-images", main);
|
package/dist/revert-notes.js
CHANGED
|
@@ -9,28 +9,22 @@ import {
|
|
|
9
9
|
makeUserId
|
|
10
10
|
} from "./chunk-RLAYINCA.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
cliNotifications,
|
|
13
|
+
runCli
|
|
14
|
+
} from "./chunk-4CXH2QIX.js";
|
|
14
15
|
import "./chunk-JZOR5GA2.js";
|
|
15
16
|
|
|
16
17
|
// src/revert-notes.ts
|
|
17
18
|
async function main() {
|
|
18
19
|
const env = {
|
|
19
20
|
DATABASE_URL: process.env.DATABASE_URL,
|
|
20
|
-
PUSHOVER_URL: process.env.PUSHOVER_URL,
|
|
21
|
-
PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
|
|
22
|
-
PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
|
|
23
21
|
USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
|
|
24
22
|
};
|
|
25
23
|
if (Object.values(env).some((v) => !v)) {
|
|
26
24
|
throw new Error("Required environment variables are not set.");
|
|
27
25
|
}
|
|
28
26
|
const prisma = createPrismaClient(env.DATABASE_URL ?? "");
|
|
29
|
-
const notificationService =
|
|
30
|
-
url: env.PUSHOVER_URL ?? "",
|
|
31
|
-
userKey: env.PUSHOVER_USER_KEY ?? "",
|
|
32
|
-
appToken: env.PUSHOVER_APP_TOKEN ?? ""
|
|
33
|
-
});
|
|
27
|
+
const notificationService = cliNotifications;
|
|
34
28
|
const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
|
|
35
29
|
try {
|
|
36
30
|
const commandRepository = createNotesCommandRepository(prisma);
|
|
@@ -41,18 +35,9 @@ async function main() {
|
|
|
41
35
|
);
|
|
42
36
|
await notificationService.notifyInfo("revert-notes completed", {
|
|
43
37
|
caller: "revert-notes"
|
|
44
|
-
})
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
|
|
47
|
-
await notificationService.notifyError(`revert-notes failed: ${String(error)}`, {
|
|
48
|
-
caller: "revert-notes"
|
|
49
|
-
}).catch((notifyError) => console.error("\u901A\u77E5\u5931\u6557:", notifyError));
|
|
50
|
-
process.exitCode = 1;
|
|
38
|
+
});
|
|
51
39
|
} finally {
|
|
52
40
|
await prisma.$disconnect();
|
|
53
41
|
}
|
|
54
42
|
}
|
|
55
|
-
main
|
|
56
|
-
console.error(error);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
});
|
|
43
|
+
await runCli("revert-notes", main);
|
package/dist/s-content-format.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
runCli
|
|
5
|
+
} from "./chunk-4CXH2QIX.js";
|
|
3
6
|
import "./chunk-JZOR5GA2.js";
|
|
4
7
|
|
|
5
8
|
// src/s-content-format-runner.ts
|
|
@@ -93,16 +96,11 @@ function runContentFormat(rawArgs, cwd = process.cwd(), options = {}) {
|
|
|
93
96
|
|
|
94
97
|
// src/s-content-format.ts
|
|
95
98
|
async function main() {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
process.exitCode = code ?? 1;
|
|
103
|
-
} catch (error) {
|
|
104
|
-
console.error(error);
|
|
105
|
-
process.exitCode = 1;
|
|
99
|
+
const { code, signal } = await runContentFormat(process.argv.slice(2));
|
|
100
|
+
if (signal !== null) {
|
|
101
|
+
process.kill(process.pid, signal);
|
|
102
|
+
return;
|
|
106
103
|
}
|
|
104
|
+
process.exitCode = code ?? 1;
|
|
107
105
|
}
|
|
108
|
-
|
|
106
|
+
await runCli("s-content-format", main);
|
|
@@ -7,8 +7,10 @@ import {
|
|
|
7
7
|
resolveArticleOgImageUrl
|
|
8
8
|
} from "./chunk-IYGLKY27.js";
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
cliNotifications,
|
|
11
|
+
reportCliError,
|
|
12
|
+
runCli
|
|
13
|
+
} from "./chunk-4CXH2QIX.js";
|
|
12
14
|
import "./chunk-JZOR5GA2.js";
|
|
13
15
|
|
|
14
16
|
// src/update-json-articles.ts
|
|
@@ -43,6 +45,7 @@ async function getOgTags(url) {
|
|
|
43
45
|
const ogDescription = ogTags["og:description"];
|
|
44
46
|
return { ogImageUrl, ogTitle, ogDescription };
|
|
45
47
|
} catch (error) {
|
|
48
|
+
reportCliError(error, "update-json-articles");
|
|
46
49
|
console.error(`Error fetching OG tags for ${url}:`, error);
|
|
47
50
|
return {};
|
|
48
51
|
}
|
|
@@ -73,49 +76,24 @@ async function processArticleFile(filePath) {
|
|
|
73
76
|
);
|
|
74
77
|
console.log(`Completed processing ${filePath}`);
|
|
75
78
|
} catch (error) {
|
|
79
|
+
reportCliError(error, "update-json-articles");
|
|
76
80
|
console.error(`Error processing ${filePath}:`, error);
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
async function main() {
|
|
80
|
-
const
|
|
81
|
-
PUSHOVER_URL: process.env.PUSHOVER_URL,
|
|
82
|
-
PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
|
|
83
|
-
PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN
|
|
84
|
-
};
|
|
85
|
-
if (Object.values(env).some((v) => !v)) {
|
|
86
|
-
throw new Error("Required environment variables are not set.");
|
|
87
|
-
}
|
|
88
|
-
const notificationService = createPushoverService({
|
|
89
|
-
url: env.PUSHOVER_URL ?? "",
|
|
90
|
-
userKey: env.PUSHOVER_USER_KEY ?? "",
|
|
91
|
-
appToken: env.PUSHOVER_APP_TOKEN ?? ""
|
|
92
|
-
});
|
|
84
|
+
const notificationService = cliNotifications;
|
|
93
85
|
const articleDir = join(process.cwd(), "json", "article");
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
await processArticleFile(filePath);
|
|
102
|
-
}
|
|
103
|
-
console.log("All files processed successfully!");
|
|
104
|
-
await notificationService.notifyInfo("update-json-articles completed", {
|
|
105
|
-
caller: "update-json-articles"
|
|
106
|
-
});
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.error("Error in main process:", error);
|
|
109
|
-
await notificationService.notifyError(
|
|
110
|
-
`update-json-articles failed: ${String(error)}`,
|
|
111
|
-
{
|
|
112
|
-
caller: "update-json-articles"
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
process.exit(1);
|
|
86
|
+
const files = readdirSync(articleDir).filter(
|
|
87
|
+
(file) => file.endsWith(".json")
|
|
88
|
+
);
|
|
89
|
+
console.log(`Found ${files.length} JSON files to process`);
|
|
90
|
+
for (const file of files) {
|
|
91
|
+
const filePath = join(articleDir, file);
|
|
92
|
+
await processArticleFile(filePath);
|
|
116
93
|
}
|
|
94
|
+
console.log("All files processed successfully!");
|
|
95
|
+
await notificationService.notifyInfo("update-json-articles completed", {
|
|
96
|
+
caller: "update-json-articles"
|
|
97
|
+
});
|
|
117
98
|
}
|
|
118
|
-
main
|
|
119
|
-
console.error(error);
|
|
120
|
-
process.exit(1);
|
|
121
|
-
});
|
|
99
|
+
await runCli("update-json-articles", main);
|
|
@@ -4,8 +4,10 @@ import {
|
|
|
4
4
|
decodeHtml
|
|
5
5
|
} from "./chunk-UXGLXHQ6.js";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
cliNotifications,
|
|
8
|
+
reportCliError,
|
|
9
|
+
runCli
|
|
10
|
+
} from "./chunk-4CXH2QIX.js";
|
|
9
11
|
import "./chunk-JZOR5GA2.js";
|
|
10
12
|
|
|
11
13
|
// src/update-raw-articles.ts
|
|
@@ -73,6 +75,7 @@ async function fetchWebsiteMarkdown(url) {
|
|
|
73
75
|
const markdown = turndownService.turndown(html);
|
|
74
76
|
return markdown.trim();
|
|
75
77
|
} catch (error) {
|
|
78
|
+
reportCliError(error, "update-raw-articles");
|
|
76
79
|
console.error(`Failed to fetch ${url}:`, error);
|
|
77
80
|
return "";
|
|
78
81
|
}
|
|
@@ -118,41 +121,15 @@ ${websiteText}
|
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
async function main() {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
throw new Error("Required environment variables are not set.");
|
|
124
|
+
const notificationService = cliNotifications;
|
|
125
|
+
const jsonFiles = await readdir(JSON_DIR);
|
|
126
|
+
const jsonFilePaths = jsonFiles.filter((file) => file.endsWith(".json")).map((file) => path.join(JSON_DIR, file));
|
|
127
|
+
for (const jsonFile of jsonFilePaths) {
|
|
128
|
+
console.log(`Processing: ${jsonFile}`);
|
|
129
|
+
await jsonToMarkdown(jsonFile);
|
|
128
130
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
userKey: env.PUSHOVER_USER_KEY ?? "",
|
|
132
|
-
appToken: env.PUSHOVER_APP_TOKEN ?? ""
|
|
131
|
+
await notificationService.notifyInfo("update-raw-articles completed", {
|
|
132
|
+
caller: "update-raw-articles"
|
|
133
133
|
});
|
|
134
|
-
try {
|
|
135
|
-
const jsonFiles = await readdir(JSON_DIR);
|
|
136
|
-
const jsonFilePaths = jsonFiles.filter((file) => file.endsWith(".json")).map((file) => path.join(JSON_DIR, file));
|
|
137
|
-
for (const jsonFile of jsonFilePaths) {
|
|
138
|
-
console.log(`Processing: ${jsonFile}`);
|
|
139
|
-
await jsonToMarkdown(jsonFile);
|
|
140
|
-
}
|
|
141
|
-
await notificationService.notifyInfo("update-raw-articles completed", {
|
|
142
|
-
caller: "update-raw-articles"
|
|
143
|
-
});
|
|
144
|
-
} catch (error) {
|
|
145
|
-
console.error("Error in main process:", error);
|
|
146
|
-
await notificationService.notifyError(
|
|
147
|
-
`update-raw-articles failed: ${String(error)}`,
|
|
148
|
-
{
|
|
149
|
-
caller: "update-raw-articles"
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
process.exit(1);
|
|
153
|
-
}
|
|
154
134
|
}
|
|
155
|
-
main
|
|
156
|
-
console.error(error);
|
|
157
|
-
process.exit(1);
|
|
158
|
-
});
|
|
135
|
+
await runCli("update-raw-articles", main);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
reportCliError,
|
|
5
|
+
runCli
|
|
6
|
+
} from "./chunk-4CXH2QIX.js";
|
|
7
|
+
import "./chunk-JZOR5GA2.js";
|
|
3
8
|
|
|
4
9
|
// src/validate-json-articles.ts
|
|
5
10
|
import fs from "node:fs";
|
|
@@ -117,6 +122,7 @@ async function main() {
|
|
|
117
122
|
);
|
|
118
123
|
}
|
|
119
124
|
} catch (error) {
|
|
125
|
+
reportCliError(error, "validate-json-articles");
|
|
120
126
|
if (error instanceof SyntaxError) {
|
|
121
127
|
allIssues.push({
|
|
122
128
|
file: fileName,
|
|
@@ -137,10 +143,7 @@ async function main() {
|
|
|
137
143
|
displayResults(allIssues);
|
|
138
144
|
const errorCount = allIssues.filter((i) => i.level === "error").length;
|
|
139
145
|
if (errorCount > 0) {
|
|
140
|
-
process.
|
|
146
|
+
process.exitCode = 1;
|
|
141
147
|
}
|
|
142
148
|
}
|
|
143
|
-
main
|
|
144
|
-
console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
|
|
145
|
-
process.exit(1);
|
|
146
|
-
});
|
|
149
|
+
await runCli("validate-json-articles", main);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s-hirano-ist/s-scripts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "CLI scripts for s-private data operations",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "26.x"
|
|
@@ -49,18 +49,20 @@
|
|
|
49
49
|
},
|
|
50
50
|
"license": "AGPL-3.0",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@aws-sdk/client-s3": "3.
|
|
52
|
+
"@aws-sdk/client-s3": "3.1166.0",
|
|
53
53
|
"@googleapis/books": "13.0.1",
|
|
54
54
|
"@prisma/adapter-pg": "7.10.1",
|
|
55
55
|
"@prisma/client-runtime-utils": "7.10.1",
|
|
56
56
|
"@qdrant/js-client-rest": "1.20.0",
|
|
57
|
+
"@sentry/node": "11.12.0",
|
|
57
58
|
"cheerio": "1.2.0",
|
|
58
59
|
"js-yaml": "5.5.0",
|
|
59
|
-
"oxfmt": "0.
|
|
60
|
+
"oxfmt": "0.78.0",
|
|
61
|
+
"pino": "10.4.0",
|
|
60
62
|
"sharp": "0.35.5",
|
|
61
63
|
"turndown": "7.2.5",
|
|
62
64
|
"uuid": "14.0.3",
|
|
63
|
-
"web-push": "
|
|
65
|
+
"web-push": "4.0.0",
|
|
64
66
|
"zod": "4.6.7"
|
|
65
67
|
},
|
|
66
68
|
"publishConfig": {
|
package/dist/chunk-7PVU2Z32.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// ../notification/dist/errors.js
|
|
4
|
-
var NotificationError = class extends Error {
|
|
5
|
-
constructor(message = "notificationSend") {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "NotificationError";
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// ../notification/dist/pushover.js
|
|
12
|
-
var PushoverService = class {
|
|
13
|
-
config;
|
|
14
|
-
constructor(config) {
|
|
15
|
-
this.config = config;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Sends a message to the Pushover API.
|
|
19
|
-
*
|
|
20
|
-
* @param message - The message to send
|
|
21
|
-
* @param priority - The priority level (-1 = low, 0 = normal, 1 = high)
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
async sendMessage(message, priority = 0) {
|
|
26
|
-
try {
|
|
27
|
-
const body = new URLSearchParams({
|
|
28
|
-
token: this.config.appToken,
|
|
29
|
-
user: this.config.userKey,
|
|
30
|
-
message,
|
|
31
|
-
priority: String(priority)
|
|
32
|
-
});
|
|
33
|
-
const result = await fetch(this.config.url, {
|
|
34
|
-
method: "POST",
|
|
35
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
36
|
-
body
|
|
37
|
-
});
|
|
38
|
-
if (!result.ok) {
|
|
39
|
-
throw new NotificationError();
|
|
40
|
-
}
|
|
41
|
-
} catch (error) {
|
|
42
|
-
if (error instanceof NotificationError) {
|
|
43
|
-
console.error(`[NotificationService] Failed to send notification: ${error.message}`);
|
|
44
|
-
} else {
|
|
45
|
-
console.error("[NotificationService] Unknown error occurred while sending notification:", error);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async notifyError(message, context) {
|
|
50
|
-
const enrichedMessage = `[ERROR] ${context.caller}: ${message}`;
|
|
51
|
-
await this.sendMessage(enrichedMessage, 1);
|
|
52
|
-
}
|
|
53
|
-
async notifyWarning(message, context) {
|
|
54
|
-
const enrichedMessage = `[WARN] ${context.caller}: ${message}`;
|
|
55
|
-
await this.sendMessage(enrichedMessage, 0);
|
|
56
|
-
}
|
|
57
|
-
async notifyInfo(message, context) {
|
|
58
|
-
const enrichedMessage = `[INFO] ${context.caller}: ${message}`;
|
|
59
|
-
await this.sendMessage(enrichedMessage, -1);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
function createPushoverService(config) {
|
|
63
|
-
return new PushoverService(config);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ../notification/dist/web-push.js
|
|
67
|
-
import webPush from "web-push";
|
|
68
|
-
|
|
69
|
-
export {
|
|
70
|
-
createPushoverService
|
|
71
|
-
};
|