Skip to content

Commit

Permalink
Merge pull request #5028 from Shopify/fix-function-drafts
Browse files Browse the repository at this point in the history
Fix function drafts
  • Loading branch information
isaacroldan authored Dec 5, 2024
2 parents 673a588 + d248695 commit 2926cb0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/app/src/cli/services/dev/update-extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('updateExtensionDraft()', () => {
const content = 'test content'
const base64Content = Buffer.from(content).toString('base64')
await mkdir(joinPath(mockExtension.directory, 'dist'))
const outputPath = mockExtension.getOutputPathForDirectory(tmpDir)
const outputPath = mockExtension.outputPath
await mkdir(dirname(outputPath))
await writeFile(outputPath, content)

Expand Down
6 changes: 4 additions & 2 deletions packages/app/src/cli/services/dev/update-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ export async function updateExtensionDraft({
// When updating just the theme extension draft, upload the files as part of the config.
config = await themeExtensionConfig(extension)
} else {
config = (await extension.deployConfig({apiKey, appConfiguration})) || {}
config = (await extension.deployConfig({apiKey, appConfiguration})) ?? {}
}

const draftableConfig: {[key: string]: unknown} = {
...config,
serialized_script: encodedFile,
}
if (extension.isFunctionExtension) {
const compiledFiles = await readFile(outputPath, {encoding: 'base64'})
// For function drafts we need to use the `extension.outputPath` instead of `bundlePath`
// The wasm in the bundle path is encoded in base64.
const compiledFiles = await readFile(extension.outputPath, {encoding: 'base64'})
draftableConfig.uploaded_files = {'dist/index.wasm': compiledFiles}
}
const extensionInput: ExtensionUpdateDraftMutationVariables = {
Expand Down

0 comments on commit 2926cb0

Please sign in to comment.