diff --git a/Cargo.toml b/Cargo.toml index c6f71fa..c66a3c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,11 @@ edition = "2018" name = "rbd" path = "src/main.rs" +[features] +web = [] +docs = [] +static = ["web", "docs"] + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..23d08af --- /dev/null +++ b/build.rs @@ -0,0 +1,34 @@ +use std::{env, process::Command}; + +fn main() +{ + if env::var_os("CARGO_FEATURE_WEB").is_some() { + println!("cargo:rerun-if-changed=web"); + + let status = Command::new("yarn") + .arg("build") + .current_dir("web") + .status() + .expect("Failed to build frontend."); + + if status.code().unwrap() != 0 { + panic!("Building frontend failed."); + } + } + + // This currently isn't possible because cargo doc requires a lock on the Cargo.lock file that + // can't be provided + + // if env::var_os("CARGO_FEATURE_DOCS").is_some() { + // println!("cargo:rerun-if-changed=src"); + + // let status = Command::new(env::var("CARGO").unwrap()) + // .args(["doc", "--no-deps"]) + // .status() + // .expect("Failed to build docs."); + + // if status.code().unwrap() != 0 { + // panic!("Failed to build docs."); + // } + // } +} diff --git a/build.sh b/build.sh deleted file mode 100644 index 1d1c93f..0000000 --- a/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Install build dependencies -# apt update -# apt install \ -# -y --no-install-recommends \ -# musl-dev \ -# musl-tools \ -# libssl-dev \ -# libpq-dev - -make diff --git a/src/main.rs b/src/main.rs index 4a6db39..3c803f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ use rocket::{ fairing::AdHoc, http::Status, serde::json::{json, Value}, - Build, Request, Rocket, Orbit, + Build, Orbit, Request, Rocket, }; use rocket_sync_db_pools::database; use serde::{Deserialize, Serialize}; @@ -65,8 +65,7 @@ async fn create_admin_user<'a>(rocket: &'a Rocket) .await .expect("database connection"); conn.run(move |c| { - admin::create_admin_user(c, &admin_user, &admin_pass) - .expect("failed to create admin user") + admin::create_admin_user(c, &admin_user, &admin_pass).expect("failed to create admin user") }) .await; } diff --git a/src/sections.rs b/src/sections.rs index e4def24..013c0d3 100644 --- a/src/sections.rs +++ b/src/sections.rs @@ -5,7 +5,7 @@ use rocket::serde::json::Json; use crate::{db, errors::RbResult, guards::Admin, RbDbConn}; /// Route for creating a new section. -/// +/// /// # Arguments /// /// * `_admin` - guard ensuring user is admin diff --git a/web/src/pages/index.astro b/web/src/pages/index.astro index 0185af5..1c38f47 100644 --- a/web/src/pages/index.astro +++ b/web/src/pages/index.astro @@ -1,6 +1,5 @@ --- import { createServer } from "miragejs" -import MirageTest from "../components/MirageTest" createServer({ routes() { @@ -28,8 +27,6 @@ createServer({ - -