Crates.io | yep |
lib.rs | yep |
version | 0.0.2 |
source | src |
created_at | 2022-09-26 23:25:05.977131 |
updated_at | 2022-09-26 23:25:05.977131 |
description | yet another package manager for local cli commands |
homepage | |
repository | https://github.com/jankatins/yep |
max_upload_size | |
id | 674583 |
size | 43,910 |
[THIS IS AN IDEA, written down to see if it has any merits and looks sane... Comments welcome!]
Install and update command line apps in your $HOME folder.
Good for maintaining local cli commands, which you want to update regularly to the latest version available in the upstream release page/repo. Gives you the flexibility to install whatever you want. Minimizes the hassle of keeping them updated.
Installing a package is a three-step process:
--type=xx
(Default: downloading from a
github release page and installing as a static binary). This basically makes a minimal example
yep install cli/cli
do the right thing without removing flexibility.The "recipe" how to install a package is persisted and updates are basically reinstalls.
$PATH
is build in$HOME/.local/bin
on linux, user can overwrite)
$HOME/.local/yep/packages/<package>/.yep.v1.json
: persistent store for the "commands" to handle the packageyep install <source> <arguments>
: installs <source>
according to what is specified in the arguments.
The default arguments are --type=static-binary --from='gh-r'
which expects <source>
to be a
github org/repo
combination (see "happy path" above).yep delete <package-name or source>
: remove a package and all files created outside of the package folderyep setup
: creates the required folders and default config file and puts itself into the needed places for
everything to work and to update itself. Idempotent.Executed in the order they are given
Some arguments are "commands" (like "link this to there...") and can be given multiple times
Every enabled command/argument can be disabled via --no-<command>
which removes any such commands from the list up
to that point
--id-as <name>
: the name of the package in the packages folder; defaults to something derived from the given
url/package/repo slug by some magic conversion (todo: define it...); Can only be given once.
--from='{gh-r,gh,gl-r,gl,clone,download,nodejs}'
: uses the appropriate download method to download, maybe extract and
finally fill a folder; can only be given once; Latest given argument wins.
--dl-pick=<regex>
/ --dl-pick-os=<regex>
/ --dl-pick-os-arch=<regex>
: influences the file which is picked by the
download step
--dl-nodejs-package="<package-name>[,<package-name>]"
: Installs a/multiple node package(s) via npm into the package folder, using
package-name
(fallback: name
)
--dl-version=<str>
: the version to download, defaults to "latest release/HEAD" if not given; Can only be given once.
--mv='<regex>-><name>'
: move a file after extracting it; both parts relative to the package folder; Explicit arguments overwrite
default ones; can be given multiple times.
--ln='<regex>-><name>'
: symlink a file after extracting it; both parts relative to the package folder; Explicit arguments
overwrite default ones; can be given multiple times.
--exec=<command to exec>
: executes the given command in the folder; Explicit arguments overwrite default ones; can be given
multiple times.
--install-link='<regex>-><name>'
: Symlinks the file specified by the first part in the package folder into the configured
binaries folder; first part is relative to the package folder, second part is either relative to the binaries folder
or absolute; if first part matches more than one file, will all symlink them (if a second part is given as a file,
will error); if second part is given and ends in a slash (=folder), will add the symlink under the same name in that
folder. If nothing is given, will symlink all executable files in the root folder of the package under the same name. Explicit
arguments overwrite default ones; can be given multiple times.
--install-link=!...
or --no-install-link=<regex>
variant which excludes files again? But how would that work with extensions which
get called once per specified argument instead of with all arguments?--install-yep-extensions
: will put symlinks to any executable files matching (type|command|from)_*
in the package
folder into the extension folder (see below).
--install-shell-wrapper-node="<path/to/binary> [-> <name>]
: Install a shell script which wraps a node.js installation
into the configured binaries folder as name
(fallback: filename of <path/to/binary>
) ; (Similar things for python-pip/...)
(Probably more, e.g. install man files or zsh completions)
TODO: think about how to overwrite/extend stuff from the template/default type: I can see both "overwrite it" (e.g. the rust case below installs a different executable) and extend it (e.g. installs two executables").
Before actually doing the actions specified by the arguments, some string replacements are done:
%PACKAGEFOLDER%
: folder to the packageThree cases:
--type=<name>
which then can set the
defaults: $HOME/.local/yep/extensions/type_<type name>
:
calling it with the <source>
will output default options which are inserted into the start of the original
cli: e.g.
yep install cli/cli
will use the default static-binary
and
calls $HOME/.local/yep/packages/yep/yep type_static-binary cli/cli
(after checking that there is
no $HOME/.local/yep/extensions/type_static-binary
) which then outputs --from='gh-r' --install-link
which
downloads the latest release from github and symlinks all executables in the root folder of the resulting package
folder.yep install whatever --type=rust
calls $HOME/.local/yep/extensions/type_rust whatever
which might return something
like --from='rust' --install-link='bin/whatever -> whatever'
which then
might install rust into the folder and then use cargo in that folder to install the
whatever
package and finally symlink the installed package into the binary folderyep install whatever --type=nodejs
calls $HOME/.local/yep/extensions/type_nodejs whatever
which might
return something like --from='nodejs' --install-shell-wrapper-node='node_module/.bin/whatever -> whatever'
which
then might install nodejs into the folder, use that nodejs to install the whatever
package and finally create
a shells cript wrapper arround node_module/.bin/whatever
package into the binary folder.yep install org/repo --type=make
calls $HOME/.local/yep/extensions/type_make org/repo
which
might return --from='gh' --exec='make install DESTDIR=%PACKAGEFOLDER% --install-link
which clones the org/repo
from github, runs the specified make command and finally symlinks all executable files in the root folder of the
package into the binary folder.$HOME/.local/yep/extensions/from_<from name>
: yep --from="git-clone" https://git.whatever.com/repo.git ...
will call
$HOME/.local/yep/extensions/from_git-clone https://git.whatever.com/repo.git <packages folder> -- <original arguments>
and expects that command to fill the package folder with the content of the
repo; The from
command should indicate via return code if the content of the packages
was refreshed (=rerun the rest of the recipe, return code 0) or not (TODO: some special code, outside of the normal
error codes).$HOME/.local/yep/extensions/command_<new command>
which get called: yep ... --whatever='x->y'
-> exec $HOME/.local/yep/extensions/command_whatever {install,remove} 'x->y'
Installation by a special argument/type (e.g. yep --type=extension ...
which will ln all files in the root folder
which fit the required file patterns into the extension folder (see --install-yep-extensions
).
Download the appropriate file for your arch/os, make it executable and run yep setup
. This will do:
$HOME/.local/yep/{...}
$HOME/.local/bin/
(=installs it)TODO: how to persist this steps so update runs this again? probably nothing special, if really needed, add appropriate arguments/ commands in the persisted file. Or put that into the "update" command as a special post-update step.
(The command is idempotent, so can be rerun again without harming your installation or fixing it if something is broken)
yep BurntSushi/ripgrep
$HOME/.local/bin/ripgrep
This project is proudly licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).
yep can be distributed according to the MIT license. Contributions will be accepted under the same license.