cli icon indicating copy to clipboard operation
cli copied to clipboard

[DNM] [LogStreaming Prototype] Add replay command

Open lopert opened this issue 1 year ago β€’ 5 comments

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

lopert avatar Mar 28 '24 15:03 lopert

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.

github-actions[bot] avatar Apr 28 '24 03:04 github-actions[bot]

Some activity to keep the PR open, will pick this up after ATC work this week.

lopert avatar Apr 29 '24 14:04 lopert

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

github-actions[bot] avatar May 06 '24 20:05 github-actions[bot]

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.

github-actions[bot] avatar May 10 '24 18:05 github-actions[bot]

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. πŸ€”

mssalemi avatar May 13 '24 13:05 mssalemi

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 main you might see odd diffs, rebase main into 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

github-actions[bot] avatar Jun 05 '24 20:06 github-actions[bot]