Add flag to allow —unpublished to reuse theme names #5309
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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:
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:
Checklist