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

[Feature]: Theme command to load the default environment #4692

Open
cesarho opened this issue Oct 19, 2024 · 2 comments
Open

[Feature]: Theme command to load the default environment #4692

cesarho opened this issue Oct 19, 2024 · 2 comments
Labels
Area: @shopify/theme @shopify/theme package issues open for contributions theme bugs that won't be prioritized in the near future Type: Enhancement New feature or request

Comments

@cesarho
Copy link

cesarho commented Oct 19, 2024

What area(s) will this request affect?

Theme

What type of change do you want to see?

New feature

Overview

The Shopify CLI already supports environment settings through shopify.theme.toml. I propose a small tweak to improve the default behavior by automatically loading the default environment if it is available.

Proposed Change
Modify the default behavior of shopify theme related command to load the environment configuration by default. Specifically:

  • When a developer runs shopify theme dev, the CLI would effectively execute shopify theme dev -e default in the background.
  • If the developer has created a shopify.theme.toml file with the default store settings, the command will automatically load these settings.
  • If the shopify.theme.toml file doesn’t exist or doesn't contain default environment, the CLI would continue to work as it currently does —without any breaking changes.

Example Configuration

[environments.default]
store = "abc.myshopify.com"

With this change, developers could avoid unexpected deployment issues and simplify their workflow, particularly when switching between different stores.

How do you feel about this feature enhancement? If this makes sense, I’d be happy to go ahead and raise a PR to implement it.

Motivation

Currently, the Shopify CLI remembers the last store that was worked on and keeps this stored for future sessions. However, this behavior can lead to unexpected issues: when a developer switches to another project folder and runs shopify theme dev, the CLI mistakenly uploads files to the previous working store instead of the intended one. This can cause significant, unintended trouble, especially if the developer is unaware of this stored preference.

Although there are alternatives, such as setting the environment variable manually or writing scripts to ensure the correct store information is set, I believe the CLI could handle this more seamlessly by improving the default behavior. A solution that prevents accidental deployment to the wrong store would benefit everyone and make the experience smoother and safer for all users.

@cesarho cesarho added the Type: Enhancement New feature or request label Oct 19, 2024
@cesarho cesarho changed the title [Feature]: Theme command load a default environment [Feature]: Theme command to load the default environment Oct 19, 2024
@karreiro karreiro added Area: @shopify/theme @shopify/theme package issues open for contributions theme bugs that won't be prioritized in the near future labels Oct 21, 2024
@karreiro
Copy link
Contributor

karreiro commented Oct 21, 2024

@jamesmengo @graygilmore I believe this issue illustrates well how Shopify CLI aims to support multiple-store development (mentioning this, because I've noticed you're investigating #3509).

@jamesmengo
Copy link
Contributor

You can set SHOPIFY_FLAG_ENVIRONMENT in your shell config and overriding that with the -e flag as needed.
Let me know how that works out for you!

Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: @shopify/theme @shopify/theme package issues open for contributions theme bugs that won't be prioritized in the near future Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants