-
Couldn't load subscription status.
- Fork 0
Reworking runFunction to invoke function-runner directly #30
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
base: main
Are you sure you want to change the base?
Conversation
614cc17 to
10ab8bf
Compare
10ab8bf to
fe12442
Compare
| @@ -0,0 +1,24 @@ | |||
| { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just renamed this file, I dont know why it doesn't show as a rename.
…or the discount test function
857c853 to
711d863
Compare
| @@ -1,8 +1,7 @@ | |||
| { | |||
| "shopId": 55479926983, | |||
| "apiClientId": 282965573633, | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned up this test fixture and moved the target up for better visibility now that we have 2 discount fixtures corresponding to different discount targets.
| let functionInfoJson; | ||
| try { | ||
| functionInfoJson = execSync( | ||
| `shopify app function info --json --path ${functionDir}`, | ||
| { | ||
| encoding: 'utf-8' | ||
| } | ||
| ); | ||
| } catch (error) { | ||
| // Check if the error is due to the command not being found | ||
| if (error.message.includes('Command app function info not found')) { | ||
| throw new Error( | ||
| 'The "shopify app function info" command is not available in your CLI version.\n' + | ||
| 'Please upgrade to the latest version:\n' + | ||
| ' npm install -g @shopify/cli@latest\n\n' | ||
| ); | ||
| } | ||
| throw error; | ||
| } | ||
|
|
||
| const functionInfo = JSON.parse(functionInfoJson); | ||
| schemaPath = functionInfo.schemaPath; | ||
| functionRunnerPath = functionInfo.functionRunnerPath; | ||
| wasmPath = functionInfo.wasmPath; | ||
| targeting = functionInfo.targeting; | ||
|
|
||
| schema = await loadSchema(schemaPath); | ||
| inputQueryAST = await loadInputQuery(inputQueryPath); | ||
| }, 20000); // 20 second timeout for building the function | ||
| }, 20000); // 20 second timeout for building and obtaining information about the function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put this into a helper method? loadFunctionInfo / getFunctionDetails or something?
That way the test wouldn't need to handle the try/error or perform the execSync directly.
Somewhat related; I like keeping getInfo and runFunction separate, since it gives the user of an older version of the CLI the flexibiltyy of just providing the details manually if they want. (probably not a use case we actually want to support, but it's nice to have imo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes can make it a helper.
I thought in the meeting we decided we are mandating a CLI upgrade and this would be the only way of doing things.
Fixes https://github.com/shop/issues-shopifyvm/issues/697
Created a new CLI command
shopify function app infohere.This PR runs this new command to obtain all the required and necessary info to invoke the function-runner directly in
runFunction.