@s-hirano-ist/s-scripts 1.26.8 → 4.0.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 +2 -0
- package/dist/chunk-5OXUZW2Q.js +590 -0
- package/dist/chunk-7PVU2Z32.js +71 -0
- package/dist/chunk-AJMTRCPJ.js +15 -0
- package/dist/chunk-AZF2R2BF.js +85 -0
- package/dist/chunk-F4J6JBR4.js +115 -0
- package/dist/chunk-HDYQV2Y2.js +58 -0
- package/dist/chunk-HIK7SX34.js +85 -0
- package/dist/chunk-IWNZQXDG.js +7660 -0
- package/dist/chunk-J4VLH4VA.js +267 -0
- package/dist/chunk-JZOR5GA2.js +42 -0
- package/dist/chunk-KKZP7ZF3.js +77 -0
- package/dist/chunk-N6TZF755.js +102 -0
- package/dist/chunk-S5WJ5VXW.js +85 -0
- package/dist/chunk-UXGLXHQ6.js +40 -0
- package/dist/cleanup-minio-images.js +115 -92
- package/dist/enrich-books.js +87 -78
- package/dist/fetch-articles.js +101 -90
- package/dist/fetch-books.js +147 -128
- package/dist/fetch-images.js +88 -72
- package/dist/fetch-notes.js +66 -54
- package/dist/find-duplicate-json-articles.js +100 -97
- package/dist/fix-book-frontmatter.js +111 -99
- package/dist/fix-image-formats.js +81 -65
- package/dist/ingest-articles.js +30 -249
- package/dist/ingest-books.js +61 -318
- package/dist/ingest-images.js +33 -184
- package/dist/ingest-notes.js +41 -171
- package/dist/rag/delete-collection.js +32 -22
- package/dist/rag/ingest.js +371 -92
- package/dist/rag/search.js +80 -76
- package/dist/reset-articles.js +57 -60
- package/dist/reset-books.js +57 -59
- package/dist/reset-images.js +57 -59
- package/dist/reset-notes.js +57 -59
- package/dist/revert-articles.js +53 -55
- package/dist/revert-books.js +53 -53
- package/dist/revert-images.js +53 -53
- package/dist/revert-notes.js +53 -53
- package/dist/s-content-format.js +103 -13
- package/dist/update-json-articles.js +101 -97
- package/dist/update-raw-articles.js +130 -130
- package/dist/validate-json-articles.js +129 -130
- package/package.json +13 -50
- package/dist/cleanup-minio-images.d.ts +0 -3
- package/dist/cleanup-minio-images.d.ts.map +0 -1
- package/dist/cleanup-minio-images.js.map +0 -1
- package/dist/enrich-books.d.ts +0 -3
- package/dist/enrich-books.d.ts.map +0 -1
- package/dist/enrich-books.js.map +0 -1
- package/dist/fetch-articles.d.ts +0 -3
- package/dist/fetch-articles.d.ts.map +0 -1
- package/dist/fetch-articles.js.map +0 -1
- package/dist/fetch-books.d.ts +0 -3
- package/dist/fetch-books.d.ts.map +0 -1
- package/dist/fetch-books.js.map +0 -1
- package/dist/fetch-images.d.ts +0 -3
- package/dist/fetch-images.d.ts.map +0 -1
- package/dist/fetch-images.js.map +0 -1
- package/dist/fetch-notes.d.ts +0 -3
- package/dist/fetch-notes.d.ts.map +0 -1
- package/dist/fetch-notes.js.map +0 -1
- package/dist/find-duplicate-json-articles.d.ts +0 -3
- package/dist/find-duplicate-json-articles.d.ts.map +0 -1
- package/dist/find-duplicate-json-articles.js.map +0 -1
- package/dist/fix-book-frontmatter.d.ts +0 -3
- package/dist/fix-book-frontmatter.d.ts.map +0 -1
- package/dist/fix-book-frontmatter.js.map +0 -1
- package/dist/fix-image-formats.d.ts +0 -3
- package/dist/fix-image-formats.d.ts.map +0 -1
- package/dist/fix-image-formats.js.map +0 -1
- package/dist/infrastructures/articles-command-repository.d.ts +0 -57
- package/dist/infrastructures/articles-command-repository.d.ts.map +0 -1
- package/dist/infrastructures/articles-command-repository.js +0 -68
- package/dist/infrastructures/articles-command-repository.js.map +0 -1
- package/dist/infrastructures/books-command-repository.d.ts +0 -34
- package/dist/infrastructures/books-command-repository.d.ts.map +0 -1
- package/dist/infrastructures/books-command-repository.js +0 -53
- package/dist/infrastructures/books-command-repository.js.map +0 -1
- package/dist/infrastructures/cache-invalidation-client.d.ts +0 -9
- package/dist/infrastructures/cache-invalidation-client.d.ts.map +0 -1
- package/dist/infrastructures/cache-invalidation-client.js +0 -21
- package/dist/infrastructures/cache-invalidation-client.js.map +0 -1
- package/dist/infrastructures/cache-invalidation-client.test.d.ts +0 -2
- package/dist/infrastructures/cache-invalidation-client.test.d.ts.map +0 -1
- package/dist/infrastructures/cache-invalidation-client.test.js +0 -25
- package/dist/infrastructures/cache-invalidation-client.test.js.map +0 -1
- package/dist/infrastructures/images-command-repository.d.ts +0 -34
- package/dist/infrastructures/images-command-repository.d.ts.map +0 -1
- package/dist/infrastructures/images-command-repository.js +0 -53
- package/dist/infrastructures/images-command-repository.js.map +0 -1
- package/dist/infrastructures/notes-command-repository.d.ts +0 -34
- package/dist/infrastructures/notes-command-repository.d.ts.map +0 -1
- package/dist/infrastructures/notes-command-repository.js +0 -53
- package/dist/infrastructures/notes-command-repository.js.map +0 -1
- package/dist/ingest-articles.d.ts +0 -3
- package/dist/ingest-articles.d.ts.map +0 -1
- package/dist/ingest-articles.js.map +0 -1
- package/dist/ingest-books.d.ts +0 -3
- package/dist/ingest-books.d.ts.map +0 -1
- package/dist/ingest-books.js.map +0 -1
- package/dist/ingest-images.d.ts +0 -3
- package/dist/ingest-images.d.ts.map +0 -1
- package/dist/ingest-images.js.map +0 -1
- package/dist/ingest-notes.d.ts +0 -3
- package/dist/ingest-notes.d.ts.map +0 -1
- package/dist/ingest-notes.js.map +0 -1
- package/dist/lib/glob-paths.d.ts +0 -6
- package/dist/lib/glob-paths.d.ts.map +0 -1
- package/dist/lib/glob-paths.js +0 -9
- package/dist/lib/glob-paths.js.map +0 -1
- package/dist/lib/glob-paths.test.d.ts +0 -2
- package/dist/lib/glob-paths.test.d.ts.map +0 -1
- package/dist/lib/glob-paths.test.js +0 -30
- package/dist/lib/glob-paths.test.js.map +0 -1
- package/dist/lib/html-charset.d.ts +0 -4
- package/dist/lib/html-charset.d.ts.map +0 -1
- package/dist/lib/html-charset.js +0 -33
- package/dist/lib/html-charset.js.map +0 -1
- package/dist/lib/html-charset.test.d.ts +0 -2
- package/dist/lib/html-charset.test.d.ts.map +0 -1
- package/dist/lib/html-charset.test.js +0 -27
- package/dist/lib/html-charset.test.js.map +0 -1
- package/dist/rag/delete-collection.d.ts +0 -3
- package/dist/rag/delete-collection.d.ts.map +0 -1
- package/dist/rag/delete-collection.js.map +0 -1
- package/dist/rag/ingest-config.d.ts +0 -8
- package/dist/rag/ingest-config.d.ts.map +0 -1
- package/dist/rag/ingest-config.js +0 -8
- package/dist/rag/ingest-config.js.map +0 -1
- package/dist/rag/ingest.d.ts +0 -3
- package/dist/rag/ingest.d.ts.map +0 -1
- package/dist/rag/ingest.js.map +0 -1
- package/dist/rag/search.d.ts +0 -3
- package/dist/rag/search.d.ts.map +0 -1
- package/dist/rag/search.js.map +0 -1
- package/dist/reset-articles.d.ts +0 -3
- package/dist/reset-articles.d.ts.map +0 -1
- package/dist/reset-articles.js.map +0 -1
- package/dist/reset-books.d.ts +0 -3
- package/dist/reset-books.d.ts.map +0 -1
- package/dist/reset-books.js.map +0 -1
- package/dist/reset-images.d.ts +0 -3
- package/dist/reset-images.d.ts.map +0 -1
- package/dist/reset-images.js.map +0 -1
- package/dist/reset-notes.d.ts +0 -3
- package/dist/reset-notes.d.ts.map +0 -1
- package/dist/reset-notes.js.map +0 -1
- package/dist/revert-articles.d.ts +0 -3
- package/dist/revert-articles.d.ts.map +0 -1
- package/dist/revert-articles.js.map +0 -1
- package/dist/revert-books.d.ts +0 -3
- package/dist/revert-books.d.ts.map +0 -1
- package/dist/revert-books.js.map +0 -1
- package/dist/revert-images.d.ts +0 -3
- package/dist/revert-images.d.ts.map +0 -1
- package/dist/revert-images.js.map +0 -1
- package/dist/revert-notes.d.ts +0 -3
- package/dist/revert-notes.d.ts.map +0 -1
- package/dist/revert-notes.js.map +0 -1
- package/dist/s-content-format-runner.d.ts +0 -10
- package/dist/s-content-format-runner.d.ts.map +0 -1
- package/dist/s-content-format-runner.js +0 -76
- package/dist/s-content-format-runner.js.map +0 -1
- package/dist/s-content-format.d.ts +0 -3
- package/dist/s-content-format.d.ts.map +0 -1
- package/dist/s-content-format.js.map +0 -1
- package/dist/s-content-format.test.d.ts +0 -2
- package/dist/s-content-format.test.d.ts.map +0 -1
- package/dist/s-content-format.test.js +0 -99
- package/dist/s-content-format.test.js.map +0 -1
- package/dist/update-json-articles.d.ts +0 -3
- package/dist/update-json-articles.d.ts.map +0 -1
- package/dist/update-json-articles.js.map +0 -1
- package/dist/update-raw-articles.d.ts +0 -3
- package/dist/update-raw-articles.d.ts.map +0 -1
- package/dist/update-raw-articles.js.map +0 -1
- package/dist/validate-json-articles.d.ts +0 -3
- package/dist/validate-json-articles.d.ts.map +0 -1
- package/dist/validate-json-articles.js.map +0 -1
package/dist/revert-books.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
2
|
+
import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
BooksBatchApplicationService,
|
|
5
|
+
createBooksCommandRepository
|
|
6
|
+
} from "./chunk-AZF2R2BF.js";
|
|
7
|
+
import {
|
|
8
|
+
createPrismaClient,
|
|
9
|
+
makeUserId
|
|
10
|
+
} from "./chunk-IWNZQXDG.js";
|
|
11
|
+
import {
|
|
12
|
+
createPushoverService
|
|
13
|
+
} from "./chunk-7PVU2Z32.js";
|
|
14
|
+
import "./chunk-JZOR5GA2.js";
|
|
15
|
+
|
|
16
|
+
// src/revert-books.ts
|
|
8
17
|
async function main() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
await notificationService.notifyError(`revert-books failed: ${String(error)}`, {
|
|
46
|
-
caller: "revert-books",
|
|
47
|
-
});
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
await prisma.$disconnect();
|
|
52
|
-
}
|
|
18
|
+
const env = {
|
|
19
|
+
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
|
+
USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
|
|
24
|
+
};
|
|
25
|
+
if (Object.values(env).some((v) => !v)) {
|
|
26
|
+
throw new Error("Required environment variables are not set.");
|
|
27
|
+
}
|
|
28
|
+
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
|
+
});
|
|
34
|
+
const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
|
|
35
|
+
try {
|
|
36
|
+
const commandRepository = createBooksCommandRepository(prisma);
|
|
37
|
+
const batchService = new BooksBatchApplicationService(commandRepository);
|
|
38
|
+
const result = await batchService.revertBooks(userId);
|
|
39
|
+
console.log(
|
|
40
|
+
`\u{1F4BE} LAST_UPDATED\u306E\u672C\u3092UNEXPORTED\u306B\u5909\u66F4\u3057\u307E\u3057\u305F\uFF08${result.count}\u4EF6\uFF09`
|
|
41
|
+
);
|
|
42
|
+
await notificationService.notifyInfo("revert-books completed", {
|
|
43
|
+
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;
|
|
51
|
+
} finally {
|
|
52
|
+
await prisma.$disconnect();
|
|
53
|
+
}
|
|
53
54
|
}
|
|
54
55
|
main().catch((error) => {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
console.error(error);
|
|
57
|
+
process.exit(1);
|
|
57
58
|
});
|
|
58
|
-
//# sourceMappingURL=revert-books.js.map
|
package/dist/revert-images.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
2
|
+
import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
ImagesBatchApplicationService,
|
|
5
|
+
createImagesCommandRepository
|
|
6
|
+
} from "./chunk-HIK7SX34.js";
|
|
7
|
+
import {
|
|
8
|
+
createPrismaClient,
|
|
9
|
+
makeUserId
|
|
10
|
+
} from "./chunk-IWNZQXDG.js";
|
|
11
|
+
import {
|
|
12
|
+
createPushoverService
|
|
13
|
+
} from "./chunk-7PVU2Z32.js";
|
|
14
|
+
import "./chunk-JZOR5GA2.js";
|
|
15
|
+
|
|
16
|
+
// src/revert-images.ts
|
|
8
17
|
async function main() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
await notificationService.notifyError(`revert-images failed: ${String(error)}`, {
|
|
46
|
-
caller: "revert-images",
|
|
47
|
-
});
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
await prisma.$disconnect();
|
|
52
|
-
}
|
|
18
|
+
const env = {
|
|
19
|
+
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
|
+
USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
|
|
24
|
+
};
|
|
25
|
+
if (Object.values(env).some((v) => !v)) {
|
|
26
|
+
throw new Error("Required environment variables are not set.");
|
|
27
|
+
}
|
|
28
|
+
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
|
+
});
|
|
34
|
+
const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
|
|
35
|
+
try {
|
|
36
|
+
const commandRepository = createImagesCommandRepository(prisma);
|
|
37
|
+
const batchService = new ImagesBatchApplicationService(commandRepository);
|
|
38
|
+
const result = await batchService.revertImages(userId);
|
|
39
|
+
console.log(
|
|
40
|
+
`\u{1F4BE} LAST_UPDATED\u306E\u753B\u50CF\u3092UNEXPORTED\u306B\u5909\u66F4\u3057\u307E\u3057\u305F\uFF08${result.count}\u4EF6\uFF09`
|
|
41
|
+
);
|
|
42
|
+
await notificationService.notifyInfo("revert-images completed", {
|
|
43
|
+
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;
|
|
51
|
+
} finally {
|
|
52
|
+
await prisma.$disconnect();
|
|
53
|
+
}
|
|
53
54
|
}
|
|
54
55
|
main().catch((error) => {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
console.error(error);
|
|
57
|
+
process.exit(1);
|
|
57
58
|
});
|
|
58
|
-
//# sourceMappingURL=revert-images.js.map
|
package/dist/revert-notes.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
2
|
+
import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
NotesBatchApplicationService,
|
|
5
|
+
createNotesCommandRepository
|
|
6
|
+
} from "./chunk-S5WJ5VXW.js";
|
|
7
|
+
import {
|
|
8
|
+
createPrismaClient,
|
|
9
|
+
makeUserId
|
|
10
|
+
} from "./chunk-IWNZQXDG.js";
|
|
11
|
+
import {
|
|
12
|
+
createPushoverService
|
|
13
|
+
} from "./chunk-7PVU2Z32.js";
|
|
14
|
+
import "./chunk-JZOR5GA2.js";
|
|
15
|
+
|
|
16
|
+
// src/revert-notes.ts
|
|
8
17
|
async function main() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
await notificationService.notifyError(`revert-notes failed: ${String(error)}`, {
|
|
46
|
-
caller: "revert-notes",
|
|
47
|
-
});
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
await prisma.$disconnect();
|
|
52
|
-
}
|
|
18
|
+
const env = {
|
|
19
|
+
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
|
+
USERNAME_TO_EXPORT: process.env.USERNAME_TO_EXPORT
|
|
24
|
+
};
|
|
25
|
+
if (Object.values(env).some((v) => !v)) {
|
|
26
|
+
throw new Error("Required environment variables are not set.");
|
|
27
|
+
}
|
|
28
|
+
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
|
+
});
|
|
34
|
+
const userId = makeUserId(env.USERNAME_TO_EXPORT ?? "");
|
|
35
|
+
try {
|
|
36
|
+
const commandRepository = createNotesCommandRepository(prisma);
|
|
37
|
+
const batchService = new NotesBatchApplicationService(commandRepository);
|
|
38
|
+
const result = await batchService.revertNotes(userId);
|
|
39
|
+
console.log(
|
|
40
|
+
`\u{1F4BE} LAST_UPDATED\u306E\u30CE\u30FC\u30C8\u3092UNEXPORTED\u306B\u5909\u66F4\u3057\u307E\u3057\u305F\uFF08${result.count}\u4EF6\uFF09`
|
|
41
|
+
);
|
|
42
|
+
await notificationService.notifyInfo("revert-notes completed", {
|
|
43
|
+
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;
|
|
51
|
+
} finally {
|
|
52
|
+
await prisma.$disconnect();
|
|
53
|
+
}
|
|
53
54
|
}
|
|
54
55
|
main().catch((error) => {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
console.error(error);
|
|
57
|
+
process.exit(1);
|
|
57
58
|
});
|
|
58
|
-
//# sourceMappingURL=revert-notes.js.map
|
package/dist/s-content-format.js
CHANGED
|
@@ -1,18 +1,108 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { createRequire as __cliCreateRequire } from "node:module"; const require = __cliCreateRequire(import.meta.url);
|
|
3
|
+
import "./chunk-JZOR5GA2.js";
|
|
4
|
+
|
|
5
|
+
// src/s-content-format-runner.ts
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
var CONTENT_EXTENSIONS = [
|
|
11
|
+
".md",
|
|
12
|
+
".markdown",
|
|
13
|
+
".json",
|
|
14
|
+
".jsonc",
|
|
15
|
+
".json5",
|
|
16
|
+
".yml",
|
|
17
|
+
".yaml"
|
|
18
|
+
];
|
|
19
|
+
var DEFAULT_EXCLUDES = [
|
|
20
|
+
"!**/node_modules",
|
|
21
|
+
"!**/dist",
|
|
22
|
+
"!**/build",
|
|
23
|
+
"!**/coverage",
|
|
24
|
+
"!**/raw/article/**",
|
|
25
|
+
"!**/bun.lock",
|
|
26
|
+
"!**/package-lock.json",
|
|
27
|
+
"!**/yarn.lock",
|
|
28
|
+
"!**/.env",
|
|
29
|
+
"!**/.env.*"
|
|
30
|
+
];
|
|
31
|
+
function resolveOxfmtBin() {
|
|
32
|
+
const packageJsonPath = fileURLToPath(
|
|
33
|
+
import.meta.resolve("oxfmt/package.json")
|
|
34
|
+
);
|
|
35
|
+
const manifest = JSON.parse(
|
|
36
|
+
readFileSync(packageJsonPath, "utf8")
|
|
37
|
+
);
|
|
38
|
+
const bin = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.oxfmt;
|
|
39
|
+
if (bin === void 0) {
|
|
40
|
+
throw new Error("The installed oxfmt package does not expose an oxfmt bin");
|
|
41
|
+
}
|
|
42
|
+
return path.resolve(path.dirname(packageJsonPath), bin);
|
|
43
|
+
}
|
|
44
|
+
function isContentFile(target) {
|
|
45
|
+
const lowerTarget = target.toLowerCase();
|
|
46
|
+
return CONTENT_EXTENSIONS.some(
|
|
47
|
+
(extension) => lowerTarget.endsWith(extension)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
function toContentTargets(target) {
|
|
51
|
+
if (isContentFile(target)) {
|
|
52
|
+
return [target];
|
|
53
|
+
}
|
|
54
|
+
let normalizedTarget = target.replaceAll("\\", "/");
|
|
55
|
+
while (normalizedTarget.endsWith("/")) {
|
|
56
|
+
normalizedTarget = normalizedTarget.slice(0, -1);
|
|
57
|
+
}
|
|
58
|
+
const base = normalizedTarget === "" ? "." : normalizedTarget;
|
|
59
|
+
return CONTENT_EXTENSIONS.map((extension) => `${base}/**/*${extension}`);
|
|
60
|
+
}
|
|
61
|
+
function buildOxfmtArgs(rawArgs) {
|
|
62
|
+
const isCheck = rawArgs.includes("--check");
|
|
63
|
+
const remaining = rawArgs.filter((arg) => arg !== "--check");
|
|
64
|
+
const options = remaining.filter((arg) => arg.startsWith("-"));
|
|
65
|
+
const paths = remaining.filter((arg) => !arg.startsWith("-"));
|
|
66
|
+
const contentTargets = (paths.length === 0 ? ["."] : paths).flatMap(
|
|
67
|
+
(target) => toContentTargets(target)
|
|
68
|
+
);
|
|
69
|
+
const packageRoot = path.resolve(import.meta.dirname, "..");
|
|
70
|
+
const configPath = path.join(packageRoot, "configs", "oxfmt.json");
|
|
71
|
+
return [
|
|
72
|
+
isCheck ? "--check" : "--write",
|
|
73
|
+
"--config",
|
|
74
|
+
configPath,
|
|
75
|
+
"--disable-nested-config",
|
|
76
|
+
"--no-error-on-unmatched-pattern",
|
|
77
|
+
...options,
|
|
78
|
+
...contentTargets,
|
|
79
|
+
...DEFAULT_EXCLUDES
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
function runContentFormat(rawArgs, cwd = process.cwd(), options = {}) {
|
|
83
|
+
const child = spawn(
|
|
84
|
+
process.execPath,
|
|
85
|
+
[resolveOxfmtBin(), ...buildOxfmtArgs(rawArgs)],
|
|
86
|
+
{ cwd, stdio: options.stdio ?? "inherit" }
|
|
87
|
+
);
|
|
88
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
89
|
+
child.once("error", reject);
|
|
90
|
+
child.once("exit", (code, signal) => resolve({ code, signal }));
|
|
91
|
+
return promise;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/s-content-format.ts
|
|
3
95
|
async function main() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
process.exitCode = code ?? 1;
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
console.error(error);
|
|
14
|
-
process.exitCode = 1;
|
|
96
|
+
try {
|
|
97
|
+
const { code, signal } = await runContentFormat(process.argv.slice(2));
|
|
98
|
+
if (signal !== null) {
|
|
99
|
+
process.kill(process.pid, signal);
|
|
100
|
+
return;
|
|
15
101
|
}
|
|
102
|
+
process.exitCode = code ?? 1;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error(error);
|
|
105
|
+
process.exitCode = 1;
|
|
106
|
+
}
|
|
16
107
|
}
|
|
17
108
|
void main();
|
|
18
|
-
//# sourceMappingURL=s-content-format.js.map
|