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

Add flag to allow —unpublished to reuse theme names #5309

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeffreyguenther
Copy link

@jeffreyguenther jeffreyguenther commented Jan 29, 2025

Note

I have opened this PR early to allow for conversations on the flag name.

Also, it's my style to open PRs as soon as the first line is written so the work can be
done the open.

Will remove this line once the PR is set for review.

WHY are these changes introduced?

Fixes #2699

shopify theme push —theme <name> --unpublished

Repeated calls the above command generates multiple themes with identical names. If you're using theme names to map to git branches in CI, this causes a problem. You need an idempotent way to push themes.

We want something like:

shopify theme push --theme <name> —-unpublished --upsert

We want to retain the ability to push multiple themes with the same name as that mirrors the Online Store UI behaviour. Therefore, we add a flag to modify how --unpublished works in a similar manner to how --unpublished modifies how a basic push works.

WHAT is this pull request doing?

In this PR, I add a flag to optionally allow to --unpublished to update a theme if there is already one with the passed name. The flag is dependent on --unpublished so we should get the nice OCLIF errors if it's passed without --unpublished

Here's my rationale:

This command pushes to a theme named "Iteration", but the theme with that name must exist. If it doesn't, an error is output.

shopify theme push --theme "Iteration"

So we add the --unpublished flag, to allow us to create a new, unpublished theme with the passed name.

shopify theme push --theme "Iteration" --unpublished

Then, we want to provide more information to this push to reuse the theme with the matching name if it exists.

shopify theme push --theme "Iteration" --unpublished --upsert

How to test your changes?

Setup the project locally and run the following multiple times on a test store.

pnpm shopify theme push --theme fancy-branch-name --unpublished --upsert

You should only see a single instance of a theme named fancy-branch-name

Post-release steps

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

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.

[Feature]: Add flag to make theme push idempotent
1 participant