-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow online installation of packages #56
Conversation
Poggers! This is really cool! Good job kobouch! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without looking at the changes, i'm not able to make the commands in Try it out work 🤔
Note
i've added ause ./nupm/
to load Nupm before runningnupm install
- installing from the
kubouch
registry
nupm install spam_script --registry kubouch
https://git.sr.ht/~kubouch/nupkgs/blob/main/registry.nuon
Error: × No package matching version ``
- installing from the local registry
nupm install spam_script --registry local_test --force
/home/amtoine/.local/share/nupm/modules/tests/packages/registry.nuon
Error: nu::shell::eval_block_with_input
× Eval block failed with pipeline input
╭─[entry #2:1:1]
1 │ ╭─▶ $env.NUPM_REGISTRIES = {
2 │ │ kubouch: 'https://git.sr.ht/~kubouch/nupkgs/blob/main/registry.nuon'
3 │ │ local_test: ($env.FILE_PWD | path join tests packages registry.nuon)
4 │ ├─▶ }
· ╰──── source value
╰────
Error: × Cannot open '/home/amtoine/.local/share/nupm/modules/tests/packages/registry.nuon' as a file or URL.
- giving a package version
nupm install spam_script --registry local_test --pkg-version
Error: nu::parser::missing_flag_param
× Missing flag argument.
╭─[entry #6:1:1]
1 │ nupm install spam_script --registry local_test --pkg-version
· ──────┬──────
· ╰── flag missing string argument
╰────
i could run the first step with nupm install spam_script --registry kubouch --pkg-version '0.1.0' |
Ah, you managed to find a Nushell type checking bug, I fixed the missing |
Seems like you're trying to run it from the installed directory, the test commands in the PR description are meant to be run from the nupm repo root . The |
ehe 😏 |
nice the first one is fixed 👌 but the two other ones are not 🤔 Seems like you're trying to run it from the installed directory, the test commands in the PR description are meant to be run from the nupm repo root . The > pwd
/home/amtoine/documents/repos/github.com/amtoine/nushell-nupm and nupm install spam_script --registry local_test --force and nupm install spam_script --registry local_test --pkg-version 0.1.0 --force both give me
|
I also reordered and fixed the steps, check it out. Save the whole snippet to a file and run |
ooh interesting
|
The first bullet should work now. The second bullet is because you have misconfigured the registry path (note, I changed FILE_PWD to PWD). It's just for the sake of the example, you can define your own paths. |
yup, the first bullet is fixed 👌 as for the second one, i'm not sure what i should run in the REPL to make it work... $env.NUPM_HOME = /tmp/nupm
$env.NUPM_REGISTRIES = {
kubouch: 'https://git.sr.ht/~kubouch/nupkgs/blob/main/registry.nuon'
local_test: ($env.PWD | path join tests packages registry.nuon)
}
# Make installed scripts executable
$env.PATH ++= [ ($env.NUPM_HOME | path join scripts) ]
use nupm
nupm install spam_script --registry kubouch --force
spam_script.nu # prints "Hello world!"
nupm install spam_script --registry local_test --force
spam_script.nu # prints "Hello world v0.2.0!"
nupm install spam_script --registry local_test --pkg-version 0.1.0 --force
spam_script.nu # prints "Hello world!" |
You can run each line/statement as its own REPL iteration. Note that you've set NUPM_HOME to a file, not a directory. You might have some old stuff lingering around from the previous REPL attempts. Try running a fresh |
yeah my bad that was a typo...
yes i did run everything above (with the typo fixed) from |
but there is something fishy going on |
before running the first
and after
i run BSPWM with Nushell, no idea what it has to do with Nupm here 👀 |
That's because NUPM_REGISTRIES are currently set to some debugging values, do not run it with Not sure what's going on with bspwm, but there are still some debug hardcoded values like that that will be removed. |
aah yeah, sorry again for the back and forth @kubouch, it works fine both in a script and in the REPL after i apply diff --git a/nupm/mod.nu b/nupm/mod.nu
index 3b7b0de..53152bd 100644
--- a/nupm/mod.nu
+++ b/nupm/mod.nu
@@ -26,7 +26,7 @@ export-env {
$env.NUPM_REGISTRIES = {
# nupm: ($env.NUPM_HOME | path join registry.nuon)
kubouch:'https://git.sr.ht/~kubouch/nupkgs/blob/main/registry.nuon'
- local_test: ($env.FILE_PWD | path join tests packages registry.nuon)
+ local_test: ("/home/amtoine/documents/repos/github.com/amtoine/nushell-nupm" | path join tests packages registry.nuon)
# remote_test: 'https://raw.githubusercontent.com/nushell/nupm/main/tests/packages/registry.nuon'
}
} |
3e8ff6b
to
6f4a43a
Compare
c82b0f3
to
40a533d
Compare
OK, I think it's ready for review. Could be polished and tested more thoroughly, but then it would never be ready :-D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okey, i've had a look at the tests and they look great.
before moving on to a quick look at the code, i can report you @kubouch that running
use ./nupm/
and then
nupm search nu-git-manager
gives
Error: nu::shell::eval_block_with_input
× Eval block failed with pipeline input
╭─[/home/amtoine/documents/repos/github.com/amtoine/nushell-nupm/nupm/utils/registry.nu:28:1]
28 │ # Collect all registries matching the package and all matching packages
29 │ let regs = $registries
· ─────┬─────
· ╰── source value
30 │ | items {|name, path|
╰────
Error: × Cannot open '/home/amtoine/.local/share/nupm/modules/registry.nuon' as a file or URL.
and
nupm install --no-confirm nu-git-manager
gives
Error: nu::shell::eval_block_with_input
× Eval block failed with pipeline input
╭─[/home/amtoine/documents/repos/github.com/amtoine/nushell-nupm/nupm/utils/registry.nu:28:1]
28 │ # Collect all registries matching the package and all matching packages
29 │ let regs = $registries
· ─────┬─────
· ╰── source value
30 │ | items {|name, path|
╰────
Error: × Cannot open '/home/amtoine/.local/share/nupm/modules/registry.nuon' as a file or URL.
That's because the registry is pointing at the local registry.nuon which doesn't get installed by nupm. This will be pointing at the online file, but because it's not merged yet, I put the local file there for now. Maybe I should commit the registry separetely? Try running it from the repo root without installing nupm. It's a chicken and egg problem... |
@kubouch what i'm seeing is that the |
i'm really just running the two commands i mention above 😕 |
Now, I changed the default registry to point at nupm repository so it should work regardless of how you installed nupm, one #68 is merged. |
aah yeah, let me try again 👍 |
okey, the example appears to work now 🥳 i won't have time to finish this right now, i'll come back to it soon 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okey, the code looks mostly fine to me, especially as the commands appear to be working fine!
i just have a minor question, but feel free to land this regardless 😉
thanks @kubouch for working on this 🙏
let's try it out and see how it goes 😋 |
followup to #56 ## Description this should update the `registry.nuon` file thanks to the content of previous `index.nuon` (see cbca144 for the pipeline used to update the registry). this PR uses the latest version of each package. ## try it out ```nushell nupm search --registry ./registry.nuon explore | into record | update pkgs { into record } | table --expand ``` ``` ────┬────────────────────────────────────────────────────── name│registry path│./registry.nuon │────────┬───────────────────────────────────────────── pkgs│name │nu_plugin_explore │version │0.1.2 │url │https://github.com/:amtoine/nu_plugin_explore │revision│0.1.2 │path │. │type │git │────────┴───────────────────────────────────────────── ────┴────────────────────────────────────────────────────── ```
Registries
See the newly added registry.nuon file for more specific info about the registry format.
This PR adds a new concept: registry. Registries are .nuon files containing a list of packages, their versions, and how they should be installed. Currently, registry can contain two kinds of packages:
local
-- installed from local file systemgit
-- installed from remote Git repositoryThe list of recognized registries is stored in
$env.NUPM_REGISTRIES
as a record of name: path pairs. That way, users can maintain their collection of sources from where they want to install packages. Not sure if this will be the final way to pass available registries to nupm, but should be good enough for early testing.Online Installation
If a package is to be installed from a Git repository, the repository is cached in
$env.NUPM_CACHE
to avoid re-cloning the same repository all the time. Once cloned, the local path of the cloned repository is passed to the installer, as if you callednupm install --path=...
.One important missing feature is some kind of file integrity check. One step at a time...
Versions
If a registry contains multiple versions (common scenario), by default, the newest one is installed. "Newest" currently means sorting the versions alphabetically and taking the last one. If
--pkg-version
is specified, nupm tries to install the exact version passed to this option. This needs better version matching (e.g., version 0.2 matching 0.2.1 etc.), but again, one step at a time...New command
nupm search
searches for packages in registries without installing them. I thought this would be useful to have early on.Try it out
From the repository root:
TODO
After
0.2
shouldn't match0.2.1