summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.envrc2
-rw-r--r--.forgejo/default_merge_message/MERGE_TEMPLATE.md5
-rw-r--r--.gitignore1
-rw-r--r--Cargo.lock60
-rw-r--r--Cargo.toml2
-rw-r--r--build.rs4
-rw-r--r--package.json3
-rw-r--r--src/ui/assets.rs2
-rw-r--r--svelte.config.js13
-rwxr-xr-xtools/build-ui10
-rwxr-xr-xtools/run2
-rwxr-xr-xtools/run-frontend4
12 files changed, 85 insertions, 23 deletions
diff --git a/.envrc b/.envrc
index 56295f5..28a3690 100644
--- a/.envrc
+++ b/.envrc
@@ -1,3 +1,5 @@
+layout node
+
PATH_add tools
PATH_add target/debug
diff --git a/.forgejo/default_merge_message/MERGE_TEMPLATE.md b/.forgejo/default_merge_message/MERGE_TEMPLATE.md
new file mode 100644
index 0000000..e4d5b13
--- /dev/null
+++ b/.forgejo/default_merge_message/MERGE_TEMPLATE.md
@@ -0,0 +1,5 @@
+${PullRequestTitle}
+
+${PullRequestDescription}
+
+Merges ${HeadBranch} into ${BaseBranch}.
diff --git a/.gitignore b/.gitignore
index 7a5c67e..5966399 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/.envrc.local
/node_modules
/target
/.hi
diff --git a/Cargo.lock b/Cargo.lock
index b6ea4d9..65cacbd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-version = 3
+version = 4
[[package]]
name = "addr2line"
@@ -481,6 +481,27 @@ dependencies = [
]
[[package]]
+name = "dirs"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
+dependencies = [
+ "dirs-sys",
+]
+
+[[package]]
+name = "dirs-sys"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
+dependencies = [
+ "libc",
+ "option-ext",
+ "redox_users",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
name = "displaydoc"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1157,6 +1178,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
[[package]]
+name = "libredox"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
+dependencies = [
+ "bitflags",
+ "libc",
+]
+
+[[package]]
name = "libsqlite3-sys"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1312,6 +1343,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
[[package]]
+name = "option-ext"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
+
+[[package]]
name = "parking"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1532,6 +1569,17 @@ dependencies = [
]
[[package]]
+name = "redox_users"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
+dependencies = [
+ "getrandom 0.2.15",
+ "libredox",
+ "thiserror",
+]
+
+[[package]]
name = "rsa"
version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1585,6 +1633,7 @@ dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
+ "shellexpand",
"syn",
"walkdir",
]
@@ -1735,6 +1784,15 @@ dependencies = [
]
[[package]]
+name = "shellexpand"
+version = "3.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b1fdf65dd6331831494dd616b30351c38e96e45921a27745cf98490458b90bb"
+dependencies = [
+ "dirs",
+]
+
+[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 10e6adb..82693e3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -38,7 +38,7 @@ rand_core = { version = "0.6.4", features = ["getrandom"] }
# Pinned to maintain libsqlite3 version match between this and sqlx. See also:
# <https://docs.rs/sqlx/latest/sqlx/sqlite/index.html>
rusqlite = { version = "=0.32.1", features = ["backup"] }
-rust-embed = "8.5.0"
+rust-embed = { version = "8.5.0", features = ["interpolate-folder-path"] }
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.138"
# Pinned to maintain libsqlite3 version match between this and rusqlite. See
diff --git a/build.rs b/build.rs
index 3b7abda..6d4805f 100644
--- a/build.rs
+++ b/build.rs
@@ -20,7 +20,7 @@ fn main() -> Result<(), io::Error> {
)));
}
- // rerun `npm run build` whenever the UI changes.
+ // rerun `vite build` whenever the UI changes.
//
// `node_modules` is always touched if `npm install` runs, leading to spurious
// rebuilds. (This duplicate is purely organizational; it reflects that the ui
@@ -32,7 +32,7 @@ fn main() -> Result<(), io::Error> {
println!("cargo::rerun-if-changed=svelte.config.js");
println!("cargo::rerun-if-changed=vite.config.js");
println!("cargo::rerun-if-changed=ui");
- let status = Command::new("npm").args(["run", "build"]).status()?;
+ let status = Command::new("npx").args(["vite", "build"]).status()?;
if !status.success() {
return Err(io::Error::other(format!(
"'npm run build' exited with status {status:?}"
diff --git a/package.json b/package.json
index c6d01ec..4501576 100644
--- a/package.json
+++ b/package.json
@@ -7,9 +7,6 @@
"node": ">=22.0.0 <23.0.0"
},
"scripts": {
- "dev": "vite dev",
- "build": "vite build",
- "preview": "vite preview",
"lint": "prettier --check ui && eslint ui",
"format": "prettier --write ui"
},
diff --git a/src/ui/assets.rs b/src/ui/assets.rs
index 642679b..0ca9593 100644
--- a/src/ui/assets.rs
+++ b/src/ui/assets.rs
@@ -9,7 +9,7 @@ use super::{error::NotFound, mime};
use crate::error::Internal;
#[derive(rust_embed::Embed)]
-#[folder = "target/ui"]
+#[folder = "$OUT_DIR/ui"]
pub struct Assets;
impl Assets {
diff --git a/svelte.config.js b/svelte.config.js
index 5e64863..dbef20d 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -1,11 +1,20 @@
+import path from 'node:path';
+import process from 'node:process';
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
+// OUT_DIR is set by Cargo at build time:
+// <https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts>
+//
+// When we're building through `vite` directly, it will not be set; we use "target" as a generic
+// output directory to keep all the build products in one place.
+const outDir = process.env['OUT_DIR'] ?? 'target';
+
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter({
- pages: 'target/ui',
+ pages: path.join(outDir, 'ui'),
fallback: 'index.html',
}),
files: {
@@ -22,7 +31,7 @@ const config = {
appTemplate: 'ui/app.html',
errorTemplate: 'ui/error.html',
},
- outDir: 'target/svelte-kit',
+ outDir: path.join(outDir, 'svelte-kit'),
},
preprocess: vitePreprocess(),
};
diff --git a/tools/build-ui b/tools/build-ui
deleted file mode 100755
index ba8d016..0000000
--- a/tools/build-ui
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash -e
-
-## tools/build-ui
-##
-## Builds the Svelte UI.
-
-cd "$(dirname "$0")/.."
-
-npm install
-npm run build
diff --git a/tools/run b/tools/run
index 88262c6..8560c31 100755
--- a/tools/run
+++ b/tools/run
@@ -11,7 +11,7 @@ trap 'kill "${PIDS[@]}"' EXIT
cargo run &
PIDS+=($!)
-npm run dev -- --host &
+npx vite dev --host &
PIDS+=($!)
wait "${PIDS[@]}"
diff --git a/tools/run-frontend b/tools/run-frontend
index 14ff49c..ccb9bd4 100755
--- a/tools/run-frontend
+++ b/tools/run-frontend
@@ -3,8 +3,8 @@
## tools/run-frontend [OPTIONS…]
##
## Runs a development server for the Pilcrow UI. Options are passed through to
-## the `npm run dev` command. This is best combined with the `API_SERVER`
+## the `npx vite dev` command. This is best combined with the `API_SERVER`
## environment variable, to configure the development server to connect to a
## running Pilcrow instance.
-exec npm run dev -- --host "$@"
+exec npx vite dev --host "$@"