From 9e48862a5f684f54742ee03df0f21d556001e648 Mon Sep 17 00:00:00 2001 From: ThatGuySam Date: Sun, 15 Mar 2026 11:57:41 -0500 Subject: [PATCH] fix(stork): support netlify ubuntu 24 builds Switch Stork downloads to artifacts that match current runtimes and fix the runtime detection path that Node 22 changed. This keeps the existing Stork pipeline working on Netlify's Noble image and on Apple Silicon development machines. --- helpers/environment.js | 7 ++++++- helpers/stork/executable.js | 34 +++++++++++++++++++++------------- scripts/stork-netlify.sh | 8 ++++---- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/helpers/environment.js b/helpers/environment.js index 5b081a5..e9a77ba 100644 --- a/helpers/environment.js +++ b/helpers/environment.js @@ -6,7 +6,10 @@ export function isNuxt( VueThis ) { } export function isBrowserContext () { - if ( typeof navigator === 'undefined' ) return false + // Node 22 exposes a global navigator, so use window/document instead. + if ( typeof window === 'undefined' ) return false + + if ( typeof document === 'undefined' ) return false return true } @@ -14,6 +17,8 @@ export function isBrowserContext () { export function hasProcesGlobal () { if ( typeof process === 'undefined' ) return false + if ( !process.versions?.node ) return false + return true } diff --git a/helpers/stork/executable.js b/helpers/stork/executable.js index e402943..cc86b65 100644 --- a/helpers/stork/executable.js +++ b/helpers/stork/executable.js @@ -2,7 +2,6 @@ import fs from 'fs-extra' import execa from 'execa' -import { isDarwin } from '~/helpers/environment.js' import { storkVersion, storkExecutableName, @@ -11,15 +10,25 @@ import { storkIndexPath } from '~/helpers/stork/config.js' +// Netlify's Ubuntu 24 (Noble) image needs the OpenSSL 3 compatible binary. +export function getStorkExecutableTarget ( { + platform = process.platform, + arch = process.arch +} = {} ) { + if ( platform === 'darwin' ) { + if ( arch === 'arm64' ) return 'stork-macos-13-arm' + + return 'stork-macos-10-15' + } + + return 'stork-ubuntu-22-04' +} + // https://stork-search.net/docs/install -const execDownloadUrls = { - darwin: `https://files.stork-search.net/releases/v${ storkVersion }/stork-macos-10-15`, - default: `https://files.stork-search.net/releases/v${ storkVersion }/stork-ubuntu-20-04` +export function getStorkExecutableDownloadUrl ( options = {} ) { + const target = getStorkExecutableTarget( options ) - // Stork 2.0 - // darwin: `https://files.stork-search.net/releases/v${ storkVersion }/stork-macos-12`, - - // default: `https://files.stork-search.net/releases/v${ storkVersion }/stork-amazon-linux` + return `https://files.stork-search.net/releases/v${ storkVersion }/${ target }` } // Check if a file is executable @@ -33,9 +42,7 @@ async function isExecutable ( path ) { // 👩‍💻 Bash Download example - https://github.com/jmooring/hugo-stork/blob/main/build.sh export async function downloadStorkExecutable () { - const envKey = isDarwin() ? 'darwin' : 'default' - - const execDownloadUrl = execDownloadUrls[ envKey ] + const execDownloadUrl = getStorkExecutableDownloadUrl() // console.log( { execDownloadUrl } ) @@ -46,6 +53,7 @@ export async function downloadStorkExecutable () { // Download the binary await execa( `curl`, [ + '-fsSL', execDownloadUrl, // Set filename @@ -60,7 +68,7 @@ export async function downloadStorkExecutable () { // console.log( 'isExecutable', isExecutable ) - if ( !isExecutable( storkExecutablePath ) ) throw new Error( `Downloaded binary at ${ storkExecutablePath } is not executable.` ) + if ( !(await isExecutable( storkExecutablePath )) ) throw new Error( `Downloaded binary at ${ storkExecutablePath } is not executable.` ) // Check Stork version @@ -78,7 +86,7 @@ export async function downloadStorkExecutable () { export async function buildIndex () { - if ( !isExecutable( storkExecutablePath ) ) throw new Error( `Binary at ${ storkExecutablePath } is not executable.` ) + if ( !(await isExecutable( storkExecutablePath )) ) throw new Error( `Binary at ${ storkExecutablePath } is not executable.` ) // Check Stork version // so we know our binary is working diff --git a/scripts/stork-netlify.sh b/scripts/stork-netlify.sh index 4e5f52b..714a28b 100755 --- a/scripts/stork-netlify.sh +++ b/scripts/stork-netlify.sh @@ -2,11 +2,11 @@ # Hugo Bash Example https://github.com/jmooring/hugo-stork/blob/main/build.sh -# curl https://files.stork-search.net/releases/latest/stork-amazon-linux -o stork-executable -# curl https://files.stork-search.net/releases/v1.4.3/stork-macos-latest -o stork-executable +# Netlify's Noble/Ubuntu 24 image needs the Ubuntu 22.04 Stork build. +# curl -fsSL https://files.stork-search.net/releases/v1.6.0/stork-macos-13-arm -o stork-executable -curl https://files.stork-search.net/releases/v1.4.2/stork-amazon-linux -o stork-executable -# curl https://files.stork-search.net/releases/v1.4.2/stork-macos-10-15 -o stork-executable +curl -fsSL https://files.stork-search.net/releases/v1.6.0/stork-ubuntu-22-04 -o stork-executable +# curl -fsSL https://files.stork-search.net/releases/v1.6.0/stork-macos-10-15 -o stork-executable chmod +x stork-executable ./stork-executable build --input static/stork.toml --output static/search-index.st