Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Javy and function-runner download on Windows #4291

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smart-mugs-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': patch
---

Fix Javy and function-runner downloads on Windows
25 changes: 22 additions & 3 deletions packages/app/src/cli/services/function/binaries.test.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -200,4 +214,9 @@ describe('functionRunner', () => {
)
})
})

test('function-runner installs and runs', async () => {
await installBinary(functionRunner)
await exec(functionRunner.path, ['--help'])
})
})
3 changes: 2 additions & 1 deletion packages/app/src/cli/services/function/binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down