@s-hirano-ist/s-scripts 4.2.0 → 4.4.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.
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
3
- import {
4
- createObjectStorageClient
5
- } from "./chunk-M6LFKOUH.js";
6
- import {
7
- createPushoverService
8
- } from "./chunk-7PVU2Z32.js";
9
3
  import {
10
4
  globPaths
11
5
  } from "./chunk-AJMTRCPJ.js";
6
+ import {
7
+ createObjectStorageClient
8
+ } from "./chunk-MVYAZJB2.js";
9
+ import {
10
+ cliNotifications,
11
+ reportCliError,
12
+ runCli
13
+ } from "./chunk-KKWRXAAY.js";
12
14
  import "./chunk-JZOR5GA2.js";
13
15
 
14
16
  // src/cleanup-minio-images.ts
@@ -26,93 +28,72 @@ function listObjects(client, bucket, prefix) {
26
28
  async function main() {
27
29
  const dryRun = process.argv.includes("--dry-run");
28
30
  const env = {
29
- PUSHOVER_URL: process.env.PUSHOVER_URL,
30
- PUSHOVER_USER_KEY: process.env.PUSHOVER_USER_KEY,
31
- PUSHOVER_APP_TOKEN: process.env.PUSHOVER_APP_TOKEN,
32
31
  S3_BUCKET_NAME: process.env.S3_BUCKET_NAME
33
32
  };
34
33
  if (Object.values(env).some((v) => !v)) {
35
34
  throw new Error("Required environment variables are not set.");
36
35
  }
37
36
  const contentsPath = process.env.S_CONTENTS_PATH ?? process.cwd();
38
- const notificationService = createPushoverService({
39
- url: env.PUSHOVER_URL ?? "",
40
- userKey: env.PUSHOVER_USER_KEY ?? "",
41
- appToken: env.PUSHOVER_APP_TOKEN ?? ""
42
- });
37
+ const notificationService = cliNotifications;
43
38
  const storageClient = createObjectStorageClient();
44
39
  const bucketName = env.S3_BUCKET_NAME ?? "";
45
- try {
46
- const localFiles = await globPaths(`${contentsPath}/image/dump/*`);
47
- const localFileNames = new Set(
48
- localFiles.filter((f) => isImageFile(f)).map((f) => basename(f))
49
- );
50
- console.log(
51
- `\u{1F4C1} \u30ED\u30FC\u30AB\u30EB\u306B ${localFileNames.size} \u4EF6\u306E\u753B\u50CF\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u51FA\u3057\u307E\u3057\u305F\u3002`
52
- );
53
- const [originalKeys, thumbnailKeys] = await Promise.all([
54
- listObjects(storageClient, bucketName, `${ORIGINAL_IMAGE_PATH}/`),
55
- listObjects(storageClient, bucketName, `${THUMBNAIL_IMAGE_PATH}/`)
56
- ]);
57
- console.log(
58
- `\u{1F4E6} S3: original ${originalKeys.length} \u4EF6, thumbnail ${thumbnailKeys.length} \u4EF6`
59
- );
60
- const orphanedOriginals = originalKeys.filter(
61
- (key) => !localFileNames.has(basename(key))
62
- );
63
- const orphanedThumbnails = thumbnailKeys.filter(
64
- (key) => !localFileNames.has(basename(key))
65
- );
66
- const totalOrphaned = orphanedOriginals.length + orphanedThumbnails.length;
67
- if (totalOrphaned === 0) {
68
- console.log("\u2705 \u5B64\u7ACB\u30D5\u30A1\u30A4\u30EB\u306A\u3057");
69
- if (!dryRun)
70
- await notificationService.notifyInfo(
71
- `${SCRIPT_NAME} completed: no orphaned files`,
72
- { caller: SCRIPT_NAME }
73
- );
74
- return;
75
- }
76
- console.log(
77
- `\u{1F5D1}\uFE0F \u5B64\u7ACB\u30D5\u30A1\u30A4\u30EB\u691C\u51FA: original ${orphanedOriginals.length} \u4EF6, thumbnail ${orphanedThumbnails.length} \u4EF6`
78
- );
79
- let deletedCount = 0;
80
- let errorCount = 0;
81
- for (const key of [...orphanedOriginals, ...orphanedThumbnails]) {
82
- try {
83
- if (dryRun) {
84
- console.log(`\u{1F50D} [dry-run] \u524A\u9664\u4E88\u5B9A: ${key}`);
85
- } else {
86
- await storageClient.removeObject(bucketName, key);
87
- console.log(`\u{1F5D1}\uFE0F \u524A\u9664: ${key}`);
88
- }
89
- deletedCount++;
90
- } catch (error) {
91
- console.error(`\u274C \u524A\u9664\u30A8\u30E9\u30FC\uFF08${key}\uFF09:`, error);
92
- errorCount++;
93
- }
94
- }
95
- console.log(
96
- `
97
- \u{1F4CA} \u7D50\u679C: \u524A\u9664 ${deletedCount} \u4EF6, \u30A8\u30E9\u30FC ${errorCount} \u4EF6${dryRun ? " (dry-run)" : ""}`
98
- );
40
+ const localFiles = await globPaths(`${contentsPath}/image/dump/*`);
41
+ const localFileNames = new Set(
42
+ localFiles.filter((f) => isImageFile(f)).map((f) => basename(f))
43
+ );
44
+ console.log(
45
+ `\u{1F4C1} \u30ED\u30FC\u30AB\u30EB\u306B ${localFileNames.size} \u4EF6\u306E\u753B\u50CF\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u51FA\u3057\u307E\u3057\u305F\u3002`
46
+ );
47
+ const [originalKeys, thumbnailKeys] = await Promise.all([
48
+ listObjects(storageClient, bucketName, `${ORIGINAL_IMAGE_PATH}/`),
49
+ listObjects(storageClient, bucketName, `${THUMBNAIL_IMAGE_PATH}/`)
50
+ ]);
51
+ console.log(
52
+ `\u{1F4E6} S3: original ${originalKeys.length} \u4EF6, thumbnail ${thumbnailKeys.length} \u4EF6`
53
+ );
54
+ const orphanedOriginals = originalKeys.filter(
55
+ (key) => !localFileNames.has(basename(key))
56
+ );
57
+ const orphanedThumbnails = thumbnailKeys.filter(
58
+ (key) => !localFileNames.has(basename(key))
59
+ );
60
+ const totalOrphaned = orphanedOriginals.length + orphanedThumbnails.length;
61
+ if (totalOrphaned === 0) {
62
+ console.log("\u2705 \u5B64\u7ACB\u30D5\u30A1\u30A4\u30EB\u306A\u3057");
99
63
  if (!dryRun)
100
- await notificationService.notifyInfo(`${SCRIPT_NAME} completed`, {
101
- caller: SCRIPT_NAME
102
- });
103
- } catch (error) {
104
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
105
- if (!dryRun)
106
- await notificationService.notifyError(
107
- `${SCRIPT_NAME} failed: ${String(error)}`,
108
- {
109
- caller: SCRIPT_NAME
110
- }
64
+ await notificationService.notifyInfo(
65
+ `${SCRIPT_NAME} completed: no orphaned files`,
66
+ { caller: SCRIPT_NAME }
111
67
  );
112
- process.exit(1);
68
+ return;
113
69
  }
70
+ console.log(
71
+ `\u{1F5D1}\uFE0F \u5B64\u7ACB\u30D5\u30A1\u30A4\u30EB\u691C\u51FA: original ${orphanedOriginals.length} \u4EF6, thumbnail ${orphanedThumbnails.length} \u4EF6`
72
+ );
73
+ let deletedCount = 0;
74
+ let errorCount = 0;
75
+ for (const key of [...orphanedOriginals, ...orphanedThumbnails]) {
76
+ try {
77
+ if (dryRun) {
78
+ console.log(`\u{1F50D} [dry-run] \u524A\u9664\u4E88\u5B9A: ${key}`);
79
+ } else {
80
+ await storageClient.removeObject(bucketName, key);
81
+ console.log(`\u{1F5D1}\uFE0F \u524A\u9664: ${key}`);
82
+ }
83
+ deletedCount++;
84
+ } catch (error) {
85
+ reportCliError(error, "cleanup-minio-images");
86
+ console.error(`\u274C \u524A\u9664\u30A8\u30E9\u30FC\uFF08${key}\uFF09:`, error);
87
+ errorCount++;
88
+ }
89
+ }
90
+ console.log(
91
+ `
92
+ \u{1F4CA} \u7D50\u679C: \u524A\u9664 ${deletedCount} \u4EF6, \u30A8\u30E9\u30FC ${errorCount} \u4EF6${dryRun ? " (dry-run)" : ""}`
93
+ );
94
+ if (!dryRun)
95
+ await notificationService.notifyInfo(`${SCRIPT_NAME} completed`, {
96
+ caller: SCRIPT_NAME
97
+ });
114
98
  }
115
- main().catch((error) => {
116
- console.error(error);
117
- process.exit(1);
118
- });
99
+ await runCli("cleanup-minio-images", 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-KKWRXAAY.js";
9
13
  import "./chunk-JZOR5GA2.js";
10
14
 
11
15
  // src/enrich-books.ts
@@ -85,6 +89,7 @@ ${body}`;
85
89
  }
86
90
  enrichedCount++;
87
91
  } catch (error) {
92
+ reportCliError(error, "enrich-books");
88
93
  console.error(`\u274C ${fileName}:`, error);
89
94
  errorCount++;
90
95
  }
@@ -94,7 +99,4 @@ ${body}`;
94
99
  \u{1F4CA} \u7D50\u679C: \u66F4\u65B0 ${enrichedCount} \u4EF6, \u30A8\u30E9\u30FC ${errorCount} \u4EF6${dryRun ? " (dry-run)" : ""}`
95
100
  );
96
101
  }
97
- main().catch((error) => {
98
- console.error("\u274C \u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F:", error);
99
- process.exit(1);
100
- });
102
+ await runCli("enrich-books", 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-KKWRXAAY.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-KKWRXAAY.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-KKWRXAAY.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-KKWRXAAY.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-KKWRXAAY.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-KKWRXAAY.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-KKWRXAAY.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-QHM2WC7S.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-KKWRXAAY.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-QHM2WC7S.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-KKWRXAAY.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-QHM2WC7S.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-KKWRXAAY.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-QHM2WC7S.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-KKWRXAAY.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));