mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 11:45:02 +01:00
improve things
This commit is contained in:
parent
f437754618
commit
a7dba08990
9 changed files with 185 additions and 26 deletions
4
.github/workflows/rust.yml
vendored
4
.github/workflows/rust.yml
vendored
|
|
@ -20,7 +20,7 @@ jobs:
|
|||
uses: creyD/prettier_action@v4.2
|
||||
with:
|
||||
dry: true
|
||||
prettier_options: --check **/*.{html,css,js,md} --ignore-path .gitignore
|
||||
prettier_options: --check amqp_dashboard/assets/* --ignore-path .gitignore
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run clippy -D clippy::all
|
||||
|
|
@ -29,3 +29,5 @@ jobs:
|
|||
run: cargo fmt --verbose --all -- --check
|
||||
- name: Run tests
|
||||
run: cargo test --verbose --all
|
||||
- name: Run client integration tests
|
||||
run: cargo xtask tests-js
|
||||
|
|
|
|||
105
Cargo.lock
generated
105
Cargo.lock
generated
|
|
@ -213,10 +213,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"textwrap",
|
||||
"textwrap 0.11.0",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d76c22c9b9b215eeb8d016ad3a90417bd13cb24cf8142756e6472445876cab7"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"os_str_bytes",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap 0.14.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fd1122e63869df2cb309f449da1ad54a7c6dfeb7c7e6ccd8e0825d9eb93bb72"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "criterion"
|
||||
version = "0.3.5"
|
||||
|
|
@ -225,7 +255,7 @@ checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10"
|
|||
dependencies = [
|
||||
"atty",
|
||||
"cast",
|
||||
"clap",
|
||||
"clap 2.34.0",
|
||||
"criterion-plot",
|
||||
"csv",
|
||||
"itertools",
|
||||
|
|
@ -397,6 +427,12 @@ version = "1.8.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
|
|
@ -475,6 +511,16 @@ dependencies = [
|
|||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.3"
|
||||
|
|
@ -662,6 +708,15 @@ version = "11.1.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.0"
|
||||
|
|
@ -757,6 +812,30 @@ version = "0.2.16"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.36"
|
||||
|
|
@ -1022,6 +1101,12 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.86"
|
||||
|
|
@ -1039,6 +1124,15 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8"
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
|
|
@ -1048,6 +1142,12 @@ dependencies = [
|
|||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.30"
|
||||
|
|
@ -1468,6 +1568,7 @@ name = "xtask"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap 3.1.1",
|
||||
"heck",
|
||||
"itertools",
|
||||
"strong-xml",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! (Very) partial implementation of SASL Authentication (see [RFC 4422](https://datatracker.ietf.org/doc/html/rfc4422))
|
||||
//!
|
||||
//! Currently only supports PLAN (see [RFC 4616](https://datatracker.ietf.org/doc/html/rfc4616))
|
||||
//! Currently only supports PLAIN (see [RFC 4616](https://datatracker.ietf.org/doc/html/rfc4616))
|
||||
|
||||
use crate::error::{ConException, Result};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
"type": "module",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"fmt": "prettier -w ."
|
||||
"fmt": "prettier -w .",
|
||||
"test": "echo '✔️ Everything fine!'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/amqplib": "^0.8.2",
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.54"
|
||||
clap = { version = "3.1.1", features = ["derive"] }
|
||||
heck = "0.4.0"
|
||||
itertools = "0.10.3"
|
||||
strong-xml = "0.6.3"
|
||||
|
|
@ -4,13 +4,14 @@ mod parser;
|
|||
mod random;
|
||||
mod write;
|
||||
|
||||
use anyhow::Context;
|
||||
use anyhow::{bail, Context};
|
||||
use heck::ToUpperCamelCase;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::iter::Peekable;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::str::FromStr;
|
||||
use strong_xml::XmlRead;
|
||||
|
||||
|
|
@ -105,6 +106,15 @@ struct Codegen {
|
|||
output: Box<dyn Write>,
|
||||
}
|
||||
|
||||
fn fmt(path: &Path) -> anyhow::Result<()> {
|
||||
println!("Formatting {path:?}...");
|
||||
let status = Command::new("rustfmt").arg(path).status()?;
|
||||
if !status.success() {
|
||||
bail!("error formatting {path:?}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn main() -> anyhow::Result<()> {
|
||||
let this_file = PathBuf::from_str(file!()).context("own file path")?;
|
||||
let xtask_root = this_file
|
||||
|
|
@ -125,8 +135,8 @@ pub fn main() -> anyhow::Result<()> {
|
|||
let amqp = Amqp::from_str(&content).context("parse amqp spec file")?;
|
||||
|
||||
let transport_output =
|
||||
File::create(transport_generated_path).context("transport output file create")?;
|
||||
let core_output = File::create(core_generated_path).context("core output file create")?;
|
||||
File::create(&transport_generated_path).context("transport output file create")?;
|
||||
let core_output = File::create(&core_generated_path).context("core output file create")?;
|
||||
|
||||
Codegen {
|
||||
output: Box::new(transport_output),
|
||||
|
|
@ -138,6 +148,9 @@ pub fn main() -> anyhow::Result<()> {
|
|||
}
|
||||
.core_codegen(&amqp);
|
||||
|
||||
fmt(&transport_generated_path)?;
|
||||
fmt(&core_generated_path)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
impl Codegen {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,41 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
mod codegen;
|
||||
mod test_js;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[clap(author)]
|
||||
struct Args {
|
||||
#[clap(subcommand)]
|
||||
command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
/// Generate method definitions/parser/writer
|
||||
Generate,
|
||||
/// Run Javascript integration tests
|
||||
TestJs,
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let command = std::env::args().nth(1).unwrap_or_else(|| {
|
||||
eprintln!("Error: No task provided");
|
||||
help();
|
||||
std::process::exit(1);
|
||||
});
|
||||
let args: Args = Args::parse();
|
||||
|
||||
match command.as_str() {
|
||||
"generate" | "gen" => codegen::main(),
|
||||
_ => {
|
||||
eprintln!("Unknown command {command}.");
|
||||
Ok(())
|
||||
}
|
||||
match args.command {
|
||||
Commands::Generate => codegen::main(),
|
||||
Commands::TestJs => test_js::main(),
|
||||
}
|
||||
}
|
||||
|
||||
fn help() {
|
||||
println!(
|
||||
"Available tasks:
|
||||
generate, gen - Generate amqp method code in `amqp_transport/src/methods/generated.rs and amqp_core/src/methods/generated.rs"
|
||||
);
|
||||
pub fn project_root() -> PathBuf {
|
||||
PathBuf::from(file!())
|
||||
.parent()
|
||||
.expect("src directory path")
|
||||
.parent()
|
||||
.expect("xtask root path")
|
||||
.parent()
|
||||
.expect("project root path")
|
||||
.to_path_buf()
|
||||
}
|
||||
|
|
|
|||
20
xtask/src/test_js.rs
Normal file
20
xtask/src/test_js.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use crate::project_root;
|
||||
use anyhow::{bail, Result};
|
||||
use std::process::Command;
|
||||
|
||||
pub fn main() -> Result<()> {
|
||||
let test_js_root = project_root().join("tests-js");
|
||||
let status = Command::new("yarn").current_dir(&test_js_root).status()?;
|
||||
if !status.success() {
|
||||
bail!("yarn install failed");
|
||||
}
|
||||
let status = Command::new("yarn")
|
||||
.arg("test")
|
||||
.current_dir(&test_js_root)
|
||||
.status()?;
|
||||
if !status.success() {
|
||||
bail!("yarn tests failed");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
4
yarn.lock
Normal file
4
yarn.lock
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue