mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vpm: add 'vpm upgrade' to update all the outdated vpm modules (#6157)
This commit is contained in:
parent
fe5575f384
commit
b5b53a5311
@ -9,7 +9,7 @@ import v.vmod
|
||||
|
||||
const (
|
||||
default_vpm_server_urls = ['https://vpm.vlang.io']
|
||||
valid_vpm_commands = ['help', 'search', 'install', 'update', 'outdated', 'list', 'remove']
|
||||
valid_vpm_commands = ['help', 'search', 'install', 'update', 'upgrade', 'outdated', 'list', 'remove']
|
||||
excluded_dirs = ['cache', 'vlib']
|
||||
supported_vcs_systems = ['git', 'hg']
|
||||
supported_vcs_folders = ['.git', '.hg']
|
||||
@ -76,6 +76,9 @@ fn main() {
|
||||
'update' {
|
||||
vpm_update(module_names)
|
||||
}
|
||||
'upgrade' {
|
||||
vpm_upgrade()
|
||||
}
|
||||
'outdated' {
|
||||
vpm_outdated()
|
||||
}
|
||||
@ -239,9 +242,8 @@ fn vpm_update(m []string) {
|
||||
}
|
||||
}
|
||||
|
||||
fn vpm_outdated() {
|
||||
fn get_outdated() ?[]string {
|
||||
module_names := get_installed_modules()
|
||||
mut errors := 0
|
||||
mut outdated := []string{}
|
||||
for name in module_names {
|
||||
final_module_path := valid_final_path_of_existing_module(name) or {
|
||||
@ -260,11 +262,9 @@ fn vpm_outdated() {
|
||||
mut outputs := []string{}
|
||||
for step in vcs_cmd_steps {
|
||||
res := os.exec(step) or {
|
||||
errors++
|
||||
println('Error while checking latest commits for "$name".')
|
||||
verbose_println('Error command: git fetch')
|
||||
verbose_println('Error details:\n$err')
|
||||
continue
|
||||
return error('Error while checking latest commits for "$name".')
|
||||
}
|
||||
outputs << res.output
|
||||
}
|
||||
@ -272,6 +272,20 @@ fn vpm_outdated() {
|
||||
outdated << name
|
||||
}
|
||||
}
|
||||
return outdated
|
||||
}
|
||||
|
||||
fn vpm_upgrade() {
|
||||
outdated := get_outdated() or { exit(1) }
|
||||
if outdated.len > 0 {
|
||||
vpm_update(outdated)
|
||||
} else {
|
||||
println('Modules are up to date.')
|
||||
}
|
||||
}
|
||||
|
||||
fn vpm_outdated() {
|
||||
outdated := get_outdated() or { exit(1) }
|
||||
if outdated.len > 0 {
|
||||
println('Outdated modules:')
|
||||
for m in outdated {
|
||||
@ -280,9 +294,6 @@ fn vpm_outdated() {
|
||||
} else {
|
||||
println('Modules are up to date.')
|
||||
}
|
||||
if errors > 0 {
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
fn vpm_list() {
|
||||
|
@ -31,6 +31,7 @@ V supports the following commands:
|
||||
remove Remove a module that was installed from VPM.
|
||||
search Search for a module from VPM.
|
||||
update Update an installed module from VPM.
|
||||
upgrade Upgrade all the outdated modules.
|
||||
list List all installed modules.
|
||||
outdated Show installed modules that need updates.
|
||||
* Others:
|
||||
|
@ -70,7 +70,7 @@ fn main() {
|
||||
println('Translating C to V will be available in V 0.3')
|
||||
return
|
||||
}
|
||||
'search', 'install', 'update', 'outdated', 'list', 'remove' {
|
||||
'search', 'install', 'update', 'upgrade', 'outdated', 'list', 'remove' {
|
||||
util.launch_tool(prefs.is_verbose, 'vpm', os.args[1..])
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user