Skip to content

Commit ab42fa4

Browse files
graygilmoreclaude
andcommitted
Add glob pattern support for --environment flag
Theme users with many similarly-named environments (e.g. us-production, eu-production, int-production) currently must specify each one individually with -e. This adds glob pattern support so they can use patterns like --environment "*-production" to target multiple environments at once. The implementation expands glob patterns at a single point in base-command's resultWithEnvironment(), before the single/multi environment routing logic. This avoids needing downstream consumers like theme-command to handle expansion themselves. Key design decisions: - Uses minimatch (already a dependency) for pattern matching - Extracts shared TOML parsing into private decodeEnvironments() to avoid duplication between loadEnvironment() and the new getEnvironmentNames() - Expansion happens early so originalResult.flags.environment gets real names, not glob patterns - Deduplicates across multiple patterns via Set - Warns per-pattern when no environments match Closes https://github.com/Shopify/cli/issues/6481 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 15e2bcd commit ab42fa4

25 files changed

+425
-86
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@shopify/cli-kit': patch
3+
'@shopify/theme': patch
4+
---
5+
6+
Add glob pattern support for the `--environment` flag. You can now use patterns
7+
like `--environment "*-production"` to target multiple environments at once.
8+
Wrap glob patterns in quotes to prevent shell expansion.

docs-shopify.dev/commands/interfaces/theme-check.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface themecheck {
1616
'-C, --config <value>'?: string
1717

1818
/**
19-
* The environment to apply to the current command.
19+
* The environment to apply to the current command. Supports glob patterns (e.g. "*-production"). Wrap the value in double quotes if you're using wildcards.
2020
* @environment SHOPIFY_FLAG_ENVIRONMENT
2121
*/
2222
'-e, --environment <value>'?: string

docs-shopify.dev/commands/interfaces/theme-console.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This is an autogenerated file. Don't edit this file manually.
22
export interface themeconsole {
33
/**
4-
* The environment to apply to the current command.
4+
* The environment to apply to the current command. Supports glob patterns (e.g. "*-production"). Wrap the value in double quotes if you're using wildcards.
55
* @environment SHOPIFY_FLAG_ENVIRONMENT
66
*/
77
'-e, --environment <value>'?: string

docs-shopify.dev/commands/interfaces/theme-delete.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface themedelete {
77
'-d, --development'?: ''
88

99
/**
10-
* The environment to apply to the current command.
10+
* The environment to apply to the current command. Supports glob patterns (e.g. "*-production"). Wrap the value in double quotes if you're using wildcards.
1111
* @environment SHOPIFY_FLAG_ENVIRONMENT
1212
*/
1313
'-e, --environment <value>'?: string

docs-shopify.dev/commands/interfaces/theme-dev.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface themedev {
77
'-a, --allow-live'?: ''
88

99
/**
10-
* The environment to apply to the current command.
10+
* The environment to apply to the current command. Supports glob patterns (e.g. "*-production"). Wrap the value in double quotes if you're using wildcards.
1111
* @environment SHOPIFY_FLAG_ENVIRONMENT
1212
*/
1313
'-e, --environment <value>'?: string

docs-shopify.dev/commands/interfaces/theme-duplicate.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This is an autogenerated file. Don't edit this file manually.
22
export interface themeduplicate {
33
/**
4-
* The environment to apply to the current command.
4+
* The environment to apply to the current command. Supports glob patterns (e.g. "*-production"). Wrap the value in double quotes if you're using wildcards.
55
* @environment SHOPIFY_FLAG_ENVIRONMENT
66
*/
77
'-e, --environment <value>'?: string

docs-shopify.dev/commands/interfaces/theme-info.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface themeinfo {
77
'-d, --development'?: ''
88

99
/**
10-
* The environment to apply to the current command.
10+
* The environment to apply to the current command. Supports glob patterns (e.g. "*-production"). Wrap the value in double quotes if you're using wildcards.
1111
* @environment SHOPIFY_FLAG_ENVIRONMENT
1212
*/
1313
'-e, --environment <value>'?: string

docs-shopify.dev/commands/interfaces/theme-list.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This is an autogenerated file. Don't edit this file manually.
22
export interface themelist {
33
/**
4-
* The environment to apply to the current command.
4+
* The environment to apply to the current command. Supports glob patterns (e.g. "*-production"). Wrap the value in double quotes if you're using wildcards.
55
* @environment SHOPIFY_FLAG_ENVIRONMENT
66
*/
77
'-e, --environment <value>'?: string

docs-shopify.dev/commands/interfaces/theme-metafields-pull.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This is an autogenerated file. Don't edit this file manually.
22
export interface thememetafieldspull {
33
/**
4-
* The environment to apply to the current command.
4+
* The environment to apply to the current command. Supports glob patterns (e.g. "*-production"). Wrap the value in double quotes if you're using wildcards.
55
* @environment SHOPIFY_FLAG_ENVIRONMENT
66
*/
77
'-e, --environment <value>'?: string

docs-shopify.dev/commands/interfaces/theme-open.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface themeopen {
1313
'-E, --editor'?: ''
1414

1515
/**
16-
* The environment to apply to the current command.
16+
* The environment to apply to the current command. Supports glob patterns (e.g. "*-production"). Wrap the value in double quotes if you're using wildcards.
1717
* @environment SHOPIFY_FLAG_ENVIRONMENT
1818
*/
1919
'-e, --environment <value>'?: string

0 commit comments

Comments
 (0)