@@ -3,25 +3,26 @@ import {chmod, createFileWriteStream, fileExists, inTemporaryDirectory, mkdir, m
33import { outputDebug } from '@shopify/cli-kit/node/output'
44import { performActionWithRetryAfterRecovery } from '@shopify/cli-kit/common/retry'
55import { fetch } from '@shopify/cli-kit/node/http'
6+ import { versionSatisfies } from '@shopify/cli-kit/node/node-package-manager'
67import { PipelineSource } from 'stream'
78import { pipeline } from 'stream/promises'
89import stream from 'node:stream/promises'
910import fs from 'node:fs'
1011import * as gzip from 'node:zlib'
1112import { fileURLToPath } from 'node:url'
1213
13- export const PREFERRED_FUNCTION_RUNNER_VERSION = 'v9 .1.0 '
14+ export const PREFERRED_FUNCTION_RUNNER_VERSION = '9 .1.1 '
1415
1516// Javy dependencies.
16- export const PREFERRED_JAVY_VERSION = 'v6 .0.0'
17+ export const PREFERRED_JAVY_VERSION = '7 .0.0'
1718// The Javy plugin version should match the plugin version used in the
1819// function-runner version specified above.
19- export const PREFERRED_JAVY_PLUGIN_VERSION = 'v3 '
20+ export const PREFERRED_JAVY_PLUGIN_VERSION = '3 '
2021
2122const BINARYEN_VERSION = '123.0.0'
2223
23- export const V1_TRAMPOLINE_VERSION = 'v1 .0.2'
24- export const V2_TRAMPOLINE_VERSION = 'v2 .0.0 '
24+ export const V1_TRAMPOLINE_VERSION = '1 .0.2'
25+ export const V2_TRAMPOLINE_VERSION = '2 .0.1 '
2526
2627interface DownloadableBinary {
2728 path : string
@@ -43,9 +44,9 @@ export interface BinaryDependencies {
4344export function deriveJavaScriptBinaryDependencies ( version : string ) : BinaryDependencies | null {
4445 if ( version === '0' || version === '1' ) {
4546 return {
46- functionRunner : 'v7 .0.1' ,
47- javy : 'v4 .0.0' ,
48- javyPlugin : 'v1 ' ,
47+ functionRunner : '7 .0.1' ,
48+ javy : '4 .0.0' ,
49+ javyPlugin : '1 ' ,
4950 }
5051 } else if ( version === '2' ) {
5152 return {
@@ -67,11 +68,19 @@ class Executable implements DownloadableBinary {
6768 readonly path : string
6869 readonly release : string
6970 private readonly gitHubRepo : string
70-
71- constructor ( name : string , version : string , gitHubRepo : string , release = version ) {
71+ private readonly supportsWindowsOnArm : boolean
72+
73+ constructor (
74+ name : string ,
75+ version : string ,
76+ gitHubRepo : string ,
77+ supportsWindowsOnArm : boolean ,
78+ release = `v${ version } ` ,
79+ ) {
7280 this . name = name
7381 this . version = version
7482 this . release = release
83+ this . supportsWindowsOnArm = supportsWindowsOnArm
7584
7685 let filename : string
7786 // add version to the filename
@@ -115,13 +124,15 @@ class Executable implements DownloadableBinary {
115124 }
116125
117126 const archPlatform = `${ arch } -${ platform } `
118- // These are currently the same between both binaries _coincidentally_.
119127 const supportedTargets = [ 'arm-linux' , 'arm-macos' , 'x86_64-macos' , 'x86_64-windows' , 'x86_64-linux' ]
128+ if ( this . supportsWindowsOnArm ) {
129+ supportedTargets . push ( 'arm-windows' )
130+ }
120131 if ( ! supportedTargets . includes ( archPlatform ) ) {
121132 throw Error ( `Unsupported platform/architecture combination ${ processPlatform } /${ processArch } ` )
122133 }
123134
124- return `https://github.com/${ this . gitHubRepo } /releases/download/${ this . release } /${ this . name } -${ archPlatform } -${ this . version } .gz`
135+ return `https://github.com/${ this . gitHubRepo } /releases/download/${ this . release } /${ this . name } -${ archPlatform } -v ${ this . version } .gz`
125136 }
126137
127138 async processResponse ( responseStream : PipelineSource < unknown > , outputStream : fs . WriteStream ) : Promise < void > {
@@ -135,13 +146,18 @@ class JavyPlugin implements DownloadableBinary {
135146 readonly path : string
136147
137148 constructor ( version : string ) {
138- this . name = `shopify_functions_javy_ ${ version } `
149+ this . name = `shopify_functions_javy_v ${ version } `
139150 this . version = version
140- this . path = joinPath ( dirname ( fileURLToPath ( import . meta. url ) ) , '..' , 'bin' , `shopify_functions_javy_${ version } .wasm` )
151+ this . path = joinPath (
152+ dirname ( fileURLToPath ( import . meta. url ) ) ,
153+ '..' ,
154+ 'bin' ,
155+ `shopify_functions_javy_v${ version } .wasm` ,
156+ )
141157 }
142158
143159 downloadUrl ( _processPlatform : string , _processArch : string ) {
144- return `https://cdn.shopify.com/shopifycloud/shopify-functions-javy-plugin/shopify_functions_javy_ ${ this . version } .wasm`
160+ return `https://cdn.shopify.com/shopifycloud/shopify-functions-javy-plugin/shopify_functions_javy_v ${ this . version } .wasm`
145161 }
146162
147163 async processResponse ( responseStream : PipelineSource < unknown > , outputStream : fs . WriteStream ) : Promise < void > {
@@ -172,15 +188,25 @@ class WasmOptExecutable implements DownloadableBinary {
172188let _wasmOpt : DownloadableBinary
173189
174190export function javyBinary ( version : string = PREFERRED_JAVY_VERSION ) {
175- return new Executable ( 'javy' , version , 'bytecodealliance/javy' ) as DownloadableBinary
191+ return new Executable (
192+ 'javy' ,
193+ version ,
194+ 'bytecodealliance/javy' ,
195+ versionSatisfies ( version , '>=7.0.0' ) ,
196+ ) as DownloadableBinary
176197}
177198
178199export function javyPluginBinary ( version : string = PREFERRED_JAVY_PLUGIN_VERSION ) {
179200 return new JavyPlugin ( version ) as DownloadableBinary
180201}
181202
182203export function functionRunnerBinary ( version : string = PREFERRED_FUNCTION_RUNNER_VERSION ) {
183- return new Executable ( 'function-runner' , version , 'Shopify/function-runner' ) as DownloadableBinary
204+ return new Executable (
205+ 'function-runner' ,
206+ version ,
207+ 'Shopify/function-runner' ,
208+ versionSatisfies ( version , '>=9.1.1' ) ,
209+ ) as DownloadableBinary
184210}
185211
186212export function wasmOptBinary ( ) {
@@ -196,7 +222,8 @@ export function trampolineBinary(version: string) {
196222 'shopify-function-trampoline' ,
197223 version ,
198224 'Shopify/shopify-function-wasm-api' ,
199- `shopify_function_trampoline/${ version } ` ,
225+ versionSatisfies ( version , '>=2.0.1' ) ,
226+ `shopify_function_trampoline/v${ version } ` ,
200227 )
201228}
202229
0 commit comments