Shopify / cli

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

[Bug]: theme pull --only Removing Files #4472

Closed jonathanmoore closed 1 month ago

jonathanmoore commented 1 month ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

Theme

Expected behavior

I have a script that pulls the latest template .json and config json files that I have used for over a year without any issues. shopify theme pull --live --store STORE-NAME --path theme --only templates/*.json config/settings_data.json --verbose

The expectation is that this will pull any changed template and config JSON files.

Actual behavior

The files are pulling as expected, however it has a side effect of removing some of the built asset/ js and css files.

2024-09-18T20:18:45.423Z: Ignoring theme file templates/password.liquid via --only...
2024-09-18T20:18:45.424Z: Ignoring theme file templates/product.gwp.liquid via --only...
2024-09-18T20:18:45.424Z: Ignoring theme file templates/search.liquid via --only...
2024-09-18T20:18:45.443Z: Removing file at theme/assets/main.ea786824.min.js...
2024-09-18T20:18:45.445Z: Removing file at theme/assets/theme.2e3e8879.min.css...

Verbose output

$ shopify theme pull --live --store STORE-NAME --path theme --only templates/**/*.json config/settings_data.json --verbose
2024-09-18T20:20:00.909Z: Running command theme pull
2024-09-18T20:20:00.919Z: Ensuring that the user is authenticated with the Theme API with the following scopes:
[]

2024-09-18T20:20:00.920Z: Ensuring that the user is authenticated with the Admin API with the following scopes for the store STORE-NAME.myshopify.com:
[]

2024-09-18T20:20:00.920Z: Getting session store...
2024-09-18T20:20:00.921Z: Validating existing session against the scopes:
[
  "openid",
  "https://api.shopify.com/auth/shop.admin.graphql",
  "https://api.shopify.com/auth/shop.admin.themes",
  "https://api.shopify.com/auth/partners.collaborator-relationships.readonly",
  "https://api.shopify.com/auth/shop.storefront-renderer.devtools",
  "https://api.shopify.com/auth/partners.app.cli.access",
  "https://api.shopify.com/auth/destinations.readonly"
]
For applications:
{
  "adminApi": {
    "scopes": [],
    "storeFqdn": "STORE-NAME.myshopify.com"
  }
}

2024-09-18T20:20:00.921Z: Sending Identity Introspection request to URL: https://accounts.shopify.com/oauth/introspection
2024-09-18T20:20:00.922Z: Sending POST request to URL https://accounts.shopify.com/oauth/introspection
With request headers:
 - User-Agent: Shopify CLI; v=3.67.0
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-09-18T20:20:01.147Z: Request to https://accounts.shopify.com/oauth/introspection completed in 225 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"84854360719bf25cee8f6b0d27fe25e9"
 - server-timing: processing;dur=41, socket_queue;dur=2.15, edge;dur=0.024, util;dur=0.1, cfRequestDuration;dur=89.999914
 - x-request-id: d6bc60ac-43fa-404b-97aa-2c82b08ac134-1726690801

2024-09-18T20:20:01.150Z: The identity token is valid: true
2024-09-18T20:20:01.150Z: 
The validation of the token for application/identity completed with the following results:
- It's expired: false
- It's invalid in identity: false

2024-09-18T20:20:01.151Z: Getting development theme...
2024-09-18T20:20:01.420Z: Request to https://STORE-NAME.myshopify.com/admin/api/unstable/themes/139597021241.json?fields=id%2Cname%2Crole%2Cprocessing completed in 267 ms
With response headers:
 - content-type: application/json; charset=utf-8
 - server-timing: processing;dur=58, cfRequestDuration;dur=171.999931, ipv6
 - x-request-id: cfe44bc4-4e54-4a57-8e48-2db69f67dd61-1726690801

2024-09-18T20:20:01.614Z: Request to https://STORE-NAME.myshopify.com/admin/api/unstable/themes.json?fields=id%2Cname%2Crole%2Cprocessing completed in 193 ms
With response headers:
 - content-type: application/json; charset=utf-8
 - server-timing: processing;dur=68, cfRequestDuration;dur=156.999826, ipv6
 - x-request-id: f88114fd-d4b1-4631-991d-101c3342f6b4-1726690801

2024-09-18T20:20:01.652Z: Reading the content of file at theme/assets/FoundersGroteskWeb-Bold.woff...
2024-09-18T20:20:01.652Z: Reading the content of file at theme/assets/FoundersGroteskWeb-Bold.woff2...
~~~SKIPPING OVER THE LONG LIST OF THEME FILES~~~
2024-09-18T20:20:01.673Z: Reading the content of file at theme/templates/customers/reset_password.liquid...
2024-09-18T20:20:01.852Z: Request to https://STORE-NAME.myshopify.com/admin/api/unstable/themes/139863719993/assets.json?fields=key%2Cchecksum completed in 224 ms
With response headers:
 - content-type: application/json; charset=utf-8
 - server-timing: processing;dur=82, cfRequestDuration;dur=171.000004, ipv6
 - x-request-id: cb4a2a52-1c87-4e5e-a34b-65f62bf4a37a-1726690801

2024-09-18T20:20:01.882Z: Ignoring theme file assets/a11y-patch.f12605d0.min.js via --only...
~~~SKIPPING OVER THE LONG LIST OF THEME FILES~~~
2024-09-18T20:20:01.901Z: Ignoring theme file templates/search.liquid via --only...
2024-09-18T20:20:01.918Z: Removing file at theme/assets/main.ea786824.min.js...
2024-09-18T20:20:01.920Z: Removing file at theme/assets/theme.2e3e8879.min.css...

╭─ success ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                      │
│  The theme 'store 5.0 - Direct Build' (#139863719993) has been pulled.                                                                               │
│                                                                                                                                                      │
│  Next steps                                                                                                                                          │
│    • View your theme [1]                                                                                                                             │
│    • Customize your theme at the theme editor [2]                                                                                                    │
│                                                                                                                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
[1] https://STORE-NAME.myshopify.com/?preview_theme_id=139863719993
[2] https://STORE-NAME.myshopify.com/admin/themes/139863719993/editor

2024-09-18T20:20:01.940Z: 
Running system process:
  · Command: npm prefix
  · Working directory: /Users/moore/Dev/store

2024-09-18T20:20:02.053Z: Obtaining the dependency manager in directory /Users/moore/Dev/store...
2024-09-18T20:20:02.151Z: 
Running system process:
  · Command: ruby -v
  · Working directory: /Users/moore/Dev/store

2024-09-18T20:20:02.372Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 174 ms
With response headers:
 - x-request-id: 9262136e-1d95-4bf4-b2d5-b45205dbe696

2024-09-18T20:20:02.373Z: Analytics event sent: {
  "command": "theme pull",
  "time_start": 1726690800910,
  "time_end": 1726690801935,
  "total_time": 1025,
  "success": true,
  "cli_version": "3.67.0",
  "ruby_version": "2.7.6",
  "node_version": "20.14.0",
  "is_employee": false,
  "uname": "darwin arm64",
  "env_ci": false,
  "env_plugin_installed_any_custom": true,
  "env_plugin_installed_shopify": "[\"@shopify/cli\"]",
  "env_shell": "zsh",
  "env_device_id": "0baefcaa9c4045d760bbe7b846bab3f972c1db6b",
  "env_cloud": "localhost",
  "env_package_manager": "bun",
  "env_is_global": true,
  "cmd_app_warning_api_key_deprecation_displayed": false,
  "cmd_all_timing_network_ms": 909,
  "cmd_all_timing_prompts_ms": 0,
  "cmd_all_launcher": "bun",
  "cmd_all_topic": "theme",
  "cmd_all_plugin": "@shopify/theme",
  "cmd_all_force": false,
  "cmd_all_verbose": true,
  "cmd_all_path_override": true,
  "cmd_all_path_override_hash": "3d1ea1dd5c000bc9209452ad525cf64de5f5a5a7",
  "cmd_all_timing_active_ms": 115,
  "cmd_all_exit": "ok",
  "args": "--live --store STORE-NAME --path theme --only templates/**/*.json config/settings_data.json --verbose",
  "env_plugin_installed_all": "[\"@shopify/cli\",\"shopify-livereload\"]",
  "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
}
2024-09-18T20:20:02.373Z: Completed command theme pull

Reproduction steps

  1. Using --only with theme pull has the side effect of removing unrelated files.

Operating System

Mac OS 14.5

Shopify CLI version (check your project's package.json if you're not sure)

3.67.0

Shell

zsh

Node version (run node -v if you're not sure)

20.14.0

What language and version are you using in your application?

No response

mgmanzella commented 1 month ago

👋 hey @jonathanmoore thanks for reporting this issue, we're taking a look but in the meantime can you add the --legacy flag to your command and let us know if that works as a workaround? thanks in advance

jonathanmoore commented 1 month ago

The legacy flag does work, and in this case adding --nodelete also works. Still I don't think the unrelated removal when using --only makes sense

CodeBrotha commented 1 month ago

Our team is also experiencing this issue. Reverting to 3.66.1 resolves it