Shopify / cli

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

[Feature]: Ignore globs from .gitignore when looking for `shopify.web.toml` #3702

Closed bradylill closed 5 hours ago

bradylill commented 4 months ago

What area(s) will this request affect?

Deployment

What type of change do you want to see?

New feature

Overview

I'm currently using sst.dev to deploy some of my infrastructure to support our Shopify app. I notice that sst will copy the shopify.web.toml file multiple time to it's local cache directory located at .sst/.

After a sst deploy if I run shopify app deploy it will throw an error saying "You can only have one web with the backend role in your app"

On further inspection I noticed that the function loadWebs will automatically look for any shopify.web.toml file. If I look at the value of webTomlPaths in that function I can see it found the following paths:

It would be nice if there was a way to have the contents of .gitignore added to webConfigGlobs so that it would ignore any other cases like this. Personally I would always want it to use .gitignore but I imagine there are cases where someone would want that to be configurable.

This might also be classified as a bug, but I figured it was a bit of an edge case.

I'm also happy to open a PR around this if it's something ya'll deem useful. My workaround at the moment is to force delete the .sst directory before running shopify app deploy in our ci/cd pipeline.

Motivation

I was running into this issue when trying to run shopify app deploy while also working with sst.dev. Figured it would be something that others might run into.

shauns commented 4 months ago

You could also workaround by putting your web.toml in a specific directory and setting web_directories accordingly

A PR would be very welcome! I'm not sure about loading from .gitignore by default -- that would be a change that might break some unusual existing workflows. Maybe we could make web_directories smarter -- if an option starts with a ! include it in the negation list (we already do some of this to avoid loading from node_modules for instance).

thenbe commented 4 months ago

This is also an issue when using direnv.

$ shopify app info
CURRENT APP CONFIGURATION

💡 To change these, run `dev --reset`

YOUR PROJECT
Root location   /home/nbe/projects/playground/d-shopifie-2

DIRECTORY COMPONENTS
web
📂 web
    📂 remix (frontend,backend)
    📂 remix (frontend,backend)   .direnv/flake-inputs/bwwr59ppz8ibh1r0dvazdy6j7cbywsyc-source
! You can only have one web with the frontend role in your app

Extensions with errors

TOOLING AND SYSTEM
Shopify CLI       3.59.1
Package manager   pnpm
OS                linux-amd64
Shell             /run/current-system/sw/bin/zsh

Workaround

Here's a workaround:

# file: shopify.app.*.toml

# default value: https://github.com/Shopify/cli/blob/f12748a53845efd9ba58595912d455a3aafa0890/packages/app/src/cli/models/app/loader.ts#L365
- web_directories = ["**"]
# amended value (only looks for a shopify.web.toml in the current directory): https://shopify.dev/docs/apps/structure#configuration
+ web_directories = ["."]
github-actions[bot] commented 3 months ago

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.

thenbe commented 3 months ago

still relevant

github-actions[bot] commented 1 month ago

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.

thenbe commented 1 month ago

still relevant

github-actions[bot] commented 1 week ago

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.