diff --git a/hugo-extended/README.md b/hugo-extended/README.md new file mode 100644 index 0000000..cd0de5a --- /dev/null +++ b/hugo-extended/README.md @@ -0,0 +1,64 @@ +--- +title: Hugo Extended Edition +homepage: https://github.com/gohugoio/hugo +tagline: | + Hugo, but with libsass and WebP support. +--- + +To update or switch versions, run `webi hugo-extended@stable` (or `@v0.118.2`, +`@beta`, etc). + +### Files + +These are the files / directories that are created and/or modified with this +install: + +```text +~/.config/envman/PATH.env +~/.local/opt/hugo-extended/ +~/.local/bin/hugo +``` + +## Cheat Sheet + +> Hugo Extended Edition sacrifices some of the portability and memory-safety of +> Go in order to include libsass and WebP support. + +- **libsass** (as opposed to ["dartsass"](../sass/) - a.k.a. [sass](../sass/)) +- **WebP** encoding + +If you DON'T need those, check out [Hugo](../hugo/) (Standard Edition). + +### How to Switch Between Editions + +If you've installed `hugo` and `hugo-extended` with Webi, you can switch easily: + +```sh +webi hugo +``` + +```text +switched to 'hugo v0.118.2': + /Users/aj/.local/bin/hugo => /Users/aj/.local/opt/hugo-v0.118.2/bin/hugo +``` + +```sh +webi hugo-extended +``` + +```text +switched to 'hugo v0.118.2': + /home/me/.local/bin/hugo => /home/me/.local/opt/hugo-extended-v0.118.2/bin/hugo +``` + +### Why NOT Use Extended Edition? + +The Standard Edition is written and compiled with Go, which means it's binaries: + +- work on all OSes and architectures Go supports (musl, arm, BSD, etc) +- are more secure against attacks (Go is memory-safe, C languages are not) +- _slightly_ smaller file size (but... it doesn't really matter) + +### [Hugo](../hugo/) Quick Start & Tips + +See the [Hugo Cheat Sheet](../hugo/). See the [Hugo Cheat Sheet](../hugo/). diff --git a/hugo-extended/install.ps1 b/hugo-extended/install.ps1 new file mode 100644 index 0000000..d2daaa8 --- /dev/null +++ b/hugo-extended/install.ps1 @@ -0,0 +1,57 @@ +#!/usr/bin/env pwsh + +######################### +# Install hugo-extended # +######################### + +# Every package should define these variables +$pkg_cmd_name = "hugo" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\hugo.exe" +$pkg_dst_bin = "$Env:USERPROFILE\.local\bin" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\hugo-extended-v$Env:WEBI_VERSION\bin\hugo.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\hugo-extended-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\hugo-extended-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")) { + echo "Downloading hugo-extended 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 hugo-extended" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\hugo-extended-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\hugo.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 ".\hugo.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 +New-Item "$pkg_dst_bin" -ItemType Directory -Force | out-null +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/hugo-extended/install.sh b/hugo-extended/install.sh new file mode 100644 index 0000000..9539424 --- /dev/null +++ b/hugo-extended/install.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# shellcheck disable=SC2034 +# "'pkg_cmd_name' appears unused. Verify it or export it." + +__init_hugoextended() { + set -e + set -u + + WEBI_SINGLE=true + + # Every package should define these 6 variables + pkg_cmd_name="hugo" + + pkg_dst_cmd="$HOME/.local/bin/hugo" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/hugo-extended-v$WEBI_VERSION/bin/hugo" + pkg_src_dir="$HOME/.local/opt/hugo-extended-v$WEBI_VERSION/bin" + pkg_src="$pkg_src_dir" + + # pkg_install must be defined by every package + pkg_install() { + # ~/.local/opt/hugo-extended-v0.118.2/bin + mkdir -p "$(dirname "${pkg_src_cmd}")" + + # mv ./hugo ~/.local/opt/hugo-extended-v0.118.2/bin/ + mv ./hugo "${pkg_src_cmd}" + } + + pkg_get_current_version() { + # 'hugo version' has output in this format: + # hugo v0.118.2-da7983ac4b94d97d776d7c2405040de97e95c03d darwin/arm64 BuildDate=2023-08-31T11:23:51Z VendorInfo=gohugoio + # This trims it down to just the version number: + # 0.118.2 + hugo version 2> /dev/null | head -n 1 | cut -d' ' -f2 | cut -d '-' -f1 | sed 's:^v::' + } +} + +__init_hugoextended diff --git a/hugo-extended/releases.js b/hugo-extended/releases.js new file mode 100644 index 0000000..dcd2142 --- /dev/null +++ b/hugo-extended/releases.js @@ -0,0 +1,35 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'gohugoio'; +var repo = 'hugo'; + +module.exports = async function (request) { + let all = await github(request, owner, repo); + + all.releases = all.releases.filter(function (rel) { + let isExtended = rel.name.includes('_extended_'); + if (!isExtended) { + return false; + } + + // remove checksums and .deb + for (let ignorableExt of ['.txt', '.deb']) { + let isIgnorable = rel.name.endsWith(ignorableExt); + if (isIgnorable) { + return false; + } + } + + return true; + }); + + return all; +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_webi/normalize.js')(all); + console.info(JSON.stringify(all)); + }); +}