mirror of
https://github.com/r-darwish/topgrade
synced 2024-07-08 20:16:24 +00:00
Vagrant boxes (#905)
This commit is contained in:
parent
020a0619b8
commit
14809322b4
46
.vscode/launch.json
vendored
Normal file
46
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug executable 'topgrade'",
|
||||
"console": "integratedTerminal",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=topgrade",
|
||||
"--package=topgrade"
|
||||
],
|
||||
"filter": {
|
||||
"name": "topgrade",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in executable 'topgrade'",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"test",
|
||||
"--no-run",
|
||||
"--bin=topgrade",
|
||||
"--package=topgrade"
|
||||
],
|
||||
"filter": {
|
||||
"name": "topgrade",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
12
.vscode/topgrade.code-snippets
vendored
12
.vscode/topgrade.code-snippets
vendored
|
@ -21,5 +21,15 @@
|
|||
"body": [
|
||||
"return Err(SkipStep(format!(\"$1\").into()));"
|
||||
]
|
||||
},
|
||||
"Step": {
|
||||
"scope": "rust",
|
||||
"prefix": "step",
|
||||
"body": [
|
||||
"pub fn $1(ctx: &ExecutionContext) -> Result<()> {",
|
||||
" $0",
|
||||
" Ok(())",
|
||||
"}"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,6 +392,7 @@ fn run() -> Result<()> {
|
|||
}
|
||||
}
|
||||
}
|
||||
runner.execute(Step::Vagrant, "Vagrant boxes", || vagrant::upgrade_vagrant_boxes(&ctx))?;
|
||||
|
||||
if !runner.report().data().is_empty() {
|
||||
print_separator("Summary");
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::{fmt::Display, rc::Rc, str::FromStr};
|
|||
|
||||
use anyhow::Result;
|
||||
use log::{debug, error};
|
||||
use regex::Regex;
|
||||
use strum::EnumString;
|
||||
|
||||
use crate::execution_context::ExecutionContext;
|
||||
|
@ -200,3 +201,35 @@ pub fn topgrade_vagrant_box(ctx: &ExecutionContext, vagrant_box: &VagrantBox) ->
|
|||
.args(&["ssh", "-c", &command])
|
||||
.check_run()
|
||||
}
|
||||
|
||||
pub fn upgrade_vagrant_boxes(ctx: &ExecutionContext) -> Result<()> {
|
||||
let vagrant = utils::require("vagrant")?;
|
||||
print_separator("Vagrant boxes");
|
||||
|
||||
let outdated = Command::new(&vagrant)
|
||||
.args(&["box", "outdated", "--global"])
|
||||
.check_output()?;
|
||||
|
||||
let re = Regex::new(r"\* '(.*?)' for '(.*?)' is outdated").unwrap();
|
||||
|
||||
let mut found = false;
|
||||
for ele in re.captures_iter(&outdated) {
|
||||
found = true;
|
||||
let _ = ctx
|
||||
.run_type()
|
||||
.execute(&vagrant)
|
||||
.args(&["box", "update", "--box"])
|
||||
.arg(&ele.get(1).unwrap().as_str())
|
||||
.arg("--provider")
|
||||
.arg(ele.get(2).unwrap().as_str())
|
||||
.check_run();
|
||||
}
|
||||
|
||||
if !found {
|
||||
println!("No outdated boxes")
|
||||
} else {
|
||||
ctx.run_type().execute(&vagrant).args(&["box", "prune"]).check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user