feat: add hugo-extended

This commit is contained in:
AJ ONeal
2023-09-16 23:05:30 +00:00
parent 1d87306129
commit cf1c486616
4 changed files with 196 additions and 0 deletions
+64
View File
@@ -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/).
+57
View File
@@ -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
+40
View File
@@ -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
+35
View File
@@ -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));
});
}