Tried to add docs & frontend as features

develop
Jef Roosens 2021-09-24 16:18:41 +02:00
parent cae6632cf6
commit 0da8eb127c
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
6 changed files with 42 additions and 21 deletions

View File

@ -8,6 +8,11 @@ edition = "2018"
name = "rbd" name = "rbd"
path = "src/main.rs" 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 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]

34
build.rs 100644
View File

@ -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.");
// }
// }
}

View File

@ -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

View File

@ -16,7 +16,7 @@ use rocket::{
fairing::AdHoc, fairing::AdHoc,
http::Status, http::Status,
serde::json::{json, Value}, serde::json::{json, Value},
Build, Request, Rocket, Orbit, Build, Orbit, Request, Rocket,
}; };
use rocket_sync_db_pools::database; use rocket_sync_db_pools::database;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -65,8 +65,7 @@ async fn create_admin_user<'a>(rocket: &'a Rocket<Orbit>)
.await .await
.expect("database connection"); .expect("database connection");
conn.run(move |c| { conn.run(move |c| {
admin::create_admin_user(c, &admin_user, &admin_pass) admin::create_admin_user(c, &admin_user, &admin_pass).expect("failed to create admin user")
.expect("failed to create admin user")
}) })
.await; .await;
} }

View File

@ -5,7 +5,7 @@ use rocket::serde::json::Json;
use crate::{db, errors::RbResult, guards::Admin, RbDbConn}; use crate::{db, errors::RbResult, guards::Admin, RbDbConn};
/// Route for creating a new section. /// Route for creating a new section.
/// ///
/// # Arguments /// # Arguments
/// ///
/// * `_admin` - guard ensuring user is admin /// * `_admin` - guard ensuring user is admin

View File

@ -1,6 +1,5 @@
--- ---
import { createServer } from "miragejs" import { createServer } from "miragejs"
import MirageTest from "../components/MirageTest"
createServer({ createServer({
routes() { routes() {
@ -28,8 +27,6 @@ createServer({
<li class="nav-bar-item"><a href="/microblog">Microblog</a></li> <li class="nav-bar-item"><a href="/microblog">Microblog</a></li>
<li class="nav-bar-item"><a href="/devlogs">Devlogs</a></li> <li class="nav-bar-item"><a href="/devlogs">Devlogs</a></li>
</ul> </ul>
<MirageTest client:load />
</body> </body>
</html> </html>