From: Jay Palacio Date: Sun, 21 Nov 2021 11:36:46 +0000 (-0500) Subject: feature(delta): add *nix and Windows installer + cheat sheet X-Git-Url: https://git.josue.xyz/?p=webi-installers%2F.git;a=commitdiff_plain;h=e7dad6227425d813b17dadd6138cdffbc3341d8b feature(delta): add *nix and Windows installer + cheat sheet --- diff --git a/delta/README.md b/delta/README.md new file mode 100644 index 0000000..461fc76 --- /dev/null +++ b/delta/README.md @@ -0,0 +1,27 @@ +--- +title: delta +homepage: https://github.com/dandavison/delta +tagline: | + delta: A syntax-highlighting pager for git and diff output +--- + +To update or switch versions, run `webi delta` (or `@0.9.1`, `@0.9.0`, +etc). + +## Cheat Sheet + +Install delta and add this to your `~/.gitconfig`: + +```gitconfig +[pager] + diff = delta + show = delta + log = delta + blame = delta + reflog = delta + +[interactive] + diffFilter = delta --color-only +``` + +Make sure to check out the helpful [ReadMe](https://github.com/dandavison/delta/blob/master/README.md) diff --git a/delta/install.ps1 b/delta/install.ps1 new file mode 100644 index 0000000..8679d09 --- /dev/null +++ b/delta/install.ps1 @@ -0,0 +1,59 @@ +#!/usr/bin/env pwsh + +################## +# Install delta # +################## + +# Every package should define these variables +$pkg_cmd_name = "delta" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\delta.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\delta-v$Env:WEBI_VERSION\bin\delta.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\delta-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\delta-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | out-null +$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) +{ + # TODO: arch detection + # useragent -A was causing download to fail at 1kb + echo "Downloading delta from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) +{ + echo "Installing delta" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\delta-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\delta.exe" -Recurse -ErrorAction Ignore + + # Unpack archive file into this temporary directory + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Settle unpacked archive into place + echo "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force | out-null + Move-Item -Path ".\delta-*\delta.exe" -Destination "$pkg_src_bin" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | out-null +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/delta/install.sh b/delta/install.sh new file mode 100644 index 0000000..748143a --- /dev/null +++ b/delta/install.sh @@ -0,0 +1,44 @@ +#!/bin/bash +set -e +set -u + +function __init_delta() { + + + ################# + # Install delta # + ################# + + # Every package should define these 6 variables + pkg_cmd_name="delta" + + pkg_dst_cmd="$HOME/.local/bin/delta" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/delta-v$WEBI_VERSION/bin/delta" + pkg_src_dir="$HOME/.local/opt/delta-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + + # pkg_install must be defined by every package + pkg_install() { + # ~/.local/opt/delta-v0.99.9/bin + mkdir -p "$(dirname $pkg_src_cmd)" + + # mv ./delta-*/delta ~/.local/opt/delta-v0.99.9/bin/delta + mv ./delta-*/delta "$pkg_src_cmd" + } + + # pkg_get_current_version is recommended, but not required + pkg_get_current_version() { + # 'delta --version' has output in this format: + # delta 0.9.2 + # This trims it down to just the version number: + # 0.9.2 + delta --version 2> /dev/null | + head -n 1 | + cut -d ' ' -f 2 + } + +} + +__init_delta diff --git a/delta/releases.js b/delta/releases.js new file mode 100644 index 0000000..47c16ac --- /dev/null +++ b/delta/releases.js @@ -0,0 +1,20 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'dandavison'; +var repo = 'delta'; + +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); + // just select the first 15 for demonstration + all.releases = all.releases.slice(0, 15); + console.info(JSON.stringify(all, null, 2)); + }); +} diff --git a/test/install.sh b/test/install.sh index 43d3768..3d55469 100644 --- a/test/install.sh +++ b/test/install.sh @@ -14,6 +14,7 @@ function __rmrf_local() { chromedriver \ comrak \ curlie \ + delta \ deno \ dotenv \ dotenv-linter \ @@ -103,6 +104,7 @@ function __rmrf_local() { chromedriver \ comrak \ curlie \ + delta \ deno \ dotenv \ dotenv-linter \ @@ -196,6 +198,7 @@ function __test() { chromedriver \ comrak \ curlie \ + delta \ deno \ dotenv \ dotenv-linter \