forked from owid/owid-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbakeGdocPost.ts
32 lines (29 loc) · 983 Bytes
/
bakeGdocPost.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env node
import yargs from "yargs"
import { hideBin } from "yargs/helpers"
import { SiteBaker } from "./SiteBaker.js"
import { BAKED_SITE_DIR, BAKED_BASE_URL } from "../settings/serverSettings.js"
import * as db from "../db/db.js"
void yargs(hideBin(process.argv))
.command<{ slug: string }>(
"$0 [slug]",
"Bake single GDoc post",
(yargs) => {
yargs.positional("slug", {
type: "string",
describe: "GDoc slug",
})
},
async ({ slug }) => {
const baker = new SiteBaker(BAKED_SITE_DIR, BAKED_BASE_URL)
// TODO: this transaction is only RW because somewhere inside it we fetch images
await db.knexReadWriteTransaction(
(trx) => baker.bakeGDocPosts(trx, [slug]),
db.TransactionCloseMode.Close
)
process.exit(0)
}
)
.help()
.alias("help", "h")
.strict().argv