feat: support Vscode packages updates (#536)
feat: support vscode extensions update
This commit is contained in:
@@ -190,6 +190,7 @@ pub enum Step {
|
|||||||
Vagrant,
|
Vagrant,
|
||||||
Vcpkg,
|
Vcpkg,
|
||||||
Vim,
|
Vim,
|
||||||
|
Vscode,
|
||||||
Winget,
|
Winget,
|
||||||
Wsl,
|
Wsl,
|
||||||
WslUpdate,
|
WslUpdate,
|
||||||
|
|||||||
@@ -320,6 +320,9 @@ fn run() -> Result<()> {
|
|||||||
runner.execute(Step::Opam, "opam", || generic::run_opam_update(&ctx))?;
|
runner.execute(Step::Opam, "opam", || generic::run_opam_update(&ctx))?;
|
||||||
runner.execute(Step::Vcpkg, "vcpkg", || generic::run_vcpkg_update(&ctx))?;
|
runner.execute(Step::Vcpkg, "vcpkg", || generic::run_vcpkg_update(&ctx))?;
|
||||||
runner.execute(Step::Pipx, "pipx", || generic::run_pipx_update(&ctx))?;
|
runner.execute(Step::Pipx, "pipx", || generic::run_pipx_update(&ctx))?;
|
||||||
|
runner.execute(Step::Vscode, "Visual Studio Code extensions", || {
|
||||||
|
generic::run_vscode_extensions_upgrade(&ctx)
|
||||||
|
})?;
|
||||||
runner.execute(Step::Conda, "conda", || generic::run_conda_update(&ctx))?;
|
runner.execute(Step::Conda, "conda", || generic::run_conda_update(&ctx))?;
|
||||||
runner.execute(Step::Mamba, "mamba", || generic::run_mamba_update(&ctx))?;
|
runner.execute(Step::Mamba, "mamba", || generic::run_mamba_update(&ctx))?;
|
||||||
runner.execute(Step::Miktex, "miktex", || generic::run_miktex_packages_update(&ctx))?;
|
runner.execute(Step::Miktex, "miktex", || generic::run_miktex_packages_update(&ctx))?;
|
||||||
|
|||||||
@@ -318,6 +318,30 @@ pub fn run_vcpkg_update(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
command.args(["upgrade", "--no-dry-run"]).status_checked()
|
command.args(["upgrade", "--no-dry-run"]).status_checked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run_vscode_extensions_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
let vscode = require("code")?;
|
||||||
|
print_separator("Visual Studio Code extensions");
|
||||||
|
|
||||||
|
// Vscode does not have CLI command to upgrade all extensions (see https://github.com/microsoft/vscode/issues/56578)
|
||||||
|
// Instead we get the list of installed extensions with `code --list-extensions` command (obtain a line-return separated list of installed extensions)
|
||||||
|
let extensions = Command::new(&vscode)
|
||||||
|
.arg("--list-extensions")
|
||||||
|
.output_checked_utf8()?
|
||||||
|
.stdout;
|
||||||
|
|
||||||
|
// Then we construct the upgrade command: `code --force --install-extension [ext0] --install-extension [ext1] ... --install-extension [extN]`
|
||||||
|
if !extensions.is_empty() {
|
||||||
|
let mut command_args = vec!["--force"];
|
||||||
|
for extension in extensions.split_whitespace() {
|
||||||
|
command_args.extend(["--install-extension", extension]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.run_type().execute(&vscode).args(command_args).status_checked()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run_pipx_update(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_pipx_update(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let pipx = require("pipx")?;
|
let pipx = require("pipx")?;
|
||||||
print_separator("pipx");
|
print_separator("pipx");
|
||||||
|
|||||||
Reference in New Issue
Block a user