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

[Theme] Theme Uploader: Silence Output when JSON flag is provided #3763

Closed
wants to merge 1 commit into from

Conversation

jamesmengo
Copy link
Contributor

@jamesmengo jamesmengo commented Apr 19, 2024

WHY are these changes introduced?

Addresses some of the issues raised in #3734 by silencing progress bar output to stdout when the --json flag is provided to theme push. This does not 'solve' our problems, but will at least prevent stdout from getting polluted until we can give this some TLC

  • Currently, stdout is getting polluted because there's no way to silence the progress bar (and the progress bar is writing to stdout)
  • All messages should log to stderr imo, but to bring us to parity with the ruby implementation first I'm using a silent stream

WHAT is this pull request doing?

  • This provides a way to silence the progress bar renderTasks from cli-kit by overriding the WriteableStream we use when calling renderTasks

How to test your changes?

Try running
pnpm shopify theme push --path <theme_path> --json -> you should only see the final json output

OR

pnpm shopify theme push --path <theme_path> --json | jq .
pnpm shopify theme push --path <theme_path> --json 1> stdout.txt

Note: Don't test with the --verbose flag - outputDebug writes everything stdout (for now).

Measuring impact

How do we know this change was effective? Please choose one:

  • [ x] n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've made sure that any changes to dev or deploy have been reflected in the internal flowchart.

Copy link
Contributor

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-management

Copy link
Contributor

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/ui.d.ts
@@ -324,6 +324,7 @@ interface RenderTableOptions<T extends ScalarDict> extends TableProps<T> {
 export declare function renderTable<T extends ScalarDict>({ renderOptions, ...props }: RenderTableOptions<T>): string | undefined;
 interface RenderTasksOptions {
     renderOptions?: RenderOptions;
+    silent?: boolean;
 }
 /**
  * Runs async tasks and displays their progress to the console.
@@ -331,7 +332,7 @@ interface RenderTasksOptions {
  * ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  * Installing dependencies ...
  */
-export declare function renderTasks<TContext>(tasks: Task<TContext>[], { renderOptions }?: RenderTasksOptions): Promise<TContext>;
+export declare function renderTasks<TContext>(tasks: Task<TContext>[], { renderOptions, silent }?: RenderTasksOptions): Promise<TContext>;
 export interface RenderTextPromptOptions extends Omit<TextPromptProps, 'onSubmit'> {
     renderOptions?: RenderOptions;
 }

@jamesmengo jamesmengo changed the title [Demo] Create a silentwritesteram to silence task rendering output [Demo] Create a silent writesteram for stdout to silence task rendering output Apr 19, 2024
@jamesmengo jamesmengo changed the title [Demo] Create a silent writesteram for stdout to silence task rendering output [Demo] Create a silent writestream for stdout to silence task rendering output Apr 19, 2024
Copy link
Contributor

github-actions bot commented Apr 19, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
71.99% (-0.05% 🔻)
6977/9691
🟡 Branches
69.02% (+0.03% 🔼)
3442/4987
🟡 Functions
71.21% (-0.08% 🔻)
1855/2605
🟡 Lines
73.3% (-0.07% 🔻)
6581/8978
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / specification.ts
100%
93.75% (-0.37% 🔻)
100% 100%
🟢
... / utilities.ts
97.44% (-0.06% 🔻)
84.62% (+4.62% 🔼)
80%
97.44% (-0.06% 🔻)
🟡
... / generate.ts
66.13% (-1.06% 🔻)
58.54% (+2.72% 🔼)
50%
70.18% (-1.01% 🔻)

Test suite run success

1656 tests passing in 765 suites.

Report generated by 🧪jest coverage report action from 954bef7

@jamesmengo jamesmengo force-pushed the jmeng/silentwritestream branch from 9f409d9 to b1da097 Compare April 19, 2024 23:35
@jamesmengo jamesmengo changed the title [Demo] Create a silent writestream for stdout to silence task rendering output [Theme] Theme Uploader: Silence Output when JSON flag is provided Apr 19, 2024
@jamesmengo jamesmengo force-pushed the jmeng/silentwritestream branch from b1da097 to 0efa292 Compare April 19, 2024 23:52
@jamesmengo jamesmengo force-pushed the jmeng/silentwritestream branch from 0efa292 to 954bef7 Compare April 20, 2024 00:49
@jamesmengo jamesmengo closed this Apr 24, 2024
@jamesmengo jamesmengo deleted the jmeng/silentwritestream branch May 2, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant