From b14b716c48e48eb55865f528c021294dc77b2d9b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 3 Mar 2021 07:01:09 +0000 Subject: [PATCH] bugfix: correct lf unpack and install --- LF/install.sh | 31 ------------------------------- {LF => lf}/README.md | 21 +++++++++++++-------- {LF => lf}/install.ps1 | 7 +++---- lf/install.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ {LF => lf}/releases.js | 15 ++++++++++++++- 5 files changed, 72 insertions(+), 44 deletions(-) delete mode 100644 LF/install.sh rename {LF => lf}/README.md (77%) rename {LF => lf}/install.ps1 (87%) create mode 100644 lf/install.sh rename {LF => lf}/releases.js (51%) diff --git a/LF/install.sh b/LF/install.sh deleted file mode 100644 index 674bbcb..0000000 --- a/LF/install.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -function __init_lf() { - set -e - set -u - - ################## - # Install lf # - ################## - - pkg_cmd_name="lf" - - pkg_dst_cmd="$HOME/.local/bin/lf" - pkg_dst="$pkg_dst_cmd" - - pkg_src_cmd="$HOME/.local/opt/lf-v$WEBI_VERSION/bin/lf" - pkg_src_dir="$HOME/.local/opt/lf-v$WEBI_VERSION" - pkg_src="$pkg_src_cmd" - - pkg_install() { - mkdir -p "$(dirname $pkg_src_cmd)" - mv ./lf-*/lf "$pkg_src_cmd" - } - - pkg_get_current_version() { - echo $(lf --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2) - } - -} - -__init_lf diff --git a/LF/README.md b/lf/README.md similarity index 77% rename from LF/README.md rename to lf/README.md index 7bd32e1..d8bb069 100644 --- a/LF/README.md +++ b/lf/README.md @@ -5,20 +5,23 @@ tagline: | lf: terminal file manager written in Go --- -To update or switch versions, run `webi lf@stable` (or `@v2`, `@beta`, -etc). +To update or switch versions, run `webi lf@stable` (or `@v2`, `@beta`, etc). ## Cheat Sheet -> lf (as in "list files") is a terminal file manager written in Go. It is heavily inspired by ranger with some missing and extra features. +> lf (as in "list files") is a terminal file manager written in Go. It is +> heavily inspired by ranger with some missing and extra features. To start the application in the current directory: + ```bash lf ``` + ### Navigating in lf: -| Action | Command/Key | -|-----------|-------------| + +| Action | Command/Key | +| --------- | ------------------ | | quit | 'q' | | up | 'k' or '\' | | page-up | '\' | @@ -28,14 +31,16 @@ lf | open | 'l' or '\' | | top | 'gg' and '\' | | bottom | 'G' and '\' | -||| +| | | ### For command line options: + ```bash -lf -help +lf --help ``` ### For documentation + ```bash -lf -doc +lf --doc ``` diff --git a/LF/install.ps1 b/lf/install.ps1 similarity index 87% rename from LF/install.ps1 rename to lf/install.ps1 index 51f4830..b2d4935 100644 --- a/LF/install.ps1 +++ b/lf/install.ps1 @@ -1,8 +1,8 @@ #!/usr/bin/env pwsh -################## +############## # Install lf # -################## +############## $pkg_cmd_name = "lf" @@ -29,7 +29,6 @@ IF (!(Test-Path -Path "$pkg_src_cmd")) pushd .local\tmp - Remove-Item -Path ".\lf-v*" -Recurse -ErrorAction Ignore Remove-Item -Path ".\lf.exe" -Recurse -ErrorAction Ignore echo "Unpacking $pkg_download" @@ -37,7 +36,7 @@ IF (!(Test-Path -Path "$pkg_src_cmd")) echo "Install Location: $pkg_src_cmd" New-Item "$pkg_src_bin" -ItemType Directory -Force - Move-Item -Path ".\lf-*\lf.exe" -Destination "$pkg_src_bin" + Move-Item -Path ".\lf.exe" -Destination "$pkg_src_bin" popd } diff --git a/lf/install.sh b/lf/install.sh new file mode 100644 index 0000000..7eaa5fa --- /dev/null +++ b/lf/install.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +function __init_lf() { + set -e + set -u + + ############## + # Install lf # + ############## + + # Every package should define these 6 variables + pkg_cmd_name="lf" + + pkg_dst_cmd="$HOME/.local/bin/lf" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/lf-v$WEBI_VERSION/bin/lf" + pkg_src_dir="$HOME/.local/opt/lf-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + + pkg_install() { + # $HOME/.local/opt/lf-v0.21.0/bin + mkdir -p "$(dirname $pkg_src_cmd)" + + # mv ./lf "$HOME/.local/opt/lf-v0.21.0/bin/lf" + mv ./lf "$pkg_src_cmd" + + # chmod a+x "$HOME/.local/opt/lf-v0.21.0/bin/lf" + chmod a+x "$pkg_src_cmd" + } + + pkg_get_current_version() { + # 'lf version' has output in this format: + # r21 + # This treats it as a minor version number: + # 0.21.0 + echo "0.$(lf --version 2>/dev/null | head -n 1 | cut -d' ' -f1 | sed 's:^r::').0" + } + +} + +__init_lf diff --git a/LF/releases.js b/lf/releases.js similarity index 51% rename from LF/releases.js rename to lf/releases.js index a960a34..f92c356 100644 --- a/LF/releases.js +++ b/lf/releases.js @@ -6,6 +6,13 @@ var repo = 'lf'; module.exports = function (request) { return github(request, owner, repo).then(function (all) { + all.releases = all.releases.map(function (r) { + // r21 -> 0.21.0 + if (/^r/.test(r.version)) { + r.version = '0.' + r.version.replace('r', '') + '.0'; + } + return r; + }); return all; }); }; @@ -13,7 +20,13 @@ module.exports = function (request) { if (module === require.main) { module.exports(require('@root/request')).then(function (all) { all = require('../_webi/normalize.js')(all); - all.releases = all.releases.slice(0, 5); + all.releases = all.releases + .filter(function (r) { + return ( + ['windows', 'macos', 'linux'].includes(r.os) && 'amd64' === r.arch + ); + }) + .slice(0, 10); console.info(JSON.stringify(all, null, 2)); }); } -- 2.25.1