1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

View File

@ -66,10 +66,8 @@ fn main() {
manifest := vmod.from_file('./v.mod') or {
panic(err)
}
module_names = manifest.dependencies
}
vpm_install(module_names)
}
'update' {
@ -121,7 +119,7 @@ fn vpm_search(keywords []string) {
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 {
println('No module(s) found for "$joined"')
}
@ -141,7 +139,7 @@ fn vpm_install(module_names []string) {
name := n.trim_space()
mod := get_module_meta_info(name) or {
errors++
println('Errors while retrieving meta data for module ${name}:')
println('Errors while retrieving meta data for module $name:')
println(err)
continue
}
@ -154,14 +152,15 @@ fn vpm_install(module_names []string) {
println('Skipping module "$name", since it uses an unsupported VCS {$vcs} .')
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) {
vpm_update([name])
continue
}
println('Installing module "$name" from $mod.url to $final_module_path ...')
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')
cmdres := os.exec(cmd) or {
errors++
@ -173,8 +172,8 @@ fn vpm_install(module_names []string) {
if cmdres.exit_code != 0 {
errors++
println('Failed installing module "$name" to "$final_module_path" .')
verbose_println('Failed command: ${cmd}')
verbose_println('Failed command output:\n${cmdres.output}')
verbose_println('Failed command: $cmd')
verbose_println('Failed command output:\n$cmdres.output')
continue
}
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]]
verbose_println(' command: $vcs_cmd')
vcs_res := os.exec('${vcs_cmd}') or {
vcs_res := os.exec('$vcs_cmd') or {
errors++
println('Could not update module "$name".')
verbose_println('Error command: ${vcs_cmd}')
verbose_println('Error command: $vcs_cmd')
verbose_println('Error details:\n$err')
continue
}
if vcs_res.exit_code != 0 {
errors++
println('Failed updating module "${name}".')
verbose_println('Failed command: ${vcs_cmd}')
verbose_println('Failed details:\n${vcs_res.output}')
println('Failed updating module "$name".')
verbose_println('Failed command: $vcs_cmd')
verbose_println('Failed details:\n$vcs_res.output')
continue
}
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 {
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)
if !os.exists(final_module_path) {
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 {
println('Resolving ${deps.len} dependencies for module "$name"...')
println('Resolving $deps.len dependencies for module "$name"...')
verbose_println('Found dependencies: $deps')
vpm_install(deps)
}
@ -391,8 +391,8 @@ fn resolve_dependencies(name, module_path string, module_names []string) {
fn parse_vmod(data string) Vmod {
keys := ['name', 'version', 'deps']
mut m := {
'name': '',
'version': '',
'name': ''
'version': ''
'deps': ''
}
for key in keys {
@ -400,7 +400,8 @@ fn parse_vmod(data string) Vmod {
continue
}
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{}
vmod.name = m['name']
@ -469,7 +470,8 @@ fn get_module_meta_info(name string) ?Mod {
continue
}
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
}
s := r.text