fix: build
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
c8230091c2
commit
5cfa9ced67
2
build.sh
2
build.sh
@ -6,4 +6,4 @@ cargo build
|
||||
|
||||
popd || exit
|
||||
|
||||
./ci/target/debug/ci
|
||||
dagger run ./ci/target/debug/ci
|
||||
|
@ -16,7 +16,7 @@ async fn main() -> eyre::Result<()> {
|
||||
.build()?,
|
||||
);
|
||||
|
||||
let variants = vec![/*"linux/amd64", */ "linux/arm64"];
|
||||
let variants = vec!["linux/amd64"]; // "linux/arm64"];
|
||||
let platform_variants = Arc::new(Mutex::new(Vec::new()));
|
||||
|
||||
tokio_scoped::scope(|s| {
|
||||
|
37
src/main.rs
37
src/main.rs
@ -15,11 +15,17 @@ async fn main() -> eyre::Result<()> {
|
||||
.arg(clap::Arg::new("repo").long("repo").required(true))
|
||||
.arg(clap::Arg::new("path").long("path").required(true))
|
||||
.arg(clap::Arg::new("out").long("out").required(true))
|
||||
.arg(
|
||||
clap::Arg::new("static-out")
|
||||
.long("static-out")
|
||||
.required(false),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
let repo = matches.get_one::<String>("repo").unwrap();
|
||||
let path = matches.get_one::<String>("path").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");
|
||||
|
||||
@ -56,7 +62,7 @@ async fn main() -> eyre::Result<()> {
|
||||
|
||||
let out_dir = PathBuf::from(out);
|
||||
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? {
|
||||
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 transformed_frontmatter = transform_frontmatter(frontmatter)?;
|
||||
let content = content.replace("assets/", "/assets/");
|
||||
|
||||
let new_article = format!("{}\n{}", transformed_frontmatter, content);
|
||||
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(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user