From 2f481afe7508f171bb27e65071e78c0d444ba29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Fri, 22 Mar 2024 19:22:24 +0200 Subject: [PATCH 01/43] Make test env more robust --- toolkit.nu | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/toolkit.nu b/toolkit.nu index 0d15bfe..974b843 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -1,10 +1,15 @@ export def --env set-nupm-env [] { - $env.NUPM_HOME = ('./_nupm_dev' | path expand) - $env.NUPM_CACHE = ('./_nupm_dev/cache' | path expand) - $env.NUPM_TEMP = ('./_nupm_dev/tmp' | path expand) + if ($env.PWD | path basename) != 'nupm' { + print 'Run from nupm repo root' + return + } - $env.PATH ++= [('./_nupm_dev/scripts' | path expand)] - $env.NU_LIB_DIRS ++= [('./_nupm_dev/modules' | path expand)] + $env.NUPM_HOME = ($env.PWD | path join '_nupm_dev') + $env.NUPM_CACHE = ($env.PWD | path join '_nupm_dev/cache') + $env.NUPM_TEMP = ($env.PWD | path join '_nupm_dev/tmp') + + $env.PATH = ($env.PATH | prepend ($env.PWD | path join '_nupm_dev/scripts')) + $env.NU_LIB_DIRS = ($env.NU_LIB_DIRS | prepend ($env.PWD | path join '_nupm_dev/modules')) print-nupm-env } From e079bbb8aa6486307f23ea6292c16bd3eb9307b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 23 Mar 2024 00:36:53 +0200 Subject: [PATCH 02/43] Add nupm publish command --- nupm/mod.nu | 3 +- nupm/publish.nu | 144 +++++++++++++++++++++++++++++++++++ nupm/utils/version.nu | 14 ++-- tests/mod.nu | 25 ++++++ tests/packages/registry.nuon | 4 +- 5 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 nupm/publish.nu diff --git a/nupm/mod.nu b/nupm/mod.nu index e75f799..97954f3 100644 --- a/nupm/mod.nu +++ b/nupm/mod.nu @@ -4,9 +4,10 @@ use utils/dirs.nu [ ] export module install.nu -export module test.nu +export module publish.nu export module search.nu export module status.nu +export module test.nu export-env { # Ensure that $env.NUPM_HOME is always set when running nupm. Any missing diff --git a/nupm/publish.nu b/nupm/publish.nu new file mode 100644 index 0000000..f71e50b --- /dev/null +++ b/nupm/publish.nu @@ -0,0 +1,144 @@ +use utils/log.nu throw-error +use utils/package.nu open-package-file +use utils/version.nu sort-by-version + +# Generate package metadata and optionally add them to a registry +# +# Needs to run from package root, i.e., where nupm.nuon is. +export def main [] { } + +export def git [ + registry?: string + --url(-u): string + --path(-p): string + --revision(-r): string + --save +]: [nothing -> nothing, nothing -> record] { + let pkg = open-package-file $env.PWD + let url = $url | default (guess-url) + let revision = $revision | default (guess-revision) + + let result = { + name: $pkg.name + version: $pkg.version + url: $url + revision: $revision + path: $path + } + + if $registry == null { + $result + } else { + let reg_path = $registry | get-registry-path + let reg_content = $reg_path | open-registry-file + let updated = $reg_content | update-registry $result $registry "git" + + if $save { + $updated | save --force $reg_path + } else { + $updated + } + } +} + +export def local [ + registry?: string + --path(-p): string + --save +]: [nothing -> nothing, nothing -> record] { + let pkg = open-package-file $env.PWD + + let result = { + name: $pkg.name + version: $pkg.version + path: $path + } + + if $registry == null { + $result + } else { + let reg_path = $registry | get-registry-path + + let path = try { + $env.PWD | path relative-to ($reg_path | path dirname) + } catch { + $env.PWD + } + + let $path = if ($path | is-empty) { null } else { $path } + let result = $result | update path $path + + let reg_content = $reg_path | open-registry-file + let updated = $reg_content | update-registry $result $registry "local" + + if $save { + $updated | save --force $reg_path + } else { + $updated + } + } +} + +def guess-url [] -> string { + mut url = ^git remote get-url origin | complete | get stdout + + if ($url | is-empty) { + let first_remote = ^git remote | lines | first + $url = (^git remote get-url $first_remote | complete | get stdout) + } + + $url | str trim +} + +def guess-revision [] -> string { + mut revision = ^git describe --tags --abbrev=0 | complete | get stdout + + if ($revision | is-empty) { + $revision = (^git rev-parse HEAD | complete | get stdout) + } + + $revision | str trim +} + +def get-registry-path []: string -> path { + let registry = $in + $env.NUPM_REGISTRIES | get -i $registry | default ($registry | path expand) +} + +def open-registry-file []: path -> record { + let reg_path = $in + + let reg_content = try { open $reg_path } + + if ($reg_content | is-not-empty) and ($reg_content | describe -d | get type) != 'record' { + throw-error ($"Unexpected content of registry ($reg_path)." + + " Needs a record.") + } + + $reg_content | default {} +} + +def update-registry [pkg_entry: record, registry: string, type: string]: record -> record { + let reg_content = $in + + let pkgs_local = $reg_content | get -i local | default [] + let pkgs_git = $reg_content | get -i git | default [] + let pkgs_all = $pkgs_local | append $pkgs_git + + if ($pkg_entry.name in $pkgs_all.name + and $pkg_entry.version in $pkgs_all.version) { + throw-error ($"Package ($pkg_entry.name) version ($pkg_entry.version)" + + $" is already present in registry ($registry)") + } + + let pkgs_out = match $type { + "git" => $pkgs_git, + "local" => $pkgs_local, + _ => { throw-error $"Internal error: wrong registry type ($type)" } + } + + $reg_content | upsert $type ($pkgs_out + | append $pkg_entry + | sort-by name + | sort-by-version) +} diff --git a/nupm/utils/version.nu b/nupm/utils/version.nu index 58eb36a..0a24b3b 100644 --- a/nupm/utils/version.nu +++ b/nupm/utils/version.nu @@ -3,16 +3,10 @@ # We might move some of this to Nushell builtins # Sort packages by version -def sort-by-version []: table -> table { +export def sort-by-version []: table -> table { sort-by version } -# Check if the target version is equal or higher than the target version -def matches-version [version: string]: string -> bool { - # TODO: Add proper version matching - $in == $version -} - # Filter packages by version and sort them by version export def filter-by-version [version: any]: table -> table { if $version == null { @@ -22,3 +16,9 @@ export def filter-by-version [version: any]: table -> table bool { + # TODO: Add proper version matching + $in == $version +} diff --git a/tests/mod.nu b/tests/mod.nu index 8b25aab..4f07c01 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -147,3 +147,28 @@ export def env-vars-are-set [] { assert equal $env.NUPM_CACHE $dirs.DEFAULT_NUPM_CACHE assert equal $env.NUPM_REGISTRIES $dirs.DEFAULT_NUPM_REGISTRIES } + +export def generate-local-registry [] { + with-test-env { + # let reg_file = [tests packages registry.nuon] + # | path join + # | path parse + # | update stem test.nuon + + cp -r tests/packages $env.NUPM_TEMP + + let reg_file = $env.NUPM_TEMP | path join packages registry.nuon + let tmp_reg_file = $env.NUPM_TEMP | path join packages test_registry.nuon + + + [spam_script spam_script_old spam_custom spam_module] | each {|pkg| + cd ($env.NUPM_TEMP | path join packages $pkg) + nupm publish local $tmp_reg_file --save + } + + let expected = open $reg_file | to nuon + let actual = open $tmp_reg_file | to nuon + + assert equal $actual $expected + } +} diff --git a/tests/packages/registry.nuon b/tests/packages/registry.nuon index 5eed899..c6d6bdb 100644 --- a/tests/packages/registry.nuon +++ b/tests/packages/registry.nuon @@ -2,9 +2,9 @@ { local: [ [name version path]; - [spam_script 0.2.0 spam_script] - [spam_script 0.1.0 spam_script_old] [spam_custom 0.1.0 spam_custom] [spam_module 0.1.0 spam_module] + [spam_script 0.1.0 spam_script_old] + [spam_script 0.2.0 spam_script] ] } From e66256f9ecb6acde2e7fc8cffe6896caf5d3e55c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 23 Mar 2024 00:49:27 +0200 Subject: [PATCH 03/43] Add registry doc --- docs/design/registry.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 docs/design/registry.md diff --git a/docs/design/registry.md b/docs/design/registry.md new file mode 100644 index 0000000..37a01ca --- /dev/null +++ b/docs/design/registry.md @@ -0,0 +1,29 @@ +# Registry + +_moved from old registry.nuon_ + +Registry is a NUON file that tells nupm where to look for packages + +Currently, these package types are supported: +* git ..... package is an online git repository +* local ... package is on a local filesystem + +The package type defines the columns of the registry record. Each column holds +holds a table of packages. + +Git packages accept the following columns: +* name ....... name of the package +* version .... version of the package +* url ........ Git URL of the package +* revision ... Git revision to check out when installing the package (commit + hash, version, branch name, ...) +* path ....... Path relative to the repository root where to look for nupm.nuon + +Local packages accept the following columns: +* name ....... name of the package +* version .... version of the package +* path ....... Path where to look for nupm.nuon. It can be absolute, or + relative. If relative, then relative to the registry file. + +One registry can contain packages with the same name, but they must be of +different version. From bcaa264af3c8e289ce2dc004d6618cc2a16e186b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 23 Mar 2024 00:51:23 +0200 Subject: [PATCH 04/43] Remove top-level nupm publish --- nupm/publish.nu | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nupm/publish.nu b/nupm/publish.nu index f71e50b..ffe22b5 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -2,11 +2,9 @@ use utils/log.nu throw-error use utils/package.nu open-package-file use utils/version.nu sort-by-version -# Generate package metadata and optionally add them to a registry +# Generate git package metadata and optionally add them to a registry # # Needs to run from package root, i.e., where nupm.nuon is. -export def main [] { } - export def git [ registry?: string --url(-u): string @@ -41,6 +39,9 @@ export def git [ } } +# Generate local package metadata and optionally add them to a registry +# +# Needs to run from package root, i.e., where nupm.nuon is. export def local [ registry?: string --path(-p): string From 8e6fee5ed58de640c5afd566ef54bf76f792d9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Fri, 22 Mar 2024 19:22:24 +0200 Subject: [PATCH 05/43] Make test env more robust --- toolkit.nu | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/toolkit.nu b/toolkit.nu index 0d15bfe..974b843 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -1,10 +1,15 @@ export def --env set-nupm-env [] { - $env.NUPM_HOME = ('./_nupm_dev' | path expand) - $env.NUPM_CACHE = ('./_nupm_dev/cache' | path expand) - $env.NUPM_TEMP = ('./_nupm_dev/tmp' | path expand) + if ($env.PWD | path basename) != 'nupm' { + print 'Run from nupm repo root' + return + } - $env.PATH ++= [('./_nupm_dev/scripts' | path expand)] - $env.NU_LIB_DIRS ++= [('./_nupm_dev/modules' | path expand)] + $env.NUPM_HOME = ($env.PWD | path join '_nupm_dev') + $env.NUPM_CACHE = ($env.PWD | path join '_nupm_dev/cache') + $env.NUPM_TEMP = ($env.PWD | path join '_nupm_dev/tmp') + + $env.PATH = ($env.PATH | prepend ($env.PWD | path join '_nupm_dev/scripts')) + $env.NU_LIB_DIRS = ($env.NU_LIB_DIRS | prepend ($env.PWD | path join '_nupm_dev/modules')) print-nupm-env } From 3524db8223be0a42121203f5cb14af1cbb0f1e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 23 Mar 2024 00:36:53 +0200 Subject: [PATCH 06/43] Add nupm publish command --- nupm/mod.nu | 3 +- nupm/publish.nu | 144 +++++++++++++++++++++++++++++++++++ nupm/utils/version.nu | 14 ++-- tests/mod.nu | 25 ++++++ tests/packages/registry.nuon | 4 +- 5 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 nupm/publish.nu diff --git a/nupm/mod.nu b/nupm/mod.nu index e75f799..97954f3 100644 --- a/nupm/mod.nu +++ b/nupm/mod.nu @@ -4,9 +4,10 @@ use utils/dirs.nu [ ] export module install.nu -export module test.nu +export module publish.nu export module search.nu export module status.nu +export module test.nu export-env { # Ensure that $env.NUPM_HOME is always set when running nupm. Any missing diff --git a/nupm/publish.nu b/nupm/publish.nu new file mode 100644 index 0000000..f71e50b --- /dev/null +++ b/nupm/publish.nu @@ -0,0 +1,144 @@ +use utils/log.nu throw-error +use utils/package.nu open-package-file +use utils/version.nu sort-by-version + +# Generate package metadata and optionally add them to a registry +# +# Needs to run from package root, i.e., where nupm.nuon is. +export def main [] { } + +export def git [ + registry?: string + --url(-u): string + --path(-p): string + --revision(-r): string + --save +]: [nothing -> nothing, nothing -> record] { + let pkg = open-package-file $env.PWD + let url = $url | default (guess-url) + let revision = $revision | default (guess-revision) + + let result = { + name: $pkg.name + version: $pkg.version + url: $url + revision: $revision + path: $path + } + + if $registry == null { + $result + } else { + let reg_path = $registry | get-registry-path + let reg_content = $reg_path | open-registry-file + let updated = $reg_content | update-registry $result $registry "git" + + if $save { + $updated | save --force $reg_path + } else { + $updated + } + } +} + +export def local [ + registry?: string + --path(-p): string + --save +]: [nothing -> nothing, nothing -> record] { + let pkg = open-package-file $env.PWD + + let result = { + name: $pkg.name + version: $pkg.version + path: $path + } + + if $registry == null { + $result + } else { + let reg_path = $registry | get-registry-path + + let path = try { + $env.PWD | path relative-to ($reg_path | path dirname) + } catch { + $env.PWD + } + + let $path = if ($path | is-empty) { null } else { $path } + let result = $result | update path $path + + let reg_content = $reg_path | open-registry-file + let updated = $reg_content | update-registry $result $registry "local" + + if $save { + $updated | save --force $reg_path + } else { + $updated + } + } +} + +def guess-url [] -> string { + mut url = ^git remote get-url origin | complete | get stdout + + if ($url | is-empty) { + let first_remote = ^git remote | lines | first + $url = (^git remote get-url $first_remote | complete | get stdout) + } + + $url | str trim +} + +def guess-revision [] -> string { + mut revision = ^git describe --tags --abbrev=0 | complete | get stdout + + if ($revision | is-empty) { + $revision = (^git rev-parse HEAD | complete | get stdout) + } + + $revision | str trim +} + +def get-registry-path []: string -> path { + let registry = $in + $env.NUPM_REGISTRIES | get -i $registry | default ($registry | path expand) +} + +def open-registry-file []: path -> record { + let reg_path = $in + + let reg_content = try { open $reg_path } + + if ($reg_content | is-not-empty) and ($reg_content | describe -d | get type) != 'record' { + throw-error ($"Unexpected content of registry ($reg_path)." + + " Needs a record.") + } + + $reg_content | default {} +} + +def update-registry [pkg_entry: record, registry: string, type: string]: record -> record { + let reg_content = $in + + let pkgs_local = $reg_content | get -i local | default [] + let pkgs_git = $reg_content | get -i git | default [] + let pkgs_all = $pkgs_local | append $pkgs_git + + if ($pkg_entry.name in $pkgs_all.name + and $pkg_entry.version in $pkgs_all.version) { + throw-error ($"Package ($pkg_entry.name) version ($pkg_entry.version)" + + $" is already present in registry ($registry)") + } + + let pkgs_out = match $type { + "git" => $pkgs_git, + "local" => $pkgs_local, + _ => { throw-error $"Internal error: wrong registry type ($type)" } + } + + $reg_content | upsert $type ($pkgs_out + | append $pkg_entry + | sort-by name + | sort-by-version) +} diff --git a/nupm/utils/version.nu b/nupm/utils/version.nu index 58eb36a..0a24b3b 100644 --- a/nupm/utils/version.nu +++ b/nupm/utils/version.nu @@ -3,16 +3,10 @@ # We might move some of this to Nushell builtins # Sort packages by version -def sort-by-version []: table -> table { +export def sort-by-version []: table -> table { sort-by version } -# Check if the target version is equal or higher than the target version -def matches-version [version: string]: string -> bool { - # TODO: Add proper version matching - $in == $version -} - # Filter packages by version and sort them by version export def filter-by-version [version: any]: table -> table { if $version == null { @@ -22,3 +16,9 @@ export def filter-by-version [version: any]: table -> table bool { + # TODO: Add proper version matching + $in == $version +} diff --git a/tests/mod.nu b/tests/mod.nu index 8b25aab..4f07c01 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -147,3 +147,28 @@ export def env-vars-are-set [] { assert equal $env.NUPM_CACHE $dirs.DEFAULT_NUPM_CACHE assert equal $env.NUPM_REGISTRIES $dirs.DEFAULT_NUPM_REGISTRIES } + +export def generate-local-registry [] { + with-test-env { + # let reg_file = [tests packages registry.nuon] + # | path join + # | path parse + # | update stem test.nuon + + cp -r tests/packages $env.NUPM_TEMP + + let reg_file = $env.NUPM_TEMP | path join packages registry.nuon + let tmp_reg_file = $env.NUPM_TEMP | path join packages test_registry.nuon + + + [spam_script spam_script_old spam_custom spam_module] | each {|pkg| + cd ($env.NUPM_TEMP | path join packages $pkg) + nupm publish local $tmp_reg_file --save + } + + let expected = open $reg_file | to nuon + let actual = open $tmp_reg_file | to nuon + + assert equal $actual $expected + } +} diff --git a/tests/packages/registry.nuon b/tests/packages/registry.nuon index 5eed899..c6d6bdb 100644 --- a/tests/packages/registry.nuon +++ b/tests/packages/registry.nuon @@ -2,9 +2,9 @@ { local: [ [name version path]; - [spam_script 0.2.0 spam_script] - [spam_script 0.1.0 spam_script_old] [spam_custom 0.1.0 spam_custom] [spam_module 0.1.0 spam_module] + [spam_script 0.1.0 spam_script_old] + [spam_script 0.2.0 spam_script] ] } From 1cefbe03368f6b607e4b3df592a9d148c244556d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 23 Mar 2024 00:49:27 +0200 Subject: [PATCH 07/43] Add registry doc --- docs/design/registry.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 docs/design/registry.md diff --git a/docs/design/registry.md b/docs/design/registry.md new file mode 100644 index 0000000..37a01ca --- /dev/null +++ b/docs/design/registry.md @@ -0,0 +1,29 @@ +# Registry + +_moved from old registry.nuon_ + +Registry is a NUON file that tells nupm where to look for packages + +Currently, these package types are supported: +* git ..... package is an online git repository +* local ... package is on a local filesystem + +The package type defines the columns of the registry record. Each column holds +holds a table of packages. + +Git packages accept the following columns: +* name ....... name of the package +* version .... version of the package +* url ........ Git URL of the package +* revision ... Git revision to check out when installing the package (commit + hash, version, branch name, ...) +* path ....... Path relative to the repository root where to look for nupm.nuon + +Local packages accept the following columns: +* name ....... name of the package +* version .... version of the package +* path ....... Path where to look for nupm.nuon. It can be absolute, or + relative. If relative, then relative to the registry file. + +One registry can contain packages with the same name, but they must be of +different version. From 5fc741bdb76fca0dd5e295b7c52a6cd69391e162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 23 Mar 2024 00:51:23 +0200 Subject: [PATCH 08/43] Remove top-level nupm publish --- nupm/publish.nu | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nupm/publish.nu b/nupm/publish.nu index f71e50b..ffe22b5 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -2,11 +2,9 @@ use utils/log.nu throw-error use utils/package.nu open-package-file use utils/version.nu sort-by-version -# Generate package metadata and optionally add them to a registry +# Generate git package metadata and optionally add them to a registry # # Needs to run from package root, i.e., where nupm.nuon is. -export def main [] { } - export def git [ registry?: string --url(-u): string @@ -41,6 +39,9 @@ export def git [ } } +# Generate local package metadata and optionally add them to a registry +# +# Needs to run from package root, i.e., where nupm.nuon is. export def local [ registry?: string --path(-p): string From 30725d79cf65179ccfb75697517450ecb477b66a Mon Sep 17 00:00:00 2001 From: kubouch Date: Mon, 25 Mar 2024 21:02:40 +0200 Subject: [PATCH 09/43] Fix toolkit env on Windows --- toolkit.nu | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/toolkit.nu b/toolkit.nu index 974b843..382c7b0 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -4,12 +4,17 @@ export def --env set-nupm-env [] { return } - $env.NUPM_HOME = ($env.PWD | path join '_nupm_dev') - $env.NUPM_CACHE = ($env.PWD | path join '_nupm_dev/cache') - $env.NUPM_TEMP = ($env.PWD | path join '_nupm_dev/tmp') + $env.NUPM_HOME = ($env.PWD | path join _nupm_dev) + $env.NUPM_CACHE = ($env.PWD | path join _nupm_dev cache) + $env.NUPM_TEMP = ($env.PWD | path join _nupm_dev tmp) + $env.NUPM_REGISTRIES = { nupm_dev: ($env.PWD | path join registry registry.nuon) } - $env.PATH = ($env.PATH | prepend ($env.PWD | path join '_nupm_dev/scripts')) - $env.NU_LIB_DIRS = ($env.NU_LIB_DIRS | prepend ($env.PWD | path join '_nupm_dev/modules')) + if $nu.os-info.family == 'windows' and 'Path' in $env { + $env.Path = ($env.Path | prepend ($env.PWD | path join _nupm_dev scripts)) + } else if 'PATH' in $env { + $env.PATH = ($env.PATH | prepend ($env.PWD | path join _nupm_dev scripts)) + } + $env.NU_LIB_DIRS = ($env.NU_LIB_DIRS | prepend ($env.PWD | path join _nupm_dev modules)) print-nupm-env } @@ -18,6 +23,13 @@ export def print-nupm-env [] { print $'NUPM_HOME: ($env.NUPM_HOME?)' print $'NUPM_CACHE: ($env.NUPM_CACHE?)' print $'NUPM_TEMP: ($env.NUPM_TEMP?)' - print $'PATH: ($env.PATH?)' + if $nu.os-info.family == 'windows' and 'Path' in $env { + print $'Path: ($env.Path?)' + } else if 'PATH' in $env { + print $'PATH: ($env.PATH?)' + } else { + print 'no PATH env var' + } print $'NU_LIB_DIRS: ($env.NU_LIB_DIRS?)' + print $'NUPM_REGISTRIES: ($env.NUPM_REGISTRIES?)' } From 852bef2aebd9efaeaa81ff0aec03cc5bd5b65bf1 Mon Sep 17 00:00:00 2001 From: kubouch Date: Mon, 25 Mar 2024 21:25:12 +0200 Subject: [PATCH 10/43] Reorder comparison --- nupm/utils/registry.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index 5ad32cb..d895e2a 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -20,7 +20,7 @@ export def search-package [ } let name_matcher: closure = if $exact_match { - {|row| $row.name == $package } + {|row| $package == $row.name } } else { {|row| $package in $row.name } } From ed6172bee8ea3b83ddbc93a1fcdf72f1fb0e9d16 Mon Sep 17 00:00:00 2001 From: kubouch Date: Mon, 25 Mar 2024 21:27:16 +0200 Subject: [PATCH 11/43] Add missing import --- nupm/utils/registry.nu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index d895e2a..d12971b 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -1,5 +1,7 @@ # Utilities related to nupm registries +use misc.nu check-cols + # Search for a package in a registry export def search-package [ package: string # Name of the package From a8e59890bbfacf912745843c2a00994eb2e750e6 Mon Sep 17 00:00:00 2001 From: kubouch Date: Mon, 25 Mar 2024 22:20:25 +0200 Subject: [PATCH 12/43] Revamp package search for new registry --- nupm/search.nu | 3 +- nupm/utils/registry.nu | 67 +++++++++++++++++++++++++----------------- toolkit.nu | 3 +- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/nupm/search.nu b/nupm/search.nu index 4695826..bcbd621 100644 --- a/nupm/search.nu +++ b/nupm/search.nu @@ -7,6 +7,7 @@ export def main [ --registry: string@complete-registries # Which registry to use (either a name # in $env.NUPM_REGISTRIES or a path) --pkg-version(-v): string # Package version to install + --exact-match(-e) # Match package name exactly ]: nothing -> table { - search-package $package --registry $registry --version $pkg_version + search-package $package --registry $registry --version $pkg_version --exact-match=$exact_match } diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index d12971b..2ce0803 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -1,6 +1,8 @@ # Utilities related to nupm registries +use dirs.nu cache-dir use misc.nu check-cols +use version.nu filter-by-version # Search for a package in a registry export def search-package [ @@ -17,7 +19,7 @@ export def search-package [ let reg_name = $registry | path parse | get stem { $reg_name: $registry } } else { - # Otherwise use $env.NUPM_REGISTRIES + # Otherwise use $env.NUPM_REGISTRIES as-is $env.NUPM_REGISTRIES } @@ -29,47 +31,58 @@ export def search-package [ # Collect all registries matching the package and all matching packages let regs = $registries - | items {|name, path| + | items {|name, url_or_path| # Open registry (online or offline) - let registry = if ($path | path type) == file { - open $path + let registry = if ($url_or_path | path type) == file { + { + reg: (open $url_or_path) + path: $url_or_path + } + } else { try { - let reg = http get $path + let reg = http get $url_or_path - if local in $reg { - throw-error ("Can't have local packages in online registry" - + $" '($path)'.") - } + let reg_file = cache-dir --ensure + | path join registry $'($name).nuon' + + mkdir ($reg_file | path dirname) + $reg | save --force $reg_file - $reg + { + reg: $reg + path: $reg_file + } } catch { - throw-error $"Cannot open '($path)' as a file or URL." + throw-error $"Cannot open '($url_or_path)' as a file or URL." } } - $registry | check-cols --missing-ok "registry" [ git local ] | ignore + $registry.reg + | check-cols "registry" [ name path url ] + | ignore # Find all packages matching $package in the registry - let pkgs_local = $registry.local? - | default [] - | check-cols "local packages" [ name version path ] - | filter $name_matcher + let pkg_files = $registry.reg | filter $name_matcher + + let pkgs = $pkg_files | each {|row| + let pkg_file_path = $registry.path + | path dirname + | path join $row.path - let pkgs_git = $registry.git? - | default [] - | check-cols "git packages" [ name version url revision path ] - | filter $name_matcher + if $row.url != null { + let pkg_file_content = http get $row.url + $pkg_file_content | save --force $pkg_file_path + } - let pkgs = $pkgs_local - | insert type local - | insert url null - | insert revision null - | append ($pkgs_git | insert type git) + open $pkg_file_path + } + | flatten + | filter-by-version $version { - name: $name - path: $path + registry_name: $name + registry_path: $registry.path pkgs: $pkgs } } diff --git a/toolkit.nu b/toolkit.nu index 382c7b0..d07b87f 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -7,7 +7,8 @@ export def --env set-nupm-env [] { $env.NUPM_HOME = ($env.PWD | path join _nupm_dev) $env.NUPM_CACHE = ($env.PWD | path join _nupm_dev cache) $env.NUPM_TEMP = ($env.PWD | path join _nupm_dev tmp) - $env.NUPM_REGISTRIES = { nupm_dev: ($env.PWD | path join registry registry.nuon) } + # $env.NUPM_REGISTRIES = { nupm_dev: ($env.PWD | path join registry registry.nuon) } + $env.NUPM_REGISTRIES = { nupm_dev: 'https://git.sr.ht/~kubouch/nupkgs/blob/main/registry/registry.nuon' } if $nu.os-info.family == 'windows' and 'Path' in $env { $env.Path = ($env.Path | prepend ($env.PWD | path join _nupm_dev scripts)) From d0c3f91a5467226b01f6294775a0ccde19383427 Mon Sep 17 00:00:00 2001 From: kubouch Date: Mon, 25 Mar 2024 22:20:50 +0200 Subject: [PATCH 13/43] Add new registry style --- registry/nu-clippy.nuon | 1 + registry/nu-discord-update.nuon | 1 + registry/nu-fonts-install.nuon | 1 + registry/nu-git-manager-sugar.nuon | 1 + registry/nu-git-manager.nuon | 1 + registry/nu-hooks.nuon | 1 + registry/nu-logout.nuon | 1 + registry/nu-monitor-manager.nuon | 1 + registry/nu-pomodoro.nuon | 1 + registry/nu-right-prompt.nuon | 1 + registry/nu-scripts.nuon | 1 + registry/nu-sound-manager.nuon | 1 + registry/nu-themes.nuon | 1 + registry/nu-zellij.nuon | 1 + registry/nu_plugin_audio_hook.nuon | 1 + registry/nu_plugin_clipboard.nuon | 1 + registry/nu_plugin_desktop_notifications.nuon | 1 + registry/nu_plugin_explore.nuon | 1 + registry/nu_plugin_image.nuon | 1 + registry/nu_plugin_port_list.nuon | 1 + registry/nu_plugin_port_scan.nuon | 1 + registry/nu_plugin_qr_maker.nuon | 1 + registry/nupm_pkg.nuon | 1 + registry/registry.nuon | 1 + registry/tmux-sessionizer.nuon | 1 + 25 files changed, 25 insertions(+) create mode 100644 registry/nu-clippy.nuon create mode 100644 registry/nu-discord-update.nuon create mode 100644 registry/nu-fonts-install.nuon create mode 100644 registry/nu-git-manager-sugar.nuon create mode 100644 registry/nu-git-manager.nuon create mode 100644 registry/nu-hooks.nuon create mode 100644 registry/nu-logout.nuon create mode 100644 registry/nu-monitor-manager.nuon create mode 100644 registry/nu-pomodoro.nuon create mode 100644 registry/nu-right-prompt.nuon create mode 100644 registry/nu-scripts.nuon create mode 100644 registry/nu-sound-manager.nuon create mode 100644 registry/nu-themes.nuon create mode 100644 registry/nu-zellij.nuon create mode 100644 registry/nu_plugin_audio_hook.nuon create mode 100644 registry/nu_plugin_clipboard.nuon create mode 100644 registry/nu_plugin_desktop_notifications.nuon create mode 100644 registry/nu_plugin_explore.nuon create mode 100644 registry/nu_plugin_image.nuon create mode 100644 registry/nu_plugin_port_list.nuon create mode 100644 registry/nu_plugin_port_scan.nuon create mode 100644 registry/nu_plugin_qr_maker.nuon create mode 100644 registry/nupm_pkg.nuon create mode 100644 registry/registry.nuon create mode 100644 registry/tmux-sessionizer.nuon diff --git a/registry/nu-clippy.nuon b/registry/nu-clippy.nuon new file mode 100644 index 0000000..81ebc5c --- /dev/null +++ b/registry/nu-clippy.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-clippy, "0.1.0", nu-clippy, git, {url: "https://github.com/amtoine/scripts", revision: "b7c3401b4d2019909af203bfe89207aa39d52a1e"}]] \ No newline at end of file diff --git a/registry/nu-discord-update.nuon b/registry/nu-discord-update.nuon new file mode 100644 index 0000000..e6b6c76 --- /dev/null +++ b/registry/nu-discord-update.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-discord-update, "0.1.0", null, git, {url: "https://github.com/amtoine/nu-discord-update", revision: "0284223340519630ee94d56c224cf8611abe2d0b"}]] \ No newline at end of file diff --git a/registry/nu-fonts-install.nuon b/registry/nu-fonts-install.nuon new file mode 100644 index 0000000..e795e1f --- /dev/null +++ b/registry/nu-fonts-install.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-fonts-install, "0.1.0", null, git, {url: "https://github.com/amtoine/nu-fonts-install", revision: "6b03e9eec09c6784393a725308c34d301a67f7e4"}]] \ No newline at end of file diff --git a/registry/nu-git-manager-sugar.nuon b/registry/nu-git-manager-sugar.nuon new file mode 100644 index 0000000..dfb58f6 --- /dev/null +++ b/registry/nu-git-manager-sugar.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-git-manager-sugar, "0.1.0", pkgs/nu-git-manager-sugar, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.1.0"}], [nu-git-manager-sugar, "0.2.0", pkgs/nu-git-manager-sugar, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.2.0"}], [nu-git-manager-sugar, "0.3.0", pkgs/nu-git-manager-sugar, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.3.0"}], [nu-git-manager-sugar, "0.4.0", pkgs/nu-git-manager-sugar, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.4.0"}], [nu-git-manager-sugar, "0.5.0", pkgs/nu-git-manager-sugar, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.5.0"}], [nu-git-manager-sugar, "0.6.0", pkgs/nu-git-manager-sugar, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.6.0"}], [nu-git-manager-sugar, "0.7.0", pkgs/nu-git-manager-sugar, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.7.0"}]] \ No newline at end of file diff --git a/registry/nu-git-manager.nuon b/registry/nu-git-manager.nuon new file mode 100644 index 0000000..aaf66a5 --- /dev/null +++ b/registry/nu-git-manager.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-git-manager, "0.1.0", pkgs/nu-git-manager, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.1.0"}], [nu-git-manager, "0.2.0", pkgs/nu-git-manager, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.2.0"}], [nu-git-manager, "0.3.0", pkgs/nu-git-manager, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.3.0"}], [nu-git-manager, "0.4.0", pkgs/nu-git-manager, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.4.0"}], [nu-git-manager, "0.5.0", pkgs/nu-git-manager, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.5.0"}], [nu-git-manager, "0.6.0", pkgs/nu-git-manager, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.6.0"}], [nu-git-manager, "0.7.0", pkgs/nu-git-manager, git, {url: "https://github.com/amtoine/nu-git-manager", revision: "0.7.0"}]] \ No newline at end of file diff --git a/registry/nu-hooks.nuon b/registry/nu-hooks.nuon new file mode 100644 index 0000000..348ce89 --- /dev/null +++ b/registry/nu-hooks.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-hooks, "0.1.0", nu-hooks, git, {url: "https://github.com/nushell/nu_scripts", revision: "f04cb44"}]] \ No newline at end of file diff --git a/registry/nu-logout.nuon b/registry/nu-logout.nuon new file mode 100644 index 0000000..59ae01b --- /dev/null +++ b/registry/nu-logout.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-logout, "0.1.0", nu-logout, git, {url: "https://github.com/amtoine/scripts", revision: "b7c3401b4d2019909af203bfe89207aa39d52a1e"}]] \ No newline at end of file diff --git a/registry/nu-monitor-manager.nuon b/registry/nu-monitor-manager.nuon new file mode 100644 index 0000000..a2fd2e0 --- /dev/null +++ b/registry/nu-monitor-manager.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-monitor-manager, "0.1.0", nu-monitor-manager, git, {url: "https://github.com/amtoine/scripts", revision: "b7c3401b4d2019909af203bfe89207aa39d52a1e"}]] \ No newline at end of file diff --git a/registry/nu-pomodoro.nuon b/registry/nu-pomodoro.nuon new file mode 100644 index 0000000..4bfa1dd --- /dev/null +++ b/registry/nu-pomodoro.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-pomodoro, "0.1.0", null, git, {url: "https://github.com/amtoine/nu-pomodoro", revision: main}]] \ No newline at end of file diff --git a/registry/nu-right-prompt.nuon b/registry/nu-right-prompt.nuon new file mode 100644 index 0000000..d55d578 --- /dev/null +++ b/registry/nu-right-prompt.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-right-prompt, "0.1.0", null, git, {url: "https://github.com/amtoine/nu-right-prompt", revision: main}]] \ No newline at end of file diff --git a/registry/nu-scripts.nuon b/registry/nu-scripts.nuon new file mode 100644 index 0000000..9c09b9e --- /dev/null +++ b/registry/nu-scripts.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-scripts, "0.1.0", nu-scripts, git, {url: "https://github.com/amtoine/scripts", revision: "b7c3401b4d2019909af203bfe89207aa39d52a1e"}]] \ No newline at end of file diff --git a/registry/nu-sound-manager.nuon b/registry/nu-sound-manager.nuon new file mode 100644 index 0000000..712c145 --- /dev/null +++ b/registry/nu-sound-manager.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-sound-manager, "0.1.0", nu-sound-manager, git, {url: "https://github.com/amtoine/scripts", revision: "b7c3401b4d2019909af203bfe89207aa39d52a1e"}]] \ No newline at end of file diff --git a/registry/nu-themes.nuon b/registry/nu-themes.nuon new file mode 100644 index 0000000..45752e3 --- /dev/null +++ b/registry/nu-themes.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-themes, "0.1.0", themes, git, {url: "https://github.com/nushell/nu_scripts", revision: "f04cb44"}]] \ No newline at end of file diff --git a/registry/nu-zellij.nuon b/registry/nu-zellij.nuon new file mode 100644 index 0000000..dcf0cb3 --- /dev/null +++ b/registry/nu-zellij.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu-zellij, "0.1.0", nu-zellij, git, {url: "https://github.com/amtoine/zellij-layouts", revision: "46f4ded194a13b6acfb7b5b25ea9d179e4e74e12"}]] \ No newline at end of file diff --git a/registry/nu_plugin_audio_hook.nuon b/registry/nu_plugin_audio_hook.nuon new file mode 100644 index 0000000..948ddc1 --- /dev/null +++ b/registry/nu_plugin_audio_hook.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu_plugin_audio_hook, "0.1.12", null, git, {url: "https://github.com/FMotalleb/nu_plugin_audio_hook", revision: "v0.1.12"}]] \ No newline at end of file diff --git a/registry/nu_plugin_clipboard.nuon b/registry/nu_plugin_clipboard.nuon new file mode 100644 index 0000000..25f3237 --- /dev/null +++ b/registry/nu_plugin_clipboard.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu_plugin_clipboard, "0.3.4", null, git, {url: "https://github.com/FMotalleb/nu_plugin_clipboard", revision: "27faf8d"}], [nu_plugin_clipboard, "0.91.0", null, git, {url: "https://github.com/FMotalleb/nu_plugin_clipboard", revision: "2cd2a67"}]] \ No newline at end of file diff --git a/registry/nu_plugin_desktop_notifications.nuon b/registry/nu_plugin_desktop_notifications.nuon new file mode 100644 index 0000000..9e59ebd --- /dev/null +++ b/registry/nu_plugin_desktop_notifications.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu_plugin_desktop_notifications, "1.0.7", null, git, {url: "https://github.com/FMotalleb/nu_plugin_desktop_notifications", revision: "7556310"}]] \ No newline at end of file diff --git a/registry/nu_plugin_explore.nuon b/registry/nu_plugin_explore.nuon new file mode 100644 index 0000000..9b93051 --- /dev/null +++ b/registry/nu_plugin_explore.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu_plugin_explore, "0.1.2", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.1.2"}], [nu_plugin_explore, "0.2.0", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.2.0"}]] \ No newline at end of file diff --git a/registry/nu_plugin_image.nuon b/registry/nu_plugin_image.nuon new file mode 100644 index 0000000..b7c890e --- /dev/null +++ b/registry/nu_plugin_image.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu_plugin_image, "0.3.2", null, git, {url: "https://github.com/FMotalleb/nu_plugin_image", revision: "7703e79"}]] \ No newline at end of file diff --git a/registry/nu_plugin_port_list.nuon b/registry/nu_plugin_port_list.nuon new file mode 100644 index 0000000..26fff62 --- /dev/null +++ b/registry/nu_plugin_port_list.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu_plugin_port_list, "1.2.10", null, git, {url: "https://github.com/FMotalleb/nu_plugin_port_list", revision: "dddd72d"}], [nu_plugin_port_list, "1.2.11", null, git, {url: "https://github.com/FMotalleb/nu_plugin_port_list", revision: "6bef9d8"}]] \ No newline at end of file diff --git a/registry/nu_plugin_port_scan.nuon b/registry/nu_plugin_port_scan.nuon new file mode 100644 index 0000000..99f69d3 --- /dev/null +++ b/registry/nu_plugin_port_scan.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu_plugin_port_scan, "1.0.10", null, git, {url: "https://github.com/FMotalleb/nu_plugin_port_scan", revision: "7424a69"}], [nu_plugin_port_scan, "1.0.11", null, git, {url: "https://github.com/FMotalleb/nu_plugin_port_scan", revision: "d4e6c8d"}]] \ No newline at end of file diff --git a/registry/nu_plugin_qr_maker.nuon b/registry/nu_plugin_qr_maker.nuon new file mode 100644 index 0000000..9586636 --- /dev/null +++ b/registry/nu_plugin_qr_maker.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nu_plugin_qr_maker, "1.0.2", null, git, {url: "https://github.com/FMotalleb/nu_plugin_qr_maker", revision: "73bf1e4"}]] \ No newline at end of file diff --git a/registry/nupm_pkg.nuon b/registry/nupm_pkg.nuon new file mode 100644 index 0000000..737f62d --- /dev/null +++ b/registry/nupm_pkg.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [nupm, "0.1.0", null, git, {url: "https://github.com/nushell/nupm", revision: "29916fc"}]] \ No newline at end of file diff --git a/registry/registry.nuon b/registry/registry.nuon new file mode 100644 index 0000000..22d071f --- /dev/null +++ b/registry/registry.nuon @@ -0,0 +1 @@ +[[name, path, url]; [nu-clippy, nu-clippy.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-clippy.nuon"], [nu-discord-update, nu-discord-update.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-discord-update.nuon"], [nu-fonts-install, nu-fonts-install.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-fonts-install.nuon"], [nu-git-manager, nu-git-manager.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-git-manager.nuon"], [nu-git-manager-sugar, nu-git-manager-sugar.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-git-manager-sugar.nuon"], [nu-hooks, nu-hooks.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-hooks.nuon"], [nu-logout, nu-logout.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-logout.nuon"], [nu-monitor-manager, nu-monitor-manager.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-monitor-manager.nuon"], [nu-pomodoro, nu-pomodoro.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-pomodoro.nuon"], [nu-right-prompt, nu-right-prompt.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-right-prompt.nuon"], [nu-scripts, nu-scripts.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-scripts.nuon"], [nu-sound-manager, nu-sound-manager.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-sound-manager.nuon"], [nu-themes, nu-themes.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-themes.nuon"], [nu-zellij, nu-zellij.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-zellij.nuon"], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_audio_hook.nuon"], [nu_plugin_clipboard, nu_plugin_clipboard.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_clipboard.nuon"], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_desktop_notifications.nuon"], [nu_plugin_explore, nu_plugin_explore.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_explore.nuon"], [nu_plugin_image, nu_plugin_image.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_image.nuon"], [nu_plugin_port_list, nu_plugin_port_list.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_port_list.nuon"], [nu_plugin_port_scan, nu_plugin_port_scan.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_port_scan.nuon"], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_qr_maker.nuon"], [nupm, nupm_pkg.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nupm_pkg.nuon"], [tmux-sessionizer, tmux-sessionizer.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/tmux-sessionizer.nuon"]] \ No newline at end of file diff --git a/registry/tmux-sessionizer.nuon b/registry/tmux-sessionizer.nuon new file mode 100644 index 0000000..bde119b --- /dev/null +++ b/registry/tmux-sessionizer.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [tmux-sessionizer, "0.1.0", null, git, {url: "https://github.com/amtoine/tmux-sessionizer", revision: "18f5cef534b8b494e4dee645e453231dd5d1bc4c"}], [tmux-sessionizer, main, null, git, {url: "https://github.com/amtoine/tmux-sessionizer", revision: main}]] \ No newline at end of file From 5ad56515fcf8b79e1a487ba229ff213e422d5a22 Mon Sep 17 00:00:00 2001 From: kubouch Date: Mon, 25 Mar 2024 22:34:43 +0200 Subject: [PATCH 14/43] Change tests registry --- tests/mod.nu | 2 +- tests/packages/registry/registry.nuon | 1 + tests/packages/registry/spam_custom.nuon | 1 + tests/packages/registry/spam_module.nuon | 1 + tests/packages/registry/spam_script.nuon | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/packages/registry/registry.nuon create mode 100644 tests/packages/registry/spam_custom.nuon create mode 100644 tests/packages/registry/spam_module.nuon create mode 100644 tests/packages/registry/spam_script.nuon diff --git a/tests/mod.nu b/tests/mod.nu index 4f07c01..dcbe4cc 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -3,7 +3,7 @@ use std assert use ../nupm/utils/dirs.nu tmp-dir use ../nupm -const TEST_REGISTRY_PATH = ([tests packages registry.nuon] | path join) +const TEST_REGISTRY_PATH = ([tests packages registry registry.nuon] | path join) def with-test-env [closure: closure]: nothing -> nothing { diff --git a/tests/packages/registry/registry.nuon b/tests/packages/registry/registry.nuon new file mode 100644 index 0000000..93d739c --- /dev/null +++ b/tests/packages/registry/registry.nuon @@ -0,0 +1 @@ +[[name, path, url]; [spam_custom, spam_custom.nuon, null], [spam_module, spam_module.nuon, null], [spam_script, spam_script.nuon, null]] \ No newline at end of file diff --git a/tests/packages/registry/spam_custom.nuon b/tests/packages/registry/spam_custom.nuon new file mode 100644 index 0000000..371a345 --- /dev/null +++ b/tests/packages/registry/spam_custom.nuon @@ -0,0 +1 @@ +{name: spam_custom, version: "0.1.0", path: ../spam_custom, type: local, info: null} \ No newline at end of file diff --git a/tests/packages/registry/spam_module.nuon b/tests/packages/registry/spam_module.nuon new file mode 100644 index 0000000..16f40f9 --- /dev/null +++ b/tests/packages/registry/spam_module.nuon @@ -0,0 +1 @@ +{name: spam_module, version: "0.1.0", path: ../spam_module, type: local, info: null} \ No newline at end of file diff --git a/tests/packages/registry/spam_script.nuon b/tests/packages/registry/spam_script.nuon new file mode 100644 index 0000000..618d532 --- /dev/null +++ b/tests/packages/registry/spam_script.nuon @@ -0,0 +1 @@ +[[name, version, path, type, info]; [spam_script, "0.1.0", ../spam_script_old, local, null], [spam_script, "0.2.0", ../spam_script, local, null]] \ No newline at end of file From 9c8514cb3857f5e719d9be466a3566ee3eebc076 Mon Sep 17 00:00:00 2001 From: kubouch Date: Tue, 26 Mar 2024 00:31:32 +0200 Subject: [PATCH 15/43] Flatten search output --- nupm/install.nu | 7 ++----- nupm/search.nu | 16 +++++++++++++++- nupm/utils/registry.nu | 2 -- tests/mod.nu | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/nupm/install.nu b/nupm/install.nu index 50c0f8b..6dcc739 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -187,10 +187,7 @@ def fetch-package [ --registry: string # Which registry to use --version: string # Package version to install (string or null) ]: nothing -> path { - let regs = (search-package $package - --registry $registry - --version $version - --exact-match) + let regs = search-package $package --registry $registry --exact-match if ($regs | is-empty) { throw-error $'Package ($package) not found in any registry' @@ -216,7 +213,7 @@ def fetch-package [ } else { # local package path is relative to the registry file (absolute paths # are discouraged but work) - $reg.path | path dirname | path join $pkg.path + $reg.registry_path | path dirname | path join $pkg.path } } diff --git a/nupm/search.nu b/nupm/search.nu index bcbd621..e4dc200 100644 --- a/nupm/search.nu +++ b/nupm/search.nu @@ -1,5 +1,6 @@ use utils/completions.nu complete-registries use utils/registry.nu search-package +use utils/version.nu filter-by-version # Search for a package export def main [ @@ -9,5 +10,18 @@ export def main [ --pkg-version(-v): string # Package version to install --exact-match(-e) # Match package name exactly ]: nothing -> table { - search-package $package --registry $registry --version $pkg_version --exact-match=$exact_match + search-package $package --registry $registry --exact-match=$exact_match + | flatten + | each {|row| + { + registry_name: $row.registry_name + registry_path: $row.registry_path + name: $row.pkgs.name + version: $row.pkgs.version + path: $row.pkgs.path + type: $row.pkgs.type + info: $row.pkgs.info + } + } + | filter-by-version $pkg_version } diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index 2ce0803..a2c050a 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -8,7 +8,6 @@ use version.nu filter-by-version export def search-package [ package: string # Name of the package --registry: string # Which registry to use - --version: any # Package version to install (string or null) --exact-match # Searched package name must match exactly ] -> table { let registries = if (not ($registry | is-empty)) and ($registry in $env.NUPM_REGISTRIES) { @@ -78,7 +77,6 @@ export def search-package [ open $pkg_file_path } | flatten - | filter-by-version $version { registry_name: $name diff --git a/tests/mod.nu b/tests/mod.nu index dcbe4cc..25f66c7 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -119,7 +119,7 @@ export def install-package-not-found [] { export def search-registry [] { with-test-env { - assert ((nupm search spam | get pkgs.0 | length) == 4) + assert ((nupm search spam | length) == 4) } } From 07c34b6f9e1129858731867d4f71e2aece8e87ac Mon Sep 17 00:00:00 2001 From: kubouch Date: Tue, 26 Mar 2024 00:43:01 +0200 Subject: [PATCH 16/43] Fix online installs --- nupm/install.nu | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/nupm/install.nu b/nupm/install.nu index 6dcc739..ce6c520 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -130,10 +130,12 @@ def download-pkg [ pkg: record< name: string, version: string, - url: string, - revision: string, path: string, type: string, + info: record< + url: string, + revision: string, + > > ]: nothing -> path { # TODO: Add some kind of hashing to check that files really match @@ -149,33 +151,37 @@ def download-pkg [ mkdir $git_dir cd $git_dir - let repo_name = $pkg.url | url parse | get path | path parse | get stem - let url_hash = $pkg.url | hash md5 # in case of git repo name collision - let clone_dir = $'($repo_name)-($url_hash)-($pkg.revision)' + let repo_name = $pkg.info.url | url parse | get path | path parse | get stem + let url_hash = $pkg.info.url | hash md5 # in case of git repo name collision + let clone_dir = $'($repo_name)-($url_hash)-($pkg.info.revision)' - let pkg_dir = $env.PWD | path join $clone_dir $pkg.path + let pkg_dir = if $pkg.path == null { + $env.PWD | path join $clone_dir + } else { + $env.PWD | path join $clone_dir $pkg.path + } if ($pkg_dir | path exists) { - print $'Package ($pkg.name) found in cache' + print $'Package ($pkg.info.name) found in cache' return $pkg_dir } try { - git clone $pkg.url $clone_dir + git clone $pkg.info.url $clone_dir } catch { - throw-error $'Error cloning repository ($pkg.url)' + throw-error $'Error cloning repository ($pkg.info.url)' } cd $clone_dir try { - git checkout $pkg.revision + git checkout $pkg.info.revision } catch { - throw-error $'Error checking out revision ($pkg.revision)' + throw-error $'Error checking out revision ($pkg.info.revision)' } if not ($pkg_dir | path exists) { - throw-error $'Path ($pkg.path) does not exist' + throw-error $'Path ($pkg_dir) does not exist' } $pkg_dir @@ -213,7 +219,11 @@ def fetch-package [ } else { # local package path is relative to the registry file (absolute paths # are discouraged but work) - $reg.registry_path | path dirname | path join $pkg.path + if $pkg.path == null { + $reg.registry_path | path dirname + } else { + $reg.registry_path | path dirname | path join $pkg.path + } } } From 0a86ddbeee1e43ea62b1b46e231d044fbe858cf8 Mon Sep 17 00:00:00 2001 From: kubouch Date: Tue, 26 Mar 2024 18:46:46 +0200 Subject: [PATCH 17/43] Rewrite nupm publish --- nupm/publish.nu | 251 +++++++++++++++++++++++++++-------------- nupm/utils/registry.nu | 8 +- 2 files changed, 171 insertions(+), 88 deletions(-) diff --git a/nupm/publish.nu b/nupm/publish.nu index ffe22b5..32a3450 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -1,101 +1,189 @@ use utils/log.nu throw-error use utils/package.nu open-package-file +use utils/registry.nu search-package use utils/version.nu sort-by-version -# Generate git package metadata and optionally add them to a registry +# Publish package to registry # +# By default, changes are only previewed. To apply them, use the --save flag. # Needs to run from package root, i.e., where nupm.nuon is. -export def git [ - registry?: string - --url(-u): string - --path(-p): string - --revision(-r): string - --save -]: [nothing -> nothing, nothing -> record] { +export def main [ + registry: string # Registry file to publish to (name or path) + --git # Publish package as a git package + --local # Publish package as a local package + --info: record # Package info based on package type (e.g., url and + # revision for a git package) + --path: string # Path to the package root + --pkg-file-url: string # URL of a package registry file + --save # Write changes to registry instead of printing changes +] { + if $git and $local { + throw-error ("Cannot have more than one package type. Choose one of" + + " --git or --local or neither, not both.") + } + let pkg = open-package-file $env.PWD - let url = $url | default (guess-url) - let revision = $revision | default (guess-revision) - let result = { - name: $pkg.name - version: $pkg.version - url: $url - revision: $revision - path: $path + # Registry must point to a local path + let reg_path = $registry | get-registry-path + + if ($reg_path | path type) != 'file' { + throw-error $'Registry path ($reg_path) must be a local path.' + } + + print $'Registry path: (ansi cyan_bold)($reg_path)(ansi reset)' + + # Guess package type + let pkg_type = if $git { + "git" + } else if $local { + "local" + } else { + let res = search-package $pkg.name --registry $reg_path --exact-match + | first # there will be only one result because we passed local path + | get pkgs + | sort-by-version + + if ($res | is-empty) { + throw-error ($"Cannot guess package type because pacakge" + + $" ($pkg.name) was not found in registry ($registry). Specify" + + " the type manually with --git or --local flag.") + } + + $res | last | get type + } + + # Create entry to the registry file + mut reg_content = $reg_path | open-registry-file + + let name_matches = if ($reg_content | length) > 0 { + $reg_content | where name == $pkg.name + } else { + [] } - if $registry == null { - $result + mut existing_entry = null + + if ($name_matches | length) == 1 { + $existing_entry = ($name_matches | first) + } else if ($name_matches | length) > 1 { + throw-error ($"Registry ($registry) contains multiple packages named" + + $" ($pkg.name). This shouldn't happen.") + } + + let pkg_file_path = if $existing_entry == null { + $'($pkg.name).nuon' } else { - let reg_path = $registry | get-registry-path - let reg_content = $reg_path | open-registry-file - let updated = $reg_content | update-registry $result $registry "git" + $existing_entry.path + } + + if $existing_entry == null { + let pkg_file_url = if $pkg_file_url != null { + $pkg_file_url + } + + let reg_entry = { + name: $pkg.name + path: $pkg_file_path + url: $pkg_file_url + } + + print "" + print $"New entry to registry file (ansi cyan_bold)($reg_path)(ansi reset):" + print ($reg_entry | table --expand) + + # Add the entry to the registry file + $reg_content = $reg_content | append $reg_entry | sort-by name if $save { - $updated | save --force $reg_path - } else { - $updated + print $"(ansi yellow)=> SAVED!(ansi reset)" + $reg_content | save --force $reg_path } + } else { + print $"Registry file (ansi cyan_bold)($reg_path)(ansi reset) unchanged" } -} -# Generate local package metadata and optionally add them to a registry -# -# Needs to run from package root, i.e., where nupm.nuon is. -export def local [ - registry?: string - --path(-p): string - --save -]: [nothing -> nothing, nothing -> record] { - let pkg = open-package-file $env.PWD + # Create entry to the package file + mut info = $info + + if $pkg_type == 'git' { + $info = ($info | default { + url: (guess-url) + revision: (guess-revision) + }) + } - let result = { + match $pkg_type { + 'git' => { + if $info == null or ($info | columns) != [url revision] { + throw-error ("Package type 'git' requires info with url and" + + " revision fields.") + } + } + 'local' => { + if $info != null { + throw-error "Package type 'local' must have null info." + } + } + } + + let pkg_entry = { name: $pkg.name version: $pkg.version path: $path + type: $pkg_type + info: $info } - if $registry == null { - $result - } else { - let reg_path = $registry | get-registry-path + let pkg_file_path = $reg_path | path dirname | path join $pkg_file_path - let path = try { - $env.PWD | path relative-to ($reg_path | path dirname) - } catch { - $env.PWD - } + print "" + print ("New entry to package file" + + $" (ansi cyan_bold)($pkg_file_path)(ansi reset):") + print ($pkg_entry | table --expand) - let $path = if ($path | is-empty) { null } else { $path } - let result = $result | update path $path + # Add the entry to the package file + let pkg_file_content = $pkg_file_path | open-reg-pkg-file - let reg_content = $reg_path | open-registry-file - let updated = $reg_content | update-registry $result $registry "local" + if $pkg.version in $pkg_file_content.version { + throw-error ($"Version ($pkg.version) of package ($pkg.name) is already" + + $" published in registry ($registry)") + } - if $save { - $updated | save --force $reg_path - } else { - $updated - } + let pkg_file_content = $pkg_file_content + | append $pkg_entry + | sort-by-version + + if $save { + print $"(ansi yellow)=> SAVED!(ansi reset)" + $pkg_file_content | save --force $pkg_file_path + } else { + print "" + print $"(ansi yellow)If the changes look good, re-run with --save to apply them.(ansi reset)" } } def guess-url [] -> string { - mut url = ^git remote get-url origin | complete | get stdout + mut url = (do -i { ^git remote get-url origin | complete } | get stdout) if ($url | is-empty) { - let first_remote = ^git remote | lines | first - $url = (^git remote get-url $first_remote | complete | get stdout) + let first_remote = do -i { ^git remote | lines | first } | get stdout + + if not ($first_remote | is-empty) { + $url = (do -i { ^git remote get-url $first_remote | complete } + | get stdout) + } } $url | str trim } def guess-revision [] -> string { - mut revision = ^git describe --tags --abbrev=0 | complete | get stdout + mut revision = (do -i { ^git describe --tags --abbrev=0 | complete } + | get stdout) if ($revision | is-empty) { - $revision = (^git rev-parse HEAD | complete | get stdout) + $revision = (do -i { ^git rev-parse HEAD | complete } | get stdout) } $revision | str trim @@ -106,40 +194,37 @@ def get-registry-path []: string -> path { $env.NUPM_REGISTRIES | get -i $registry | default ($registry | path expand) } -def open-registry-file []: path -> record { +def open-registry-file []: path -> table { let reg_path = $in let reg_content = try { open $reg_path } + let exp_type = 'table' - if ($reg_content | is-not-empty) and ($reg_content | describe -d | get type) != 'record' { + if (($reg_content | is-not-empty) + and ($reg_content | describe) != $exp_type) { throw-error ($"Unexpected content of registry ($reg_path)." - + " Needs a record.") + + $" Needs ($exp_type).") } - $reg_content | default {} + $reg_content | default [] } -def update-registry [pkg_entry: record, registry: string, type: string]: record -> record { - let reg_content = $in - - let pkgs_local = $reg_content | get -i local | default [] - let pkgs_git = $reg_content | get -i git | default [] - let pkgs_all = $pkgs_local | append $pkgs_git - - if ($pkg_entry.name in $pkgs_all.name - and $pkg_entry.version in $pkgs_all.version) { - throw-error ($"Package ($pkg_entry.name) version ($pkg_entry.version)" - + $" is already present in registry ($registry)") +def open-reg-pkg-file []: [ path -> table< + name: string + version: string + path: string + type: string + info: record> ] { + let pkg_path = $in + + let pkg_content = try { open $pkg_path } + let exp_cols = [name version path type info] + + if (($pkg_content | is-not-empty) + and ($pkg_content | columns) != $exp_cols) { + throw-error ($"Unexpected columns of package file ($pkg_path)." + + $" Needs ($exp_cols).") } - let pkgs_out = match $type { - "git" => $pkgs_git, - "local" => $pkgs_local, - _ => { throw-error $"Internal error: wrong registry type ($type)" } - } - - $reg_content | upsert $type ($pkgs_out - | append $pkg_entry - | sort-by name - | sort-by-version) + $pkg_content | default [] } diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index a2c050a..0aa9405 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -2,12 +2,11 @@ use dirs.nu cache-dir use misc.nu check-cols -use version.nu filter-by-version # Search for a package in a registry export def search-package [ package: string # Name of the package - --registry: string # Which registry to use + --registry: string # Which registry to use (name or path) --exact-match # Searched package name must match exactly ] -> table { let registries = if (not ($registry | is-empty)) and ($registry in $env.NUPM_REGISTRIES) { @@ -57,9 +56,7 @@ export def search-package [ } } - $registry.reg - | check-cols "registry" [ name path url ] - | ignore + $registry.reg | check-cols "registry" [ name path url ] | ignore # Find all packages matching $package in the registry let pkg_files = $registry.reg | filter $name_matcher @@ -71,6 +68,7 @@ export def search-package [ if $row.url != null { let pkg_file_content = http get $row.url + # TODO: Add file hashing $pkg_file_content | save --force $pkg_file_path } From 7f16e18b4786b745a69d3515d87ac322b8a7df9c Mon Sep 17 00:00:00 2001 From: kubouch Date: Tue, 26 Mar 2024 18:55:44 +0200 Subject: [PATCH 18/43] Remove old registry --- registry.nuon | 324 -------------------------------------------------- 1 file changed, 324 deletions(-) delete mode 100644 registry.nuon diff --git a/registry.nuon b/registry.nuon deleted file mode 100644 index 23ee537..0000000 --- a/registry.nuon +++ /dev/null @@ -1,324 +0,0 @@ -# Registry is a NUON file that tells nupm where to look for packages -# -# Currently, these package types are supported: -# * git ..... package is an online git repository -# * local ... package is on a local filesystem -# -# The package type defines the columns of the registry record. Each column holds -# holds a table of packages. -# -# Git packages accept the following columns: -# * name ....... name of the package -# * version .... version of the package -# * url ........ Git URL of the package -# * revision ... Git revision to check out when installing the package (commit -# hash, version, branch name, ...) -# * path ....... Path relative to the repository root where to look for nupm.nuon -# -# Local packages accept the following columns: -# * name ....... name of the package -# * version .... version of the package -# * path ....... Path where to look for nupm.nuon. It can be absolute, or -# relative. If relative, then relative to the registry file. -# -# One registry can contain packages with the same name, but they must be of -# different version. - -{ - git: [ - [ - name, - version, - url, - revision, - path - ]; - [ - nu_plugin_audio_hook, - "0.1.12", - "https://github.com/FMotalleb/nu_plugin_audio_hook", - "v0.1.12", - . - ], - [ - nu_plugin_clipboard, - "0.3.4", - "https://github.com/FMotalleb/nu_plugin_clipboard", - "27faf8d", - . - ], - [ - nu_plugin_clipboard, - "0.91.0", - "https://github.com/FMotalleb/nu_plugin_clipboard", - "2cd2a67", - . - ], - [ - nu_plugin_desktop_notifications, - "1.0.7", - "https://github.com/FMotalleb/nu_plugin_desktop_notifications", - "7556310", - . - ], - [ - nu_plugin_image, - "0.3.2", - "https://github.com/FMotalleb/nu_plugin_image", - "7703e79", - . - ], - [ - nu_plugin_port_list, - "1.2.10", - "https://github.com/FMotalleb/nu_plugin_port_list", - "dddd72d", - . - ], - [ - nu_plugin_port_list, - "1.2.11", - "https://github.com/FMotalleb/nu_plugin_port_list", - "6bef9d8", - . - ], - [ - nu_plugin_port_scan, - "1.0.10", - "https://github.com/FMotalleb/nu_plugin_port_scan", - "7424a69", - . - ], - [ - nu_plugin_port_scan, - "1.0.11", - "https://github.com/FMotalleb/nu_plugin_port_scan", - "d4e6c8d", - . - ], - [ - nu_plugin_qr_maker, - "1.0.2", - "https://github.com/FMotalleb/nu_plugin_qr_maker", - "73bf1e4", - . - ], - [ - nu-git-manager, - "0.7.0", - "https://github.com/amtoine/nu-git-manager", - "0.7.0", - pkgs/nu-git-manager - ], - [ - nu-git-manager-sugar, - "0.7.0", - "https://github.com/amtoine/nu-git-manager", - "0.7.0", - pkgs/nu-git-manager-sugar - ], - [ - nu-git-manager, - "0.6.0", - "https://github.com/amtoine/nu-git-manager", - "0.6.0", - pkgs/nu-git-manager - ], - [ - nu-git-manager-sugar, - "0.6.0", - "https://github.com/amtoine/nu-git-manager", - "0.6.0", - pkgs/nu-git-manager-sugar - ], - [ - nu-git-manager, - "0.5.0", - "https://github.com/amtoine/nu-git-manager", - "0.5.0", - pkgs/nu-git-manager - ], - [ - nu-git-manager-sugar, - "0.5.0", - "https://github.com/amtoine/nu-git-manager", - "0.5.0", - pkgs/nu-git-manager-sugar - ], - [ - nu-git-manager, - "0.4.0", - "https://github.com/amtoine/nu-git-manager", - "0.4.0", - pkgs/nu-git-manager - ], - [ - nu-git-manager-sugar, - "0.4.0", - "https://github.com/amtoine/nu-git-manager", - "0.4.0", - pkgs/nu-git-manager-sugar - ], - [ - nu-git-manager, - "0.3.0", - "https://github.com/amtoine/nu-git-manager", - "0.3.0", - pkgs/nu-git-manager - ], - [ - nu-git-manager-sugar, - "0.3.0", - "https://github.com/amtoine/nu-git-manager", - "0.3.0", - pkgs/nu-git-manager-sugar - ], - [ - nu-git-manager, - "0.2.0", - "https://github.com/amtoine/nu-git-manager", - "0.2.0", - pkgs/nu-git-manager - ], - [ - nu-git-manager-sugar, - "0.2.0", - "https://github.com/amtoine/nu-git-manager", - "0.2.0", - pkgs/nu-git-manager-sugar - ], - [ - nu-git-manager, - "0.1.0", - "https://github.com/amtoine/nu-git-manager", - "0.1.0", - pkgs/nu-git-manager - ], - [ - nu-git-manager-sugar, - "0.1.0", - "https://github.com/amtoine/nu-git-manager", - "0.1.0", - pkgs/nu-git-manager-sugar - ], - [ - nu-pomodoro, - "0.1.0", - "https://github.com/amtoine/nu-pomodoro", - "main", - . - ], - [ - nu-right-prompt, - "0.1.0", - "https://github.com/amtoine/nu-right-prompt", - "main", - . - ], - [ - nu_plugin_explore, - "0.1.2", - "https://github.com/amtoine/nu_plugin_explore", - "0.1.2", - . - ], - [ - nu_plugin_explore, - "0.2.0", - "https://github.com/amtoine/nu_plugin_explore", - "0.2.0", - . - ], - [ - nu-clippy, - "0.1.0", - "https://github.com/amtoine/scripts", - "b7c3401b4d2019909af203bfe89207aa39d52a1e", - nu-clippy - ], - [ - nu-logout, - "0.1.0", - "https://github.com/amtoine/scripts", - "b7c3401b4d2019909af203bfe89207aa39d52a1e", - nu-logout - ], - [ - nu-monitor-manager, - "0.1.0", - "https://github.com/amtoine/scripts", - "b7c3401b4d2019909af203bfe89207aa39d52a1e", - nu-monitor-manager - ], - [ - nu-scripts, - "0.1.0", - "https://github.com/amtoine/scripts", - "b7c3401b4d2019909af203bfe89207aa39d52a1e", - nu-scripts - ], - [ - nu-sound-manager, - "0.1.0", - "https://github.com/amtoine/scripts", - "b7c3401b4d2019909af203bfe89207aa39d52a1e", - nu-sound-manager - ], - [ - nu-zellij, - "0.1.0", - "https://github.com/amtoine/zellij-layouts", - "46f4ded194a13b6acfb7b5b25ea9d179e4e74e12", - nu-zellij - ], - [ - nu-hooks, - "0.1.0", - "https://github.com/nushell/nu_scripts", - "f04cb44", - nu-hooks - ], - [ - nu-themes, - "0.1.0", - "https://github.com/nushell/nu_scripts", - "f04cb44", - themes - ], - [ - nupm, - "0.1.0", - "https://github.com/nushell/nupm", - "29916fc", - . - ], - [ - tmux-sessionizer, - "0.1.0", - "https://github.com/amtoine/tmux-sessionizer", - "18f5cef534b8b494e4dee645e453231dd5d1bc4c", - . - ], - [ - tmux-sessionizer, - "main", - "https://github.com/amtoine/tmux-sessionizer", - "main", - . - ], - [ - nu-discord-update, - "0.1.0", - "https://github.com/amtoine/nu-discord-update", - "0284223340519630ee94d56c224cf8611abe2d0b", - . - ], - [ - nu-fonts-install, - "0.1.0", - "https://github.com/amtoine/nu-fonts-install", - "6b03e9eec09c6784393a725308c34d301a67f7e4", - . - ] - ] -} From 43411ae03485e4a16342563a8f3c9baa188d5eab Mon Sep 17 00:00:00 2001 From: kubouch Date: Tue, 26 Mar 2024 19:23:22 +0200 Subject: [PATCH 19/43] Fix local publish and tests --- nupm/publish.nu | 10 +++++----- tests/mod.nu | 8 ++++---- tests/packages/registry.nuon | 10 ---------- 3 files changed, 9 insertions(+), 19 deletions(-) delete mode 100644 tests/packages/registry.nuon diff --git a/nupm/publish.nu b/nupm/publish.nu index 32a3450..19342fc 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -93,7 +93,7 @@ export def main [ print ($reg_entry | table --expand) # Add the entry to the registry file - $reg_content = $reg_content | append $reg_entry | sort-by name + $reg_content = ($reg_content | append $reg_entry | sort-by name) if $save { print $"(ansi yellow)=> SAVED!(ansi reset)" @@ -198,12 +198,12 @@ def open-registry-file []: path -> table Date: Thu, 28 Mar 2024 14:34:39 +0200 Subject: [PATCH 20/43] Remove comment --- tests/mod.nu | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/mod.nu b/tests/mod.nu index c62828d..04b5c96 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -150,11 +150,6 @@ export def env-vars-are-set [] { export def generate-local-registry [] { with-test-env { - # let reg_file = [tests packages registry.nuon] - # | path join - # | path parse - # | update stem test.nuon - cp -r tests/packages $env.NUPM_TEMP let reg_file = $env.NUPM_TEMP | path join packages registry registry.nuon From 9e6bc4be92344c486f88f9cf9bcb0840d72ed810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Thu, 28 Mar 2024 15:16:37 +0200 Subject: [PATCH 21/43] toolkit: Allow clearing dev directory --- toolkit.nu | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/toolkit.nu b/toolkit.nu index d07b87f..422690b 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -1,9 +1,13 @@ -export def --env set-nupm-env [] { +export def --env set-nupm-env [--clear] { if ($env.PWD | path basename) != 'nupm' { print 'Run from nupm repo root' return } + if $clear { + rm -rf _nupm_dev + } + $env.NUPM_HOME = ($env.PWD | path join _nupm_dev) $env.NUPM_CACHE = ($env.PWD | path join _nupm_dev cache) $env.NUPM_TEMP = ($env.PWD | path join _nupm_dev tmp) From 2704398343a884df78d5a112b21ac1e990f8f4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Thu, 28 Mar 2024 15:17:01 +0200 Subject: [PATCH 22/43] Remove 'url' column from registry file --- nupm.nuon | 2 +- nupm/install.nu | 4 ++-- nupm/publish.nu | 16 ++++++++-------- nupm/utils/misc.nu | 24 ++++++++++++++++++++++-- nupm/utils/registry.nu | 12 +++++++----- registry/registry.nuon | 2 +- tests/packages/registry/registry.nuon | 2 +- 7 files changed, 42 insertions(+), 20 deletions(-) diff --git a/nupm.nuon b/nupm.nuon index 7d93255..e5804c3 100644 --- a/nupm.nuon +++ b/nupm.nuon @@ -1,7 +1,7 @@ { name: nupm type: module - version: "0.1.0" + version: "0.2.0" description: "Nushell package manager" license: "LICENSE" } diff --git a/nupm/install.nu b/nupm/install.nu index ce6c520..38c83db 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -3,7 +3,7 @@ use std log use utils/completions.nu complete-registries use utils/dirs.nu [ nupm-home-prompt cache-dir module-dir script-dir tmp-dir ] use utils/log.nu throw-error -use utils/misc.nu check-cols +use utils/misc.nu [check-cols url] use utils/package.nu open-package-file use utils/registry.nu search-package use utils/version.nu filter-by-version @@ -151,7 +151,7 @@ def download-pkg [ mkdir $git_dir cd $git_dir - let repo_name = $pkg.info.url | url parse | get path | path parse | get stem + let repo_name = $pkg.info.url | url stem let url_hash = $pkg.info.url | hash md5 # in case of git repo name collision let clone_dir = $'($repo_name)-($url_hash)-($pkg.info.revision)' diff --git a/nupm/publish.nu b/nupm/publish.nu index 19342fc..f477a80 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -13,8 +13,8 @@ export def main [ --local # Publish package as a local package --info: record # Package info based on package type (e.g., url and # revision for a git package) - --path: string # Path to the package root - --pkg-file-url: string # URL of a package registry file + --path: string # Path to the package root relative to the registry file + # --pkg-file-url: string # URL of a package registry file --save # Write changes to registry instead of printing changes ] { if $git and $local { @@ -28,7 +28,7 @@ export def main [ let reg_path = $registry | get-registry-path if ($reg_path | path type) != 'file' { - throw-error $'Registry path ($reg_path) must be a local path.' + throw-error $'Registry path ($reg_path) must be a path.' } print $'Registry path: (ansi cyan_bold)($reg_path)(ansi reset)' @@ -78,14 +78,14 @@ export def main [ } if $existing_entry == null { - let pkg_file_url = if $pkg_file_url != null { - $pkg_file_url - } + # let pkg_file_url = if $pkg_file_url != null { + # $pkg_file_url + # } let reg_entry = { name: $pkg.name path: $pkg_file_path - url: $pkg_file_url + # url: $pkg_file_url } print "" @@ -198,7 +198,7 @@ def open-registry-file []: path -> table --extra-ok --missing-ok @@ -16,7 +16,7 @@ export def check-cols [ let cols = $inp | columns if not $missing_ok { let missing_cols = $required_cols | where {|req_col| $req_col not-in $cols } - + if not ($missing_cols | is-empty) { throw-error ($"Missing the following required columns in ($what):" + $" ($missing_cols | str join ', ')") @@ -34,3 +34,23 @@ export def check-cols [ $inp } + +# Extensions to the `url ...` commands +export module url { + + # Get the stem of a URL path + export def stem []: string -> string { + url parse | get path | path parse | get stem + } + + # Update the last element of a URL path with a new name + export def update-name [new_name: string]: string -> string { + url parse + | update path {|url| + # skip the first '/' and replace last elemnt with the new name + let parts = $url.path | path split | skip 1 | drop 1 + $parts | append $new_name | str join '/' + } + | url join + } +} diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index 0aa9405..c2db368 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -1,7 +1,7 @@ # Utilities related to nupm registries use dirs.nu cache-dir -use misc.nu check-cols +use misc.nu [check-cols url] # Search for a package in a registry export def search-package [ @@ -35,6 +35,7 @@ export def search-package [ { reg: (open $url_or_path) path: $url_or_path + is_url: false } } else { @@ -50,13 +51,14 @@ export def search-package [ { reg: $reg path: $reg_file + is_url: true } } catch { throw-error $"Cannot open '($url_or_path)' as a file or URL." } } - $registry.reg | check-cols "registry" [ name path url ] | ignore + $registry.reg | check-cols "registry" [ name path ] | ignore # Find all packages matching $package in the registry let pkg_files = $registry.reg | filter $name_matcher @@ -66,10 +68,10 @@ export def search-package [ | path dirname | path join $row.path - if $row.url != null { - let pkg_file_content = http get $row.url + if $registry.is_url { + let url = $url_or_path | url update-name $row.path # TODO: Add file hashing - $pkg_file_content | save --force $pkg_file_path + http get $url | save --force $pkg_file_path } open $pkg_file_path diff --git a/registry/registry.nuon b/registry/registry.nuon index 22d071f..bb18bbe 100644 --- a/registry/registry.nuon +++ b/registry/registry.nuon @@ -1 +1 @@ -[[name, path, url]; [nu-clippy, nu-clippy.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-clippy.nuon"], [nu-discord-update, nu-discord-update.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-discord-update.nuon"], [nu-fonts-install, nu-fonts-install.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-fonts-install.nuon"], [nu-git-manager, nu-git-manager.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-git-manager.nuon"], [nu-git-manager-sugar, nu-git-manager-sugar.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-git-manager-sugar.nuon"], [nu-hooks, nu-hooks.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-hooks.nuon"], [nu-logout, nu-logout.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-logout.nuon"], [nu-monitor-manager, nu-monitor-manager.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-monitor-manager.nuon"], [nu-pomodoro, nu-pomodoro.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-pomodoro.nuon"], [nu-right-prompt, nu-right-prompt.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-right-prompt.nuon"], [nu-scripts, nu-scripts.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-scripts.nuon"], [nu-sound-manager, nu-sound-manager.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-sound-manager.nuon"], [nu-themes, nu-themes.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-themes.nuon"], [nu-zellij, nu-zellij.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu-zellij.nuon"], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_audio_hook.nuon"], [nu_plugin_clipboard, nu_plugin_clipboard.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_clipboard.nuon"], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_desktop_notifications.nuon"], [nu_plugin_explore, nu_plugin_explore.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_explore.nuon"], [nu_plugin_image, nu_plugin_image.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_image.nuon"], [nu_plugin_port_list, nu_plugin_port_list.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_port_list.nuon"], [nu_plugin_port_scan, nu_plugin_port_scan.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_port_scan.nuon"], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nu_plugin_qr_maker.nuon"], [nupm, nupm_pkg.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/nupm_pkg.nuon"], [tmux-sessionizer, tmux-sessionizer.nuon, "https://raw.githubusercontent.com/nushell/nupm/main/registry/tmux-sessionizer.nuon"]] \ No newline at end of file +[[name, path]; [nu-clippy, nu-clippy.nuon], [nu-discord-update, nu-discord-update.nuon], [nu-fonts-install, nu-fonts-install.nuon], [nu-git-manager, nu-git-manager.nuon], [nu-git-manager-sugar, nu-git-manager-sugar.nuon], [nu-hooks, nu-hooks.nuon], [nu-logout, nu-logout.nuon], [nu-monitor-manager, nu-monitor-manager.nuon], [nu-pomodoro, nu-pomodoro.nuon], [nu-right-prompt, nu-right-prompt.nuon], [nu-scripts, nu-scripts.nuon], [nu-sound-manager, nu-sound-manager.nuon], [nu-themes, nu-themes.nuon], [nu-zellij, nu-zellij.nuon], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon], [nu_plugin_clipboard, nu_plugin_clipboard.nuon], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon], [nu_plugin_explore, nu_plugin_explore.nuon], [nu_plugin_image, nu_plugin_image.nuon], [nu_plugin_port_list, nu_plugin_port_list.nuon], [nu_plugin_port_scan, nu_plugin_port_scan.nuon], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon], [nupm, nupm_pkg.nuon], [tmux-sessionizer, tmux-sessionizer.nuon]] \ No newline at end of file diff --git a/tests/packages/registry/registry.nuon b/tests/packages/registry/registry.nuon index 93d739c..02c5ac6 100644 --- a/tests/packages/registry/registry.nuon +++ b/tests/packages/registry/registry.nuon @@ -1 +1 @@ -[[name, path, url]; [spam_custom, spam_custom.nuon, null], [spam_module, spam_module.nuon, null], [spam_script, spam_script.nuon, null]] \ No newline at end of file +[[name, path]; [spam_custom, spam_custom.nuon], [spam_module, spam_module.nuon], [spam_script, spam_script.nuon]] \ No newline at end of file From fbdf28216081b2208f98f208efdc24f8017c70fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Thu, 28 Mar 2024 15:17:57 +0200 Subject: [PATCH 23/43] Reword error message --- nupm/publish.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nupm/publish.nu b/nupm/publish.nu index f477a80..812d3e1 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -28,7 +28,7 @@ export def main [ let reg_path = $registry | get-registry-path if ($reg_path | path type) != 'file' { - throw-error $'Registry path ($reg_path) must be a path.' + throw-error $'Registry path ($reg_path) must be a path to a local file.' } print $'Registry path: (ansi cyan_bold)($reg_path)(ansi reset)' From 156b688b62c49e7a5173f918fe14e133e9f3efc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Thu, 28 Mar 2024 15:18:10 +0200 Subject: [PATCH 24/43] Remove comments --- nupm/publish.nu | 5 ----- 1 file changed, 5 deletions(-) diff --git a/nupm/publish.nu b/nupm/publish.nu index 812d3e1..df438ba 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -78,14 +78,9 @@ export def main [ } if $existing_entry == null { - # let pkg_file_url = if $pkg_file_url != null { - # $pkg_file_url - # } - let reg_entry = { name: $pkg.name path: $pkg_file_path - # url: $pkg_file_url } print "" From a4ff70834e03c085ad62051d63e7e4ed268cfff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Thu, 28 Mar 2024 15:26:00 +0200 Subject: [PATCH 25/43] Remove extra registry path print --- nupm/publish.nu | 2 -- 1 file changed, 2 deletions(-) diff --git a/nupm/publish.nu b/nupm/publish.nu index df438ba..c560376 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -31,8 +31,6 @@ export def main [ throw-error $'Registry path ($reg_path) must be a path to a local file.' } - print $'Registry path: (ansi cyan_bold)($reg_path)(ansi reset)' - # Guess package type let pkg_type = if $git { "git" From 66b9cb2bb0590769b15ebf5b374c6d098e71241a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Thu, 28 Mar 2024 18:12:05 +0200 Subject: [PATCH 26/43] Add hashing of registry package files --- nupm/install.nu | 11 ++-- nupm/publish.nu | 75 +++++++++++++----------- nupm/utils/misc.nu | 11 ++++ nupm/utils/registry.nu | 25 ++++++-- registry/registry.nuon | 2 +- tests/mod.nu | 15 +++-- tests/packages/registry/registry.nuon | 2 +- tests/packages/registry/spam_custom.nuon | 2 +- tests/packages/registry/spam_module.nuon | 2 +- 9 files changed, 92 insertions(+), 53 deletions(-) diff --git a/nupm/install.nu b/nupm/install.nu index 38c83db..f513e91 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -3,7 +3,7 @@ use std log use utils/completions.nu complete-registries use utils/dirs.nu [ nupm-home-prompt cache-dir module-dir script-dir tmp-dir ] use utils/log.nu throw-error -use utils/misc.nu [check-cols url] +use utils/misc.nu [check-cols hash-fn url] use utils/package.nu open-package-file use utils/registry.nu search-package use utils/version.nu filter-by-version @@ -132,10 +132,7 @@ def download-pkg [ version: string, path: string, type: string, - info: record< - url: string, - revision: string, - > + info: any, > ]: nothing -> path { # TODO: Add some kind of hashing to check that files really match @@ -152,7 +149,7 @@ def download-pkg [ cd $git_dir let repo_name = $pkg.info.url | url stem - let url_hash = $pkg.info.url | hash md5 # in case of git repo name collision + let url_hash = $pkg.info.url | hash-fn # in case of git repo name collision let clone_dir = $'($repo_name)-($url_hash)-($pkg.info.revision)' let pkg_dir = if $pkg.path == null { @@ -162,7 +159,7 @@ def download-pkg [ } if ($pkg_dir | path exists) { - print $'Package ($pkg.info.name) found in cache' + print $'Package ($pkg.name) found in cache' return $pkg_dir } diff --git a/nupm/publish.nu b/nupm/publish.nu index c560376..bccd45c 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -1,6 +1,7 @@ use utils/log.nu throw-error +use utils/misc.nu hash-fn use utils/package.nu open-package-file -use utils/registry.nu search-package +use utils/registry.nu [ search-package REG_COLS REG_PKG_COLS ] use utils/version.nu sort-by-version # Publish package to registry @@ -51,7 +52,7 @@ export def main [ $res | last | get type } - # Create entry to the registry file + # Preparation mut reg_content = $reg_path | open-registry-file let name_matches = if ($reg_content | length) > 0 { @@ -75,27 +76,6 @@ export def main [ $existing_entry.path } - if $existing_entry == null { - let reg_entry = { - name: $pkg.name - path: $pkg_file_path - } - - print "" - print $"New entry to registry file (ansi cyan_bold)($reg_path)(ansi reset):" - print ($reg_entry | table --expand) - - # Add the entry to the registry file - $reg_content = ($reg_content | append $reg_entry | sort-by name) - - if $save { - print $"(ansi yellow)=> SAVED!(ansi reset)" - $reg_content | save --force $reg_path - } - } else { - print $"Registry file (ansi cyan_bold)($reg_path)(ansi reset) unchanged" - } - # Create entry to the package file mut info = $info @@ -128,28 +108,57 @@ export def main [ info: $info } - let pkg_file_path = $reg_path | path dirname | path join $pkg_file_path + let pkg_file_path_full = $reg_path + | path dirname + | path join $pkg_file_path + | path expand print "" print ("New entry to package file" - + $" (ansi cyan_bold)($pkg_file_path)(ansi reset):") + + $" (ansi cyan_bold)($pkg_file_path_full)(ansi reset):") print ($pkg_entry | table --expand) - # Add the entry to the package file - let pkg_file_content = $pkg_file_path | open-reg-pkg-file + # add the entry to the package file + let pkg_file_content = $pkg_file_path_full | open-reg-pkg-file if $pkg.version in $pkg_file_content.version { throw-error ($"Version ($pkg.version) of package ($pkg.name) is already" + $" published in registry ($registry)") } - let pkg_file_content = $pkg_file_content + let pkg_file_nuon = $pkg_file_content | append $pkg_entry | sort-by-version + | to nuon + + if $save { + print $"(ansi yellow)=> SAVED!(ansi reset)" + $pkg_file_nuon | save --raw --force $pkg_file_path_full + } + + # Create entry to the registry file + let hash = $pkg_file_nuon | hash-fn + + let reg_entry = { + name: $pkg.name + path: $pkg_file_path + hash: $hash + } + + print "" + print $"New entry to registry file (ansi cyan_bold)($reg_path)(ansi reset):" + print ($reg_entry | table --expand) + + # add the entry to the registry file + let reg_nuon = $reg_content + | where name != $pkg.name + | append $reg_entry + | sort-by name + | to nuon if $save { print $"(ansi yellow)=> SAVED!(ansi reset)" - $pkg_file_content | save --force $pkg_file_path + $reg_nuon | save --raw --force $reg_path } else { print "" print $"(ansi yellow)If the changes look good, re-run with --save to apply them.(ansi reset)" @@ -191,12 +200,12 @@ def open-registry-file []: path -> table table< let pkg_path = $in let pkg_content = try { open $pkg_path } - let exp_cols = [name version path type info] + let exp_cols = $REG_PKG_COLS if (($pkg_content | is-not-empty) and ($pkg_content | columns) != $exp_cols) { throw-error ($"Unexpected columns of package file ($pkg_path)." - + $" Needs ($exp_cols).") + + $" Got ($pkg_content | columns), needs ($exp_cols).") } $pkg_content | default [] diff --git a/nupm/utils/misc.nu b/nupm/utils/misc.nu index 23794e4..3f3e7be 100644 --- a/nupm/utils/misc.nu +++ b/nupm/utils/misc.nu @@ -35,6 +35,17 @@ export def check-cols [ $inp } +# Compute a hash of a string +export def hash-fn []: string -> string { + let hash = $in | hash md5 + [ 'md5' $hash ] | str join '-' +} + +# Compute a hash of file contents +export def hash-file []: path -> string { + open --raw | hash-fn +} + # Extensions to the `url ...` commands export module url { diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index c2db368..006e105 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -1,7 +1,14 @@ # Utilities related to nupm registries use dirs.nu cache-dir -use misc.nu [check-cols url] +use log.nu throw-error +use misc.nu [check-cols url hash-file] + +# Columns of a registry file +export const REG_COLS = [ name path hash ] + +# Columns of a registry package file +export const REG_PKG_COLS = [ name version path type info ] # Search for a package in a registry export def search-package [ @@ -58,7 +65,7 @@ export def search-package [ } } - $registry.reg | check-cols "registry" [ name path ] | ignore + $registry.reg | check-cols "registry" $REG_COLS | ignore # Find all packages matching $package in the registry let pkg_files = $registry.reg | filter $name_matcher @@ -68,12 +75,22 @@ export def search-package [ | path dirname | path join $row.path - if $registry.is_url { + let hash = if ($pkg_file_path | path type) == file { + $pkg_file_path | hash-file + } + + if $registry.is_url and $hash != $row.hash { let url = $url_or_path | url update-name $row.path - # TODO: Add file hashing http get $url | save --force $pkg_file_path } + let new_hash = $pkg_file_path | hash-file + + if $new_hash != $row.hash { + throw-error ($'Content of package file ($pkg_file_path)' + + $' does not match expected hash ($row.hash)') + } + open $pkg_file_path } | flatten diff --git a/registry/registry.nuon b/registry/registry.nuon index bb18bbe..6c3ee7f 100644 --- a/registry/registry.nuon +++ b/registry/registry.nuon @@ -1 +1 @@ -[[name, path]; [nu-clippy, nu-clippy.nuon], [nu-discord-update, nu-discord-update.nuon], [nu-fonts-install, nu-fonts-install.nuon], [nu-git-manager, nu-git-manager.nuon], [nu-git-manager-sugar, nu-git-manager-sugar.nuon], [nu-hooks, nu-hooks.nuon], [nu-logout, nu-logout.nuon], [nu-monitor-manager, nu-monitor-manager.nuon], [nu-pomodoro, nu-pomodoro.nuon], [nu-right-prompt, nu-right-prompt.nuon], [nu-scripts, nu-scripts.nuon], [nu-sound-manager, nu-sound-manager.nuon], [nu-themes, nu-themes.nuon], [nu-zellij, nu-zellij.nuon], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon], [nu_plugin_clipboard, nu_plugin_clipboard.nuon], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon], [nu_plugin_explore, nu_plugin_explore.nuon], [nu_plugin_image, nu_plugin_image.nuon], [nu_plugin_port_list, nu_plugin_port_list.nuon], [nu_plugin_port_scan, nu_plugin_port_scan.nuon], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon], [nupm, nupm_pkg.nuon], [tmux-sessionizer, tmux-sessionizer.nuon]] \ No newline at end of file +[[name, path, hash]; [nu-clippy, nu-clippy.nuon, "md5-15ccbe07dfb7d5f2de260b2b40bf36b5"], [nu-discord-update, nu-discord-update.nuon, "md5-d593c0f41ffd71873028871fcd74b5a9"], [nu-fonts-install, nu-fonts-install.nuon, "md5-cd57f47aeece1679e2febc438d195e8d"], [nu-git-manager, nu-git-manager.nuon, "md5-4aaae15412fb84233fcb19716f6b7e89"], [nu-git-manager-sugar, nu-git-manager-sugar.nuon, "md5-d0c7641c0b369e7c944cc668741734d9"], [nu-hooks, nu-hooks.nuon, "md5-5368e1bc61e9a567263fa4cc55c29783"], [nu-logout, nu-logout.nuon, "md5-9cb6e927f4823dafa8b48867ef1cf70f"], [nu-monitor-manager, nu-monitor-manager.nuon, "md5-15f64df367e8b59606f9b29347cce8a9"], [nu-pomodoro, nu-pomodoro.nuon, "md5-53e18e3476358a813e3ba289dbc5609c"], [nu-right-prompt, nu-right-prompt.nuon, "md5-8a684d7720f0703943317709abfc87bb"], [nu-scripts, nu-scripts.nuon, "md5-733ba206358f545ba9274854fda1c4a5"], [nu-sound-manager, nu-sound-manager.nuon, "md5-f305740d2e93cfeb76c40302f7f5246a"], [nu-themes, nu-themes.nuon, "md5-e303b8f08b1158aacef80a53c5432662"], [nu-zellij, nu-zellij.nuon, "md5-5b0c46f155261507c08c693366639c7a"], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon, "md5-b2f7807acf002c5e02e1c43e2f80eb16"], [nu_plugin_clipboard, nu_plugin_clipboard.nuon, "md5-cb9d8d27e8fd1814dce58dd0fdb604e5"], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon, "md5-f682e6fd6eecf2743686a3da71c1917c"], [nu_plugin_explore, nu_plugin_explore.nuon, "md5-9f9ecf5bbd943645daaa515210bb113a"], [nu_plugin_image, nu_plugin_image.nuon, "md5-d842828405fa74d1056767fa4c3de248"], [nu_plugin_port_list, nu_plugin_port_list.nuon, "md5-59cf1913f6041f45d8c4b4a99d518501"], [nu_plugin_port_scan, nu_plugin_port_scan.nuon, "md5-c4a8347de871a0f626c78d1b05740e19"], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon, "md5-3eb8130c45318fe8a90abaf0680574de"], [nupm, nupm_pkg.nuon, "md5-2cf3b52cb9535f74d94d7b68abe0acd1"], [tmux-sessionizer, tmux-sessionizer.nuon, "md5-252d0e1da316ff5f597402d2a2bb09b5"]] \ No newline at end of file diff --git a/tests/mod.nu b/tests/mod.nu index 04b5c96..bea2071 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -150,15 +150,20 @@ export def env-vars-are-set [] { export def generate-local-registry [] { with-test-env { - cp -r tests/packages $env.NUPM_TEMP + # cp -r tests/packages $env.NUPM_TEMP + mkdir ($env.NUPM_TEMP | path join packages registry) + + let reg_file = [tests packages registry registry.nuon] | path join + let tmp_reg_file = [ + $env.NUPM_TEMP packages registry test_registry.nuon + ] + | path join - let reg_file = $env.NUPM_TEMP | path join packages registry registry.nuon - let tmp_reg_file = $env.NUPM_TEMP | path join packages test_registry.nuon touch $tmp_reg_file [spam_script spam_script_old spam_custom spam_module] | each {|pkg| - cd ($env.NUPM_TEMP | path join packages $pkg) - nupm publish $tmp_reg_file --local --save + cd ([tests packages $pkg] | path join) + nupm publish $tmp_reg_file --local --save --path $'../($pkg)' } let actual = open $tmp_reg_file | to nuon diff --git a/tests/packages/registry/registry.nuon b/tests/packages/registry/registry.nuon index 02c5ac6..bc4ae11 100644 --- a/tests/packages/registry/registry.nuon +++ b/tests/packages/registry/registry.nuon @@ -1 +1 @@ -[[name, path]; [spam_custom, spam_custom.nuon], [spam_module, spam_module.nuon], [spam_script, spam_script.nuon]] \ No newline at end of file +[[name, path, hash]; [spam_custom, spam_custom.nuon, "md5-90c14f51108a3c067d1f1e11f156ca98"], [spam_module, spam_module.nuon, "md5-c14d7a703fb0e587cf19934c5a397619"], [spam_script, spam_script.nuon, "md5-d7724c6282cc7eb878178b79f8617e29"]] \ No newline at end of file diff --git a/tests/packages/registry/spam_custom.nuon b/tests/packages/registry/spam_custom.nuon index 371a345..2cbe70e 100644 --- a/tests/packages/registry/spam_custom.nuon +++ b/tests/packages/registry/spam_custom.nuon @@ -1 +1 @@ -{name: spam_custom, version: "0.1.0", path: ../spam_custom, type: local, info: null} \ No newline at end of file +[[name, version, path, type, info]; [spam_custom, "0.1.0", ../spam_custom, local, null]] \ No newline at end of file diff --git a/tests/packages/registry/spam_module.nuon b/tests/packages/registry/spam_module.nuon index 16f40f9..aab116b 100644 --- a/tests/packages/registry/spam_module.nuon +++ b/tests/packages/registry/spam_module.nuon @@ -1 +1 @@ -{name: spam_module, version: "0.1.0", path: ../spam_module, type: local, info: null} \ No newline at end of file +[[name, version, path, type, info]; [spam_module, "0.1.0", ../spam_module, local, null]] \ No newline at end of file From bde509cfd9a53939c7a4df01564136e1f9c0b2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Thu, 28 Mar 2024 18:53:48 +0200 Subject: [PATCH 27/43] Add registry documentation --- docs/design/registry.md | 116 ++++++++++++++++++++++++++++++++-------- nupm/publish.nu | 4 +- 2 files changed, 97 insertions(+), 23 deletions(-) diff --git a/docs/design/registry.md b/docs/design/registry.md index 37a01ca..7f219a8 100644 --- a/docs/design/registry.md +++ b/docs/design/registry.md @@ -1,29 +1,103 @@ # Registry -_moved from old registry.nuon_ +Registry is a collection of .nuon files that tell nupm where to look for packages when doing tasks like `nupm search` or `nupm install`. -Registry is a NUON file that tells nupm where to look for packages +Two types of files compose a registry: +* The "main" registry file containing the list of "registry package files" +* Registry package files containing the details of each package. -Currently, these package types are supported: -* git ..... package is an online git repository -* local ... package is on a local filesystem +These files **should not** be edited manually. They are intended to be auto-generated and updated with `nupm publish` only. -The package type defines the columns of the registry record. Each column holds -holds a table of packages. +## "Main" registry file -Git packages accept the following columns: -* name ....... name of the package -* version .... version of the package -* url ........ Git URL of the package -* revision ... Git revision to check out when installing the package (commit - hash, version, branch name, ...) -* path ....... Path relative to the repository root where to look for nupm.nuon +Table with one package per row and the following columns: +* `name`: Name of the package +* `path`: Path to the "registry package file", relative* to the main registry file. When looking up a package, nupm joins this path to the path/URL of the "main" registry file and fetches it. Both local paths and URLs are handled the same way. +* `hash`: Hash of the "registry package file" to avoid re-downloading them all the time. -Local packages accept the following columns: -* name ....... name of the package -* version .... version of the package -* path ....... Path where to look for nupm.nuon. It can be absolute, or - relative. If relative, then relative to the registry file. +The file is sorted by `name`. No duplicate package names allowed. -One registry can contain packages with the same name, but they must be of -different version. +## "Registry package file" + +These files contain the actual information about the package that is used do fetch and install the package. Multiple versions of the same package are supported. It has exactly the following columns: +* `name`: Name of the package +* `version`: Version of the package +* `path`: Path where to look for nupm.nuon (relative to the package root*) +* `type`: Type of the package. Currently only "git" and "local" +* `info`: Package-specific info based on `type`. It can be one of the following: + * `null` if `type` is "local" + * `record` if `type` is "git" + +This file is sorted by `version`. No duplicate versions allowed. + +_*absolute paths work, but are discouraged, only to be used for local testing etc._ + +## Example registry structure + +_See the new `registry/` directory, the following example slightly differs from it._ + +``` +./registry + +-- registry.nuon + +-- amtoine + +-- nu-git-manager.nuon + +-- nu-git-manager-sugar.nuon +``` + +```nushell +> open registry/registry.nuon + # name path hash +─────────────────────────────────────────────────────────────────────────── + 0 nu-git-manager amtoine/nu-git-manager.nuon md5-4aaae15412fb84233fcb19716f6b7e89 + 1 nu-git-manager-sugar amtoine/nu-git-manager-sugar.nuon md5-d0c7641c0b369e7c944cc668741734d9 + +> open amtoine/nu-git-manager.nuon | table -e + # name version path type info +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 nu-git-manager 0.1.0 pkgs/nu-git-manager git url https://github.com/amtoine/nu-git-manager + revision 0.1.0 + 1 nu-git-manager 0.2.0 pkgs/nu-git-manager git url https://github.com/amtoine/nu-git-manager + revision 0.2.0 + 2 nu-git-manager 0.3.0 pkgs/nu-git-manager git url https://github.com/amtoine/nu-git-manager + revision 0.3.0 + 3 nu-git-manager 0.4.0 pkgs/nu-git-manager git url https://github.com/amtoine/nu-git-manager + revision 0.4.0 + 4 nu-git-manager 0.5.0 pkgs/nu-git-manager git url https://github.com/amtoine/nu-git-manager + revision 0.5.0 + 5 nu-git-manager 0.6.0 pkgs/nu-git-manager git url https://github.com/amtoine/nu-git-manager + revision 0.6.0 + 6 nu-git-manager 0.7.0 pkgs/nu-git-manager git url https://github.com/amtoine/nu-git-manager + revision 0.7.0 + +> open amtoine/nu-git-manager-sugar.nuon | table -e + # name version path type info +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── + 0 nu-git-manager-sugar 0.1.0 pkgs/nu-git-manager-sugar git url https://github.com/amtoine/nu-git-manager + revision 0.1.0 + 1 nu-git-manager-sugar 0.2.0 pkgs/nu-git-manager-sugar git url https://github.com/amtoine/nu-git-manager + revision 0.2.0 + 2 nu-git-manager-sugar 0.3.0 pkgs/nu-git-manager-sugar git url https://github.com/amtoine/nu-git-manager + revision 0.3.0 + 3 nu-git-manager-sugar 0.4.0 pkgs/nu-git-manager-sugar git url https://github.com/amtoine/nu-git-manager + revision 0.4.0 + 4 nu-git-manager-sugar 0.5.0 pkgs/nu-git-manager-sugar git url https://github.com/amtoine/nu-git-manager + revision 0.5.0 + 5 nu-git-manager-sugar 0.6.0 pkgs/nu-git-manager-sugar git url https://github.com/amtoine/nu-git-manager + revision 0.6.0 + 6 nu-git-manager-sugar 0.7.0 pkgs/nu-git-manager-sugar git url https://github.com/amtoine/nu-git-manager + revision 0.7.0 +``` + +## Publishing a package + +It is possible to only publish to a registry stored on your file system because we don't have a web service or anything like that. + +The intented workflow for publishing a package is: +1. Check out the git repository with the registry +2. `cd` into the package you want to publish +3. Run `nupm publish chosen_registry` to preview the changes +4. Repeat 3 by adjusting the `nupm publish` flags until you have the desired output +5. Run the final command with the `--save` flag which will save the registry files +6. Commit the changes to the registry, create a PR upstream, etc. + +The reason for steps 3. and 4. is that `nupm publish` tries to guess some values to make publishing less tedious. For example, if you're in a git repository, nupm tries to get the URL of the "origin", or the first available remote by default. This should be a sane default for most packages and frees you from having to pass the `--info` flag every time. The guess can be wrong, however, that's why you should check the output of step 3 and make the desired changes before saving the changes with `--save`. diff --git a/nupm/publish.nu b/nupm/publish.nu index bccd45c..88c2e47 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -9,13 +9,13 @@ use utils/version.nu sort-by-version # By default, changes are only previewed. To apply them, use the --save flag. # Needs to run from package root, i.e., where nupm.nuon is. export def main [ - registry: string # Registry file to publish to (name or path) + registry: string # Registry file to publish to (local file or name pointing + # at a local registry) --git # Publish package as a git package --local # Publish package as a local package --info: record # Package info based on package type (e.g., url and # revision for a git package) --path: string # Path to the package root relative to the registry file - # --pkg-file-url: string # URL of a package registry file --save # Write changes to registry instead of printing changes ] { if $git and $local { From 661865f14f17b58193a5215b6cf9bc7ae39c39e8 Mon Sep 17 00:00:00 2001 From: kubouch Date: Fri, 29 Mar 2024 00:38:06 +0200 Subject: [PATCH 28/43] Change default registry to the new one --- nupm/utils/dirs.nu | 2 +- toolkit.nu | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/nupm/utils/dirs.nu b/nupm/utils/dirs.nu index 1c8b732..5bcfae2 100644 --- a/nupm/utils/dirs.nu +++ b/nupm/utils/dirs.nu @@ -12,7 +12,7 @@ export const DEFAULT_NUPM_TEMP = ($nu.temp-path | path join "nupm") # Default registry export const DEFAULT_NUPM_REGISTRIES = { - nupm_test: 'https://raw.githubusercontent.com/nushell/nupm/main/registry.nuon' + nupm_test: 'https://raw.githubusercontent.com/nushell/nupm/main/registry/registry.nuon' } # Prompt to create $env.NUPM_HOME if it does not exist and some sanity checks. diff --git a/toolkit.nu b/toolkit.nu index 422690b..9081bf4 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -11,8 +11,7 @@ export def --env set-nupm-env [--clear] { $env.NUPM_HOME = ($env.PWD | path join _nupm_dev) $env.NUPM_CACHE = ($env.PWD | path join _nupm_dev cache) $env.NUPM_TEMP = ($env.PWD | path join _nupm_dev tmp) - # $env.NUPM_REGISTRIES = { nupm_dev: ($env.PWD | path join registry registry.nuon) } - $env.NUPM_REGISTRIES = { nupm_dev: 'https://git.sr.ht/~kubouch/nupkgs/blob/main/registry/registry.nuon' } + $env.NUPM_REGISTRIES = { nupm_dev: ($env.PWD | path join registry registry.nuon) } if $nu.os-info.family == 'windows' and 'Path' in $env { $env.Path = ($env.Path | prepend ($env.PWD | path join _nupm_dev scripts)) From ecc8a0061cb2f8e8cb0fbebcf31e5dd45acbc248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Wed, 10 Apr 2024 23:22:25 +0300 Subject: [PATCH 29/43] Make path crossplatform Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com> --- tests/mod.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mod.nu b/tests/mod.nu index bea2071..8587076 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -163,7 +163,7 @@ export def generate-local-registry [] { [spam_script spam_script_old spam_custom spam_module] | each {|pkg| cd ([tests packages $pkg] | path join) - nupm publish $tmp_reg_file --local --save --path $'../($pkg)' + nupm publish $tmp_reg_file --local --save --path (".." | path join $pkg) } let actual = open $tmp_reg_file | to nuon From e9a952e75a956735639b4b205732d86cfeba14ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Wed, 10 Apr 2024 23:22:36 +0300 Subject: [PATCH 30/43] Remove comment Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com> --- tests/mod.nu | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/mod.nu b/tests/mod.nu index 8587076..c3f98a0 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -150,7 +150,6 @@ export def env-vars-are-set [] { export def generate-local-registry [] { with-test-env { - # cp -r tests/packages $env.NUPM_TEMP mkdir ($env.NUPM_TEMP | path join packages registry) let reg_file = [tests packages registry registry.nuon] | path join From 382728d7f8d006809598bda02f036798b632aab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Wed, 10 Apr 2024 23:25:09 +0300 Subject: [PATCH 31/43] Compact PATH print --- toolkit.nu | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/toolkit.nu b/toolkit.nu index 9081bf4..65f6c1c 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -27,13 +27,7 @@ export def print-nupm-env [] { print $'NUPM_HOME: ($env.NUPM_HOME?)' print $'NUPM_CACHE: ($env.NUPM_CACHE?)' print $'NUPM_TEMP: ($env.NUPM_TEMP?)' - if $nu.os-info.family == 'windows' and 'Path' in $env { - print $'Path: ($env.Path?)' - } else if 'PATH' in $env { - print $'PATH: ($env.PATH?)' - } else { - print 'no PATH env var' - } + print $"PATH: ($env.PATH? | default $env.Path? | default [])" print $'NU_LIB_DIRS: ($env.NU_LIB_DIRS?)' print $'NUPM_REGISTRIES: ($env.NUPM_REGISTRIES?)' } From bb8b3c68030b8a980b5afb56847fc76450a07d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 4 May 2024 14:38:59 +0300 Subject: [PATCH 32/43] Try avoiding newlines when hashing nuon files --- nupm/utils/misc.nu | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nupm/utils/misc.nu b/nupm/utils/misc.nu index 3f3e7be..c0e3204 100644 --- a/nupm/utils/misc.nu +++ b/nupm/utils/misc.nu @@ -43,7 +43,13 @@ export def hash-fn []: string -> string { # Compute a hash of file contents export def hash-file []: path -> string { - open --raw | hash-fn + let p = $in + + if ($p | path parse).extension == "nuon" { + open $p | to nuon | hash-fn + } else { + open $p --raw | hash-fn + } } # Extensions to the `url ...` commands From 4c80dbcc9b55cbbf2c0c0a43179c9673c80f51fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 4 May 2024 14:47:09 +0300 Subject: [PATCH 33/43] Revert "Try avoiding newlines when hashing nuon files" This reverts commit bb8b3c68030b8a980b5afb56847fc76450a07d30. --- nupm/utils/misc.nu | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/nupm/utils/misc.nu b/nupm/utils/misc.nu index c0e3204..3f3e7be 100644 --- a/nupm/utils/misc.nu +++ b/nupm/utils/misc.nu @@ -43,13 +43,7 @@ export def hash-fn []: string -> string { # Compute a hash of file contents export def hash-file []: path -> string { - let p = $in - - if ($p | path parse).extension == "nuon" { - open $p | to nuon | hash-fn - } else { - open $p --raw | hash-fn - } + open --raw | hash-fn } # Extensions to the `url ...` commands From 28326dbc6dec660bb936d06461663c3a2bc9d9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 4 May 2024 15:20:36 +0300 Subject: [PATCH 34/43] Better help msg --- nupm/publish.nu | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nupm/publish.nu b/nupm/publish.nu index 88c2e47..4b379c8 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -8,14 +8,21 @@ use utils/version.nu sort-by-version # # By default, changes are only previewed. To apply them, use the --save flag. # Needs to run from package root, i.e., where nupm.nuon is. +# +# The --path flag defines the `path` field of the registry package file. Its +# meaning depends on the package type: +# * git packages : Path to the package relative to git repo root +# * local packages : Path to the package relative to registry file +# Furthermore, `\` inside the `path` field are replaced with `/` to avoid +# conflicts between Windows and non-Windows platforms. export def main [ registry: string # Registry file to publish to (local file or name pointing # at a local registry) --git # Publish package as a git package --local # Publish package as a local package - --info: record # Package info based on package type (e.g., url and - # revision for a git package) - --path: string # Path to the package root relative to the registry file + --info: record # Package info based on package type (e.g., `url` and + # `revision` for a git package) + --path: string # `path` field of the registry entry file --save # Write changes to registry instead of printing changes ] { if $git and $local { From c4289481a1b71899c9ad37f3ea7c0f6e97fe0a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 4 May 2024 15:25:03 +0300 Subject: [PATCH 35/43] Replace \ with / in --path --- nupm/publish.nu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nupm/publish.nu b/nupm/publish.nu index 4b379c8..6edea95 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -107,6 +107,8 @@ export def main [ } } + let path = if $path != null { $path | str replace '\' '/' } + let pkg_entry = { name: $pkg.name version: $pkg.version From c6644404f01566e46b65b6d3ef93acbba749e746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 4 May 2024 15:48:33 +0300 Subject: [PATCH 36/43] Update docs --- docs/design/registry.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/design/registry.md b/docs/design/registry.md index 7f219a8..dc225ed 100644 --- a/docs/design/registry.md +++ b/docs/design/registry.md @@ -6,7 +6,7 @@ Two types of files compose a registry: * The "main" registry file containing the list of "registry package files" * Registry package files containing the details of each package. -These files **should not** be edited manually. They are intended to be auto-generated and updated with `nupm publish` only. +These files **should not** be edited manually. They are intended to be auto-generated and updated with `nupm publish` only. They also shouldn't contain any newlines to avoid potential problems with file hashes between Windows and non-Windows platforms. ## "Main" registry file @@ -22,7 +22,7 @@ The file is sorted by `name`. No duplicate package names allowed. These files contain the actual information about the package that is used do fetch and install the package. Multiple versions of the same package are supported. It has exactly the following columns: * `name`: Name of the package * `version`: Version of the package -* `path`: Path where to look for nupm.nuon (relative to the package root*) +* `path`: Path where to look for nupm.nuon (relative to the package root*, in the case of git packages, or the main registry file, if local package) * `type`: Type of the package. Currently only "git" and "local" * `info`: Package-specific info based on `type`. It can be one of the following: * `null` if `type` is "local" From 5c76423b073e714c9e54a1353370a47824855e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 4 May 2024 15:53:25 +0300 Subject: [PATCH 37/43] Test for newlines in testing registry files --- tests/mod.nu | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/mod.nu b/tests/mod.nu index c3f98a0..3acc556 100644 --- a/tests/mod.nu +++ b/tests/mod.nu @@ -171,3 +171,8 @@ export def generate-local-registry [] { assert equal $actual $expected } } + +export def registry-files-no-newlines [] { + assert (ls tests/packages/registry/*nuon + | all { not (open $in.name --raw | str contains (char nl)) }) +} From 524e756af78cfa82ee0c4a932222316fdd99aadb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sun, 5 May 2024 15:35:08 +0300 Subject: [PATCH 38/43] Update nupm/publish.nu Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com> --- nupm/publish.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nupm/publish.nu b/nupm/publish.nu index 6edea95..f33daa8 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -107,7 +107,7 @@ export def main [ } } - let path = if $path != null { $path | str replace '\' '/' } + let path = if $path != null { $path | str replace --all '\' '/' } let pkg_entry = { name: $pkg.name From c20ccf937bc5cedc1036befb65cf5649555fedd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sun, 5 May 2024 15:43:27 +0300 Subject: [PATCH 39/43] Add usage note --- nupm/publish.nu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nupm/publish.nu b/nupm/publish.nu index f33daa8..37957b0 100644 --- a/nupm/publish.nu +++ b/nupm/publish.nu @@ -6,6 +6,8 @@ use utils/version.nu sort-by-version # Publish package to registry # +# The package being published is determined by the current working directory. +# # By default, changes are only previewed. To apply them, use the --save flag. # Needs to run from package root, i.e., where nupm.nuon is. # From 4140560a32625a5d63c6f241966e82ad3f8a47f5 Mon Sep 17 00:00:00 2001 From: amtoine Date: Wed, 8 May 2024 09:24:28 +0200 Subject: [PATCH 40/43] publish missing versions of `nu_plugin_explore` these versions have been removed in a merge conflict resolution and were defined in #88. i did run the following command after checking out on the different revisions: ```nushell use /path/to/nupm/nupm nupm publish /path/to/nupm/registry/registry.nuon --save --git ``` --- registry/nu_plugin_explore.nuon | 2 +- registry/registry.nuon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/nu_plugin_explore.nuon b/registry/nu_plugin_explore.nuon index 9b93051..e2a7882 100644 --- a/registry/nu_plugin_explore.nuon +++ b/registry/nu_plugin_explore.nuon @@ -1 +1 @@ -[[name, version, path, type, info]; [nu_plugin_explore, "0.1.2", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.1.2"}], [nu_plugin_explore, "0.2.0", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.2.0"}]] \ No newline at end of file +[[name, version, path, type, info]; [nu_plugin_explore, "0.1.2", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.1.2"}], [nu_plugin_explore, "0.2.0", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.2.0"}], [nu_plugin_explore, "0.92.3-2595f31541554c6d8602ebebc9dffbc4dd29dd89", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.92.3-2595f31541554c6d8602ebebc9dffbc4dd29dd89"}], [nu_plugin_explore, "0.92.3-55edef5ddaf3d3d55290863446c2dd50c012e9bc", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.92.3-55edef5ddaf3d3d55290863446c2dd50c012e9bc"}], [nu_plugin_explore, "0.92.3-be5ed3290cb116cbe9f3038f7a2d46aaac85a25c", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.92.3-be5ed3290cb116cbe9f3038f7a2d46aaac85a25c"}], [nu_plugin_explore, "0.92.3-c06ef201b72b3cbe901820417106b7d65c6f01e1", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.92.3-c06ef201b72b3cbe901820417106b7d65c6f01e1"}], [nu_plugin_explore, "0.93.0", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.93.0"}]] \ No newline at end of file diff --git a/registry/registry.nuon b/registry/registry.nuon index 6c3ee7f..806e8d3 100644 --- a/registry/registry.nuon +++ b/registry/registry.nuon @@ -1 +1 @@ -[[name, path, hash]; [nu-clippy, nu-clippy.nuon, "md5-15ccbe07dfb7d5f2de260b2b40bf36b5"], [nu-discord-update, nu-discord-update.nuon, "md5-d593c0f41ffd71873028871fcd74b5a9"], [nu-fonts-install, nu-fonts-install.nuon, "md5-cd57f47aeece1679e2febc438d195e8d"], [nu-git-manager, nu-git-manager.nuon, "md5-4aaae15412fb84233fcb19716f6b7e89"], [nu-git-manager-sugar, nu-git-manager-sugar.nuon, "md5-d0c7641c0b369e7c944cc668741734d9"], [nu-hooks, nu-hooks.nuon, "md5-5368e1bc61e9a567263fa4cc55c29783"], [nu-logout, nu-logout.nuon, "md5-9cb6e927f4823dafa8b48867ef1cf70f"], [nu-monitor-manager, nu-monitor-manager.nuon, "md5-15f64df367e8b59606f9b29347cce8a9"], [nu-pomodoro, nu-pomodoro.nuon, "md5-53e18e3476358a813e3ba289dbc5609c"], [nu-right-prompt, nu-right-prompt.nuon, "md5-8a684d7720f0703943317709abfc87bb"], [nu-scripts, nu-scripts.nuon, "md5-733ba206358f545ba9274854fda1c4a5"], [nu-sound-manager, nu-sound-manager.nuon, "md5-f305740d2e93cfeb76c40302f7f5246a"], [nu-themes, nu-themes.nuon, "md5-e303b8f08b1158aacef80a53c5432662"], [nu-zellij, nu-zellij.nuon, "md5-5b0c46f155261507c08c693366639c7a"], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon, "md5-b2f7807acf002c5e02e1c43e2f80eb16"], [nu_plugin_clipboard, nu_plugin_clipboard.nuon, "md5-cb9d8d27e8fd1814dce58dd0fdb604e5"], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon, "md5-f682e6fd6eecf2743686a3da71c1917c"], [nu_plugin_explore, nu_plugin_explore.nuon, "md5-9f9ecf5bbd943645daaa515210bb113a"], [nu_plugin_image, nu_plugin_image.nuon, "md5-d842828405fa74d1056767fa4c3de248"], [nu_plugin_port_list, nu_plugin_port_list.nuon, "md5-59cf1913f6041f45d8c4b4a99d518501"], [nu_plugin_port_scan, nu_plugin_port_scan.nuon, "md5-c4a8347de871a0f626c78d1b05740e19"], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon, "md5-3eb8130c45318fe8a90abaf0680574de"], [nupm, nupm_pkg.nuon, "md5-2cf3b52cb9535f74d94d7b68abe0acd1"], [tmux-sessionizer, tmux-sessionizer.nuon, "md5-252d0e1da316ff5f597402d2a2bb09b5"]] \ No newline at end of file +[[name, path, hash]; [nu-clippy, nu-clippy.nuon, "md5-15ccbe07dfb7d5f2de260b2b40bf36b5"], [nu-discord-update, nu-discord-update.nuon, "md5-d593c0f41ffd71873028871fcd74b5a9"], [nu-fonts-install, nu-fonts-install.nuon, "md5-cd57f47aeece1679e2febc438d195e8d"], [nu-git-manager, nu-git-manager.nuon, "md5-4aaae15412fb84233fcb19716f6b7e89"], [nu-git-manager-sugar, nu-git-manager-sugar.nuon, "md5-d0c7641c0b369e7c944cc668741734d9"], [nu-hooks, nu-hooks.nuon, "md5-5368e1bc61e9a567263fa4cc55c29783"], [nu-logout, nu-logout.nuon, "md5-9cb6e927f4823dafa8b48867ef1cf70f"], [nu-monitor-manager, nu-monitor-manager.nuon, "md5-15f64df367e8b59606f9b29347cce8a9"], [nu-pomodoro, nu-pomodoro.nuon, "md5-53e18e3476358a813e3ba289dbc5609c"], [nu-right-prompt, nu-right-prompt.nuon, "md5-8a684d7720f0703943317709abfc87bb"], [nu-scripts, nu-scripts.nuon, "md5-733ba206358f545ba9274854fda1c4a5"], [nu-sound-manager, nu-sound-manager.nuon, "md5-f305740d2e93cfeb76c40302f7f5246a"], [nu-themes, nu-themes.nuon, "md5-e303b8f08b1158aacef80a53c5432662"], [nu-zellij, nu-zellij.nuon, "md5-5b0c46f155261507c08c693366639c7a"], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon, "md5-b2f7807acf002c5e02e1c43e2f80eb16"], [nu_plugin_clipboard, nu_plugin_clipboard.nuon, "md5-cb9d8d27e8fd1814dce58dd0fdb604e5"], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon, "md5-f682e6fd6eecf2743686a3da71c1917c"], [nu_plugin_explore, nu_plugin_explore.nuon, "md5-63db3ee7027bb97443b88997b6df5e3d"], [nu_plugin_image, nu_plugin_image.nuon, "md5-d842828405fa74d1056767fa4c3de248"], [nu_plugin_port_list, nu_plugin_port_list.nuon, "md5-59cf1913f6041f45d8c4b4a99d518501"], [nu_plugin_port_scan, nu_plugin_port_scan.nuon, "md5-c4a8347de871a0f626c78d1b05740e19"], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon, "md5-3eb8130c45318fe8a90abaf0680574de"], [nupm, nupm_pkg.nuon, "md5-2cf3b52cb9535f74d94d7b68abe0acd1"], [tmux-sessionizer, tmux-sessionizer.nuon, "md5-252d0e1da316ff5f597402d2a2bb09b5"]] \ No newline at end of file From f1af61289083f64db9757b67c451b35f2b308f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 25 May 2024 22:43:21 +0300 Subject: [PATCH 41/43] Fix nu_plugin_explore registry entries --- registry/nu_plugin_explore.nuon | 2 +- registry/registry.nuon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/nu_plugin_explore.nuon b/registry/nu_plugin_explore.nuon index e2a7882..d54119c 100644 --- a/registry/nu_plugin_explore.nuon +++ b/registry/nu_plugin_explore.nuon @@ -1 +1 @@ -[[name, version, path, type, info]; [nu_plugin_explore, "0.1.2", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.1.2"}], [nu_plugin_explore, "0.2.0", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.2.0"}], [nu_plugin_explore, "0.92.3-2595f31541554c6d8602ebebc9dffbc4dd29dd89", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.92.3-2595f31541554c6d8602ebebc9dffbc4dd29dd89"}], [nu_plugin_explore, "0.92.3-55edef5ddaf3d3d55290863446c2dd50c012e9bc", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.92.3-55edef5ddaf3d3d55290863446c2dd50c012e9bc"}], [nu_plugin_explore, "0.92.3-be5ed3290cb116cbe9f3038f7a2d46aaac85a25c", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.92.3-be5ed3290cb116cbe9f3038f7a2d46aaac85a25c"}], [nu_plugin_explore, "0.92.3-c06ef201b72b3cbe901820417106b7d65c6f01e1", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.92.3-c06ef201b72b3cbe901820417106b7d65c6f01e1"}], [nu_plugin_explore, "0.93.0", null, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "0.93.0"}]] \ No newline at end of file +[[name, version, path, type, info]; [nu_plugin_explore, "0.1.2", nu_plugin_registry.nuon, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "e5518c7f25cec3537bf897a7ef8d1818eb76aa94"}], [nu_plugin_explore, "0.93.0", nu_plugin_registry.nuon, git, {url: "https://github.com/amtoine/nu_plugin_explore", revision: "15d87012538084d73571718af5b5e858de447065"}]] \ No newline at end of file diff --git a/registry/registry.nuon b/registry/registry.nuon index 806e8d3..d3b7f1c 100644 --- a/registry/registry.nuon +++ b/registry/registry.nuon @@ -1 +1 @@ -[[name, path, hash]; [nu-clippy, nu-clippy.nuon, "md5-15ccbe07dfb7d5f2de260b2b40bf36b5"], [nu-discord-update, nu-discord-update.nuon, "md5-d593c0f41ffd71873028871fcd74b5a9"], [nu-fonts-install, nu-fonts-install.nuon, "md5-cd57f47aeece1679e2febc438d195e8d"], [nu-git-manager, nu-git-manager.nuon, "md5-4aaae15412fb84233fcb19716f6b7e89"], [nu-git-manager-sugar, nu-git-manager-sugar.nuon, "md5-d0c7641c0b369e7c944cc668741734d9"], [nu-hooks, nu-hooks.nuon, "md5-5368e1bc61e9a567263fa4cc55c29783"], [nu-logout, nu-logout.nuon, "md5-9cb6e927f4823dafa8b48867ef1cf70f"], [nu-monitor-manager, nu-monitor-manager.nuon, "md5-15f64df367e8b59606f9b29347cce8a9"], [nu-pomodoro, nu-pomodoro.nuon, "md5-53e18e3476358a813e3ba289dbc5609c"], [nu-right-prompt, nu-right-prompt.nuon, "md5-8a684d7720f0703943317709abfc87bb"], [nu-scripts, nu-scripts.nuon, "md5-733ba206358f545ba9274854fda1c4a5"], [nu-sound-manager, nu-sound-manager.nuon, "md5-f305740d2e93cfeb76c40302f7f5246a"], [nu-themes, nu-themes.nuon, "md5-e303b8f08b1158aacef80a53c5432662"], [nu-zellij, nu-zellij.nuon, "md5-5b0c46f155261507c08c693366639c7a"], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon, "md5-b2f7807acf002c5e02e1c43e2f80eb16"], [nu_plugin_clipboard, nu_plugin_clipboard.nuon, "md5-cb9d8d27e8fd1814dce58dd0fdb604e5"], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon, "md5-f682e6fd6eecf2743686a3da71c1917c"], [nu_plugin_explore, nu_plugin_explore.nuon, "md5-63db3ee7027bb97443b88997b6df5e3d"], [nu_plugin_image, nu_plugin_image.nuon, "md5-d842828405fa74d1056767fa4c3de248"], [nu_plugin_port_list, nu_plugin_port_list.nuon, "md5-59cf1913f6041f45d8c4b4a99d518501"], [nu_plugin_port_scan, nu_plugin_port_scan.nuon, "md5-c4a8347de871a0f626c78d1b05740e19"], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon, "md5-3eb8130c45318fe8a90abaf0680574de"], [nupm, nupm_pkg.nuon, "md5-2cf3b52cb9535f74d94d7b68abe0acd1"], [tmux-sessionizer, tmux-sessionizer.nuon, "md5-252d0e1da316ff5f597402d2a2bb09b5"]] \ No newline at end of file +[[name, path, hash]; [nu-clippy, nu-clippy.nuon, "md5-15ccbe07dfb7d5f2de260b2b40bf36b5"], [nu-discord-update, nu-discord-update.nuon, "md5-d593c0f41ffd71873028871fcd74b5a9"], [nu-fonts-install, nu-fonts-install.nuon, "md5-cd57f47aeece1679e2febc438d195e8d"], [nu-git-manager, nu-git-manager.nuon, "md5-4aaae15412fb84233fcb19716f6b7e89"], [nu-git-manager-sugar, nu-git-manager-sugar.nuon, "md5-d0c7641c0b369e7c944cc668741734d9"], [nu-hooks, nu-hooks.nuon, "md5-5368e1bc61e9a567263fa4cc55c29783"], [nu-logout, nu-logout.nuon, "md5-9cb6e927f4823dafa8b48867ef1cf70f"], [nu-monitor-manager, nu-monitor-manager.nuon, "md5-15f64df367e8b59606f9b29347cce8a9"], [nu-pomodoro, nu-pomodoro.nuon, "md5-53e18e3476358a813e3ba289dbc5609c"], [nu-right-prompt, nu-right-prompt.nuon, "md5-8a684d7720f0703943317709abfc87bb"], [nu-scripts, nu-scripts.nuon, "md5-733ba206358f545ba9274854fda1c4a5"], [nu-sound-manager, nu-sound-manager.nuon, "md5-f305740d2e93cfeb76c40302f7f5246a"], [nu-themes, nu-themes.nuon, "md5-e303b8f08b1158aacef80a53c5432662"], [nu-zellij, nu-zellij.nuon, "md5-5b0c46f155261507c08c693366639c7a"], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon, "md5-b2f7807acf002c5e02e1c43e2f80eb16"], [nu_plugin_clipboard, nu_plugin_clipboard.nuon, "md5-cb9d8d27e8fd1814dce58dd0fdb604e5"], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon, "md5-f682e6fd6eecf2743686a3da71c1917c"], [nu_plugin_explore, nu_plugin_explore.nuon, "md5-3ae85f18e11c0e830f450c5882f9dc47"], [nu_plugin_image, nu_plugin_image.nuon, "md5-d842828405fa74d1056767fa4c3de248"], [nu_plugin_port_list, nu_plugin_port_list.nuon, "md5-59cf1913f6041f45d8c4b4a99d518501"], [nu_plugin_port_scan, nu_plugin_port_scan.nuon, "md5-c4a8347de871a0f626c78d1b05740e19"], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon, "md5-3eb8130c45318fe8a90abaf0680574de"], [nupm, nupm_pkg.nuon, "md5-2cf3b52cb9535f74d94d7b68abe0acd1"], [tmux-sessionizer, tmux-sessionizer.nuon, "md5-252d0e1da316ff5f597402d2a2bb09b5"]] \ No newline at end of file From 78b9baa5cce171073639edcbc75dc9a221eb1d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 25 May 2024 22:59:23 +0300 Subject: [PATCH 42/43] Fix nu_plugin_clipboard registry entries --- registry/nu_plugin_clipboard.nuon | 2 +- registry/registry.nuon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/nu_plugin_clipboard.nuon b/registry/nu_plugin_clipboard.nuon index 25f3237..a65b5f7 100644 --- a/registry/nu_plugin_clipboard.nuon +++ b/registry/nu_plugin_clipboard.nuon @@ -1 +1 @@ -[[name, version, path, type, info]; [nu_plugin_clipboard, "0.3.4", null, git, {url: "https://github.com/FMotalleb/nu_plugin_clipboard", revision: "27faf8d"}], [nu_plugin_clipboard, "0.91.0", null, git, {url: "https://github.com/FMotalleb/nu_plugin_clipboard", revision: "2cd2a67"}]] \ No newline at end of file +[[name, version, path, type, info]; [nu_plugin_clipboard, "0.3.1", nu_plugin_clipboard.nuon, git, {url: "https://github.com/FMotalleb/nu_plugin_clipboard", revision: "1aa1cf99b3edec3ea7d962e91bac8af2b47d56b6"}], [nu_plugin_clipboard, "0.3.3", nu_plugin_clipboard.nuon, git, {url: "https://github.com/FMotalleb/nu_plugin_clipboard", revision: "97deea6845e2ae80e31b32892b6fc8357045e579"}], [nu_plugin_clipboard, "0.3.4", nu_plugin_clipboard.nuon, git, {url: "https://github.com/FMotalleb/nu_plugin_clipboard", revision: "27faf8d987cda6400f1a0f98a58c27fda4435d5e"}], [nu_plugin_clipboard, "0.91.0", nu_plugin_clipboard.nuon, git, {url: "https://github.com/FMotalleb/nu_plugin_clipboard", revision: "089cc15a168ffe790cae6ed608c84e51e689752c"}], [nu_plugin_clipboard, "0.93.0", nu_plugin_clipboard.nuon, git, {url: "https://github.com/FMotalleb/nu_plugin_clipboard", revision: "163bbb7617d24527e1a367a33922ec24ff57a26c"}]] \ No newline at end of file diff --git a/registry/registry.nuon b/registry/registry.nuon index d3b7f1c..c0e02ff 100644 --- a/registry/registry.nuon +++ b/registry/registry.nuon @@ -1 +1 @@ -[[name, path, hash]; [nu-clippy, nu-clippy.nuon, "md5-15ccbe07dfb7d5f2de260b2b40bf36b5"], [nu-discord-update, nu-discord-update.nuon, "md5-d593c0f41ffd71873028871fcd74b5a9"], [nu-fonts-install, nu-fonts-install.nuon, "md5-cd57f47aeece1679e2febc438d195e8d"], [nu-git-manager, nu-git-manager.nuon, "md5-4aaae15412fb84233fcb19716f6b7e89"], [nu-git-manager-sugar, nu-git-manager-sugar.nuon, "md5-d0c7641c0b369e7c944cc668741734d9"], [nu-hooks, nu-hooks.nuon, "md5-5368e1bc61e9a567263fa4cc55c29783"], [nu-logout, nu-logout.nuon, "md5-9cb6e927f4823dafa8b48867ef1cf70f"], [nu-monitor-manager, nu-monitor-manager.nuon, "md5-15f64df367e8b59606f9b29347cce8a9"], [nu-pomodoro, nu-pomodoro.nuon, "md5-53e18e3476358a813e3ba289dbc5609c"], [nu-right-prompt, nu-right-prompt.nuon, "md5-8a684d7720f0703943317709abfc87bb"], [nu-scripts, nu-scripts.nuon, "md5-733ba206358f545ba9274854fda1c4a5"], [nu-sound-manager, nu-sound-manager.nuon, "md5-f305740d2e93cfeb76c40302f7f5246a"], [nu-themes, nu-themes.nuon, "md5-e303b8f08b1158aacef80a53c5432662"], [nu-zellij, nu-zellij.nuon, "md5-5b0c46f155261507c08c693366639c7a"], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon, "md5-b2f7807acf002c5e02e1c43e2f80eb16"], [nu_plugin_clipboard, nu_plugin_clipboard.nuon, "md5-cb9d8d27e8fd1814dce58dd0fdb604e5"], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon, "md5-f682e6fd6eecf2743686a3da71c1917c"], [nu_plugin_explore, nu_plugin_explore.nuon, "md5-3ae85f18e11c0e830f450c5882f9dc47"], [nu_plugin_image, nu_plugin_image.nuon, "md5-d842828405fa74d1056767fa4c3de248"], [nu_plugin_port_list, nu_plugin_port_list.nuon, "md5-59cf1913f6041f45d8c4b4a99d518501"], [nu_plugin_port_scan, nu_plugin_port_scan.nuon, "md5-c4a8347de871a0f626c78d1b05740e19"], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon, "md5-3eb8130c45318fe8a90abaf0680574de"], [nupm, nupm_pkg.nuon, "md5-2cf3b52cb9535f74d94d7b68abe0acd1"], [tmux-sessionizer, tmux-sessionizer.nuon, "md5-252d0e1da316ff5f597402d2a2bb09b5"]] \ No newline at end of file +[[name, path, hash]; [nu-clippy, nu-clippy.nuon, "md5-15ccbe07dfb7d5f2de260b2b40bf36b5"], [nu-discord-update, nu-discord-update.nuon, "md5-d593c0f41ffd71873028871fcd74b5a9"], [nu-fonts-install, nu-fonts-install.nuon, "md5-cd57f47aeece1679e2febc438d195e8d"], [nu-git-manager, nu-git-manager.nuon, "md5-4aaae15412fb84233fcb19716f6b7e89"], [nu-git-manager-sugar, nu-git-manager-sugar.nuon, "md5-d0c7641c0b369e7c944cc668741734d9"], [nu-hooks, nu-hooks.nuon, "md5-5368e1bc61e9a567263fa4cc55c29783"], [nu-logout, nu-logout.nuon, "md5-9cb6e927f4823dafa8b48867ef1cf70f"], [nu-monitor-manager, nu-monitor-manager.nuon, "md5-15f64df367e8b59606f9b29347cce8a9"], [nu-pomodoro, nu-pomodoro.nuon, "md5-53e18e3476358a813e3ba289dbc5609c"], [nu-right-prompt, nu-right-prompt.nuon, "md5-8a684d7720f0703943317709abfc87bb"], [nu-scripts, nu-scripts.nuon, "md5-733ba206358f545ba9274854fda1c4a5"], [nu-sound-manager, nu-sound-manager.nuon, "md5-f305740d2e93cfeb76c40302f7f5246a"], [nu-themes, nu-themes.nuon, "md5-e303b8f08b1158aacef80a53c5432662"], [nu-zellij, nu-zellij.nuon, "md5-5b0c46f155261507c08c693366639c7a"], [nu_plugin_audio_hook, nu_plugin_audio_hook.nuon, "md5-b2f7807acf002c5e02e1c43e2f80eb16"], [nu_plugin_clipboard, nu_plugin_clipboard.nuon, "md5-6b639ea8c8db03e0148cd00ec6ff9e69"], [nu_plugin_desktop_notifications, nu_plugin_desktop_notifications.nuon, "md5-f682e6fd6eecf2743686a3da71c1917c"], [nu_plugin_explore, nu_plugin_explore.nuon, "md5-3ae85f18e11c0e830f450c5882f9dc47"], [nu_plugin_image, nu_plugin_image.nuon, "md5-d842828405fa74d1056767fa4c3de248"], [nu_plugin_port_list, nu_plugin_port_list.nuon, "md5-59cf1913f6041f45d8c4b4a99d518501"], [nu_plugin_port_scan, nu_plugin_port_scan.nuon, "md5-c4a8347de871a0f626c78d1b05740e19"], [nu_plugin_qr_maker, nu_plugin_qr_maker.nuon, "md5-3eb8130c45318fe8a90abaf0680574de"], [nupm, nupm_pkg.nuon, "md5-2cf3b52cb9535f74d94d7b68abe0acd1"], [tmux-sessionizer, tmux-sessionizer.nuon, "md5-252d0e1da316ff5f597402d2a2bb09b5"]] \ No newline at end of file From b7003f1c4c14ebf29ad10d4ad3b69c67edc21734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Sat, 25 May 2024 23:17:16 +0300 Subject: [PATCH 43/43] Fix wrong pkg dir --- nupm/install.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nupm/install.nu b/nupm/install.nu index f513e91..f42abe7 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -155,7 +155,7 @@ def download-pkg [ let pkg_dir = if $pkg.path == null { $env.PWD | path join $clone_dir } else { - $env.PWD | path join $clone_dir $pkg.path + $env.PWD | path join $clone_dir ($pkg.path | path dirname) } if ($pkg_dir | path exists) {