@s-hirano-ist/s-scripts 4.1.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.
Files changed (43) hide show
  1. package/README.md +8 -0
  2. package/dist/{chunk-7XX57D7G.js → chunk-3INTMHPH.js} +1 -1
  3. package/dist/chunk-4CXH2QIX.js +445 -0
  4. package/dist/chunk-67LIMNXH.js +36 -0
  5. package/dist/{chunk-OCEV2QX3.js → chunk-BYEEIQ7O.js} +1 -1
  6. package/dist/{chunk-2PZXXOYG.js → chunk-GBQOCN2C.js} +24 -25
  7. package/dist/chunk-MJYGMGH5.js +382 -0
  8. package/dist/chunk-MVYAZJB2.js +160 -0
  9. package/dist/{chunk-DIG75T3J.js → chunk-RLAYINCA.js} +10 -13
  10. package/dist/{chunk-MNBEFEFR.js → chunk-RO5QUZFR.js} +1 -1
  11. package/dist/chunk-SFKQ2RAP.js +87 -0
  12. package/dist/{chunk-FVK44UTM.js → chunk-ZMQUO6OA.js} +1 -1
  13. package/dist/cleanup-minio-images.js +62 -91
  14. package/dist/enrich-books.js +6 -4
  15. package/dist/fetch-articles.js +6 -24
  16. package/dist/fetch-books.js +12 -35
  17. package/dist/fetch-images.js +12 -35
  18. package/dist/fetch-notes.js +6 -24
  19. package/dist/find-duplicate-json-articles.js +11 -13
  20. package/dist/fix-book-frontmatter.js +6 -4
  21. package/dist/fix-image-formats.js +7 -5
  22. package/dist/ingest-articles.js +7 -5
  23. package/dist/ingest-books.js +10 -8
  24. package/dist/ingest-images.js +7 -5
  25. package/dist/ingest-notes.js +10 -8
  26. package/dist/rag/delete-collection.js +5 -30
  27. package/dist/rag/ingest.js +5 -379
  28. package/dist/rag/search.js +5 -84
  29. package/dist/reset-articles.js +8 -23
  30. package/dist/reset-books.js +8 -23
  31. package/dist/reset-images.js +8 -23
  32. package/dist/reset-notes.js +8 -23
  33. package/dist/revert-articles.js +8 -23
  34. package/dist/revert-books.js +8 -23
  35. package/dist/revert-images.js +8 -23
  36. package/dist/revert-notes.js +8 -23
  37. package/dist/s-content-format.js +9 -11
  38. package/dist/update-json-articles.js +19 -41
  39. package/dist/update-raw-articles.js +14 -37
  40. package/dist/validate-json-articles.js +8 -5
  41. package/package.json +13 -11
  42. package/dist/chunk-7PVU2Z32.js +0 -71
  43. package/dist/chunk-F4J6JBR4.js +0 -115
@@ -1,91 +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
- ensureCollection,
5
- search
6
- } from "../chunk-J4VLH4VA.js";
4
+ runCli
5
+ } from "../chunk-4CXH2QIX.js";
7
6
  import "../chunk-JZOR5GA2.js";
8
7
 
9
8
  // src/rag/search.ts
10
- function parseArgs() {
11
- const args = process.argv.slice(2);
12
- const options = {};
13
- const positional = [];
14
- for (let i = 0; i < args.length; i++) {
15
- const arg = args[i];
16
- if (arg === "--top-k" && i + 1 < args.length) {
17
- options.topK = Number(args[++i]);
18
- } else if (arg === "--type" && i + 1 < args.length) {
19
- options.type = args[++i];
20
- } else if (arg === "--heading" && i + 1 < args.length) {
21
- options.heading = args[++i];
22
- } else if (arg === "--content-type" && i + 1 < args.length) {
23
- const value = args[++i];
24
- const types = value.split(",");
25
- options.contentType = types.length === 1 ? types[0] : types;
26
- } else {
27
- positional.push(arg);
28
- }
29
- }
30
- const query = positional.join(" ");
31
- if (!query) {
32
- console.error(
33
- "Usage: rag-search <query> [--top-k N] [--type markdown_note|bookmark_json] [--heading HEADING] [--content-type articles|books|notes]"
34
- );
35
- process.exit(1);
36
- }
37
- return { query, options };
38
- }
39
- async function searchContent(query, options = {}) {
40
- const results = await search(query, {
41
- topK: options.topK,
42
- filter: {
43
- type: options.type,
44
- top_heading: options.heading,
45
- content_type: options.contentType
46
- }
47
- });
48
- return { results, query, totalResults: results.length };
49
- }
50
- async function search2() {
51
- const { query, options } = parseArgs();
52
- console.log(`Searching for: "${query}"`);
53
- if (options.topK) console.log(` top-k: ${options.topK}`);
54
- if (options.type) console.log(` type: ${options.type}`);
55
- if (options.heading) console.log(` heading: ${options.heading}`);
56
- if (options.contentType)
57
- console.log(
58
- ` content-type: ${Array.isArray(options.contentType) ? options.contentType.join(",") : options.contentType}`
59
- );
60
- console.log();
61
- await ensureCollection();
62
- const response = await searchContent(query, options);
63
- console.log(`Found ${response.totalResults} results:
64
- `);
65
- for (const [i, result] of response.results.entries()) {
66
- console.log(`--- Result ${i + 1} (score: ${result.score.toFixed(4)}) ---`);
67
- console.log(`Title: ${result.title}`);
68
- if (result.url) console.log(`URL: ${result.url}`);
69
- console.log(`Type: ${result.type}`);
70
- console.log(`Content-Type: ${result.content_type}`);
71
- console.log(`Heading: ${result.heading_path.join(" > ")}`);
72
- console.log(`
73
- ${result.text}
74
- `);
75
- }
76
- }
77
- async function main() {
78
- if (!process.env.QDRANT_URL) {
79
- throw new Error("QDRANT_URL environment variable is required.");
80
- }
81
- try {
82
- await search2();
83
- } catch (error) {
84
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
85
- process.exit(1);
86
- }
87
- }
88
- main().catch((error) => {
89
- console.error(error);
90
- process.exit(1);
9
+ await runCli("rag-search", async () => {
10
+ const { main } = await import("../chunk-SFKQ2RAP.js");
11
+ await main();
91
12
  });
@@ -3,34 +3,28 @@ import { createRequire as __cliCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  ArticlesBatchApplicationService,
5
5
  createArticlesCommandRepository
6
- } from "./chunk-OCEV2QX3.js";
6
+ } from "./chunk-BYEEIQ7O.js";
7
7
  import {
8
8
  createPrismaClient,
9
9
  makeUserId
10
- } from "./chunk-DIG75T3J.js";
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/reset-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 = createPushoverService({
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 resetArticles() {
36
30
  const commandRepository = createArticlesCommandRepository(prisma);
@@ -45,18 +39,9 @@ async function main() {
45
39
  await resetArticles();
46
40
  await notificationService.notifyInfo("reset-articles completed", {
47
41
  caller: "reset-articles"
48
- }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
49
- } catch (error) {
50
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
51
- await notificationService.notifyError(`reset-articles failed: ${String(error)}`, {
52
- caller: "reset-articles"
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().catch((error) => {
60
- console.error(error);
61
- process.exit(1);
62
- });
47
+ await runCli("reset-articles", main);
@@ -3,34 +3,28 @@ import { createRequire as __cliCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  BooksBatchApplicationService,
5
5
  createBooksCommandRepository
6
- } from "./chunk-MNBEFEFR.js";
6
+ } from "./chunk-RO5QUZFR.js";
7
7
  import {
8
8
  createPrismaClient,
9
9
  makeUserId
10
- } from "./chunk-DIG75T3J.js";
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/reset-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 = createPushoverService({
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 resetBooks() {
36
30
  const commandRepository = createBooksCommandRepository(prisma);
@@ -45,18 +39,9 @@ async function main() {
45
39
  await resetBooks();
46
40
  await notificationService.notifyInfo("reset-books completed", {
47
41
  caller: "reset-books"
48
- }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
49
- } catch (error) {
50
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
51
- await notificationService.notifyError(`reset-books failed: ${String(error)}`, {
52
- caller: "reset-books"
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().catch((error) => {
60
- console.error(error);
61
- process.exit(1);
62
- });
47
+ await runCli("reset-books", main);
@@ -3,34 +3,28 @@ import { createRequire as __cliCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  ImagesBatchApplicationService,
5
5
  createImagesCommandRepository
6
- } from "./chunk-FVK44UTM.js";
6
+ } from "./chunk-ZMQUO6OA.js";
7
7
  import {
8
8
  createPrismaClient,
9
9
  makeUserId
10
- } from "./chunk-DIG75T3J.js";
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/reset-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 = createPushoverService({
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 resetImages() {
36
30
  const commandRepository = createImagesCommandRepository(prisma);
@@ -45,18 +39,9 @@ async function main() {
45
39
  await resetImages();
46
40
  await notificationService.notifyInfo("reset-images completed", {
47
41
  caller: "reset-images"
48
- }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
49
- } catch (error) {
50
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
51
- await notificationService.notifyError(`reset-images failed: ${String(error)}`, {
52
- caller: "reset-images"
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().catch((error) => {
60
- console.error(error);
61
- process.exit(1);
62
- });
47
+ await runCli("reset-images", main);
@@ -3,34 +3,28 @@ import { createRequire as __cliCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  NotesBatchApplicationService,
5
5
  createNotesCommandRepository
6
- } from "./chunk-7XX57D7G.js";
6
+ } from "./chunk-3INTMHPH.js";
7
7
  import {
8
8
  createPrismaClient,
9
9
  makeUserId
10
- } from "./chunk-DIG75T3J.js";
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/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 = createPushoverService({
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
- }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
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().catch((error) => {
60
- console.error(error);
61
- process.exit(1);
62
- });
47
+ await runCli("reset-notes", main);
@@ -3,34 +3,28 @@ import { createRequire as __cliCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  ArticlesBatchApplicationService,
5
5
  createArticlesCommandRepository
6
- } from "./chunk-OCEV2QX3.js";
6
+ } from "./chunk-BYEEIQ7O.js";
7
7
  import {
8
8
  createPrismaClient,
9
9
  makeUserId
10
- } from "./chunk-DIG75T3J.js";
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/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 = createPushoverService({
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
- }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
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().catch((error) => {
56
- console.error(error);
57
- process.exit(1);
58
- });
43
+ await runCli("revert-articles", main);
@@ -3,34 +3,28 @@ import { createRequire as __cliCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  BooksBatchApplicationService,
5
5
  createBooksCommandRepository
6
- } from "./chunk-MNBEFEFR.js";
6
+ } from "./chunk-RO5QUZFR.js";
7
7
  import {
8
8
  createPrismaClient,
9
9
  makeUserId
10
- } from "./chunk-DIG75T3J.js";
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/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 = createPushoverService({
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
- }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
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().catch((error) => {
56
- console.error(error);
57
- process.exit(1);
58
- });
43
+ await runCli("revert-books", main);
@@ -3,34 +3,28 @@ import { createRequire as __cliCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  ImagesBatchApplicationService,
5
5
  createImagesCommandRepository
6
- } from "./chunk-FVK44UTM.js";
6
+ } from "./chunk-ZMQUO6OA.js";
7
7
  import {
8
8
  createPrismaClient,
9
9
  makeUserId
10
- } from "./chunk-DIG75T3J.js";
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/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 = createPushoverService({
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
- }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
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().catch((error) => {
56
- console.error(error);
57
- process.exit(1);
58
- });
43
+ await runCli("revert-images", main);
@@ -3,34 +3,28 @@ import { createRequire as __cliCreateRequire } from "node:module"; const require
3
3
  import {
4
4
  NotesBatchApplicationService,
5
5
  createNotesCommandRepository
6
- } from "./chunk-7XX57D7G.js";
6
+ } from "./chunk-3INTMHPH.js";
7
7
  import {
8
8
  createPrismaClient,
9
9
  makeUserId
10
- } from "./chunk-DIG75T3J.js";
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/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 = createPushoverService({
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
- }).catch((error) => console.error("\u901A\u77E5\u5931\u6557:", error));
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().catch((error) => {
56
- console.error(error);
57
- process.exit(1);
58
- });
43
+ await runCli("revert-notes", main);
@@ -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
- try {
97
- const { code, signal } = await runContentFormat(process.argv.slice(2));
98
- if (signal !== null) {
99
- process.kill(process.pid, signal);
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
- void main();
106
+ await runCli("s-content-format", main);