-
-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathbakeGdocPosts.ts
36 lines (33 loc) · 1.04 KB
/
bakeGdocPosts.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
33
34
35
36
#! /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<{ slugs: string[] }>(
"$0 [slug]",
"Bake multiple GDoc posts",
(yargs) => {
yargs
.option("slugs", {
type: "array",
describe: "GDoc slugs",
})
.demandOption(
["slugs"],
"Please provide slugs using --slugs slug1 slug2"
)
},
async ({ slugs }) => {
const baker = new SiteBaker(BAKED_SITE_DIR, BAKED_BASE_URL)
await db.knexReadonlyTransaction(
(trx) => baker.bakeGDocPosts(trx, slugs),
db.TransactionCloseMode.Close
)
process.exit(0)
}
)
.help()
.alias("help", "h")
.strict().argv