Replace scripts nu files by one
This commit is contained in:
parent
f1bf2e3e1d
commit
4b31c4513f
5 changed files with 102 additions and 42 deletions
|
|
@ -1 +0,0 @@
|
|||
sass --no-source-map -w scss/style_dark.scss:static/style_dark.css scss/style_light.scss:static/style_light.css
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# It needs cargo-edit: https://crates.io/crates/cargo-edit .
|
||||
cargo upgrade --dry-run --verbose
|
||||
38
deploy.nu
38
deploy.nu
|
|
@ -1,38 +0,0 @@
|
|||
def main [host: string, destination: string, ssh_key: path] {
|
||||
let ssh_args = [-i $ssh_key $host]
|
||||
let scp_args = [-r -i $ssh_key]
|
||||
|
||||
# For raspberry pi zero 1: "arm-unknown-linux-gnueabihf"
|
||||
let target = "aarch64-unknown-linux-gnu"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
cd frontend
|
||||
trunk build --release
|
||||
cd ..
|
||||
|
||||
cd backend
|
||||
cargo test
|
||||
cargo build --target $target --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/translation.ron $destination
|
||||
invoke_ssh [chmod u+x recipes/recipes]
|
||||
invoke_ssh [sudo systemctl start recipes]
|
||||
print "Deployment finished"
|
||||
}
|
||||
102
do.nu
Normal file
102
do.nu
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
# 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
|
||||
}
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
cd frontend
|
||||
trunk build --release
|
||||
cd ..
|
||||
|
||||
cd backend
|
||||
cargo test
|
||||
|
||||
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/translation.ron $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 ..
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
cargo doc --document-private-items --no-deps
|
||||
Loading…
Add table
Add a link
Reference in a new issue