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,21 @@
use std::{fs::read_to_string, path::PathBuf};
pub fn read_migrate_file(file: PathBuf) -> anyhow::Result<Vec<(PathBuf, PathBuf)>> {
let contents = read_to_string(file)?;
let lines: Vec<String> = contents
.split('\n')
.map(|x| x.to_owned())
.filter(|x| x != "")
.collect();
let migrations = lines
.iter()
.filter_map(|x| x.split_once(" -> "))
.map(|x| {
(
x.0.parse().expect("a valid path"),
x.1.parse().expect("a valid path"),
)
})
.collect::<Vec<_>>();
Ok(migrations)
}