Skip to content
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

feat: feature – support miligrams – appimage compressed plugins #554

Closed
wants to merge 4 commits into from

Conversation

psprint
Copy link
Contributor

@psprint psprint commented Aug 4, 2023

Description

This is the first commit that introduces the miligrams support via new, embedded (shipped and loaded by default) mg annex. In this commit what's implemented is:

  • loading the plugin from a miligram via normal zi for my-plugin.mg syntax, with a variation of zi mg for my-plugin,
  • keeping the miligram mounted via keep ice (i.e.: zi keep for my-plugin.mg),
  • a new subcommand xmg, that can build the miligram (via zi xmg build in the plugin dir), and also:
  • … that can extract miligram (via zi xmg extract my-plugin).

What's left is only allowing download of the miligrams from the GitHub Releases page. The planned syntax for this is: zi mg"user/repo" for my-plugin, that would look into the binary files and look up the most recent version of my-plugin.mg, like e.g.: my-plugin-v1.7.mg. The code already looks up the most recent version of the package, so zi for my-plugin.mg will load my-plugin-1.7.mg if it's the most recent version.

Related Issue(s)

#553

Motivation and Context

I think that to have the plugins like eggs in python is a good update on the plugins in Zsh world. We can exploit the already existing, well spread and supported AppImages' features, like:

  • exposing of the image's file system in a mounted directory in /tmp,
  • easy building via appimagetool,
  • etc.

…to provide an egg like solution to Zsh.

I've implemented the feature as annex that's shipped with zinit. It's located in zinit.git/lib/annex/mg and is automatically loaded at end of zinit.zsh. It is a before-load hook, like unscope annex.

Usage examples

# Download an appimage directly, as the `zi mg"psprint/n-commodoer" for N-Commodore` syntax isn't yet implmented

wget \
     https://github.com/psprint/n-commodore/releases/download/nc-1.41/N-Commodore-1.41-x86_64.AppImage \
    -O $ZINIT[PLUGINS_DIR]/n-commodore-v1.41.mg

# load the plugin
zi keep mg for n-commodore

# use its `nc` provided command:
nc

How Has This Been Tested?

By interactive use.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation change
  • New feature (non-breaking change which adds functionality)

Checklist:

  • All new and existing tests passed.
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.

@psprint
Copy link
Contributor Author

psprint commented Aug 4, 2023

@vladdoster @pschmitt @alichtman: ping. What's your opinion on this egg-like extension? Will it have any chance of merging?

This is the first commit that introduces the miligrams support via
new, embedded (shipped and loaded by default) `mg` annex. In this commit
what's implemented is:
- loading the plugin from a miligram via normal `zi for my-plugin.mg`
  syntax, with a variation of `zi mg for my-plugin`,
- keeping the miligram mounted via `keep` ice (i.e.: `zi keep for
  my-plugin.mg`),
- a new subcommand `xmg`, that can build the miligram (via `zi xmg
  build` in the plugin dir), and also:
- … that can extract miligram (via `zi xmg extract my-plugin`).

What's left is only allowing download of the miligrams from the GitHub
Releases page. The planned syntax for this is: `zi mg"user/repo" for
my-plugin`, that would look into the binary files and look up the
most recent version of `my-plugin.mg`, like e.g.: `my-plugin-v1.7.mg`.
@psprint
Copy link
Contributor Author

psprint commented Aug 5, 2023

feat: support downlaoding of miligrams

The syntax for downloading miligram is:

    zi mg"user/repo" for {FILE-NAME-ROOT}

For example, to load the n-commodore plugin that's currently shipped as miligram, one would do:

    zi mg"psprint/n-commodore" keep for N-Commodore

The output of this command is:

==> (Requesting `N-Commodore-v1.47.mg', version: nc-1.44…)
Hi! …/tmp/.mount_N-CommLbx7te/n-commodore.plugin.zsh…

The "Hi…" message comes from the plugin.zsh file of the plugin.

One can also use "debug" ice, the output will then be:

==> (Requesting `N-Commodore-v1.47.mg', version: nc-1.44…)
==> mg annex: args: N-Commodore
mg annex: Matched miligram to dir: /tmp/.mount_N-CommrJE53I
Hi! …/tmp/.mount_N-CommLbx7te/n-commodore.plugin.zsh…

What's currently left TODO is zi update support.

@vladdoster @pschmitt @alichtman: I hope that you get from vacation soon 😄

The syntax for downloading miligram is:

    zi mg"user/repo" for {FILE-NAME-ROOT}

For example, to load the n-commodore plugin that's currently shipped as
miligram, one would do:

    zi mg"psprint/n-commodore" keep for N-Commodore

The output of this command is:

```
==> (Requesting `N-Commodore-v1.47.mg', version: nc-1.44…)
Hi! …/tmp/.mount_N-CommLbx7te/n-commodore.plugin.zsh…
```

The "Hi…" message comes from the plugin.zsh file of the plugin.

One can also use "`debug`" ice, the output will then be:

==> (Requesting `N-Commodore-v1.47.mg', version: nc-1.44…)
==> mg annex: args: N-Commodore
mg annex: Matched miligram to dir: /tmp/.mount_N-CommrJE53I
Hi! …/tmp/.mount_N-CommLbx7te/n-commodore.plugin.zsh…

What's currently left TODO is `zi update` support.
@psprint psprint force-pushed the appimages-miligrams branch from beb003c to 6eda5ac Compare August 6, 2023 14:31
@vladdoster vladdoster closed this Jan 14, 2024
@zdharma-continuum zdharma-continuum locked as resolved and limited conversation to collaborators Jan 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants