vpm: replace `-` in author names with `_` (#5583)

pull/5589/head
Lukas Neubert 2020-06-30 21:42:16 +02:00 committed by GitHub
parent 34ddc9240e
commit d40334fe9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 33 deletions

View File

@ -66,10 +66,8 @@ fn main() {
manifest := vmod.from_file('./v.mod') or { manifest := vmod.from_file('./v.mod') or {
panic(err) panic(err)
} }
module_names = manifest.dependencies module_names = manifest.dependencies
} }
vpm_install(module_names) vpm_install(module_names)
} }
'update' { 'update' {
@ -121,7 +119,7 @@ fn vpm_search(keywords []string) {
break break
} }
} }
println('\nUse "v install author.module_name" to install the module') println('\nUse "v install author_name.module_name" to install the module')
if index == 0 { if index == 0 {
println('No module(s) found for "$joined"') println('No module(s) found for "$joined"')
} }
@ -141,7 +139,7 @@ fn vpm_install(module_names []string) {
name := n.trim_space() name := n.trim_space()
mod := get_module_meta_info(name) or { mod := get_module_meta_info(name) or {
errors++ errors++
println('Errors while retrieving meta data for module ${name}:') println('Errors while retrieving meta data for module $name:')
println(err) println(err)
continue continue
} }
@ -154,14 +152,15 @@ fn vpm_install(module_names []string) {
println('Skipping module "$name", since it uses an unsupported VCS {$vcs} .') println('Skipping module "$name", since it uses an unsupported VCS {$vcs} .')
continue continue
} }
final_module_path := os.real_path(os.join_path(settings.vmodules_path,mod.name.replace('.', os.path_separator))) mod_name_as_path := mod.name.replace('.', os.path_separator).replace('-', '_')
final_module_path := os.real_path(os.join_path(settings.vmodules_path, mod_name_as_path))
if os.exists(final_module_path) { if os.exists(final_module_path) {
vpm_update([name]) vpm_update([name])
continue continue
} }
println('Installing module "$name" from $mod.url to $final_module_path ...') println('Installing module "$name" from $mod.url to $final_module_path ...')
vcs_install_cmd := supported_vcs_install_cmds[vcs] vcs_install_cmd := supported_vcs_install_cmds[vcs]
cmd := '${vcs_install_cmd} "${mod.url}" "${final_module_path}"' cmd := '$vcs_install_cmd "$mod.url" "$final_module_path"'
verbose_println(' command: $cmd') verbose_println(' command: $cmd')
cmdres := os.exec(cmd) or { cmdres := os.exec(cmd) or {
errors++ errors++
@ -173,8 +172,8 @@ fn vpm_install(module_names []string) {
if cmdres.exit_code != 0 { if cmdres.exit_code != 0 {
errors++ errors++
println('Failed installing module "$name" to "$final_module_path" .') println('Failed installing module "$name" to "$final_module_path" .')
verbose_println('Failed command: ${cmd}') verbose_println('Failed command: $cmd')
verbose_println('Failed command output:\n${cmdres.output}') verbose_println('Failed command output:\n$cmdres.output')
continue continue
} }
resolve_dependencies(name, final_module_path, module_names) resolve_dependencies(name, final_module_path, module_names)
@ -206,18 +205,18 @@ fn vpm_update(m []string) {
} }
vcs_cmd := supported_vcs_update_cmds[vcs[0]] vcs_cmd := supported_vcs_update_cmds[vcs[0]]
verbose_println(' command: $vcs_cmd') verbose_println(' command: $vcs_cmd')
vcs_res := os.exec('${vcs_cmd}') or { vcs_res := os.exec('$vcs_cmd') or {
errors++ errors++
println('Could not update module "$name".') println('Could not update module "$name".')
verbose_println('Error command: ${vcs_cmd}') verbose_println('Error command: $vcs_cmd')
verbose_println('Error details:\n$err') verbose_println('Error details:\n$err')
continue continue
} }
if vcs_res.exit_code != 0 { if vcs_res.exit_code != 0 {
errors++ errors++
println('Failed updating module "${name}".') println('Failed updating module "$name".')
verbose_println('Failed command: ${vcs_cmd}') verbose_println('Failed command: $vcs_cmd')
verbose_println('Failed details:\n${vcs_res.output}') verbose_println('Failed details:\n$vcs_res.output')
continue continue
} }
resolve_dependencies(name, final_module_path, module_names) resolve_dependencies(name, final_module_path, module_names)
@ -254,7 +253,8 @@ fn vpm_remove(module_names []string) {
} }
fn valid_final_path_of_existing_module(name string) ?string { fn valid_final_path_of_existing_module(name string) ?string {
name_of_vmodules_folder := os.join_path(settings.vmodules_path,name.replace('.', os.path_separator)) mod_name_as_path := name.replace('.', os.path_separator).replace('-', '_')
name_of_vmodules_folder := os.join_path(settings.vmodules_path, mod_name_as_path)
final_module_path := os.real_path(name_of_vmodules_folder) final_module_path := os.real_path(name_of_vmodules_folder)
if !os.exists(final_module_path) { if !os.exists(final_module_path) {
println('No module with name "$name" exists at $name_of_vmodules_folder') println('No module with name "$name" exists at $name_of_vmodules_folder')
@ -382,7 +382,7 @@ fn resolve_dependencies(name, module_path string, module_names []string) {
} }
} }
if deps.len > 0 { if deps.len > 0 {
println('Resolving ${deps.len} dependencies for module "$name"...') println('Resolving $deps.len dependencies for module "$name"...')
verbose_println('Found dependencies: $deps') verbose_println('Found dependencies: $deps')
vpm_install(deps) vpm_install(deps)
} }
@ -391,8 +391,8 @@ fn resolve_dependencies(name, module_path string, module_names []string) {
fn parse_vmod(data string) Vmod { fn parse_vmod(data string) Vmod {
keys := ['name', 'version', 'deps'] keys := ['name', 'version', 'deps']
mut m := { mut m := {
'name': '', 'name': ''
'version': '', 'version': ''
'deps': '' 'deps': ''
} }
for key in keys { for key in keys {
@ -400,7 +400,8 @@ fn parse_vmod(data string) Vmod {
continue continue
} }
key_index += key.len + 1 key_index += key.len + 1
m[key] = data[key_index..data.index_after('\n', key_index)].trim_space().replace("'", '').replace('[', '').replace(']', '') m[key] = data[key_index..data.index_after('\n', key_index)].trim_space().replace("'",
'').replace('[', '').replace(']', '')
} }
mut vmod := Vmod{} mut vmod := Vmod{}
vmod.name = m['name'] vmod.name = m['name']
@ -469,7 +470,8 @@ fn get_module_meta_info(name string) ?Mod {
continue continue
} }
if r.status_code != 200 { if r.status_code != 200 {
errors << 'Skipping module "$name", since $server_url responded with $r.status_code http status code. Please try again later.' errors <<
'Skipping module "$name", since $server_url responded with $r.status_code http status code. Please try again later.'
continue continue
} }
s := r.text s := r.text