Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4d9d899
init commit
mkatychev Jun 13, 2025
573100b
changed const
mkatychev Jun 13, 2025
5409a71
get_index impl
mkatychev Jun 13, 2025
3bcf1e9
removed TODOs for callout of registry subcommand
mkatychev Jun 13, 2025
87ed5d1
Merge branch 'main' into feat/registry-submodule
mkatychev Jun 20, 2025
26c3444
made nupm config declarative
mkatychev Jun 24, 2025
67c2826
Merge branch 'main' into feat/registry-submodule
mkatychev Jun 24, 2025
fce3057
updated NUPM_ variables to match nested structure
mkatychev Jun 24, 2025
354dc8e
typos
mkatychev Jun 24, 2025
2efd004
updated initial test variables
mkatychev Jun 24, 2025
5e96f1a
fixed registry typo
mkatychev Jun 24, 2025
0821712
renamed tmp to temp
mkatychev Jun 24, 2025
445be0f
revert temp
mkatychev Jun 24, 2025
1f12490
fixed tmp-dir variable resolution issue
mkatychev Jun 26, 2025
f33f29e
updated with workaround
mkatychev Jun 26, 2025
7d3a1cf
updated test cases for exitsting registry subcommands
mkatychev Jun 26, 2025
12d95c1
initial naive registry describe impl
mkatychev Jun 26, 2025
fe5b26c
registry describe passing test
mkatychev Jun 26, 2025
2907762
moved open-index to module root
mkatychev Jun 26, 2025
11a7a38
removed log calls intest
mkatychev Jun 26, 2025
b054db3
update registry header comment
mkatychev Jun 26, 2025
aa12a95
update registry init shim
mkatychev Jun 26, 2025
d5d6699
partial test pass
mkatychev Jun 27, 2025
bac9659
all tests pass
mkatychev Jun 27, 2025
baaf4f4
revert test mod closuer
mkatychev Jun 27, 2025
8542850
simplify variable setting
mkatychev Jun 28, 2025
af2a6ad
reverted nested nupm config
mkatychev Jul 7, 2025
081677b
remove flaten-nupm-env
mkatychev Jul 7, 2025
01b33b2
added registry_filename constants
mkatychev Jul 7, 2025
b2e85f2
removed fetch command
mkatychev Jul 10, 2025
4c55581
remoted editorconfig
mkatychev Jul 10, 2025
102d970
PR feedback on addtion of registry values
mkatychev Jul 16, 2025
78848fe
revert README
mkatychev Jul 16, 2025
919865b
updated formatting messages
mkatychev Jul 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions nupm/registry.nu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Registry management for nupm

use utils/dirs.nu [nupm-home-prompt REGISTRY_FILENAME]
use utils/log.nu [throw-error UNIMPLEMENTED]
use utils/log.nu [throw-error append-help UNIMPLEMENTED]
use utils/registry.nu registry-cache

# Manage nupm registires
Expand All @@ -16,6 +16,16 @@ export def list []: nothing -> table {
$env.NUPM_REGISTRIES | transpose name url | sort-by name
}

# Formatting convenience function that is passed in the presence of the `--save` flag, informing the user on
# how to make their changes permanent
export def success-msg [success_msg: string, write_path: path, saved_to_disk: bool]: nothing -> string {
if $saved_to_disk {
return $"($success_msg) and written to ($write_path)"
}

$success_msg | append-help "To commit the change to disk, use the `--save` flag."
Comment thread
kubouch marked this conversation as resolved.
}


def registry-names [] { list | get name }
# Show detailed information about a specific registry
Expand Down Expand Up @@ -92,17 +102,13 @@ export def --env add [
throw-error $"Registry '($name)' already exists. Use 'nupm registry update' to modify it."
}
$env.NUPM_REGISTRIES = $env.NUPM_REGISTRIES | insert $name $url
mut add_success_msg = $"Registry '($name)' added successfully"

if $save {
$env.NUPM_REGISTRIES | save --force $env.NUPM_INDEX_PATH
$add_success_msg = $add_success_msg | append $" and written to ($env.NUPM_INDEX_PATH)." | str join " "

} else {
$add_success_msg = $add_success_msg | append $". To commit the change to disk, use the `--save` flag." | str join " "
}

print $add_success_msg
print (success-msg $"Registry '($name)' added successfully" $env.NUPM_INDEX_PATH $save)

}

# Remove a registry
Expand All @@ -117,41 +123,41 @@ export def --env remove [
$env.NUPM_REGISTRIES | save --force $env.NUPM_INDEX_PATH
}

print $"Registry '($name)' removed successfully."
print (success-msg $"Registry '($name)' removed successfully" $env.NUPM_INDEX_PATH $save)
}

# Update a given registry url
@example "Update registry URL" { nupm registry set-url my-registry https://new-url.com/registry.nuon }
export def --env set-url [
name: string, # Name of the registry to update
url: string,
--save, # Whether to commit the change to the registry index
name: string, # Name of the registry to update
url: string, # Registry target URL
--save, # Whether to commit the change to the registry index
]: nothing -> nothing {
$env.NUPM_REGISTRIES = $env.NUPM_REGISTRIES | update $name $url

if $save {
$env.NUPM_REGISTRIES | save --force $env.NUPM_INDEX_PATH
}

print $"Registry '($name)' URL updated successfully."
print (success-msg $"Registry '($name)' URL updated successfully" $env.NUPM_INDEX_PATH $save)
}

# https://www.nushell.sh/book/configuration.html#macos-keeping-usr-bin-open-as-open
alias nu-rename = rename
# Rename a registry
@example "Rename a registry" { nupm registry rename my-registry our-registry }
export def --env rename [
name: string, # Name of the registry to update
new_name: string,
--save, # Whether to commit the change to the registry index
name: string, # Name of the registry to update
new_name: string, # New registry name
--save, # Whether to commit the change to the registry index
] {
$env.NUPM_REGISTRIES = $env.NUPM_REGISTRIES | nu-rename --column { $name: $new_name }

if $save {
$env.NUPM_REGISTRIES | save --force $env.NUPM_INDEX_PATH
}

print $"Registry '($name)' renamed successfully."
print (success-msg $"Registry '($name)' renamed successfully" $env.NUPM_INDEX_PATH $save)
}

def init-index [] {
Expand Down
5 changes: 5 additions & 0 deletions nupm/utils/log.nu
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ export def throw-error [
}
}
}

# Append a formatted help line to mimic `error make` in core
export def append-help [help_msg: string]: string -> string {
$in + $"\n (ansi cyan)help:(ansi reset) " + $help_msg
}
Loading