22import fs from 'fs-extra'
33import execa from 'execa'
44
5- import { isDarwin } from '~/helpers/environment.js'
65import {
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
3544export 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
7987export 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
0 commit comments