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

Rework app info to use components #5170

Merged
merged 13 commits into from
Jan 13, 2025
Merged

Rework app info to use components #5170

merged 13 commits into from
Jan 13, 2025

Conversation

amcaplan
Copy link
Contributor

@amcaplan amcaplan commented Jan 8, 2025

WHY are these changes introduced?

  1. Replaces messy string generation code with orderly use of UI-kit.
  2. Hides the web section for extension-only apps.

WHAT is this pull request doing?

Instead of the mess of string generation, we reorganize the code to generate headers and data tables, then do the actual rendering in UI kit.

To make this work nicely, I added a new TabularData concept to UI kit, which does seem useful in general. It even has a parameter to dim the leftmost column, which I think creates a pleasant effect.

App with many extensions, before:

Screenshot 2025-01-08 at 13 31 56

And after:
Screenshot 2025-01-08 at 13 30 33

Extension-only app, before:
Screenshot 2025-01-08 at 13 44 12

And after:
Screenshot 2025-01-08 at 13 42 47

App with many errors, before:
Screenshot 2025-01-08 at 15 49 27

And after:
Screenshot 2025-01-08 at 15 50 10

How to test your changes?

Run shopify app info on various apps.

Measuring impact

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

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@amcaplan amcaplan force-pushed the app-info-rework branch 5 times, most recently from e4cc408 to 8144601 Compare January 9, 2025 12:17
Copy link
Contributor

github-actions bot commented Jan 9, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
75.04% (-0.14% 🔻)
8867/11817
🟡 Branches
70.12% (-0.2% 🔻)
4327/6171
🟡 Functions
74.97% (-0.12% 🔻)
2321/3096
🟡 Lines
75.59% (-0.14% 🔻)
8383/11090
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴
... / TabularData.tsx
12.5% 0% 0% 12.5%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / info.ts
81.44% (-6.74% 🔻)
60.94% (-2.52% 🔻)
90.32%
83.15% (-7.85% 🔻)
🟢
... / app-event-watcher.ts
93.83% (-1.23% 🔻)
86.49% (-2.7% 🔻)
90.48% 98.61%
🟢
... / Alert.tsx
100%
92% (-3.24% 🔻)
100% 100%
🟢
... / FatalError.tsx
100%
86.11% (-1.39% 🔻)
100% 100%

Test suite run success

2003 tests passing in 904 suites.

Report generated by 🧪jest coverage report action from 7df0f33

@amcaplan amcaplan force-pushed the app-info-rework branch 2 times, most recently from 3bf58a5 to 2d18f38 Compare January 9, 2025 14:27
@amcaplan amcaplan marked this pull request as ready for review January 9, 2025 15:32
@amcaplan amcaplan requested a review from a team as a code owner January 9, 2025 15:32

This comment has been minimized.

@amcaplan amcaplan requested a review from a team as a code owner January 9, 2025 15:51
Copy link
Contributor

@graygilmore graygilmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't speak to the introduction of a new component but this is such a massive improvement for apps – thank you!

this.tableSection(
'Current app configuration',
[
['Configuration file', {filePath: basename(this.app.configuration.path) || configurationFileNames.app}],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just flagging that the filePath token gets rendered pretty differently depending on your terminal colors. I don't mind that it's different but I wanted to point it out!

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very surprising! It's supposed to be italicized, I wonder what your settings are such that colors are inverted instead.

import {CLI_KIT_VERSION} from '@shopify/cli-kit/common/version'

type CustomSection = Exclude<Parameters<typeof renderInfo>[0]['customSections'], undefined>[number]
Copy link
Contributor

@isaacroldan isaacroldan Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment to clarify what this type represents? Asking because hovering on it in Cursor just says type CustomSection = CustomSection 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized we do already export the AlertCustomSection type so I'm just going to use that.

[' config file', relativePath(extension.directory, extension.configurationPath)],
const details: InlineToken[][] = [
[`📂 ${extension.handle || NOT_LOADED_TEXT}`, {filePath: relativePath(this.app.directory, extension.directory)}],
[' config file', {filePath: relativePath(extension.directory, extension.configurationPath)}],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably unnecessary, since the config file is always shopify.extension.toml.

Should we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is still valuable for consistency and for new users who are still learning how apps work.

{
body: [
'💡 To change these, run',
{command: formatPackageManagerCommand(this.app.packageManager, 'dev', '--reset')},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are modifying info, it's probably better to recommend running app config link.

Also, formatPackageManagerCommand expects a full global command as default, so this should be:

{command: formatPackageManagerCommand(this.app.packageManager, 'shopify app config link')},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to make the change and I think it's an improvement. But I have some thoughts about making this better in general, since now it won't really account for changing the dev store. Basically this was set up at a time when the CLI worked differently, and it needs a refresh.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree we need to rework that section 👌

@amcaplan amcaplan added this pull request to the merge queue Jan 13, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Jan 13, 2025
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

packages/cli-kit/dist/private/node/ui/components/TabularData.d.ts
import { InlineToken } from './TokenizedText.js';
import { FunctionComponent } from 'react';
export interface TabularDataProps {
    tabularData: InlineToken[][];
    firstColumnSubdued?: boolean;
}
declare const TabularData: FunctionComponent<TabularDataProps>;
export { TabularData };

Existing type declarations

packages/cli-kit/dist/private/node/ui/components/Alert.d.ts
@@ -1,9 +1,10 @@
 import { BannerType } from './Banner.js';
 import { BoldToken, InlineToken, LinkToken, TokenItem } from './TokenizedText.js';
+import { TabularDataProps } from './TabularData.js';
 import { FunctionComponent } from 'react';
 export interface CustomSection {
     title?: string;
-    body: TokenItem;
+    body: TabularDataProps | TokenItem;
 }
 export interface AlertProps {
     type: Exclude<BannerType, 'external_error'>;

@amcaplan amcaplan added this pull request to the merge queue Jan 13, 2025
Merged via the queue into main with commit 6391f7b Jan 13, 2025
27 checks passed
@amcaplan amcaplan deleted the app-info-rework branch January 13, 2025 18:03
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.

3 participants