Compare commits
9 Commits
6d2f76eb72
...
fix/8-prog
| Author | SHA1 | Date | |
|---|---|---|---|
| e053f51bf3 | |||
| f3bfd8c114 | |||
| 131bf15240 | |||
| fd1fe0d896 | |||
| 5996db8d80 | |||
| 2df54930bb | |||
| f7a1f84730 | |||
| bb82dad4cf | |||
| 303309fff9 |
@@ -1,4 +1,4 @@
|
||||
name: Docker
|
||||
name: Deploy Docker Image to Github Container Registry
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Rust
|
||||
name: Deploy Rust to Crates.io
|
||||
|
||||
on:
|
||||
push:
|
||||
24
.github/workflows/rust_test.yml
vendored
Normal file
24
.github/workflows/rust_test.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Test Rust
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main", "develop"]
|
||||
paths:
|
||||
- "./src/**"
|
||||
- "./Cargo.toml"
|
||||
pull_request:
|
||||
branches: ["main", "develop"]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
37
Cargo.lock
generated
37
Cargo.lock
generated
@@ -630,17 +630,6 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colored"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"lazy_static",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "concurrent-queue"
|
||||
version = "2.1.0"
|
||||
@@ -864,11 +853,11 @@ dependencies = [
|
||||
"bytes",
|
||||
"clap 4.1.8",
|
||||
"clap_complete",
|
||||
"colored",
|
||||
"futures",
|
||||
"home",
|
||||
"live-server",
|
||||
"notify 5.1.0",
|
||||
"nu-ansi-term",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"text_io",
|
||||
@@ -1872,6 +1861,15 @@ dependencies = [
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.50.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.45"
|
||||
@@ -3206,6 +3204,12 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.42.0"
|
||||
@@ -3230,6 +3234,15 @@ dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.42.1"
|
||||
|
||||
@@ -12,7 +12,6 @@ exclude = [".gitlab", ".github"]
|
||||
[dependencies]
|
||||
bytes = "1.4.0"
|
||||
clap = { version = "4.1.8", features = ["derive"] }
|
||||
colored = "2.0.0"
|
||||
futures = "0.3.26"
|
||||
home = "0.5.4"
|
||||
live-server = "0.6.0"
|
||||
@@ -23,3 +22,4 @@ text_io = "0.1.12"
|
||||
tokio = { version = "1.26.0", features = ["full"] }
|
||||
zip-extract = "0.1.1"
|
||||
clap_complete = "4.1.4"
|
||||
nu-ansi-term = "0.50.3"
|
||||
|
||||
@@ -12,9 +12,13 @@ fn exec_command(command: &mut process::Command) -> Result<(), String> {
|
||||
}
|
||||
} else {
|
||||
println!("{}", result.unwrap_err());
|
||||
return Err(
|
||||
"asciidoctor not installed. For more information run docki health!".to_string(),
|
||||
);
|
||||
|
||||
let binary_name = command.get_program().to_str().unwrap_or("Something is");
|
||||
|
||||
return Err(format!(
|
||||
"{} not installed. For more information run docki health!",
|
||||
binary_name
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +35,11 @@ fn asciidoctor_docs(in_path: &str, out_path: &str) -> process::Command {
|
||||
fn asciidoctor_slides(in_path: &str, out_path: &str, offline_reveal: bool) -> process::Command {
|
||||
let mut command = process::Command::new(format!("asciidoctor-revealjs"));
|
||||
let out_dir = parent_path(out_path);
|
||||
let revealjs_path = if offline_reveal {
|
||||
path_between(out_dir.to_string(), "./dist/slides/revealjs".to_string())
|
||||
} else {
|
||||
"https://cdn.jsdelivr.net/npm/reveal.js@5.2.1".to_string()
|
||||
};
|
||||
let revealjs_path = if offline_reveal {
|
||||
path_between(out_dir.to_string(), "./dist/slides/revealjs".to_string())
|
||||
} else {
|
||||
"https://cdn.jsdelivr.net/npm/reveal.js@5.2.1".to_string()
|
||||
};
|
||||
|
||||
command
|
||||
.arg(format!("{in_path}"))
|
||||
|
||||
@@ -23,10 +23,6 @@ pub fn docki_build(in_path: &str, offline_reveal: bool) -> DockiBuildResult {
|
||||
|
||||
DockiBuildResult::Doc(convert_out_path)
|
||||
} else {
|
||||
if in_path.starts_with("./docs/slides/revealjs") && !offline_reveal {
|
||||
return DockiBuildResult::Silent;
|
||||
}
|
||||
|
||||
if let Err(err) = copy(&in_path, &out_path) {
|
||||
return DockiBuildResult::Err(err);
|
||||
}
|
||||
@@ -50,5 +46,4 @@ pub enum DockiBuildResult {
|
||||
Doc(String),
|
||||
Copy(String),
|
||||
Err(String),
|
||||
Silent,
|
||||
}
|
||||
|
||||
@@ -73,20 +73,24 @@ impl BuildExecution {
|
||||
return Err(result.unwrap_err())
|
||||
};
|
||||
|
||||
let paths = paths.into_iter()
|
||||
.filter(|path| offline_reveal || !path.starts_with("./docs/slides/revealjs"))
|
||||
.collect::<Vec<String>>();
|
||||
|
||||
self.goal = paths.len();
|
||||
|
||||
for (index, in_path) in paths.iter().enumerate() {
|
||||
self.progress = index + 1;
|
||||
self.goal = paths.len();
|
||||
let result = docki_build(&in_path, offline_reveal);
|
||||
|
||||
match result {
|
||||
DockiBuildResult::Err(err) => {
|
||||
self.display_building_status("Error", in_path, "");
|
||||
self.display_building_status("Error", &in_path, "");
|
||||
println!("{}", err)
|
||||
},
|
||||
DockiBuildResult::Copy(out_path) => self.display_building_status("Copy", &in_path, &out_path),
|
||||
DockiBuildResult::Slide(out_path) => self.display_building_status("Slide", &in_path, &out_path),
|
||||
DockiBuildResult::Doc(out_path) => self.display_building_status("Doc", &in_path, &out_path),
|
||||
DockiBuildResult::Silent => ()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{process::Command, io::ErrorKind};
|
||||
use colored::Colorize;
|
||||
use nu_ansi_term::Color::{LightGray, LightGreen, LightRed};
|
||||
use std::{io::ErrorKind, process::Command};
|
||||
|
||||
const INFO_ASCIIDOC: &str = "
|
||||
Install the binary with your package manager!
|
||||
@@ -37,7 +37,7 @@ fn check_reveal() -> () {
|
||||
}
|
||||
|
||||
fn reveal_is_installed() -> bool {
|
||||
return check_command("asciidoctor-revealjs")
|
||||
return check_command("asciidoctor-revealjs");
|
||||
}
|
||||
|
||||
fn check_asciidoc() -> () {
|
||||
@@ -49,23 +49,21 @@ fn check_asciidoc() -> () {
|
||||
}
|
||||
|
||||
fn asciidoc_is_installed() -> bool {
|
||||
return check_command("asciidoctor")
|
||||
return check_command("asciidoctor");
|
||||
}
|
||||
|
||||
fn check_command(command: &str) -> bool {
|
||||
return match Command::new(command)
|
||||
.output() {
|
||||
return match Command::new(command).output() {
|
||||
Ok(_) => true,
|
||||
Err(e) => ErrorKind::NotFound != e.kind()
|
||||
}
|
||||
Err(e) => ErrorKind::NotFound != e.kind(),
|
||||
};
|
||||
}
|
||||
|
||||
fn print_health_ok(name: &str) {
|
||||
println!("- ✔️ {}", name.bright_green());
|
||||
println!("- ✔️ {}", LightGreen.paint(name));
|
||||
}
|
||||
|
||||
fn print_health_not_ok(name: &str, info: &str) {
|
||||
println!("- ❗{}", name.bright_red());
|
||||
println!("{}", info.bright_black())
|
||||
println!("- ❗{}", LightRed.paint(name));
|
||||
println!("{}", LightGray.paint(info))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use colored::Colorize;
|
||||
use nu_ansi_term::Color::Green;
|
||||
use futures::StreamExt;
|
||||
use live_server::listen;
|
||||
use notify::{
|
||||
@@ -21,15 +21,18 @@ async fn watch_and_build() {
|
||||
.expect("something went wrong")
|
||||
}
|
||||
|
||||
|
||||
async fn start_server(port: Option<u16>) {
|
||||
let unwrapped_port = port.unwrap_or(8080);
|
||||
let port = port.unwrap_or(8080);
|
||||
let link = &format!("http://localhost:{}", port);
|
||||
let hyperlink = Green.paint(link).hyperlink(link);
|
||||
|
||||
println!(
|
||||
"\nServing at {}{} ",
|
||||
"http://localhost:".bold(),
|
||||
unwrapped_port.to_string().bold()
|
||||
"\nServing at {}",
|
||||
hyperlink
|
||||
);
|
||||
|
||||
let Ok(()) = listen("localhost", port.unwrap_or(8080), "./dist").await else {
|
||||
let Ok(()) = listen("localhost", port, "./dist").await else {
|
||||
panic!("could not start server")
|
||||
};
|
||||
}
|
||||
@@ -75,7 +78,6 @@ fn build_file(paths: Vec<std::path::PathBuf>) {
|
||||
display_rebuilding_status("Error", &in_path, "");
|
||||
println!("{}", err);
|
||||
},
|
||||
DockiBuildResult::Silent => ()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
use colored::Colorize;
|
||||
use nu_ansi_term::Color::LightGreen;
|
||||
use nu_ansi_term::Color::LightRed;
|
||||
use nu_ansi_term::Style;
|
||||
|
||||
pub fn display_status(context1: &str, context2: &str, in_path: &str, out_path: &str) {
|
||||
let colored_context = color_context(context2);
|
||||
let colored_context = if context2 == "Error" {
|
||||
LightRed.paint(context2)
|
||||
} else {
|
||||
LightGreen.paint(context2)
|
||||
};
|
||||
|
||||
println!(
|
||||
"({}) [{}] {} -> {}",
|
||||
context1.bold(),
|
||||
Style::new().paint(context1),
|
||||
colored_context,
|
||||
in_path,
|
||||
out_path
|
||||
);
|
||||
}
|
||||
|
||||
fn color_context(context: &str) -> colored::ColoredString {
|
||||
if context == "Error" {
|
||||
return context.bright_red()
|
||||
} else {
|
||||
return context.bright_green()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user