Skip to content

Commit

Permalink
Restructure frontend source code
Browse files Browse the repository at this point in the history
  • Loading branch information
treiher committed Jan 10, 2025
1 parent ede119f commit a33f8a0
Show file tree
Hide file tree
Showing 58 changed files with 1,123 additions and 961 deletions.
54 changes: 42 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
[workspace]
members = [
"frontend",
"crates/domain",
"crates/storage",
"crates/web-app",
"crates/web-app-seed",
]
exclude = [
"third-party/seed"
]
resolver = "2"

[workspace.package]
version = "0.0.0"
authors = ["Tobias Reiher <[email protected]>"]
edition = "2021"

[workspace.dependencies]
assert_approx_eq = "1.1.0"
chrono = { version = "0.4.20", default-features = false }
plotters = { version = "0.3.2", default-features = false }
pretty_assertions = "1.4.0"
rstest = "0.24.0"
serde = "1.0"
serde_json = "1.0"
wasm-bindgen = "0.2.91"
web-sys = "0.3"
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ BULMA_SLIDER_VERSION := 2.0.5
FONTAWESOME_VERSION := 6.1.1

PYTHON_PACKAGES := valens tests tools fabfile.py
FRONTEND_FILES := index.css manifest.json service-worker.js valens-frontend.js valens-frontend_bg.wasm fonts images js
FRONTEND_CRATE := crates/web-app-seed
FRONTEND_FILES := index.css manifest.json service-worker.js valens-web-app-seed.js valens-web-app-seed_bg.wasm fonts images js
PACKAGE_FRONTEND_FILES := valens/frontend $(addprefix valens/frontend/,$(FRONTEND_FILES))
BUILD_DIR := $(PWD)/build
CONFIG_FILE := $(BUILD_DIR)/config.py
Expand Down Expand Up @@ -86,7 +87,7 @@ update: update_css update_fonts
update_css: third-party/bulma third-party/bulma-slider

update_fonts: third-party/fontawesome
cp third-party/fontawesome/webfonts/fa-solid-900.{woff2,ttf} frontend/assets/fonts/
cp third-party/fontawesome/webfonts/fa-solid-900.{woff2,ttf} $(FRONTEND_CRATE)/assets/fonts/

third-party/bulma:
wget -qO- https://github.com/jgthms/bulma/releases/download/$(BULMA_VERSION)/bulma-$(BULMA_VERSION).zip | bsdtar -xf- -C third-party
Expand Down Expand Up @@ -118,20 +119,20 @@ $(WHEEL): $(PACKAGE_FRONTEND_FILES)
valens/frontend:
mkdir -p valens/frontend

valens/frontend/%: frontend/dist/%
valens/frontend/%: $(FRONTEND_CRATE)/dist/%
rm -rf $@
cp -r $< $@

$(addprefix frontend/dist/,$(FRONTEND_FILES)): third-party/bulma third-party/fontawesome $(shell find frontend/src/ -type f -name '*.rs')
cd frontend && trunk build --release --filehash false
$(addprefix $(FRONTEND_CRATE)/dist/,$(FRONTEND_FILES)): third-party/bulma third-party/fontawesome $(shell find $(FRONTEND_CRATE)/src/ -type f -name '*.rs')
cd $(FRONTEND_CRATE) && trunk build --release --filehash false
.PHONY: run run_frontend run_backend

run:
tmux new-window $(MAKE) CONFIG_FILE=$(CONFIG_FILE) run_frontend
tmux new-window $(MAKE) CONFIG_FILE=$(CONFIG_FILE) run_backend

run_frontend:
PATH=~/.cargo/bin:${PATH} trunk --config frontend/Trunk.toml serve --port 8000
PATH=~/.cargo/bin:${PATH} trunk --config $(FRONTEND_CRATE)/Trunk.toml serve --port 8000

run_backend: $(CONFIG_FILE)
VALENS_CONFIG=$(CONFIG_FILE) uv run -- flask --app valens --debug run -h 0.0.0.0
Expand All @@ -148,4 +149,5 @@ clean:
rm -rf $(BUILD_DIR)
rm -rf valens.egg-info
rm -rf valens/frontend
cd frontend && trunk clean && cargo clean
cargo clean
trunk --config $(FRONTEND_CRATE) clean
15 changes: 15 additions & 0 deletions crates/domain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "valens-domain"
version.workspace = true
authors.workspace = true
edition.workspace = true
publish = false

[dependencies]
chrono = { workspace = true, default-features = false, features = ["clock", "serde"] }
serde = { workspace = true, features = ["derive"] }

[dev-dependencies]
pretty_assertions = { workspace = true }
rstest = { workspace = true }
serde_json = { workspace = true }
Loading

0 comments on commit a33f8a0

Please sign in to comment.