镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Redesign registry; Allow publishing to registry - #86

Merged
kubouch merged 46 commits into
nushell:mainfrom
kubouch:registry-revamp
Jun 3, 2024
Merged

kubouch merged 46 commits into
nushell:mainfrom
kubouch:registry-revamp

Conversation

@kubouch

@kubouch kubouch commented Mar 26, 2024 •

Copy link
Copy Markdown
Contributor

Description

This changes registry to from one file that is manually updated to multiple files that are auto-generated. Now, the registry should be only updated with the new nupm publish command.

See the doc page for more details and the registry/ directory for the new proposed structure.

Misc changes

  • The structure of the registry is also different. The git/local package type is now encoded in a flat table instead of being a separate record. See registry/ and tests/packages/registry/ for examples.
  • The path field can be null, not requiring the "."

TODO

  • Add package file hashing to stop redownloading them all the time

@kubouch
kubouch marked this pull request as ready for review March 28, 2024 16:56
@kubouch
kubouch requested a review from amtoine March 28, 2024 16:56
@texastoland

Copy link
Copy Markdown

Just devil's advocate but could you manually replace all \r with empty string before saving?

@kubouch

kubouch commented May 4, 2024

Copy link
Copy Markdown
Contributor Author

Just devil's advocate but could you manually replace all \r with empty string before saving?

Yes, that's an option (or convert all \n to \r\n). I chose to side step it entirely for now. I'm a bit afraid that once we start messing with newlines, we'd open a can of works. Like I mentioned above, I can imagine just viewing the file in some smart editor could convert the line endings automatically. Then there is also Git which can convert the line endings depending on user's preferences. It's not something I want to mess with right now 😆 .

@amtoine

amtoine commented May 5, 2024

Copy link
Copy Markdown
Member

nice job @kubouch !!

Windows is such a pain...
in nu-git-manager, i wrote a path sanitize command that makes Windows path better (lol) and i have to use it almost on all paths 🤣

amtoine
amtoine previously requested changes May 5, 2024

@amtoine amtoine left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new commits look fine to me 👌

there's just a review question and some missing packages 😉

use std assert

def make-it-similar []: table<name: string, version: string, url: string, revision: string, path: string> -> table<name: string, version: string, url: string, revision: string, path: string> {
    sort-by version name | select name version url revision path
}

let old = http get https://github.com/raw/nushell/nupm/main/registry.nuon
    | get git
    | make-it-similar

let new = open registry/registry.nuon
    | get path
    | each {|it| open ("registry/" | path join $it)} # open each registry package file
    | flatten                  # extract the path and revision from `$.info`
    | update info { flatten }  # |
    | flatten --all            # |
    | reject type
    | default "." path         # remove the `null`
    | make-it-similar

if $new != $old {
    $new | to nuon --indent 4 | save --force /tmp/new.nuon
    $old | to nuon --indent 4 | save --force /tmp/old.nuon
    diff -u /tmp/old.nuon /tmp/new.nuon
}
print "all good"

gives me

--- /tmp/old.nuon       2024-05-05 13:15:41.093046938 +0200
+++ /tmp/new.nuon       2024-05-05 13:15:41.093046938 +0200
@@ -245,55 +245,6 @@
         .
     ],
     [
-        nu_plugin_explore,
-        "0.92.0",
-        "https://github.com/amtoine/nu_plugin_explore",
-        "0.92.",
-        .
-    ],
-    [
-        nu_plugin_clipboard,
-        "0.92.1",
-        "https://github.com/FMotalleb/nu_plugin_clipboard",
-        "98d7102",
-        .
-    ],
-    [
-        nu_plugin_explore,
-        "0.92.3-2595f31541554c6d8602ebebc9dffbc4dd29dd89",
-        "https://github.com/amtoine/nu_plugin_explore",
-        "0.92.3-2595f31541554c6d8602ebebc9dffbc4dd29dd89",
-        .
-    ],
-    [
-        nu_plugin_explore,
-        "0.92.3-55edef5ddaf3d3d55290863446c2dd50c012e9bc",
-        "https://github.com/amtoine/nu_plugin_explore",
-        "0.92.3-55edef5ddaf3d3d55290863446c2dd50c012e9bc",
-        .
-    ],
-    [
-        nu_plugin_explore,
-        "0.92.3-be5ed3290cb116cbe9f3038f7a2d46aaac85a25c",
-        "https://github.com/amtoine/nu_plugin_explore",
-        "0.92.3-be5ed3290cb116cbe9f3038f7a2d46aaac85a25c",
-        .
-    ],
-    [
-        nu_plugin_explore,
-        "0.92.3-c06ef201b72b3cbe901820417106b7d65c6f01e1",
-        "https://github.com/amtoine/nu_plugin_explore",
-        "0.92.3-c06ef201b72b3cbe901820417106b7d65c6f01e1",
-        .
-    ],
-    [
-        nu_plugin_explore,
-        "0.93.0",
-        "https://github.com/amtoine/nu_plugin_explore",
-        "0.93.0",
-        .
-    ],
-    [
         nu_plugin_port_scan,
         "1.0.10",
         "https://github.com/FMotalleb/nu_plugin_port_scan",

related to

Comment thread nupm/publish.nu Resolved
kubouch and others added 2 commits May 5, 2024 15:35
Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
@kubouch

kubouch commented May 5, 2024

Copy link
Copy Markdown
Contributor Author

Ah yeah, it's missing the added packages. I currently don't have time to add them. If you have time, you can merge it and publish them again to the registry using the new nupm publish. This way it would get tested by someone apart from me. Otherwise, I can do it whenever I find the time.

these versions have been removed in a merge conflict resolution and were
defined in nushell#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
```
@amtoine

amtoine commented May 8, 2024

Copy link
Copy Markdown
Member

no worries 👍

i was able to add most of them apart from

  • nu_plugin_explore on 0.92.0:7f74017 because "Version 0.1.2 of package nu_plugin_explore is already published"
  • nu_plugin_clipboard on 98d7102 because "Version 0.91.0 of package nu_plugin_clipboard is already published"

@kubouch

kubouch commented May 8, 2024 •

Copy link
Copy Markdown
Contributor Author

Now thinking about it, I think we should support only semver-style versions because we need to be able to sort by version and select the latest. The same with the main version. At least in the official registry, having random strings would be too confusing. I understand the value of having, e.g., the main as an always up-to-date package, but it really messes up the version resolution.

I'd propose keeping only semver in the official registry, but let's keep experimenting with being able to have some alternative versions. These could be allowed e.g. only in your personal registry, but not for publishing to the official one. Or the version field could be null. Not sure...

@texastoland

Copy link
Copy Markdown

I think we should support only semver-style versions

Commit hashes are supported in semver (in case it helps).

@kubouch

kubouch commented May 8, 2024

Copy link
Copy Markdown
Contributor Author

TIL, but I still think we need to restrict our versions to a subset that doesn't prevent sorting. Otherwise, we wouldn't be able to reliably update a package. You want to type nupm update nu_plugin_explore and get the latest version. Now, which one of the four different 0.92.3s is the newest?

We could support having a null/main/latest in place of the version. In that case, this version would always be considered “newest” and would be always re-fetched when you call nupm update. nupm install would also always install this version if you don't specify the version manually. This would be useful for cases like the current tmux-sessionizer tracking the main branch. That would be OK for a private / unofficial registry. For the official registry, we'd disallow it.

@texastoland

Copy link
Copy Markdown

I still think we need to restrict our versions to a subset that doesn't prevent sorting.

I trust your vision for it ✌🏼 FWIW the spec is major.minor.patch-alphabetical+ignored.

@amtoine

amtoine commented May 10, 2024

Copy link
Copy Markdown
Member

i agree @kubouch, maybe these deps are simply ill-defined 👀

does that mean that

  • the two i cannot add shouldn't be added?
  • the ones that are not proper semver should be removed?

then we can land this PR 🙏

@kubouch

kubouch commented May 25, 2024

Copy link
Copy Markdown
Contributor Author

@amtoine I republished the problematic packages, should be good now. The problem with nu_plugin_explore is that revisions up to 0.93.0 still had the old version 0.1.2 in their nupm.nu, so they're not publishable because 0.1.2 is already published. Seems like you forgot to update it.

@amtoine

amtoine commented Jun 1, 2024

Copy link
Copy Markdown
Member

aaah yeah, you're right 😭

we're good to land then? i kinda lost track of whole the changes lol

@amtoine
amtoine dismissed their stale review June 1, 2024 10:47

appears to be ok now?

@amtoine

amtoine commented Jun 1, 2024

Copy link
Copy Markdown
Member

still think the registry diffs are impossible to review, which is a bit of a bummer imo 😕

@texastoland

Copy link
Copy Markdown

Same. I think there'd be some value in standardizing on Unix line endings. Otherwise DX will be a step above binary. Epic regardless 👏🏼

@kubouch

kubouch commented Jun 3, 2024

Copy link
Copy Markdown
Contributor Author

Thinking about it, I think what we can do is to make nupm publish generate one type of line ending (LF or CRLF), but more importantly, we can change the hash function to replace all CRLF with LF in text files and hash that. That should give us identical hashes on Windows and Unix.

I'm going to merge this as-is, but I'll play with the newlines in the next PR, or anyone else can take a shot at it. I think relying forever on having zero newlines doesn't sound very robust in the long run.

@kubouch
kubouch merged commit 42d65a9 into nushell:main Jun 3, 2024
kubouch pushed a commit that referenced this pull request Nov 27, 2024
> Related to diffing the nuon files, inspired by
https://www.youtube.com/watch?v=Md44rcw13k4. Pasting it here from
Discord so it won't get burried:
> * create a new file called .gitattributes
> * put the following like in it `*.nuon diff=nuon`
> * run the following command `git config diff.nuon.textconv nu`
> * modify a NUON file and see how the diff is pretty
>
> _Originally posted by @kubouch in
#86 (comment)
>

## Description
running the following will turn on pretty diffing for NUON files
```nushell
use toolkit.nu
toolkit set-nuon-diff
```

## example
let's diff 4140560 which is a commit part of
#86
```diff
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
```
becomes
```diff
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
@@ -25,5 +25,55 @@
             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"
+        }
     ]
 ]
diff --git a/registry/registry.nuon b/registry/registry.nuon
index 6c3ee7f..806e8d3 100644
--- a/registry/registry.nuon
+++ b/registry/registry.nuon
@@ -92,7 +92,7 @@
     [
         nu_plugin_explore,
         nu_plugin_explore.nuon,
-        "md5-9f9ecf5bbd943645daaa515210bb113a"
+        "md5-63db3ee7027bb97443b88997b6df5e3d"
     ],
     [
         nu_plugin_image,
```
which i think it muuuuuuch easier to look at 😉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants