webinstall / webi-installer-requests

This is just to house issues for requests for new Webi installers.
Mozilla Public License 2.0
5 stars 7 forks source link

how to download hugo_extended version? #49

Closed goldcoders closed 8 months ago

goldcoders commented 2 years ago

Hi i see in https://webinstall.dev/api/releases/hugo@.tab that there is a hugo extended version but i dont see a way to use webi to install the hugo extended version on webi i tried webi hugo_extended@v.0.89.2 or webi hugo@beta or webi hugo@extended_v.0.89.2

coolaj86 commented 2 years ago

Should we just make hugo_extended the default version?

Or is there a good reason to keep both?

We could either copy https://github.com/webinstall/webi-installers/tree/main/hugo to hugo_extended, or we could update it to make it the default.

What do you think? Could you make the PR?

goldcoders commented 2 years ago

i think the extended is what most developers used, since most of them uses features that requires css , sass and other goodies only available in extended version.

coolaj86 commented 2 years ago

I think if you update the filter function to include 'extended', that should do the trick: https://github.com/webinstall/webi-installers/blob/main/hugo/releases.js

Want to give it a try?

webi node
git clone https://github.com/webinstall/webi-installers
pushd webi-installers
# edit releases.js
node hugo/releases.js
goldcoders commented 2 years ago

Ive created custom powershell and bash script , which i used in my desktop app. here i can download very specific version later, than on webi hugo installation script that covers only top 10 recent versions.

also if the ARM64 on mac is not available on some version it defaults back to 64bit

you can take reference on this its uses same api as webi where in you can have multiple versions

#!/bin/bash

# invoke by ./hugo-install.sh -v 0.89.2 -h hugo
# set our variables
OS=""
ARCH=""
HUGO="hugo_extended"

# invoke ./hugo_install.sh -v
# pass in flag -v and -h
while getopts v:h: flag
do
    case "${flag}" in
        v) version=${OPTARG};;
        h) HUGO=${OPTARG};;
    esac
done
# check version for comparison
function getVersion { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }

if [ "$(uname)" == "Darwin" ];
then
# Do something under Mac OS X platform
    OS="macOS"
# check if using apple silicon
if [ "$(sysctl -n machdep.cpu.brand_string)" == "Apple M1" ];
then
ARCH="ARM64"
    if [ $(getVersion $version) -lt $(getVersion "0.81.0") ]; then
        ARCH="64bit"
    fi

else
ARCH="64bit"
fi
# On linux OS
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ];
    then
    # check for arch if 64 bit
    if [ "$(uname -m)" == "x86_64" ];
    then
        ARCH="64bit"
    else
        ARCH="32bit"
        # if arch is 32 bit then we wont download hugo_extended
        # only hugo will be downloaded
        HUGO="hugo"
    fi
fi

OPTPATH=~/.local/opt
# check directory
if [[ ! -d $OPTPATH ]]; then
    mkdir -pv $OPTPATH
fi

# download on tmp file directory
pushd /tmp
FOLDER="${HUGO}_v${version}"
EXECPATH=~/.local/opt/$FOLDER/bin

# create folder ~/.local/opt if not exist
if [[ ! -d $EXECPATH ]]; then
    mkdir -pv $EXECPATH
fi

# download hugo
curl -LJO "https://github.com/gohugoio/hugo/releases/download/v${version}/${HUGO}_${version}_${OS}-${ARCH}.tar.gz"

# find tarball
tarball="$(find . -name "*$OS-$ARCH.tar.gz")"
# move to folder
mv $tarball ~/.local/opt/$FOLDER
# change directory to FOLDER
pushd ~/.local/opt/$FOLDER
# extract tarball
tar -xzf $tarball

# make hugo executable
chmod +x hugo

# move to exec path
mv hugo $EXECPATH

# force update symlink if it exists
ln -sf $EXECPATH/hugo ~/.local/bin/hugo
popd

location="$(which hugo)"
echo "Hugo binary location: $location"

version="$(hugo version)"
echo "Hugo binary version: $version"
# ./hugo_install -version 0.89.2 -HUGO hugo
param (
    [string]$version= "",
    [string]$hugo = "hugo_extended"
 )

$OS="Windows"
$ARCH=""
$FOLDER="${hugo}_v${version}"
$OPTPATH = "$HOME\.local\opt"
$EXECPATH= "$OPTPATH\$FOLDER"
$HUGOCMD ="$OPTPATH\$FOLDER\hugo.exe"
$HUGOPATH = "$HOME\.local\bin\hugo"
$CWD = Get-Location

if ([Environment]::Is64BitProcess)
{
    $ARCH="64bit"
}else{
    $ARCH="32bit"
}

New-Item -ItemType Directory -Force -Path $OPTPATH
New-Item -ItemType Directory -Force -Path $EXECPATH
# cd to temporary directory
$TEMPDIR = [System.IO.Path]::GetTempPath()
Push-Location $TEMPDIR
# set uri
$URI = "https://github.com/gohugoio/hugo/releases/download/v${version}/${hugo}_${version}_${OS}-${ARCH}.zip"

# download hugo
Invoke-WebRequest -Uri $URI -OutFile $FOLDER
# unzip hugo
Expand-Archive $TEMPDIR\$FOLDER -DestinationPath $EXECPATH -Force

# create SymbolicLink
$link = New-Item -ItemType SymbolicLink -Path $HUGOPATH -Target $HUGOCMD -Force
$link | Select-Object LinkType, Target

Push-Location $CWD
coolaj86 commented 8 months ago

hugo-extended is now available at https://webinstall.dev/hugo-extended as of webinstall/webi-installers#650