From 09386a083ce8773e320d0dfb4522c80130a6b42b Mon Sep 17 00:00:00 2001 From: Jeff Charles Date: Tue, 6 Aug 2024 11:50:18 -0400 Subject: [PATCH 1/2] Ensure javy and function-runner binaries have exe extension on Windows --- .../cli/services/function/binaries.test.ts | 25 ++++++++++++++++--- .../app/src/cli/services/function/binaries.ts | 3 ++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/app/src/cli/services/function/binaries.test.ts b/packages/app/src/cli/services/function/binaries.test.ts index 98947b4d7e2..21371920c47 100644 --- a/packages/app/src/cli/services/function/binaries.test.ts +++ b/packages/app/src/cli/services/function/binaries.test.ts @@ -1,4 +1,5 @@ -import {javyBinary, functionRunnerBinary} from './binaries.js' +import {javyBinary, functionRunnerBinary, installBinary} from './binaries.js' +import {exec} from '@shopify/cli-kit/node/system' import {describe, expect, test} from 'vitest' const javy = javyBinary() @@ -8,7 +9,11 @@ describe('javy', () => { test('properties are set correctly', () => { expect(javy.name).toBe('javy') expect(javy.version).match(/^v\d\.\d\.\d$/) - expect(javy.path).toMatch(/(\/|\\)javy$/) + if (process.platform === 'win32') { + expect(javy.path).toMatch(/(\/|\\)javy.exe$/) + } else { + expect(javy.path).toMatch(/(\/|\\)javy$/) + } }) describe('downloadUrl returns the correct URL', () => { @@ -101,13 +106,22 @@ describe('javy', () => { ) }) }) + + test('Javy installs and runs', async () => { + await installBinary(javy) + await exec(javy.path, ['--help']) + }) }) describe('functionRunner', () => { test('properties are set correctly', () => { expect(functionRunner.name).toBe('function-runner') expect(functionRunner.version).match(/^v\d\.\d\.\d$/) - expect(functionRunner.path).toMatch(/(\/|\\)function-runner$/) + if (process.platform === 'win32') { + expect(functionRunner.path).toMatch(/(\/|\\)function-runner.exe$/) + } else { + expect(functionRunner.path).toMatch(/(\/|\\)function-runner$/) + } }) describe('downloadUrl returns the correct URL', () => { @@ -200,4 +214,9 @@ describe('functionRunner', () => { ) }) }) + + test('function-runner installs and runs', async () => { + await installBinary(functionRunner) + await exec(functionRunner.path, ['--help']) + }) }) diff --git a/packages/app/src/cli/services/function/binaries.ts b/packages/app/src/cli/services/function/binaries.ts index bfda83434cf..267103e7822 100644 --- a/packages/app/src/cli/services/function/binaries.ts +++ b/packages/app/src/cli/services/function/binaries.ts @@ -22,7 +22,8 @@ class DownloadableBinary { constructor(name: string, version: string, gitHubRepo: string) { this.name = name this.version = version - this.path = joinPath(dirname(fileURLToPath(import.meta.url)), '..', 'bin', `${this.name}`) + const filename = process.platform === 'win32' ? `${name}.exe` : name + this.path = joinPath(dirname(fileURLToPath(import.meta.url)), '..', 'bin', filename) this.gitHubRepo = gitHubRepo } From 8fa8542e165d97aece0610b4a1f92dc3c8dd0ab3 Mon Sep 17 00:00:00 2001 From: Jeff Charles Date: Wed, 7 Aug 2024 16:32:42 -0400 Subject: [PATCH 2/2] Add changeset file --- .changeset/smart-mugs-love.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/smart-mugs-love.md diff --git a/.changeset/smart-mugs-love.md b/.changeset/smart-mugs-love.md new file mode 100644 index 00000000000..bca9da9b4cd --- /dev/null +++ b/.changeset/smart-mugs-love.md @@ -0,0 +1,5 @@ +--- +'@shopify/app': patch +--- + +Fix Javy and function-runner downloads on Windows