website/scripts: Add docsmg migration tool (#10658)

* add docsmg tool

* moved to the correct scripts directory

* removed test files
This commit is contained in:
Bama
2024-07-26 15:54:41 -05:00
committed by GitHub
parent 45e464368e
commit 59973d1f06
10 changed files with 878 additions and 0 deletions

View File

@ -0,0 +1,31 @@
use std::path::PathBuf;
use crate::{migratefile::read_migrate_file, recurse_directory};
pub fn generate(migratefile: Option<PathBuf>, migrate_path: PathBuf) {
// if there is a migrate file, read it and get the paths from the left side
let paths: Vec<PathBuf> = match migratefile {
Some(i) => {
let contents = read_migrate_file(i);
if let Ok(contents) = contents {
contents.iter().map(|x| x.0.clone()).collect()
} else {
vec![]
}
}
None => {
vec![]
}
};
// get rid of paths already in the specified migrate file
let paths: Vec<PathBuf> = recurse_directory(migrate_path.clone())
.iter()
.filter(|x| !paths.contains(x))
.filter_map(|x| x.strip_prefix(migrate_path.clone()).ok())
.map(|x| x.to_path_buf())
.collect();
for path in paths {
println!("{} -> ", path.display());
}
}