[DNM] [LogStreaming Prototype] Add replay command
WHY are these changes introduced?
Part of the LogStreaming Prototype project.
WHAT is this pull request doing?
- adds a new command
shopify app function replay, which:- reads a folder for run logs
- presents the list of runs in a selector
- parses the input from the selected run
- forwards the run to function-runner
How to test your changes?
- checkout this branch in your local CLI
- create a
/runs/folder under your app's extension - (for now) manually populate it with run logs.
- ex, for our 10% discount function, you can put this in a json file in that folder
{
"payload": {
"input":"{\"cart\":{\"lines\":[{\"quantity\":1,\"merchandise\":{\"__typename\":\"ProductVariant\",\"id\":\"gid:\\\/\\\/shopify\\\/ProductVariant\\\/1\"}}]}}",
"invocationId":"11111111-ed53-4377-b30f-14e8f4653cfe"
}
}
- create a few of these to have options in the selector
- run the following command from the CLI directory
pnpm run shopify app function replay --path=<path-to-your-ext>
ex:
pnpm run shopify app function replay --path=/Users/lopert/cli/lopert-cli-local/extensions/10-percent-off
This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. β If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.
Some activity to keep the PR open, will pick this up after ATC work this week.
Coverage report
St.:grey_question: |
Category | Percentage | Covered / Total |
|---|---|---|---|
| π‘ | Statements | 71.93% (+0.04% πΌ) |
7278/10118 |
| π‘ | Branches | 69.01% (-0.01% π») |
3572/5176 |
| π‘ | Functions | 71.6% (+0.06% πΌ) |
1946/2718 |
| π‘ | Lines | 73.23% (+0.09% πΌ) |
6854/9359 |
Show new covered files π£
St.:grey_question: |
File | Statements | Branches | Functions | Lines |
|---|---|---|---|---|---|
| π΄ | ... / replay.ts |
0% | 0% | 0% | 0% |
| π’ | ... / replay.ts |
100% | 100% | 100% | 100% |
| π’ | ... / replay.ts |
100% | 66.67% | 100% | 100% |
Test suite run success
1688 tests passing in 785 suites.
Report generated by π§ͺjest coverage report action from a5364d163725d820dbafd55a73c1e1981407dd26
We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset. If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.
Related to yarn dev, and probably something we can discuss at meeting later, but how do we think these files should get saved from the yarn dev? (I guess we depend on each other on these PR's). Just thinking on how I should be saving these logs to a write. βοΈ
Since there can be multiple function running, if we save all the runs the functions directory on invocation id, it might be confusing for developer to filter through that list. π€
Differences in type declarations
We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
- Some seemingly private modules might be re-exported through public modules.
- If the branch is behind
mainyou might see odd diffs, rebasemaininto this branch.
New type declarations
We found no new type declarations in this PR
Existing type declarations
packages/cli-kit/dist/public/node/logs.d.ts
@@ -1,3 +1,3 @@
-export declare const getLogsDir: string;
+export declare const getLogsDir: () => string;
export declare const createLogsDir: (path: string) => Promise<void>;
export declare const writeLog: (path: string, logData: string) => Promise<void>;
\ No newline at end of file