add yq
authorAdithya Sunil Edakkadan <adithyasunil26@gmail.com>
Wed, 30 Dec 2020 20:46:44 +0000 (00:46 +0400)
committerAJ ONeal <aj@therootcompany.com>
Thu, 7 Jan 2021 10:14:21 +0000 (10:14 +0000)
yq/README.md [new file with mode: 0644]
yq/install.ps1 [new file with mode: 0644]
yq/install.sh [new file with mode: 0644]
yq/releases.js [new file with mode: 0644]

diff --git a/yq/README.md b/yq/README.md
new file mode 100644 (file)
index 0000000..da28833
--- /dev/null
@@ -0,0 +1,8 @@
+---
+title: yq
+homepage: https://github.com/mikefarah/yq
+tagline: |
+  yq: a lightweight and portable command-line YAML processor
+
+---
+
diff --git a/yq/install.ps1 b/yq/install.ps1
new file mode 100644 (file)
index 0000000..3740ab7
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/env pwsh
+
+$pkg_cmd_name = "yq"
+
+$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\yq.exe"
+$pkg_dst = "$pkg_dst_cmd"
+
+$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\yq-v$Env:WEBI_VERSION\bin\yq.exe"
+$pkg_src_bin = "$Env:USERPROFILE\.local\opt\yq-v$Env:WEBI_VERSION\bin"
+$pkg_src_dir = "$Env:USERPROFILE\.local\opt\yq-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 yq 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 yq"
+    pushd .local\tmp
+
+        Remove-Item -Path ".\yq-v*" -Recurse -ErrorAction Ignore
+        Remove-Item -Path ".\yq.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 ".\yq.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/yq/install.sh b/yq/install.sh
new file mode 100644 (file)
index 0000000..81d3fac
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+{
+    set -e
+    set -u
+
+    pkg_cmd_name="yq"
+
+    pkg_dst_cmd="$HOME/.local/bin/yq"
+    pkg_dst="$pkg_dst_cmd"
+
+    pkg_src_cmd="$HOME/.local/opt/yq-v$WEBI_VERSION/bin/yq"
+    pkg_src_dir="$HOME/.local/opt/yq-v$WEBI_VERSION"
+    pkg_src="$pkg_src_cmd"
+
+    pkg_install() {
+        mkdir -p "$(dirname $pkg_src_cmd)"
+        mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
+        chmod a+x "$pkg_src_cmd"
+    }
+
+    pkg_get_current_version() {
+        echo $(yq --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2)
+    }
+
+}
diff --git a/yq/releases.js b/yq/releases.js
new file mode 100644 (file)
index 0000000..8ef95a7
--- /dev/null
@@ -0,0 +1,19 @@
+'use strict';
+
+var github = require('../_common/github.js');
+var owner = 'mikefarah';
+var repo = 'yq';
+
+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));
+       });
+}