111 lines
No EOL
2.5 KiB
Text
Executable file
111 lines
No EOL
2.5 KiB
Text
Executable file
#!/usr/bin/env nu
|
|
|
|
# Build the frontend dans backend in parallel (debug mode).
|
|
def "main build" [] {
|
|
build
|
|
}
|
|
|
|
# Build the frontend dans backend in parallel then run the backend (debug mode).
|
|
def "main run" [] {
|
|
run
|
|
}
|
|
|
|
def "main test" [] {
|
|
test
|
|
}
|
|
|
|
# Generate the documentation in 'target/doc'.
|
|
def "main doc" [] {
|
|
cargo doc --document-private-items --no-deps
|
|
}
|
|
|
|
# Build in release then copy the files to a given destination using scp (ssh).
|
|
def "main deploy" [
|
|
host: string, # The host addrese, for example: "user@host.com"
|
|
destination: string, # The local path, for example: "~/recipes"
|
|
ssh_key: path # The path to the ssh key, for example: "~/.ssh/id_rsa.pub"
|
|
target: string = "" # The target architecture, for example: "aarch64-unknown-linux-gnu"
|
|
] {
|
|
let ssh_args = [-i $ssh_key $host]
|
|
let scp_args = [-r -i $ssh_key]
|
|
|
|
def invoke_ssh [command: list] {
|
|
let args = $ssh_args ++ $command
|
|
print $"Executing: ssh ($args)"
|
|
ssh ...$args
|
|
}
|
|
|
|
def copy_ssh [source: string, destination: string] {
|
|
let args = $scp_args ++ [$source $"($host):($destination)"]
|
|
print $"Executing: scp ($args)"
|
|
scp ...$args
|
|
}
|
|
|
|
test
|
|
|
|
cd frontend
|
|
trunk build --release
|
|
cd ..
|
|
|
|
if target != "" {
|
|
cargo build --target $target --release
|
|
} else {
|
|
cargo build --release
|
|
}
|
|
cd ..
|
|
|
|
invoke_ssh [sudo systemctl stop recipes]
|
|
copy_ssh ./target/($target)/release/recipes $destination
|
|
invoke_ssh [rm -rf recipes/static]
|
|
copy_ssh ./backend/static/ $destination
|
|
copy_ssh ./backend/sql/ $destination
|
|
copy_ssh ./backend/translations/ $destination
|
|
invoke_ssh [chmod u+x recipes/recipes]
|
|
invoke_ssh [sudo systemctl start recipes]
|
|
print "Deployment finished"
|
|
}
|
|
|
|
# Watch modifications on SASS files (in backend/scss/) to generate the CSS files (in backend/static).
|
|
def "main watch-scss" [] {
|
|
sass --no-source-map -w backend/scss/style_dark.scss:backend/static/style_dark.css backend/scss/style_light.scss:backend/static/style_light.css
|
|
}
|
|
|
|
def main [] {
|
|
nu do.nu --help
|
|
}
|
|
|
|
def build [] {
|
|
[
|
|
{|| build_frontend }
|
|
{|| build_backend }
|
|
] | par-each { |c| do $c }
|
|
}
|
|
|
|
def build_frontend [] {
|
|
cd frontend
|
|
trunk build
|
|
cd ..
|
|
}
|
|
|
|
def build_backend [] {
|
|
cd backend
|
|
cargo build
|
|
cd ..
|
|
}
|
|
|
|
def run [] {
|
|
[
|
|
{|| build_frontend }
|
|
{|| run_backend }
|
|
] | par-each { |c| do $c }
|
|
}
|
|
|
|
def run_backend [] {
|
|
cd backend
|
|
cargo run
|
|
cd ..
|
|
}
|
|
|
|
def test [] {
|
|
cargo test
|
|
} |