Clean up build process
This commit is contained in:
parent
fb6604e19b
commit
5d2d075eef
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
The goal of this document is to define the algorithm.
|
The goal of this document is to define the algorithm.
|
||||||
|
|
||||||
If you want to see the steps to get to this definition, go to link:DESIGN.html[DESIGN].
|
If you want to see the steps to get to this definition, go to link:/docs/DESIGN[DESIGN].
|
||||||
|
|
||||||
== Data format
|
== Data format
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
The goal of this document is to walk through how the design was chosen.
|
The goal of this document is to walk through how the design was chosen.
|
||||||
|
|
||||||
If you want to see the algorithm definition, go to link:ALGORITHM.html[ALGORITHM].
|
If you want to see the algorithm definition, go to link:/docs/ALGORITHM[ALGORITHM].
|
||||||
|
|
||||||
== 10,000 meter view
|
== 10,000 meter view
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@
|
|||||||
== Pages
|
== Pages
|
||||||
|
|
||||||
* link:..[xpin.app] - Go back to the xpin homepage
|
* link:..[xpin.app] - Go back to the xpin homepage
|
||||||
* link:ALGORITHM.html[ALGORITHM] - Algorithm definition
|
* link:/docs/ALGORITHM[ALGORITHM] - Algorithm definition
|
||||||
* link:DESIGN.html[DESIGN] - Algorithm design documentation
|
* link:/docs/DESIGN[DESIGN] - Algorithm design documentation
|
||||||
* link:WORDLIST.html[WORDLIST] - Wordlist design and implementation
|
* link:/docs/WORDLIST[WORDLIST] - Wordlist design and implementation
|
||||||
|
|
||||||
++++
|
++++
|
||||||
<style>
|
<style>
|
||||||
|
16
justfile
16
justfile
@ -1,15 +1,11 @@
|
|||||||
build: fmt js-build
|
# Rust test needs to be built after because the web crate depends on js-build
|
||||||
|
build: fmt js-build rust-build rust-test
|
||||||
# Rust test needs to be built after because it depends on js-build
|
|
||||||
all: output-clean fmt build rust-build rust-test
|
|
||||||
rsync -ha ./web-frontend/build/ build/
|
|
||||||
du -shc build/* | sort -h
|
|
||||||
|
|
||||||
rust-test:
|
rust-test:
|
||||||
cargo test --all
|
cargo test --all
|
||||||
cargo fmt --all --check
|
cargo fmt --all --check
|
||||||
|
|
||||||
rust-build:
|
rust-build: output-clean js-build
|
||||||
cargo build --all
|
cargo build --all
|
||||||
cargo build -p web --release --target x86_64-unknown-linux-musl
|
cargo build -p web --release --target x86_64-unknown-linux-musl
|
||||||
earthly +rust-image
|
earthly +rust-image
|
||||||
@ -24,11 +20,13 @@ js-build: wasm-build docs-build
|
|||||||
# mkdir -p ./web-frontend/static/docs/
|
# mkdir -p ./web-frontend/static/docs/
|
||||||
# rsync -ha ./build/docs/ ./web-frontend/static/docs/
|
# rsync -ha ./build/docs/ ./web-frontend/static/docs/
|
||||||
yarn --cwd ./web-frontend/ build
|
yarn --cwd ./web-frontend/ build
|
||||||
|
rsync -ha ./web-frontend/build/ ./build/
|
||||||
|
|
||||||
output-clean:
|
output-clean:
|
||||||
rm -vrf build
|
rm -vrf build
|
||||||
|
mkdir build
|
||||||
|
|
||||||
docs-build:
|
docs-build: output-clean
|
||||||
earthly +docs
|
earthly +docs
|
||||||
cargo doc --all
|
cargo doc --all
|
||||||
|
|
||||||
@ -51,5 +49,7 @@ init:
|
|||||||
yarn --cwd ./web-frontend/
|
yarn --cwd ./web-frontend/
|
||||||
cargo fetch
|
cargo fetch
|
||||||
cargo install wasm-pack
|
cargo install wasm-pack
|
||||||
|
|
||||||
|
init-python:
|
||||||
if [ ! -d "wordlist/venv" ]; then python3 -m virtualenv wordlist/venv -p "$(which python3)"; fi; export OSTYPE=linux-gnu && . wordlist/venv/bin/activate
|
if [ ! -d "wordlist/venv" ]; then python3 -m virtualenv wordlist/venv -p "$(which python3)"; fi; export OSTYPE=linux-gnu && . wordlist/venv/bin/activate
|
||||||
export OSTYPE=linux-gnu && . wordlist/venv/bin/activate && pip install -r wordlist/requirements.txt && python -c 'import nltk; nltk.download('wordnet')'
|
export OSTYPE=linux-gnu && . wordlist/venv/bin/activate && pip install -r wordlist/requirements.txt && python -c 'import nltk; nltk.download('wordnet')'
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<div class="text-sm">
|
<div class="text-sm">
|
||||||
<a href="/" class="block inline-block text-white hover:text-gray-500 mr-4 p-2"> Home </a>
|
<a href="/" class="block inline-block text-white hover:text-gray-500 mr-4 p-2"> Home </a>
|
||||||
<a
|
<a
|
||||||
href="/docs"
|
href="/docs/"
|
||||||
rel="external"
|
rel="external"
|
||||||
class="block inline-block text-white hover:text-gray-500 mr-4 p-2"
|
class="block inline-block text-white hover:text-gray-500 mr-4 p-2"
|
||||||
>
|
>
|
||||||
|
3
web/build.rs
Normal file
3
web/build.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-changed=../build");
|
||||||
|
}
|
@ -9,7 +9,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// Add the API
|
// Add the API
|
||||||
.mount("/api/v1", routes![api::get_address, api::get_coords])
|
.mount("/api/v1", routes![api::get_address, api::get_coords])
|
||||||
// Add the webui frontend
|
// Add the webui frontend
|
||||||
.mount("/", routes![static_assets::dist])
|
.mount("/", routes![static_assets::index, static_assets::dist])
|
||||||
.launch()
|
.launch()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ struct Asset;
|
|||||||
|
|
||||||
#[get("/<file..>")]
|
#[get("/<file..>")]
|
||||||
pub(crate) fn dist(file: PathBuf) -> Option<(ContentType, Cow<'static, [u8]>)> {
|
pub(crate) fn dist(file: PathBuf) -> Option<(ContentType, Cow<'static, [u8]>)> {
|
||||||
|
eprintln!("file: {file:?}");
|
||||||
if let Some(a) = Asset::get(&format!("{}", file.display().to_string())) {
|
if let Some(a) = Asset::get(&format!("{}", file.display().to_string())) {
|
||||||
let content_type = file
|
let content_type = file
|
||||||
.extension()
|
.extension()
|
||||||
@ -22,8 +23,13 @@ pub(crate) fn dist(file: PathBuf) -> Option<(ContentType, Cow<'static, [u8]>)> {
|
|||||||
return Some((content_type, a.data));
|
return Some((content_type, a.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
[".html", "index.html"].iter().find_map(|ext| {
|
[".html", "/index.html"].iter().find_map(|ext| {
|
||||||
Asset::get(&format!("{}{}", file.display().to_string(), ext))
|
Asset::get(&format!("{}{}", file.display().to_string(), ext))
|
||||||
.map(|a| (ContentType::HTML, a.data))
|
.map(|a| (ContentType::HTML, a.data))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
pub(crate) fn index() -> Option<(ContentType, Cow<'static, [u8]>)> {
|
||||||
|
Asset::get(&"index.html").map(|a| (ContentType::HTML, a.data))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user