@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.
@@ -6,8 +6,9 @@ import {
6
6
  makeUserId
7
7
  } from "./chunk-RLAYINCA.js";
8
8
  import {
9
- createPushoverService
10
- } from "./chunk-7PVU2Z32.js";
9
+ cliNotifications,
10
+ runCli
11
+ } from "./chunk-4CXH2QIX.js";
11
12
  import "./chunk-JZOR5GA2.js";
12
13
 
13
14
  // src/fetch-articles.ts
@@ -50,20 +51,13 @@ async function exportData(data) {
50
51
  async function main() {
51
52
  const env = {
52
53
  DATABASE_URL: process.env.DATABASE_URL,
53
- PUSHOVER_URL: process.env.PUSHOVER_URL,
54
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
55
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
56
54
  USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
57
55
  };
58
56
  if (Object.values(env).some((v) => !v)) {
59
57
  throw new Error("Required environment variables are not set.");
60
58
  }
61
59
  const prisma = createPrismaClient(env.DATABASE_URL ?? "");
62
- const notificationService = createPushoverService({
63
- url: env.PUSHOVER_URL ?? "",
64
- userKey: env.PUSHOVER_USER_KEY ?? "",
65
- appToken: env.PUSHOVER_APP_TOKEN ?? ""
66
- });
60
+ const notificationService = cliNotifications;
67
61
  const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
68
62
  const UNEXPORTED = makeUnexportedStatus();
69
63
  async function fetchArticles() {
@@ -96,20 +90,8 @@ async function main() {
96
90
  await notificationService.notifyInfo("fetch-articles completed", {
97
91
  caller: "fetch-articles"
98
92
  });
99
- } catch (error) {
100
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
101
- await notificationService.notifyError(
102
- `fetch-articles failed: ${String(error)}`,
103
- {
104
- caller: "fetch-articles"
105
- }
106
- );
107
- process.exit(1);
108
93
  } finally {
109
94
  await prisma.$disconnect();
110
95
  }
111
96
  }
112
- main().catch((error) => {
113
- console.error(error);
114
- process.exit(1);
115
- });
97
+ await runCli("fetch-articles", main);
@@ -2,15 +2,16 @@
2
2
  import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
3
  import {
4
4
  createObjectStorageClient
5
- } from "./chunk-M6LFKOUH.js";
5
+ } from "./chunk-MVYAZJB2.js";
6
6
  import {
7
7
  createPrismaClient,
8
8
  makeUnexportedStatus,
9
9
  makeUserId
10
10
  } from "./chunk-RLAYINCA.js";
11
11
  import {
12
- createPushoverService
13
- } from "./chunk-7PVU2Z32.js";
12
+ cliNotifications,
13
+ runCli
14
+ } from "./chunk-4CXH2QIX.js";
14
15
  import "./chunk-JZOR5GA2.js";
15
16
 
16
17
  // src/fetch-books.ts
@@ -77,9 +78,6 @@ ${frontmatter}---
77
78
  async function main() {
78
79
  const env = {
79
80
  DATABASE_URL: process.env.DATABASE_URL,
80
- PUSHOVER_URL: process.env.PUSHOVER_URL,
81
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
82
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
83
81
  USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT,
84
82
  S3_BUCKET_NAME: process.env.S3_BUCKET_NAME
85
83
  };
@@ -87,11 +85,7 @@ async function main() {
87
85
  throw new Error("Required environment variables are not set.");
88
86
  }
89
87
  const prisma = createPrismaClient(env.DATABASE_URL ?? "");
90
- const notificationService = createPushoverService({
91
- url: env.PUSHOVER_URL ?? "",
92
- userKey: env.PUSHOVER_USER_KEY ?? "",
93
- appToken: env.PUSHOVER_APP_TOKEN ?? ""
94
- });
88
+ const notificationService = cliNotifications;
95
89
  const storageClient = createObjectStorageClient();
96
90
  const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
97
91
  const UNEXPORTED = makeUnexportedStatus();
@@ -142,20 +136,8 @@ async function main() {
142
136
  await notificationService.notifyInfo("fetch-books completed", {
143
137
  caller: "fetch-books"
144
138
  });
145
- } catch (error) {
146
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
147
- await notificationService.notifyError(
148
- `fetch-books failed: ${String(error)}`,
149
- {
150
- caller: "fetch-books"
151
- }
152
- );
153
- process.exit(1);
154
139
  } finally {
155
140
  await prisma.$disconnect();
156
141
  }
157
142
  }
158
- main().catch((error) => {
159
- console.error(error);
160
- process.exit(1);
161
- });
143
+ await runCli("fetch-books", main);
@@ -2,15 +2,16 @@
2
2
  import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
3
  import {
4
4
  createObjectStorageClient
5
- } from "./chunk-M6LFKOUH.js";
5
+ } from "./chunk-MVYAZJB2.js";
6
6
  import {
7
7
  createPrismaClient,
8
8
  makeUnexportedStatus,
9
9
  makeUserId
10
10
  } from "./chunk-RLAYINCA.js";
11
11
  import {
12
- createPushoverService
13
- } from "./chunk-7PVU2Z32.js";
12
+ cliNotifications,
13
+ runCli
14
+ } from "./chunk-4CXH2QIX.js";
14
15
  import "./chunk-JZOR5GA2.js";
15
16
 
16
17
  // src/fetch-images.ts
@@ -33,9 +34,6 @@ async function withRetry(fn, retries = 3) {
33
34
  async function main() {
34
35
  const env = {
35
36
  DATABASE_URL: process.env.DATABASE_URL,
36
- PUSHOVER_URL: process.env.PUSHOVER_URL,
37
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
38
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
39
37
  USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT,
40
38
  S3_BUCKET_NAME: process.env.S3_BUCKET_NAME
41
39
  };
@@ -43,11 +41,7 @@ async function main() {
43
41
  throw new Error("Required environment variables are not set.");
44
42
  }
45
43
  const prisma = createPrismaClient(env.DATABASE_URL ?? "");
46
- const notificationService = createPushoverService({
47
- url: env.PUSHOVER_URL ?? "",
48
- userKey: env.PUSHOVER_USER_KEY ?? "",
49
- appToken: env.PUSHOVER_APP_TOKEN ?? ""
50
- });
44
+ const notificationService = cliNotifications;
51
45
  const storageClient = createObjectStorageClient();
52
46
  const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
53
47
  const UNEXPORTED = makeUnexportedStatus();
@@ -77,20 +71,8 @@ async function main() {
77
71
  await notificationService.notifyInfo("fetch-images completed", {
78
72
  caller: "fetch-images"
79
73
  });
80
- } catch (error) {
81
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
82
- await notificationService.notifyError(
83
- `fetch-images failed: ${String(error)}`,
84
- {
85
- caller: "fetch-images"
86
- }
87
- );
88
- process.exit(1);
89
74
  } finally {
90
75
  await prisma.$disconnect();
91
76
  }
92
77
  }
93
- main().catch((error) => {
94
- console.error(error);
95
- process.exit(1);
96
- });
78
+ await runCli("fetch-images", main);
@@ -6,8 +6,9 @@ import {
6
6
  makeUserId
7
7
  } from "./chunk-RLAYINCA.js";
8
8
  import {
9
- createPushoverService
10
- } from "./chunk-7PVU2Z32.js";
9
+ cliNotifications,
10
+ runCli
11
+ } from "./chunk-4CXH2QIX.js";
11
12
  import "./chunk-JZOR5GA2.js";
12
13
 
13
14
  // src/fetch-notes.ts
@@ -27,20 +28,13 @@ ${item.markdown}
27
28
  async function main() {
28
29
  const env = {
29
30
  DATABASE_URL: process.env.DATABASE_URL,
30
- PUSHOVER_URL: process.env.PUSHOVER_URL,
31
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
32
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
33
31
  USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
34
32
  };
35
33
  if (Object.values(env).some((v) => !v)) {
36
34
  throw new Error("Required environment variables are not set.");
37
35
  }
38
36
  const prisma = createPrismaClient(env.DATABASE_URL ?? "");
39
- const notificationService = createPushoverService({
40
- url: env.PUSHOVER_URL ?? "",
41
- userKey: env.PUSHOVER_USER_KEY ?? "",
42
- appToken: env.PUSHOVER_APP_TOKEN ?? ""
43
- });
37
+ const notificationService = cliNotifications;
44
38
  const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
45
39
  const UNEXPORTED = makeUnexportedStatus();
46
40
  async function fetchNotes() {
@@ -57,20 +51,8 @@ async function main() {
57
51
  await notificationService.notifyInfo("fetch-notes completed", {
58
52
  caller: "fetch-notes"
59
53
  });
60
- } catch (error) {
61
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
62
- await notificationService.notifyError(
63
- `fetch-notes failed: ${String(error)}`,
64
- {
65
- caller: "fetch-notes"
66
- }
67
- );
68
- process.exit(1);
69
54
  } finally {
70
55
  await prisma.$disconnect();
71
56
  }
72
57
  }
73
- main().catch((error) => {
74
- console.error(error);
75
- process.exit(1);
76
- });
58
+ await runCli("fetch-notes", 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/find-duplicate-json-articles.ts
5
10
  import fs from "node:fs";
@@ -42,6 +47,7 @@ function findDuplicateUrls() {
42
47
  }
43
48
  }
44
49
  } catch (error) {
50
+ reportCliError(error, "find-duplicate-json-articles");
45
51
  console.error(`\u30A8\u30E9\u30FC: ${fileName} \u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F:`, error);
46
52
  }
47
53
  }
@@ -104,17 +110,9 @@ function displayResults(duplicates) {
104
110
  });
105
111
  }
106
112
  async function main() {
107
- try {
108
- console.log("json/article\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u5185\u306EURL\u91CD\u8907\u3092\u691C\u7D22\u4E2D...\n");
109
- const duplicates = findDuplicateUrls();
110
- displayResults(duplicates);
111
- console.log("\n\u691C\u7D22\u5B8C\u4E86");
112
- } catch (error) {
113
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
114
- process.exit(1);
115
- }
113
+ console.log("json/article\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u5185\u306EURL\u91CD\u8907\u3092\u691C\u7D22\u4E2D...\n");
114
+ const duplicates = findDuplicateUrls();
115
+ displayResults(duplicates);
116
+ console.log("\n\u691C\u7D22\u5B8C\u4E86");
116
117
  }
117
- main().catch((error) => {
118
- console.error(error);
119
- process.exit(1);
120
- });
118
+ await runCli("find-duplicate-json-articles", main);
@@ -6,6 +6,10 @@ import {
6
6
  import {
7
7
  globPaths
8
8
  } from "./chunk-AJMTRCPJ.js";
9
+ import {
10
+ reportCliError,
11
+ runCli
12
+ } from "./chunk-4CXH2QIX.js";
9
13
  import "./chunk-JZOR5GA2.js";
10
14
 
11
15
  // src/fix-book-frontmatter.ts
@@ -94,6 +98,7 @@ ${body}`;
94
98
  }
95
99
  return "fixed";
96
100
  } catch (error) {
101
+ reportCliError(error, "fix-book-frontmatter");
97
102
  console.error(`\u274C ${fileName}: ${String(error)}`);
98
103
  return "error";
99
104
  }
@@ -127,7 +132,4 @@ async function main() {
127
132
  \u{1F4CA} \u7D50\u679C: \u4FEE\u6B63 ${fixedCount} \u4EF6, \u30B9\u30AD\u30C3\u30D7 ${skippedCount} \u4EF6, \u30A8\u30E9\u30FC ${errorCount} \u4EF6${dryRun ? " (dry-run)" : ""}`
128
133
  );
129
134
  }
130
- main().catch((error) => {
131
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
132
- process.exit(1);
133
- });
135
+ await runCli("fix-book-frontmatter", main);
@@ -6,6 +6,10 @@ import {
6
6
  import {
7
7
  globPaths
8
8
  } from "./chunk-AJMTRCPJ.js";
9
+ import {
10
+ reportCliError,
11
+ runCli
12
+ } from "./chunk-4CXH2QIX.js";
9
13
  import "./chunk-JZOR5GA2.js";
10
14
 
11
15
  // src/fix-image-formats.ts
@@ -64,6 +68,7 @@ async function processDirectory(directory, label, dryRun) {
64
68
  console.log(`\u2705 \u5909\u63DB\u5B8C\u4E86: ${fileName} \u2192 ${basename(outputPath)}`);
65
69
  converted++;
66
70
  } catch (error) {
71
+ reportCliError(error, "fix-image-formats");
67
72
  console.error(`\u274C ${fileName}: ${String(error)}`);
68
73
  errors++;
69
74
  }
@@ -87,10 +92,7 @@ async function main() {
87
92
  \u{1F4CA} \u5408\u8A08: \u5909\u63DB ${converted} \u4EF6, \u30B9\u30AD\u30C3\u30D7 ${skipped} \u4EF6, \u30A8\u30E9\u30FC ${errors} \u4EF6${dryRun ? " (dry-run)" : ""}`
88
93
  );
89
94
  if (errors > 0) {
90
- process.exit(1);
95
+ process.exitCode = 1;
91
96
  }
92
97
  }
93
- main().catch((error) => {
94
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
95
- process.exit(1);
96
- });
98
+ await runCli("fix-image-formats", main);
@@ -5,14 +5,16 @@ import {
5
5
  } from "./chunk-IYGLKY27.js";
6
6
  import {
7
7
  runContentImport
8
- } from "./chunk-R5EI7JXR.js";
8
+ } from "./chunk-GBQOCN2C.js";
9
9
  import "./chunk-KKZP7ZF3.js";
10
- import "./chunk-M6LFKOUH.js";
11
- import "./chunk-RLAYINCA.js";
12
- import "./chunk-7PVU2Z32.js";
13
10
  import {
14
11
  globPaths
15
12
  } from "./chunk-AJMTRCPJ.js";
13
+ import "./chunk-MVYAZJB2.js";
14
+ import "./chunk-RLAYINCA.js";
15
+ import {
16
+ runCli
17
+ } from "./chunk-4CXH2QIX.js";
16
18
  import "./chunk-JZOR5GA2.js";
17
19
 
18
20
  // src/ingest-articles.ts
@@ -33,4 +35,4 @@ async function* source(root) {
33
35
  };
34
36
  }
35
37
  }
36
- await runContentImport("articles", source);
38
+ await runCli("ingest-articles", () => runContentImport("articles", source));
@@ -1,19 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
+ import {
4
+ parseMarkdownFrontmatter
5
+ } from "./chunk-HDYQV2Y2.js";
3
6
  import {
4
7
  makeISBN,
5
8
  runContentImport
6
- } from "./chunk-R5EI7JXR.js";
9
+ } from "./chunk-GBQOCN2C.js";
7
10
  import "./chunk-KKZP7ZF3.js";
8
- import "./chunk-M6LFKOUH.js";
9
- import "./chunk-RLAYINCA.js";
10
- import "./chunk-7PVU2Z32.js";
11
- import {
12
- parseMarkdownFrontmatter
13
- } from "./chunk-HDYQV2Y2.js";
14
11
  import {
15
12
  globPaths
16
13
  } from "./chunk-AJMTRCPJ.js";
14
+ import "./chunk-MVYAZJB2.js";
15
+ import "./chunk-RLAYINCA.js";
16
+ import {
17
+ runCli
18
+ } from "./chunk-4CXH2QIX.js";
17
19
  import "./chunk-JZOR5GA2.js";
18
20
 
19
21
  // src/ingest-books.ts
@@ -65,4 +67,4 @@ async function* source(root) {
65
67
  };
66
68
  }
67
69
  }
68
- await runContentImport("books", source);
70
+ await runCli("ingest-books", () => runContentImport("books", source));
@@ -3,14 +3,16 @@ import { createRequire as __cliCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  runContentImport,
5
5
  sharpImageProcessor
6
- } from "./chunk-R5EI7JXR.js";
6
+ } from "./chunk-GBQOCN2C.js";
7
7
  import "./chunk-KKZP7ZF3.js";
8
- import "./chunk-M6LFKOUH.js";
9
- import "./chunk-RLAYINCA.js";
10
- import "./chunk-7PVU2Z32.js";
11
8
  import {
12
9
  globPaths
13
10
  } from "./chunk-AJMTRCPJ.js";
11
+ import "./chunk-MVYAZJB2.js";
12
+ import "./chunk-RLAYINCA.js";
13
+ import {
14
+ runCli
15
+ } from "./chunk-4CXH2QIX.js";
14
16
  import "./chunk-JZOR5GA2.js";
15
17
 
16
18
  // src/ingest-images.ts
@@ -34,4 +36,4 @@ async function* source(root) {
34
36
  };
35
37
  }
36
38
  }
37
- await runContentImport("images", source);
39
+ await runCli("ingest-images", () => runContentImport("images", source));
@@ -1,18 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
- import {
4
- runContentImport
5
- } from "./chunk-R5EI7JXR.js";
6
- import "./chunk-KKZP7ZF3.js";
7
- import "./chunk-M6LFKOUH.js";
8
- import "./chunk-RLAYINCA.js";
9
- import "./chunk-7PVU2Z32.js";
10
3
  import {
11
4
  parseMarkdownFrontmatter
12
5
  } from "./chunk-HDYQV2Y2.js";
6
+ import {
7
+ runContentImport
8
+ } from "./chunk-GBQOCN2C.js";
9
+ import "./chunk-KKZP7ZF3.js";
13
10
  import {
14
11
  globPaths
15
12
  } from "./chunk-AJMTRCPJ.js";
13
+ import "./chunk-MVYAZJB2.js";
14
+ import "./chunk-RLAYINCA.js";
15
+ import {
16
+ runCli
17
+ } from "./chunk-4CXH2QIX.js";
16
18
  import "./chunk-JZOR5GA2.js";
17
19
 
18
20
  // src/ingest-notes.ts
@@ -46,4 +48,4 @@ async function* source(root) {
46
48
  if (values) yield { values };
47
49
  }
48
50
  }
49
- await runContentImport("notes", source);
51
+ await runCli("ingest-notes", () => runContentImport("notes", source));
@@ -1,37 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
3
  import {
4
- deleteCollection,
5
- getQdrantClient
6
- } from "../chunk-J4VLH4VA.js";
4
+ runCli
5
+ } from "../chunk-4CXH2QIX.js";
7
6
  import "../chunk-JZOR5GA2.js";
8
7
 
9
8
  // src/rag/delete-collection.ts
10
- async function main() {
11
- const collectionName = process.argv[2];
12
- if (!collectionName) {
13
- console.error(
14
- "Usage: rag-delete-collection <collection-name>\nExample: rag-delete-collection knowledge_v1"
15
- );
16
- process.exit(1);
17
- }
18
- if (!process.env.QDRANT_URL) {
19
- throw new Error("QDRANT_URL environment variable is required.");
20
- }
21
- const qdrant = getQdrantClient();
22
- const collections = await qdrant.getCollections();
23
- const exists = collections.collections.some((c) => c.name === collectionName);
24
- if (!exists) {
25
- console.log(
26
- `Collection "${collectionName}" does not exist. Nothing to delete.`
27
- );
28
- return;
29
- }
30
- console.log(`Deleting collection "${collectionName}"...`);
31
- await deleteCollection(collectionName);
32
- console.log(`Collection "${collectionName}" deleted successfully.`);
33
- }
34
- main().catch((error) => {
35
- console.error("Failed to delete collection:", error);
36
- process.exit(1);
9
+ await runCli("rag-delete-collection", async () => {
10
+ const { main } = await import("../chunk-67LIMNXH.js");
11
+ await main();
37
12
  });