Skip to content

Commit 9e48862

Browse files
committed
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.
1 parent e701c48 commit 9e48862

3 files changed

Lines changed: 31 additions & 18 deletions

File tree

helpers/environment.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ export function isNuxt( VueThis ) {
66
}
77

88
export function isBrowserContext () {
9-
if ( typeof navigator === 'undefined' ) return false
9+
// Node 22 exposes a global navigator, so use window/document instead.
10+
if ( typeof window === 'undefined' ) return false
11+
12+
if ( typeof document === 'undefined' ) return false
1013

1114
return true
1215
}
1316

1417
export function hasProcesGlobal () {
1518
if ( typeof process === 'undefined' ) return false
1619

20+
if ( !process.versions?.node ) return false
21+
1722
return true
1823
}
1924

helpers/stork/executable.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import fs from 'fs-extra'
33
import execa from 'execa'
44

5-
import { isDarwin } from '~/helpers/environment.js'
65
import {
76
storkVersion,
87
storkExecutableName,
@@ -11,15 +10,25 @@ import {
1110
storkIndexPath
1211
} from '~/helpers/stork/config.js'
1312

14-
// https://stork-search.net/docs/install
15-
const execDownloadUrls = {
16-
darwin: `https://files.stork-search.net/releases/v${ storkVersion }/stork-macos-10-15`,
17-
default: `https://files.stork-search.net/releases/v${ storkVersion }/stork-ubuntu-20-04`
13+
// Netlify's Ubuntu 24 (Noble) image needs the OpenSSL 3 compatible binary.
14+
export function getStorkExecutableTarget ( {
15+
platform = process.platform,
16+
arch = process.arch
17+
} = {} ) {
18+
if ( platform === 'darwin' ) {
19+
if ( arch === 'arm64' ) return 'stork-macos-13-arm'
20+
21+
return 'stork-macos-10-15'
22+
}
23+
24+
return 'stork-ubuntu-22-04'
25+
}
1826

19-
// Stork 2.0
20-
// darwin: `https://files.stork-search.net/releases/v${ storkVersion }/stork-macos-12`,
27+
// https://stork-search.net/docs/install
28+
export function getStorkExecutableDownloadUrl ( options = {} ) {
29+
const target = getStorkExecutableTarget( options )
2130

22-
// default: `https://files.stork-search.net/releases/v${ storkVersion }/stork-amazon-linux`
31+
return `https://files.stork-search.net/releases/v${ storkVersion }/${ target }`
2332
}
2433

2534
// Check if a file is executable
@@ -33,9 +42,7 @@ async function isExecutable ( path ) {
3342

3443
// 👩‍💻 Bash Download example - https://github.com/jmooring/hugo-stork/blob/main/build.sh
3544
export async function downloadStorkExecutable () {
36-
const envKey = isDarwin() ? 'darwin' : 'default'
37-
38-
const execDownloadUrl = execDownloadUrls[ envKey ]
45+
const execDownloadUrl = getStorkExecutableDownloadUrl()
3946

4047
// console.log( { execDownloadUrl } )
4148

@@ -46,6 +53,7 @@ export async function downloadStorkExecutable () {
4653

4754
// Download the binary
4855
await execa( `curl`, [
56+
'-fsSL',
4957
execDownloadUrl,
5058

5159
// Set filename
@@ -60,7 +68,7 @@ export async function downloadStorkExecutable () {
6068

6169

6270
// console.log( 'isExecutable', isExecutable )
63-
if ( !isExecutable( storkExecutablePath ) ) throw new Error( `Downloaded binary at ${ storkExecutablePath } is not executable.` )
71+
if ( !(await isExecutable( storkExecutablePath )) ) throw new Error( `Downloaded binary at ${ storkExecutablePath } is not executable.` )
6472

6573

6674
// Check Stork version
@@ -78,7 +86,7 @@ export async function downloadStorkExecutable () {
7886

7987
export async function buildIndex () {
8088

81-
if ( !isExecutable( storkExecutablePath ) ) throw new Error( `Binary at ${ storkExecutablePath } is not executable.` )
89+
if ( !(await isExecutable( storkExecutablePath )) ) throw new Error( `Binary at ${ storkExecutablePath } is not executable.` )
8290

8391
// Check Stork version
8492
// so we know our binary is working

scripts/stork-netlify.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# Hugo Bash Example https://github.com/jmooring/hugo-stork/blob/main/build.sh
44

5-
# curl https://files.stork-search.net/releases/latest/stork-amazon-linux -o stork-executable
6-
# curl https://files.stork-search.net/releases/v1.4.3/stork-macos-latest -o stork-executable
5+
# Netlify's Noble/Ubuntu 24 image needs the Ubuntu 22.04 Stork build.
6+
# curl -fsSL https://files.stork-search.net/releases/v1.6.0/stork-macos-13-arm -o stork-executable
77

8-
curl https://files.stork-search.net/releases/v1.4.2/stork-amazon-linux -o stork-executable
9-
# curl https://files.stork-search.net/releases/v1.4.2/stork-macos-10-15 -o stork-executable
8+
curl -fsSL https://files.stork-search.net/releases/v1.6.0/stork-ubuntu-22-04 -o stork-executable
9+
# curl -fsSL https://files.stork-search.net/releases/v1.6.0/stork-macos-10-15 -o stork-executable
1010

1111
chmod +x stork-executable
1212
./stork-executable build --input static/stork.toml --output static/search-index.st

0 commit comments

Comments
 (0)