Shopify / cli

Build apps, themes, and hydrogen storefronts for Shopify
https://shopify.dev
MIT License
383 stars 114 forks source link

Shopify theme list command to find exact match by theme name #4119

Open Jay-Plumb opened 3 weeks ago

Jay-Plumb commented 3 weeks ago

What area(s) will this request affect?

Theme

What type of change do you want to see?

New feature

Overview

Example shopify theme list --environment='development_eu' --name="dev" --json currently outputs:

[
  {
    "id": 138723655843,
    "name": "dev",
    "processing": false,
    "createdAtRuntime": false,
    "role": "unpublished"
  },
  {
    "id": 138723885219,
    "name": "dev",
    "processing": false,
    "createdAtRuntime": false,
    "role": "unpublished"
  },
  {
    "id": 138629152931,
    "name": "Development (a0ffa7-MacBook-Pro-2)",
    "processing": false,
    "createdAtRuntime": false,
    "role": "development"
  },
  {
    "id": 138680959139,
    "name": "Development (229622-Andrews-MacBook-Pro)",
    "processing": false,
    "createdAtRuntime": false,
    "role": "development"
  }
]

It would be nice to have a flag that looks for an exact match such that the output returns

[
    {
    "id": 138723655843,
    "name": "dev",
    "processing": false,
    "createdAtRuntime": false,
    "role": "unpublished"
  },
  {
    "id": 138723885219,
    "name": "dev",
    "processing": false,
    "createdAtRuntime": false,
    "role": "unpublished"
  },
]

Motivation

The above impacts our CI/CD pipeline to view preview links from main against dev due to the multiple matches from the list command above.

jamesmengo commented 1 week ago

Hey @Jay-Plumb

Could you clarify what you have in mind to determine whether to return 138723885219 or 138723655843 in the example you provided?

Would specifying the theme ID via the --theme flag, or using a unique name work for your use case?

Jay-Plumb commented 1 week ago

@jamesmengo In the above example there are two themes with the name "dev" so actually i would expect both ids you mentioned to be returned.

The issue is that --name="dev" returns themes with name dev and development so i'm looking for a flag that searches for an exact match for the theme name.

I have edited the example above as I can see it was confusing.

Would specifying the theme ID via the --theme flag, or using a unique name work for your use case?

Passing in an id would not be possible because I dynamically generate preview themes on the fly so I need a way to check whether I should create or update a preview theme. If a theme name matches I then use the theme id to then update the theme.

jamesmengo commented 1 week ago

Thanks for the suggestion! I'll share this with the team to see if this is something we have the bandwidth to build

Not sure about the specifics of your workflow, but an idea I have for the meantime is to avoid conflicts with your development theme by using a different namespace such as preview

I understand that the workaround is imperfect. Feel free to share more about your workflow as well if you'd like us to see if there are any other workarounds or existing features that could address your problem :)