-
Notifications
You must be signed in to change notification settings - Fork 658
feat: new ya pack -d subcommand to delete packages
#2181
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
Conversation
|
Thanks for the PR, the code looks really neat!
Yazi's package manager supports two types of packages: one is a plugin itself, like https://github.com/dedukun/relative-motions.yazi, and the other is a subpackage within a large monorepo, like https://github.com/yazi-rs/plugins/tree/main/jump-to-char.yazi. For the second type, there is no package name, just the repo's name, so to flatten the structure, I encoded them all as hashes.
I think the current implementation is good enough for now. We can leave it as is and improve it in the future.
It can be used for now, but since Yazi plans to support other Git forges like GitLab and Bitbucket, which have different URL formats, we might end up with two different URLs pointing to the same package. So using |
sxyazi
left a comment
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.
Thank you!
ya pack -d subcommand to delete packages
|
I was just looking for this. When is the next release? |
⚠️ **CAUTION: this is a major update, indicating a breaking change!**⚠️ This MR contains the following updates: | Package | Update | Change | |---|---|---| | [sxyazi/yazi](https://github.com/sxyazi/yazi) | major | `v0.4.2` -> `v25.2.7` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>sxyazi/yazi (sxyazi/yazi)</summary> ### [`v25.2.7`](https://github.com/sxyazi/yazi/releases/tag/v25.2.7) [Compare Source](sxyazi/yazi@v0.4.2...v25.2.7) #### Deprecated - `ya.md5()` has been deprecated in favor of the new `ya.hash()`, in sxyazi/yazi#2168 - The plugin entry file `init.lua` has been deprecated in favor of the new `main.lua`, in sxyazi/yazi#2168 - `arrow -99999999` and `arrow 99999999` have been deprecated in favor of the new `arrow top` and `arrow bot`, in sxyazi/yazi#2294 - The `--args` option in the `plugin` command has been deprecated in favor of a new 2nd positional parameter, in sxyazi/yazi#2299 - The numeric return value of the preloader has been deprecated in favor of a new boolean return value, in sxyazi/yazi#2253 #### The [`mount.yazi`](https://github.com/yazi-rs/plugins/tree/main/mount.yazi) Plugin For a long time, I've been receiving requests from users for a mount manager, but never had the time to finish it. But now — it's here! [`mount.yazi`](https://github.com/yazi-rs/plugins/tree/main/mount.yazi) provides disk mount, unmount, and eject functionality: https://github.com/user-attachments/assets/b97b8156-e7ca-490c-88a2-8624f4190b29 Done in sxyazi/yazi#2199. #### Simplification of `shell` and `plugin` commands With sxyazi/yazi#2298, you can now write shell scripts directly after `--` (end of options marker). Everything after `--` will be treated as raw text, so no more escaping is required, greatly simplifying the writing of complex commands. For example, previously, a simple `echo "hello 'world'"` would look like this: ```toml [[manager.prepend_keymap]] on = "<C-e>" run = ''' shell --block 'echo "hello '\''world'\''"' ''' ``` This resulted in nested quotes, which was error-prone and unintuitive. Now, you can directly include the entire shell script as plain text after `--` without any escaping: ```toml [[manager.prepend_keymap]] on = "<C-e>" run = ''' shell --block -- echo "hello 'world'" ''' ``` Similarly, with sxyazi/yazi#2299, the `plugin` command usage has been simplified as well. For instance: ```toml [[manager.prepend_keymap]] on = "<C-e>" run = "plugin search --args='\'hello world\''" ``` Can now be written as: ```toml [[manager.prepend_keymap]] on = "<C-e>" run = "plugin search -- 'hello world'" ``` #### Replace Mode and Vim Motions (`W`, `E`, `B`, `^`, `_`) for Inputs The Input component now supports replace mode and several new Vim motions, including: - `W`: Move forward to the start of the next WORD - `E`: Move forward to the end of the current or next WORD - `B`: Move back to the start of the current or previous WORD - `^`: Move to the first non-whitespace character - `_`: Move to the first non-whitespace character Thanks to [@​dxrcy](https://github.com/dxrcy) for the work in sxyazi/yazi#2143! #### Package Manager Enhancements The package manager now supports the following new features: - `ya pack -d` to delete a package (thanks [@​MrAsler](https://github.com/MrAsler), sxyazi/yazi#2181) - Support for adding and removing multiple packages with a single command (thanks [@​evpeople](https://github.com/evpeople), sxyazi/yazi#2257) #### Support Local `tmux` Image Preview Over SSH Now, when you start tmux locally, connect to a remote SSH session, and run Yazi on the remote host, you'll get image preview support out of the box. Done in sxyazi/yazi#2229. #### New `@since` Plugin Annotation to Specify the Minimum Supported Yazi Version You can now **optionally** specify the minimum supported Yazi version in your plugin: ```lua --- @​since 25.2.7 return { entry = function() end } ``` If specified, and the user's Yazi version is lower than the given version, they will receive an error message preventing the plugin from running accidentally. Done in sxyazi/yazi#2290 #### New `ya.confirm()` API The new `ya.confirm()` API allows you to show a confirmation prompt to the user: ```lua local answer = ya.confirm { pos = { "center", w = 40, h = 10 }, title = "Test", content = "Hello, World!", } ``` You can also apply a UI element to the title and content to customize the appearance: ```lua local answer = ya.confirm { pos = { "center", w = 40, h = 10 }, title = ui.Line("Test"):fg("yellow"):bold(), content = ui.Text("Hello, World!"):bg("red"):fg("#ffffff"), } ``` </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNjQuMSIsInVwZGF0ZWRJblZlciI6IjM5LjE2NC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Closes #2147
Details about the implementation
To add the
deletecommand, I followed the same pattern that existed in thesrc/args.rs,src/main.rsandsrc/package/*directories.I tried to follow the existing code style, and kept refactorings to a minimum - I created two helper methods -
find_dep_in_packageanddeployed_directory. If there are any naming issues or you would like the code to be structured differently, feel free to say!Follow up / Questions
Some code is still not deleted
As things are, this will not delete the package code that is present in
Xdg::local()directory, as I don't understand why thestate_dir()of a dependency is using an hash to identify the package (format!("{:x}", XxHash3_128::oneshot(self.remote().as_bytes()))) instead of just using the package name.I'm assuming it is desired to also remove the content of this
state_dir(), but I'llawaitfor the answer 🕵️Can the field
Dependency.use_be used the dependency ID?The function
Package::add(..)was detecting if a package existing with the following code:However, given that the objective is to see if a package already exists in
package.tomland each package keeps theusevalue there, I'm under the impression that this can be simplified to usinguse_.If this
usefield is internal and should not be used, should there be a way of giving an ID to a package, or should we keep using theparentandchildnames?