1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2025-12-14 10:35:07 +00:00

Add user import and export scripts

This commit is contained in:
Cadence Fish
2020-02-18 20:07:11 +13:00
parent d95f6950c4
commit 6d7e089dae
3 changed files with 45 additions and 0 deletions

11
scripts/export_users.js Executable file
View File

@@ -0,0 +1,11 @@
const fs = require("fs").promises
const pj = require("path").join
const db = require("../src/lib/db")
;(async () => {
const users = db.prepare("SELECT * FROM Users").all()
const targetDir = process.argv.slice(2).includes("--publish") ? "../src/site/html" : ".."
const target = pj(__dirname, targetDir, "users_export.json")
fs.writeFile(target, JSON.stringify(users), {encoding: "utf8"})
console.log(`Users exported to ${target}`)
})()