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