From 2220875889faa800a9673d39b3e18a352399c94a Mon Sep 17 00:00:00 2001 From: Adithya Sunil Edakkadan Date: Thu, 31 Dec 2020 00:46:44 +0400 Subject: [PATCH] add yq --- yq/README.md | 8 ++++++++ yq/install.ps1 | 42 ++++++++++++++++++++++++++++++++++++++++++ yq/install.sh | 26 ++++++++++++++++++++++++++ yq/releases.js | 19 +++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 yq/README.md create mode 100644 yq/install.ps1 create mode 100644 yq/install.sh create mode 100644 yq/releases.js diff --git a/yq/README.md b/yq/README.md new file mode 100644 index 0000000..da28833 --- /dev/null +++ b/yq/README.md @@ -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 index 0000000..3740ab7 --- /dev/null +++ b/yq/install.ps1 @@ -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 index 0000000..81d3fac --- /dev/null +++ b/yq/install.sh @@ -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 index 0000000..8ef95a7 --- /dev/null +++ b/yq/releases.js @@ -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)); + }); +} -- 2.25.1