make _example current, add rg for Windows

This commit is contained in:
AJ ONeal
2020-08-22 20:21:01 +00:00
parent 31e780afa6
commit 1c97e1c661
8 changed files with 191 additions and 116 deletions

58
rg/install.ps1 Normal file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env pwsh
###################
# Install ripgrep #
###################
# Every package should define these variables
$pkg_cmd_name = "rg"
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\rg.exe"
$pkg_dst = "$pkg_dst_cmd"
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\ripgrep-v$Env:WEBI_VERSION\bin\rg.exe"
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\ripgrep-v$Env:WEBI_VERSION\bin"
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\ripgrep-v$Env:WEBI_VERSION"
$pkg_src = "$pkg_src_cmd"
$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
# Fetch archive
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"))
{
# TODO: arch detection
echo "Downloading ripgrep 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 ripgrep"
# TODO: create package-specific temp directory
# Enter tmp
pushd .local\tmp
# Remove any leftover tmp cruft
Remove-Item -Path ".\ripgrep-v*" -Recurse -ErrorAction Ignore
Remove-Item -Path ".\rg.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"
& dir
# Settle unpacked archive into place
echo "Install Location: $pkg_src_cmd"
New-Item "$pkg_src_bin" -ItemType Directory
Move-Item -Path ".\ripgrep-*\rg.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
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse

View File

@@ -13,7 +13,8 @@ module.exports = function (request) {
if (module === require.main) {
module.exports(require('@root/request')).then(function (all) {
all = require('../_webi/normalize.js')(all);
console.info(JSON.stringify(all));
//console.info(JSON.stringify(all, null, 2));
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);
console.info(JSON.stringify(all, null, 2));
});
}