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

[Themes] - Refactor pull command to prepare for public themes API #4500

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jamesmengo
Copy link
Contributor

@jamesmengo jamesmengo commented Sep 20, 2024

WHY are these changes introduced?

Fixes https://github.com/Shopify/develop-advanced-edits/issues/341
Fixes https://github.com/Shopify/develop-advanced-edits/issues/342

Allows users to call pull programatically by providing the flags as arguments

WHAT is this pull request doing?

  1. Creates a service function pull which allows users to provide command flags as args
  2. Adds JSDoc to the public pull method args
  3. Splits the CLI2 logic (this is kept in the command layer)
  4. Adds some tests to the service layer

How to test your changes?

  • Hover over the call to pull in packages/theme/src/cli/commands/theme/pull.ts to see the Docs
  • Call shopify-dev theme pull with and without the --legacy flag. Everything should work as before

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
  • 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

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-inner-loop

Copy link
Contributor

github-actions bot commented Sep 20, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.09% (+0.01% 🔼)
8407/11502
🟡 Branches
69.59% (+0.02% 🔼)
4099/5890
🟡 Functions 71.87% 2184/3039
🟡 Lines
73.44% (+0.01% 🔼)
7955/10832

Test suite run success

1894 tests passing in 860 suites.

Report generated by 🧪jest coverage report action from c2bceec

@jamesmengo jamesmengo changed the title Jm/api [Themes] - Prepare pull command for public themes API Sep 20, 2024
@jamesmengo jamesmengo self-assigned this Sep 20, 2024
@jamesmengo jamesmengo marked this pull request as ready for review September 20, 2024 21:42
Copy link
Contributor

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.

@@ -34,6 +35,12 @@ const COMMANDS = {
'theme:share': Share,
}

const PUBLIC_COMMANDS = {
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've added these to a const here for now, but we're not consuming this in packages/cli/src/index.ts just yet.

Replacing the COMMANDS constant with these new public commands affects the oclif manifests for the CLI (it removes the commands from the base README and oclif.manifest.json.

I will look into this more deeply next week, but any leads are appreciated!

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you, @jamesmengo! The PR is on an excellent direction. I've left only one comment about the documentation in the public API :)


return
const pullFlags: PullFlags = {
path: flags.path,
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about adding the documentation in the properties here instead?

Something like this:

/**
 * The directory path to download the theme.
 */
path?: string

The benefit I notice is that users get docs for their properties:

And the documentation of functions gets a bit easier to digest:

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 like this idea!

@jamesmengo
Copy link
Contributor Author

@karreiro
Ready for another round!

  • Updated the JSDoc
  • Added back CLI2 invocations

I think we could consider making some of the arguments required, but I would like to spin my wheels on that and introduce those changes in a followup

@jamesmengo jamesmengo changed the title [Themes] - Prepare pull command for public themes API [Themes] - Refactor pull command to prepare for public themes API Sep 23, 2024
@@ -16,7 +21,116 @@ interface PullOptions {
ignore?: string[]
}

export async function pull(theme: Theme, session: AdminSession, options: PullOptions) {
export interface PullFlags {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update tests

Move + fix CLI2 tests

Remove pull command test

Remove CLI2 Invocation + Tests

Remove legacy flag

Add JSDoc to pull export

Export public pull service from themes package

Revert change to theme-command
Re-arrange + export ThemeCommand helpers
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.

2 participants