fix: build

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-07-27 01:12:17 +02:00
parent c8230091c2
commit 5cfa9ced67
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394
3 changed files with 38 additions and 3 deletions

View File

@ -6,4 +6,4 @@ cargo build
popd || exit popd || exit
./ci/target/debug/ci dagger run ./ci/target/debug/ci

View File

@ -16,7 +16,7 @@ async fn main() -> eyre::Result<()> {
.build()?, .build()?,
); );
let variants = vec![/*"linux/amd64", */ "linux/arm64"]; let variants = vec!["linux/amd64"]; // "linux/arm64"];
let platform_variants = Arc::new(Mutex::new(Vec::new())); let platform_variants = Arc::new(Mutex::new(Vec::new()));
tokio_scoped::scope(|s| { tokio_scoped::scope(|s| {

View File

@ -15,11 +15,17 @@ async fn main() -> eyre::Result<()> {
.arg(clap::Arg::new("repo").long("repo").required(true)) .arg(clap::Arg::new("repo").long("repo").required(true))
.arg(clap::Arg::new("path").long("path").required(true)) .arg(clap::Arg::new("path").long("path").required(true))
.arg(clap::Arg::new("out").long("out").required(true)) .arg(clap::Arg::new("out").long("out").required(true))
.arg(
clap::Arg::new("static-out")
.long("static-out")
.required(false),
)
.get_matches(); .get_matches();
let repo = matches.get_one::<String>("repo").unwrap(); let repo = matches.get_one::<String>("repo").unwrap();
let path = matches.get_one::<String>("path").unwrap(); let path = matches.get_one::<String>("path").unwrap();
let out = matches.get_one::<String>("out").unwrap(); let out = matches.get_one::<String>("out").unwrap();
let static_out = matches.get_one::<String>("static-out");
tracing::info!(repo = repo, path = path, out = out, "pulling articles"); tracing::info!(repo = repo, path = path, out = out, "pulling articles");
@ -56,7 +62,7 @@ async fn main() -> eyre::Result<()> {
let out_dir = PathBuf::from(out); let out_dir = PathBuf::from(out);
tokio::fs::create_dir_all(&out_dir).await?; tokio::fs::create_dir_all(&out_dir).await?;
let mut dir = tokio::fs::read_dir(repo_dir).await?; let mut dir = tokio::fs::read_dir(&repo_dir).await?;
while let Some(file) = dir.next_entry().await? { while let Some(file) = dir.next_entry().await? {
if let Ok(ft) = file.file_type().await { if let Ok(ft) = file.file_type().await {
@ -66,6 +72,7 @@ async fn main() -> eyre::Result<()> {
let (frontmatter, content) = extract_frontmatter(file_str)?; let (frontmatter, content) = extract_frontmatter(file_str)?;
let transformed_frontmatter = transform_frontmatter(frontmatter)?; let transformed_frontmatter = transform_frontmatter(frontmatter)?;
let content = content.replace("assets/", "/assets/");
let new_article = format!("{}\n{}", transformed_frontmatter, content); let new_article = format!("{}\n{}", transformed_frontmatter, content);
let mut out_file = out_dir.clone(); let mut out_file = out_dir.clone();
@ -76,6 +83,34 @@ async fn main() -> eyre::Result<()> {
} }
} }
if let Some(static_out) = static_out {
let mut assets_dir = repo_dir.clone();
assets_dir.push("assets");
tracing::info!(
asserts_dir = assets_dir.display().to_string(),
"reading assets"
);
match tokio::fs::read_dir(&assets_dir).await {
Ok(mut dir) => {
tokio::fs::create_dir_all(static_out).await?;
while let Some(file) = dir.next_entry().await? {
if let Ok(_file_type) = file.file_type().await {
let from = file.path();
let to = PathBuf::from(static_out).join(file.file_name());
tracing::info!(
from = from.display().to_string(),
to = to.display().to_string(),
"moving file"
);
tokio::fs::rename(from, to).await?;
}
}
}
Err(e) => tracing::error!(error = e.to_string(), "failed to read dir"),
}
}
Ok(()) Ok(())
} }