bugfix: correct lf unpack and install
authorAJ ONeal <aj@therootcompany.com>
Wed, 3 Mar 2021 07:01:09 +0000 (07:01 +0000)
committerAJ ONeal <aj@therootcompany.com>
Wed, 3 Mar 2021 07:01:09 +0000 (07:01 +0000)
LF/README.md [deleted file]
LF/install.ps1 [deleted file]
LF/install.sh [deleted file]
LF/releases.js [deleted file]
lf/README.md [new file with mode: 0644]
lf/install.ps1 [new file with mode: 0644]
lf/install.sh [new file with mode: 0644]
lf/releases.js [new file with mode: 0644]

diff --git a/LF/README.md b/LF/README.md
deleted file mode 100644 (file)
index 7bd32e1..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
----
-title: lf
-homepage: https://github.com/gokcehan/lf
-tagline: |
-  lf: terminal file manager written in Go
----
-
-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.
-
-To start the application in the current directory:
-```bash
-lf
-```
-### Navigating in lf:
-| Action    | Command/Key |
-|-----------|-------------|
-| quit      | 'q'                |
-| up        | 'k' or '\<up>'     |
-| page-up   | '\<pgup>'          |
-| down      | 'j' or '\<down>'   |
-| page-down | '\<pgdn>'          |
-| updir     | 'h' or '\<left>'   |
-| open      | 'l' or '\<right>'  |
-| top       | 'gg' and '\<home>' |
-| bottom    | 'G' and '\<end>'   |
-|||
-
-### For command line options:
-```bash
-lf -help
-```
-
-### For documentation
-```bash
-lf -doc
-```
diff --git a/LF/install.ps1 b/LF/install.ps1
deleted file mode 100644 (file)
index 51f4830..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env pwsh
-
-##################
-# Install lf #
-##################
-
-$pkg_cmd_name = "lf"
-
-$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\lf.exe"
-$pkg_dst = "$pkg_dst_cmd"
-
-$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\lf-v$Env:WEBI_VERSION\bin\lf.exe"
-$pkg_src_bin = "$Env:USERPROFILE\.local\opt\lf-v$Env:WEBI_VERSION\bin"
-$pkg_src_dir = "$Env:USERPROFILE\.local\opt\lf-v$Env:WEBI_VERSION"
-$pkg_src = "$pkg_src_cmd"
-
-$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
-
-IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"))
-{
-    echo "Downloading lf from $Env:WEBI_PKG_URL to $pkg_download"
-    & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
-    & move "$pkg_download.part" "$pkg_download"
-}
-
-IF (!(Test-Path -Path "$pkg_src_cmd"))
-{
-    echo "Installing lf"
-
-    pushd .local\tmp
-
-        Remove-Item -Path ".\lf-v*" -Recurse -ErrorAction Ignore
-        Remove-Item -Path ".\lf.exe" -Recurse -ErrorAction Ignore
-
-        echo "Unpacking $pkg_download"
-        & tar xf "$pkg_download"
-
-        echo "Install Location: $pkg_src_cmd"
-        New-Item "$pkg_src_bin" -ItemType Directory -Force
-        Move-Item -Path ".\lf-*\lf.exe" -Destination "$pkg_src_bin"
-
-    popd
-}
-
-echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
-Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore
-Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
diff --git a/LF/install.sh b/LF/install.sh
deleted file mode 100644 (file)
index 674bbcb..0000000
+++ /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/releases.js b/LF/releases.js
deleted file mode 100644 (file)
index a960a34..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-'use strict';
-
-var github = require('../_common/github.js');
-var owner = 'gokcehan';
-var repo = 'lf';
-
-module.exports = function (request) {
-  return github(request, owner, repo).then(function (all) {
-    return all;
-  });
-};
-
-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);
-    console.info(JSON.stringify(all, null, 2));
-  });
-}
diff --git a/lf/README.md b/lf/README.md
new file mode 100644 (file)
index 0000000..d8bb069
--- /dev/null
@@ -0,0 +1,46 @@
+---
+title: lf
+homepage: https://github.com/gokcehan/lf
+tagline: |
+  lf: terminal file manager written in Go
+---
+
+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.
+
+To start the application in the current directory:
+
+```bash
+lf
+```
+
+### Navigating in lf:
+
+| Action    | Command/Key        |
+| --------- | ------------------ |
+| quit      | 'q'                |
+| up        | 'k' or '\<up>'     |
+| page-up   | '\<pgup>'          |
+| down      | 'j' or '\<down>'   |
+| page-down | '\<pgdn>'          |
+| updir     | 'h' or '\<left>'   |
+| open      | 'l' or '\<right>'  |
+| top       | 'gg' and '\<home>' |
+| bottom    | 'G' and '\<end>'   |
+|           |                    |
+
+### For command line options:
+
+```bash
+lf --help
+```
+
+### For documentation
+
+```bash
+lf --doc
+```
diff --git a/lf/install.ps1 b/lf/install.ps1
new file mode 100644 (file)
index 0000000..b2d4935
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/env pwsh
+
+##############
+# Install lf #
+##############
+
+$pkg_cmd_name = "lf"
+
+$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\lf.exe"
+$pkg_dst = "$pkg_dst_cmd"
+
+$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\lf-v$Env:WEBI_VERSION\bin\lf.exe"
+$pkg_src_bin = "$Env:USERPROFILE\.local\opt\lf-v$Env:WEBI_VERSION\bin"
+$pkg_src_dir = "$Env:USERPROFILE\.local\opt\lf-v$Env:WEBI_VERSION"
+$pkg_src = "$pkg_src_cmd"
+
+$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
+
+IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"))
+{
+    echo "Downloading lf from $Env:WEBI_PKG_URL to $pkg_download"
+    & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
+    & move "$pkg_download.part" "$pkg_download"
+}
+
+IF (!(Test-Path -Path "$pkg_src_cmd"))
+{
+    echo "Installing lf"
+
+    pushd .local\tmp
+
+        Remove-Item -Path ".\lf.exe" -Recurse -ErrorAction Ignore
+
+        echo "Unpacking $pkg_download"
+        & tar xf "$pkg_download"
+
+        echo "Install Location: $pkg_src_cmd"
+        New-Item "$pkg_src_bin" -ItemType Directory -Force
+        Move-Item -Path ".\lf.exe" -Destination "$pkg_src_bin"
+
+    popd
+}
+
+echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
+Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore
+Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
diff --git a/lf/install.sh b/lf/install.sh
new file mode 100644 (file)
index 0000000..7eaa5fa
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..f92c356
--- /dev/null
@@ -0,0 +1,32 @@
+'use strict';
+
+var github = require('../_common/github.js');
+var owner = 'gokcehan';
+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;
+  });
+};
+
+if (module === require.main) {
+  module.exports(require('@root/request')).then(function (all) {
+    all = require('../_webi/normalize.js')(all);
+    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));
+  });
+}