0
Fork 0
www/setup.ts

36 lines
1.1 KiB
TypeScript
Executable File

#!/usr/bin/env bun
// Copyright (c) 2024 Pavocracy <pavocracy@pm.me>
// This file is released under MIT License
// Find this project at https://code.pavocracy.dev/personal-projects/www
import { $ } from "bun"
import { sys } from "typescript"
const root_dir = import.meta.dir
console.log("Starting setup process...")
console.log("Installing dependencies")
if (sys.args.includes("--production")) {
$`bun install --production`
} else {
$`bun install`
}
console.log("Building tailwindcss")
await $`bun x tailwindcss -o ${root_dir}/lib/tailwind.css --minify`
console.log("Fetching htmx from node_modules")
const htmx = Bun.file(`${root_dir}/node_modules/htmx.org/dist/htmx.min.js`)
await Bun.write(`${root_dir}/lib/htmx.js`, htmx)
if (sys.args.includes("--install")) {
console.log("Installing systemd service")
await $`cp --target-directory=/etc/systemd/system/ ${root_dir}/config/www.service`
await $`systemctl daemon-reload`
await $`systemctl enable www.service`
console.log("Setting group to www-data")
await $`chown -R :www-data ${root_dir}`
}
console.log("Setup finished!")