feat(vscode): updated extensions for a given profile (#1022)
* [feat] select user profile for vscode * [feat] Update example config file * [fix] Remove unneeded imports * [feat] PR comments * [fix] formatting
This commit is contained in:
committed by
GitHub
parent
3e0c21e981
commit
66a12cc8bf
@@ -103,8 +103,8 @@
|
|||||||
# enable_pipupgrade = true ###disabled by default
|
# enable_pipupgrade = true ###disabled by default
|
||||||
# pipupgrade_arguments = "-y -u --pip-path pip" ###disabled by default
|
# pipupgrade_arguments = "-y -u --pip-path pip" ###disabled by default
|
||||||
|
|
||||||
# For the poetry step, by default, Topgrade skips its update if poetry is not
|
# For the poetry step, by default, Topgrade skips its update if poetry is not
|
||||||
# installed with the official script. This configuration entry forces Topgrade
|
# installed with the official script. This configuration entry forces Topgrade
|
||||||
# to run the update in this case.
|
# to run the update in this case.
|
||||||
#
|
#
|
||||||
# (default: false)
|
# (default: false)
|
||||||
@@ -315,3 +315,9 @@
|
|||||||
# If enabled, each updated version above will be marked with `zigup keep`.
|
# If enabled, each updated version above will be marked with `zigup keep`.
|
||||||
# (default: false)
|
# (default: false)
|
||||||
# cleanup = false
|
# cleanup = false
|
||||||
|
|
||||||
|
[vscode]
|
||||||
|
# If this is set and is a non-empty string, it specifies the profile the
|
||||||
|
# extensions should be updated for.
|
||||||
|
# (default: this won't be set by default)
|
||||||
|
# profile = ""
|
||||||
|
|||||||
@@ -471,6 +471,12 @@ pub struct Zigup {
|
|||||||
cleanup: Option<bool>,
|
cleanup: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Default, Debug, Merge)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct VscodeConfig {
|
||||||
|
profile: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug, Merge)]
|
#[derive(Deserialize, Default, Debug, Merge)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
/// Configuration file
|
/// Configuration file
|
||||||
@@ -543,6 +549,9 @@ pub struct ConfigFile {
|
|||||||
|
|
||||||
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
|
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
|
||||||
zigup: Option<Zigup>,
|
zigup: Option<Zigup>,
|
||||||
|
|
||||||
|
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
|
||||||
|
vscode: Option<VscodeConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config_directory() -> PathBuf {
|
fn config_directory() -> PathBuf {
|
||||||
@@ -1710,6 +1719,17 @@ impl Config {
|
|||||||
.and_then(|zigup| zigup.cleanup)
|
.and_then(|zigup| zigup.cleanup)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn vscode_profile(&self) -> Option<&str> {
|
||||||
|
let vscode_cfg = self.config_file.vscode.as_ref()?;
|
||||||
|
let profile = vscode_cfg.profile.as_ref()?;
|
||||||
|
|
||||||
|
if profile.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(profile.as_str())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -469,10 +469,19 @@ pub fn run_vscode_extensions_update(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
|
|
||||||
print_separator("Visual Studio Code extensions");
|
print_separator("Visual Studio Code extensions");
|
||||||
|
|
||||||
ctx.run_type()
|
if let Some(profile) = ctx.config().vscode_profile() {
|
||||||
.execute(vscode)
|
ctx.run_type()
|
||||||
.arg("--update-extensions")
|
.execute(vscode)
|
||||||
.status_checked()
|
.arg("--profile")
|
||||||
|
.arg(profile)
|
||||||
|
.arg("--update-extensions")
|
||||||
|
.status_checked()
|
||||||
|
} else {
|
||||||
|
ctx.run_type()
|
||||||
|
.execute(vscode)
|
||||||
|
.arg("--update-extensions")
|
||||||
|
.status_checked()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_pipx_update(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_pipx_update(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user