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:
11
scripts/export_users.js
Executable file
11
scripts/export_users.js
Executable 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}`)
|
||||
})()
|
||||
Reference in New Issue
Block a user