shopify-cli 2.24.0 → 2.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +1 -1
  5. data/dev.yml +0 -3
  6. data/lib/project_types/extension/commands/serve.rb +57 -3
  7. data/lib/project_types/extension/extension_project.rb +8 -1
  8. data/lib/project_types/extension/loaders/project.rb +3 -2
  9. data/lib/project_types/extension/messages/messages.rb +21 -6
  10. data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
  11. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +18 -6
  12. data/lib/project_types/script/cli.rb +0 -79
  13. data/lib/project_types/script/commands/connect.rb +3 -8
  14. data/lib/project_types/script/commands/create.rb +4 -29
  15. data/lib/project_types/script/commands/javy.rb +3 -8
  16. data/lib/project_types/script/commands/push.rb +4 -41
  17. data/lib/project_types/script/messages/messages.rb +1 -258
  18. data/lib/project_types/theme/commands/common/shop_helper.rb +13 -0
  19. data/lib/project_types/theme/commands/delete.rb +4 -1
  20. data/lib/project_types/theme/commands/list.rb +3 -4
  21. data/lib/project_types/theme/commands/open.rb +4 -1
  22. data/lib/project_types/theme/commands/publish.rb +4 -1
  23. data/lib/project_types/theme/commands/pull.rb +3 -1
  24. data/lib/project_types/theme/commands/push.rb +3 -1
  25. data/lib/project_types/theme/commands/serve.rb +15 -3
  26. data/lib/project_types/theme/messages/messages.rb +9 -7
  27. data/lib/shopify_cli/commands/logout.rb +13 -2
  28. data/lib/shopify_cli/environment.rb +1 -1
  29. data/lib/shopify_cli/file_system_listener.rb +30 -0
  30. data/lib/shopify_cli/git.rb +116 -33
  31. data/lib/shopify_cli/identity_auth.rb +1 -0
  32. data/lib/shopify_cli/messages/messages.rb +1 -1
  33. data/lib/shopify_cli/packager.rb +12 -3
  34. data/lib/shopify_cli/project.rb +1 -1
  35. data/lib/shopify_cli/release.rb +4 -2
  36. data/lib/shopify_cli/tasks/ensure_project_type.rb +3 -1
  37. data/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +1 -1
  38. data/lib/shopify_cli/theme/dev_server/certificate_manager.rb +1 -1
  39. data/lib/shopify_cli/theme/dev_server/errors.rb +9 -0
  40. data/lib/shopify_cli/theme/dev_server/header_hash.rb +1 -1
  41. data/lib/shopify_cli/theme/dev_server/hooks/file_change_hook.rb +77 -0
  42. data/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_deleter.rb +1 -1
  43. data/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb +1 -1
  44. data/lib/shopify_cli/theme/dev_server/{hot-reload-no-script.html → hot_reload/resources/hot-reload-no-script.html} +0 -0
  45. data/lib/shopify_cli/theme/dev_server/hot_reload/resources/hot_reload.js +48 -0
  46. data/lib/shopify_cli/theme/dev_server/hot_reload/resources/sse_client.js +43 -0
  47. data/lib/shopify_cli/theme/dev_server/hot_reload/resources/theme.js +114 -0
  48. data/lib/shopify_cli/theme/dev_server/hot_reload/resources/theme_extension.js +121 -0
  49. data/lib/shopify_cli/theme/dev_server/hot_reload/script_injector.rb +57 -0
  50. data/lib/shopify_cli/theme/dev_server/hot_reload/sections_index.rb +1 -1
  51. data/lib/shopify_cli/theme/dev_server/hot_reload.rb +8 -76
  52. data/lib/shopify_cli/theme/dev_server/local_assets.rb +28 -28
  53. data/lib/shopify_cli/theme/dev_server/proxy.rb +33 -25
  54. data/lib/shopify_cli/theme/dev_server/proxy_param_builder.rb +82 -0
  55. data/lib/shopify_cli/theme/dev_server/reload_mode.rb +1 -1
  56. data/lib/shopify_cli/theme/dev_server/remote_watcher/json_files_update_job.rb +1 -1
  57. data/lib/shopify_cli/theme/dev_server/remote_watcher.rb +1 -1
  58. data/lib/shopify_cli/theme/dev_server/sse.rb +1 -1
  59. data/lib/shopify_cli/theme/dev_server/watcher.rb +8 -9
  60. data/lib/shopify_cli/theme/dev_server/web_server.rb +1 -1
  61. data/lib/shopify_cli/theme/dev_server.rb +287 -99
  62. data/lib/shopify_cli/theme/extension/app_extension.rb +40 -0
  63. data/lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb +68 -0
  64. data/lib/shopify_cli/theme/extension/dev_server/hot_reload/script_injector.rb +30 -0
  65. data/lib/shopify_cli/theme/extension/dev_server/hot_reload.rb +13 -0
  66. data/lib/shopify_cli/theme/extension/dev_server/local_assets.rb +30 -0
  67. data/lib/shopify_cli/theme/{dev_server/proxy/template_param_builder.rb → extension/dev_server/proxy_param_builder.rb} +26 -16
  68. data/lib/shopify_cli/theme/extension/dev_server/watcher.rb +47 -0
  69. data/lib/shopify_cli/theme/extension/dev_server.rb +150 -0
  70. data/lib/shopify_cli/theme/extension/host_theme.rb +104 -0
  71. data/lib/shopify_cli/theme/extension/syncer/extension_serve_job.rb +133 -0
  72. data/lib/shopify_cli/theme/extension/syncer/operation.rb +21 -0
  73. data/lib/shopify_cli/theme/extension/syncer.rb +81 -0
  74. data/lib/shopify_cli/theme/extension/ui/host_theme_progress_bar.rb +35 -0
  75. data/lib/shopify_cli/theme/ignore_helper.rb +31 -0
  76. data/lib/shopify_cli/theme/root.rb +62 -0
  77. data/lib/shopify_cli/theme/syncer.rb +12 -6
  78. data/lib/shopify_cli/theme/theme.rb +10 -52
  79. data/lib/shopify_cli/version.rb +1 -1
  80. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +1 -1
  81. metadata +28 -53
  82. data/.github/workflows/triage.yml +0 -22
  83. data/lib/project_types/script/config/extension_points.yml +0 -45
  84. data/lib/project_types/script/errors.rb +0 -10
  85. data/lib/project_types/script/forms/ask_app.rb +0 -27
  86. data/lib/project_types/script/forms/ask_org.rb +0 -30
  87. data/lib/project_types/script/forms/ask_script_uuid.rb +0 -22
  88. data/lib/project_types/script/forms/create.rb +0 -33
  89. data/lib/project_types/script/forms/run_against_shopify_org.rb +0 -14
  90. data/lib/project_types/script/graphql/app_script_set.graphql +0 -46
  91. data/lib/project_types/script/graphql/get_app_scripts.graphql +0 -6
  92. data/lib/project_types/script/graphql/module_upload_url_generate.graphql +0 -13
  93. data/lib/project_types/script/graphql/script_service_proxy.graphql +0 -7
  94. data/lib/project_types/script/layers/application/build_script.rb +0 -25
  95. data/lib/project_types/script/layers/application/connect_app.rb +0 -86
  96. data/lib/project_types/script/layers/application/create_script.rb +0 -90
  97. data/lib/project_types/script/layers/application/extension_points.rb +0 -66
  98. data/lib/project_types/script/layers/application/project_dependencies.rb +0 -26
  99. data/lib/project_types/script/layers/application/push_script.rb +0 -74
  100. data/lib/project_types/script/layers/domain/app_bridge.rb +0 -16
  101. data/lib/project_types/script/layers/domain/errors.rb +0 -47
  102. data/lib/project_types/script/layers/domain/extension_point.rb +0 -81
  103. data/lib/project_types/script/layers/domain/metadata.rb +0 -46
  104. data/lib/project_types/script/layers/domain/push_package.rb +0 -41
  105. data/lib/project_types/script/layers/domain/script_config.rb +0 -32
  106. data/lib/project_types/script/layers/domain/script_project.rb +0 -61
  107. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -53
  108. data/lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb +0 -35
  109. data/lib/project_types/script/layers/infrastructure/command_runner.rb +0 -19
  110. data/lib/project_types/script/layers/infrastructure/errors.rb +0 -211
  111. data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +0 -37
  112. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +0 -62
  113. data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +0 -47
  114. data/lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb +0 -26
  115. data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +0 -45
  116. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +0 -103
  117. data/lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb +0 -12
  118. data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +0 -32
  119. data/lib/project_types/script/layers/infrastructure/metadata_repository.rb +0 -18
  120. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +0 -36
  121. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +0 -273
  122. data/lib/project_types/script/layers/infrastructure/script_service.rb +0 -135
  123. data/lib/project_types/script/layers/infrastructure/script_uploader.rb +0 -40
  124. data/lib/project_types/script/layers/infrastructure/service_locator.rb +0 -20
  125. data/lib/project_types/script/layers/infrastructure/sparse_checkout_details.rb +0 -35
  126. data/lib/project_types/script/ui/error_handler.rb +0 -331
  127. data/lib/project_types/script/ui/printing_spinner.rb +0 -75
  128. data/lib/project_types/script/ui/strict_spinner.rb +0 -20
  129. data/lib/shopify_cli/theme/dev_server/hot-reload.js +0 -194
  130. data/lib/shopify_cli/theme/syncer/ignore_helper.rb +0 -33
@@ -4,264 +4,7 @@ module Script
4
4
  module Messages
5
5
  MESSAGES = {
6
6
  script: {
7
- help: <<~HELP,
8
- Suite of commands for developing script applications. Run {{command:%1$s script <command> --help}} for usage of each command.
9
- Usage: {{command:%1$s script [ %2$s ]}}
10
- HELP
11
-
12
- error: {
13
- deprecated_ep: "This script won't run in a store because "\
14
- "it uses a deprecated Script API (%s).",
15
- deprecated_ep_cause: "Recreate this script using a supported Script API.",
16
- generic: "{{red:{{x}} Error}}",
17
- eacces_cause: "You don't have permission to write to this directory.",
18
- eacces_help: "Get permission for this directory or choose a different one.",
19
-
20
- enospc_cause: "You don't have enough disk space to do this action.",
21
- enospc_help: "Free up more space.",
22
-
23
- oauth_cause: "Something went wrong while authenticating your account with the Partner Dashboard.",
24
- oauth_help: "Wait a few minutes and try again.",
25
-
26
- invalid_context_cause: "Your .shopify-cli.yml is formatted incorrectly. It's missing values for "\
27
- "extension_point_type, title, app_bridge_create_path or app_bridge_details_path.",
28
- invalid_context_help: "Add these values.",
29
-
30
- invalid_script_title_cause: "Script title contains unsupported characters.",
31
- invalid_script_title_help: "Use only numbers, letters, hyphens, or underscores.",
32
-
33
- no_existing_apps_cause: "Your script can't be pushed to an app because your Partner account "\
34
- "doesn't have any apps.",
35
- no_existing_apps_help: "Create an app.",
36
-
37
- no_existing_orgs_cause: "Your account doesn't belong to a Partner Organization.",
38
- no_existing_orgs_help: "Visit https://partners.shopify.com/ to create an account.",
39
-
40
- project_exists_cause: "A directory with this same title already exists.",
41
- project_exists_help: "Choose a different title for your script.",
42
-
43
- invalid_extension_cause: "The name of the Script API is incorrect: %s.",
44
- invalid_extension_help: "Choose a supported API: %s.",
45
-
46
- invalid_language_cause: "The language is not supported: %s.",
47
- invalid_language_help: "Choose a supported language: %s.",
48
-
49
- missing_script_config_field_cause: "The %{filename} file is missing the required %{field} field.",
50
- missing_script_config_field_help: "Add the field.",
51
-
52
- script_config_parse_error_cause: "The %{filename} file contains incorrect %{serialization_format}.",
53
- script_config_parse_error_help: "Correct the errors.",
54
-
55
- no_script_config_file_cause: "The %{filename} file is missing.",
56
- no_script_config_file_help: "Create this file.",
57
-
58
- app_not_connected_cause: "The script is not connected to an app.",
59
- app_not_connected_help: "Run {{command:%{tool_name} script connect}}.",
60
-
61
- configuration_definition_error_cause: "In %{filename} there is a problem with the "\
62
- "configuration. %{message}",
63
- configuration_definition_error_help: "Fix the error.",
64
-
65
- configuration_definition_errors_cause: "In %{filename}, there are %{error_count} problems with "\
66
- "the configuration:\n%{concatenated_messages}\n",
67
- configuration_definition_errors_help: "Correct the errors.",
68
-
69
- configuration_syntax_error_cause: "The %{filename} is not formatted correctly.",
70
- configuration_syntax_error_help: "Fix the errors.",
71
-
72
- configuration_missing_keys_error_cause: "The %{filename} is missing required keys: "\
73
- "%{missing_keys}.",
74
- configuration_missing_keys_error_help: "Add the keys.",
75
-
76
- configuration_invalid_value_error_cause: "The %{filename} configuration accepts "\
77
- "one of the following types(s): %{valid_input_modes}.",
78
- configuration_invalid_value_error_help: "Change the value of the type.",
79
-
80
- configuration_schema_field_missing_keys_error_cause: "A configuration entry in the %{filename} file "\
81
- "is missing required keys: %{missing_keys}.",
82
- configuration_definition_schema_field_missing_keys_error_help: "Add the keys.",
83
-
84
- configuration_schema_field_invalid_value_error_cause: "The configuration entries in the "\
85
- "%{filename} file accept one of the following "\
86
- "type(s): %{valid_types}.",
87
- configuration_schema_field_invalid_value_error_help: "Change the value of the type.",
88
-
89
- input_query_error_cause: "Input query is invalid:\n%{messages}\n\n",
90
- input_query_error_help: "Fix the query in the `%{input_query_path}` file.",
91
-
92
- script_not_found_cause: "Can't find script %s for Script API %s",
93
-
94
- system_call_failure_cause: "Something went wrong while running: {{command:%{cmd}}}.",
95
- system_call_failure_help: "Correct the error.\n{{red:%{out}}}",
96
-
97
- metadata_validation_cause: "The Script API metadata is incorrect.",
98
- metadata_validation_help: "The 'schemaVersions.major' field contains an unsupported version.",
99
-
100
- metadata_schema_versions_missing: "Invalid Script metadata:" \
101
- " 'schemaVersions' field is missing",
102
- metadata_schema_versions_single_key: "Invalid Script API metadata:" \
103
- " 'schemaVersions' can have only one Script API name.",
104
- metadata_schema_versions_missing_major: "Invalid Script API metadata:" \
105
- " 'schemaVersions' is missing the 'major' field",
106
- metadata_schema_versions_missing_minor: "Invalid Script API metadata:" \
107
- " 'schemaVersions' is missing the 'minor' field",
108
-
109
- metadata_not_found_cause: "Can't find the script version file (%{filename}).",
110
- metadata_not_found_help: "Make sure your project is up-to-date and a script metadata file " \
111
- "is accessible at %{filename}.",
112
-
113
- build_error_cause: "Something went wrong while building the script.",
114
- build_error_help: "Correct the errors.",
115
-
116
- dependency_install_cause: "Something went wrong while installing the needed dependencies.",
117
- dependency_install_help: "Correct the errors.",
118
-
119
- invalid_environment_cause: "Your environment %{tool} version, %{env_version}, "\
120
- "is too low. It must be at least %{minimum_version}.",
121
- invalid_environment_help: "Update %{tool}.",
122
-
123
- failed_api_request_cause: "Something went wrong while communicating with Shopify.",
124
- failed_api_request_help: "Try again.",
125
-
126
- forbidden_error_cause: "You don't have permission to do this action.",
127
-
128
- graphql_error_cause: "An error was returned: %s.",
129
- graphql_error_help: "\nCorrect the error.",
130
-
131
- script_repush_cause: "Can’t push the script because a version of this script already exists on the app.",
132
- script_repush_help: "Use {{cyan:--force}} to replace the existing script.",
133
-
134
- build_script_not_found: "The root package.json is missing the build command that " \
135
- "is needed to compile your script to Wasm.",
136
- # rubocop:disable Layout/LineLength
137
- build_script_suggestion: "\n\nFor example, your package.json needs the following command:" \
138
- "\nbuild: npx shopify-scripts-toolchain-as build --src src/shopify_main.ts --binary build/<script_name>.wasm --metadata build/metadata.json -- --lib node_modules --optimize --use Date=",
139
-
140
- web_assembly_binary_not_found: "Wasm binary not found.",
141
- web_assembly_binary_not_found_suggestion: "Check that a valid Wasm binary is present. " \
142
- "The Wasm binary's filepath must be 'build/index.wasm'.",
143
-
144
- project_config_not_found: "Internal error - Script can't be created because the project's config file is missing from the repository.",
145
-
146
- invalid_project_config: "Internal error - Script can't be created because the project's config file is invalid in the repository.",
147
-
148
- script_upload_cause: "Something went wrong and your script couldn't be pushed.",
149
- script_upload_help: "Try again.",
150
-
151
- script_too_large_cause: "The size of your Wasm binary file is too large.",
152
- script_too_large_help: "It must be less than %{max_size}.",
153
-
154
- api_library_not_found_cause: "Script can't be created because API library %{library_name} is missing from the dependencies",
155
- api_library_not_found_help: "This can occur because the API library was removed from your system or there is a problem with dependencies in the repository.",
156
-
157
- language_library_for_api_not_found_cause: "Script can’t be pushed because the %{language} library for API %{api} is missing.",
158
- language_library_for_api_not_found_help: "Make sure extension_point.yml contains the correct API library.",
159
- no_scripts_found_in_app: "The selected apps have no scripts. Please, create them first on the partners' dashboard.",
160
- missing_push_options_ci: "The following are missing: %s. ",
161
- missing_push_options_ci_solution: "To add them to a CI environment:\n\t1. Run a connect command " \
162
- "({{command:%1$s script connect}})\n\t2. Navigate to the .env file at the root of your project\n\t" \
163
- "3. Copy the missing values and pass them through as arguments in {{command:%1$s script push}}",
164
- missing_env_file_variables: "The following are missing in the .env file: %s. ",
165
- missing_env_file_variables_solution: "To add it, connect your script with " \
166
- "{{command:%1$s script connect}} ",
167
-
168
- invalid_app_bridge_path_cause: "The script couldn't be pushed because the App Bridge path is incorrect in .shopify-cli.yml.",
169
- invalid_app_bridge_path_help: "The %{path_key} needs to be set to a path that starts with {{command:/}}.",
170
- },
171
-
172
- create: {
173
- help: <<~HELP,
174
- {{command:%1$s script create}}: Creates a script project.
175
- Usage: {{command:%1$s script create}}
176
- Options:
177
- {{command:--title=TITLE}} Script project title.
178
- {{command:--api=TYPE}} Script API name. Supported values: %2$s.
179
- {{command:--language=LANGUAGE}} Programming language. Defaults to wasm. Supported values: %3$s.
180
- HELP
181
-
182
- error: {
183
- operation_failed: "Something went wrong and the script wasn't created.",
184
- },
185
-
186
- change_directory_notice: "{{*}} Change directories to {{green:%s}} to run script commands.",
187
- creating: "Creating script.",
188
- created: "Created script.",
189
- preparing_project: "Preparing script project structure.",
190
- creating_wasm: "Creating configuration files.",
191
- created_wasm: "Configuration files created.",
192
- },
193
-
194
- push: {
195
- help: <<~HELP,
196
- Build the script, upload it to Shopify, and register it to an app.
197
- Usage: {{command:%s script push}}
198
- Options:
199
- {{command:[--force]}} Replace the existing script with this version.
200
- {{command:[--api-key=API_KEY]}} The API key used to register an app with the script. This can be found on the app page on Partners Dashboard. Overrides the value in the .env file, if present.
201
- {{command:[--api-secret=API_SECRET]}} The API secret of the app the script is registered with. Overrides the value in the .env file, if present.
202
- {{command:[--uuid=UUID]}} The uuid of the script. Overrides the value in the .env file, if present.
203
- HELP
204
-
205
- error: {
206
- operation_failed: "Couldn't push script to app.",
207
- },
208
-
209
- script_pushed: "{{v}} Script pushed to app (API key: %{api_key}).",
210
- },
211
- connect: {
212
- connected: "Connected! Your project is now connected to {{green:%s}}",
213
- help: <<~HELP,
214
- {{command:%s script connect}}: Connects an existing script to an app.
215
- Usage: {{command:%s script connect}}
216
- HELP
217
- error: {
218
- operation_failed: "Couldn't connect script to app.",
219
- },
220
- },
221
- javy: {
222
- help: <<~HELP,
223
- Compile the JavaScript code into Wasm.
224
- Usage: {{command:%s script javy}}
225
- Options:
226
- {{command:--in}} The name of the JavaScript file that will be compiled.
227
- {{command:--out}} The name of the file that the Wasm should be written to.
228
- HELP
229
- errors: {
230
- invalid_arguments: "Javy was run with invalid arguments. Run {{command: %s script javy --help}}.",
231
- },
232
- },
233
-
234
- project_deps: {
235
- none_required: "{{v}} Dependencies are up to date.",
236
- checking: "Checking dependencies.",
237
- installing: "Installing dependencies.",
238
- installed: "Installed missing dependencies.",
239
- },
240
-
241
- forms: {
242
- create: {
243
- select_extension_point: "Which Script API do you want to use?",
244
- script_title: "What do you want to title your script?",
245
- },
246
- },
247
-
248
- application: {
249
- building: "Building",
250
- building_script: "Building script",
251
- built: "Built",
252
- pushing: "Pushing",
253
- pushing_script: "Pushing script",
254
- pushed: "Pushed",
255
- ensure_env: {
256
- organization: "Partner organization {{green:%s (%s)}}.",
257
- organization_select: "Which partner organization do you want to use?",
258
- app: "Push script to app {{green:%s}}.",
259
- app_select: "Which app do you want to push this script to?",
260
- ask_connect_to_existing_script: "This app contains scripts. Do you want to replace an "\
261
- "existing script on the app with this script?",
262
- ask_which_script_to_connect_to: "Which script do you want to replace?",
263
- },
264
- },
7
+ deprecated: "Script projects are no longer supported in CLI 2.0. Please upgrade to CLI 3.0.",
265
8
  },
266
9
  }.freeze
267
10
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Theme
4
+ class Command
5
+ module Common
6
+ module ShopHelper
7
+ def shop
8
+ ShopifyCLI::AdminAPI.get_shop_or_abort(@ctx)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
  require "shopify_cli/theme/theme"
3
3
  require "shopify_cli/theme/development_theme"
4
+ require "project_types/theme/commands/common/shop_helper"
4
5
 
5
6
  module Theme
6
7
  class Command
7
8
  class Delete < ShopifyCLI::Command::SubCommand
9
+ include Common::ShopHelper
10
+
8
11
  recommend_default_ruby_range
9
12
 
10
13
  options do |parser, flags|
@@ -22,7 +25,7 @@ module Theme
22
25
  form = Forms::Select.ask(
23
26
  @ctx,
24
27
  [],
25
- title: @ctx.message("theme.delete.select"),
28
+ title: @ctx.message("theme.delete.select", shop),
26
29
  exclude_roles: ["live"],
27
30
  include_foreign_developments: options.flags[:show_all],
28
31
  cmd: :delete
@@ -2,10 +2,13 @@
2
2
 
3
3
  require "shopify_cli/theme/theme"
4
4
  require "project_types/theme/presenters/themes_presenter"
5
+ require "project_types/theme/commands/common/shop_helper"
5
6
 
6
7
  module Theme
7
8
  class Command
8
9
  class List < ShopifyCLI::Command::SubCommand
10
+ include Common::ShopHelper
11
+
9
12
  recommend_default_ruby_range
10
13
 
11
14
  def call(_args, _name)
@@ -25,10 +28,6 @@ module Theme
25
28
  def themes_presenter
26
29
  Theme::Presenters::ThemesPresenter.new(@ctx, nil)
27
30
  end
28
-
29
- def shop
30
- ShopifyCLI::AdminAPI.get_shop_or_abort(@ctx)
31
- end
32
31
  end
33
32
  end
34
33
  end
@@ -2,10 +2,13 @@
2
2
 
3
3
  require "shopify_cli/theme/theme"
4
4
  require "shopify_cli/theme/development_theme"
5
+ require "project_types/theme/commands/common/shop_helper"
5
6
 
6
7
  module Theme
7
8
  class Command
8
9
  class Open < ShopifyCLI::Command::SubCommand
10
+ include Common::ShopHelper
11
+
9
12
  recommend_default_ruby_range
10
13
 
11
14
  options do |parser, flags|
@@ -60,7 +63,7 @@ module Theme
60
63
  form = Forms::Select.ask(
61
64
  @ctx,
62
65
  [],
63
- title: @ctx.message("theme.open.select"),
66
+ title: @ctx.message("theme.open.select", shop),
64
67
  root: nil
65
68
  )
66
69
  form&.theme
@@ -1,9 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
  require "shopify_cli/theme/theme"
3
+ require "project_types/theme/commands/common/shop_helper"
3
4
 
4
5
  module Theme
5
6
  class Command
6
7
  class Publish < ShopifyCLI::Command::SubCommand
8
+ include Common::ShopHelper
9
+
7
10
  recommend_default_ruby_range
8
11
 
9
12
  options do |parser, flags|
@@ -17,7 +20,7 @@ module Theme
17
20
  form = Forms::Select.ask(
18
21
  @ctx,
19
22
  [],
20
- title: @ctx.message("theme.publish.select"),
23
+ title: @ctx.message("theme.publish.select", shop),
21
24
  exclude_roles: ["live", "development", "demo"],
22
25
  cmd: :publish
23
26
  )
@@ -5,12 +5,14 @@ require "shopify_cli/theme/ignore_filter"
5
5
  require "shopify_cli/theme/include_filter"
6
6
  require "shopify_cli/theme/syncer"
7
7
  require "project_types/theme/commands/common/root_helper"
8
+ require "project_types/theme/commands/common/shop_helper"
8
9
  require "project_types/theme/conversions/include_glob"
9
10
  require "project_types/theme/conversions/ignore_glob"
10
11
 
11
12
  module Theme
12
13
  class Command
13
14
  class Pull < ShopifyCLI::Command::SubCommand
15
+ include Common::ShopHelper
14
16
  include Common::RootHelper
15
17
 
16
18
  recommend_default_ruby_range
@@ -97,7 +99,7 @@ module Theme
97
99
  form = Forms::Select.ask(
98
100
  @ctx,
99
101
  [],
100
- title: @ctx.message("theme.pull.select"),
102
+ title: @ctx.message("theme.pull.select", shop),
101
103
  root: root,
102
104
  )
103
105
  form&.theme
@@ -5,12 +5,14 @@ require "shopify_cli/theme/ignore_filter"
5
5
  require "shopify_cli/theme/include_filter"
6
6
  require "shopify_cli/theme/syncer"
7
7
  require "project_types/theme/commands/common/root_helper"
8
+ require "project_types/theme/commands/common/shop_helper"
8
9
  require "project_types/theme/conversions/include_glob"
9
10
  require "project_types/theme/conversions/ignore_glob"
10
11
 
11
12
  module Theme
12
13
  class Command
13
14
  class Push < ShopifyCLI::Command::SubCommand
15
+ include Common::ShopHelper
14
16
  include Common::RootHelper
15
17
 
16
18
  recommend_default_ruby_range
@@ -134,7 +136,7 @@ module Theme
134
136
  form = Forms::Select.ask(
135
137
  @ctx,
136
138
  [],
137
- title: @ctx.message("theme.push.select"),
139
+ title: @ctx.message("theme.push.select", shop),
138
140
  root: root,
139
141
  )
140
142
  form&.theme
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
  require "shopify_cli/theme/dev_server"
3
3
  require "project_types/theme/commands/common/root_helper"
4
+ require "shopify_cli/theme/ignore_filter"
5
+ require "shopify_cli/theme/include_filter"
6
+ require "project_types/theme/conversions/include_glob"
7
+ require "project_types/theme/conversions/ignore_glob"
4
8
 
5
9
  module Theme
6
10
  class Command
@@ -12,6 +16,9 @@ module Theme
12
16
  DEFAULT_HTTP_HOST = "127.0.0.1"
13
17
 
14
18
  options do |parser, flags|
19
+ Conversions::IncludeGlob.register(parser)
20
+ Conversions::IgnoreGlob.register(parser)
21
+
15
22
  parser.on("--host=HOST") { |host| flags[:host] = host.to_s }
16
23
  parser.on("--port=PORT") { |port| flags[:port] = port.to_i }
17
24
  parser.on("--poll") { flags[:poll] = true }
@@ -19,6 +26,14 @@ module Theme
19
26
  parser.on("--theme-editor-sync") { flags[:editor_sync] = true }
20
27
  parser.on("--stable") { flags[:stable] = true }
21
28
  parser.on("-t", "--theme=NAME_OR_ID") { |theme| flags[:theme] = theme }
29
+ parser.on("-o", "--only=PATTERN", Conversions::IncludeGlob) do |pattern|
30
+ flags[:includes] ||= []
31
+ flags[:includes] |= pattern
32
+ end
33
+ parser.on("-x", "--ignore=PATTERN", Conversions::IgnoreGlob) do |pattern|
34
+ flags[:ignores] ||= []
35
+ flags[:ignores] |= pattern
36
+ end
22
37
  end
23
38
 
24
39
  def call(_args, name)
@@ -31,9 +46,6 @@ module Theme
31
46
  ShopifyCLI::Theme::DevServer.start(@ctx, root, host: host, **flags) do |syncer|
32
47
  UI::SyncProgressBar.new(syncer).progress(:upload_theme!, delay_low_priority_files: true)
33
48
  end
34
- rescue ShopifyCLI::Theme::DevServer::AddressBindingError
35
- raise ShopifyCLI::Abort,
36
- ShopifyCLI::Context.message("theme.serve.error.address_binding_error", ShopifyCLI::TOOL_NAME)
37
49
  end
38
50
 
39
51
  def self.as_reload_mode(mode)
@@ -47,7 +47,7 @@ module Theme
47
47
  not_found: "Theme #%s does not exist",
48
48
  no_themes_error: "You don't have any theme to be published.",
49
49
  no_themes_resolution: "Try to create an unpublished theme with {{command:theme push -u -t <theme_name>}}.",
50
- select: "Select theme to push to",
50
+ select: "Select theme to push to %s",
51
51
  confirm: "Are you sure you want to make %s the new live theme on %s?",
52
52
  },
53
53
  forms: {
@@ -87,7 +87,7 @@ module Theme
87
87
  pushing: "Pushing theme files to %s (#%s) on %s",
88
88
  },
89
89
  push: "Pushing theme files to Shopify",
90
- select: "Select theme to push to",
90
+ select: "Select theme to push to %s",
91
91
  live: "Are you sure you want to push to your live theme?",
92
92
  theme: "\n Theme: {{blue:%s #%s}} {{green:[live]}}",
93
93
  deprecated_themeid: <<~WARN,
@@ -138,6 +138,8 @@ module Theme
138
138
  viewing_theme: "Viewing theme…",
139
139
  syncing_theme: "Syncing theme #%s on %s",
140
140
  open_fail: "Couldn't open the theme",
141
+ stop_signal: "Stop signal: \"%s\"",
142
+ stopping: "Stopping…",
141
143
  auth: {
142
144
  error_message: <<~ERROR_MESSAGE,
143
145
  It looks like you are using credentials that do not work with {{command:%s theme serve}}.
@@ -230,8 +232,6 @@ module Theme
230
232
  },
231
233
  },
232
234
  error: {
233
- address_binding_error: "Couldn't bind to localhost."\
234
- " To serve your theme, set a different address with {{command:%s theme serve --host=<address>}}",
235
235
  invalid_subdirectory: <<~MESSAGE,
236
236
  The presence of %s in the directory structure isn't supported.
237
237
 
@@ -262,6 +262,8 @@ module Theme
262
262
  ENSURE_USER
263
263
  address_already_in_use: "The address \"%s\" is already in use.",
264
264
  try_port_option: "Use the --port=PORT option to serve the theme in a different port.",
265
+ binding_error: "Couldn't bind to localhost." \
266
+ " To serve your theme, set a different address with {{command:%s theme serve --host=<address>}}",
265
267
  },
266
268
  check: {
267
269
  help: <<~HELP,
@@ -283,7 +285,7 @@ module Theme
283
285
 
284
286
  Run without options to select the theme to delete from a list.
285
287
  HELP
286
- select: "Select theme to delete",
288
+ select: "Select theme to delete from %s",
287
289
  done: "%s theme(s) deleted",
288
290
  no_themes_error: "You don't have any theme to be deleted.",
289
291
  no_themes_resolution: "Try to create an unpublished theme with {{command:theme push -u -t <theme_name>}}.",
@@ -328,7 +330,7 @@ module Theme
328
330
 
329
331
  Run without options to select theme from a list.
330
332
  HELP
331
- select: "Select a theme to pull from",
333
+ select: "Select a theme to pull from %s",
332
334
  pulling: "Pulling theme files from %s (#%s) on %s",
333
335
  done: "Theme pulled successfully.",
334
336
  done_with_errors: "{{warning:Your theme was pulled with errors.}}",
@@ -338,7 +340,7 @@ module Theme
338
340
  theme_not_found: "Theme \"%s\" doesn't exist",
339
341
  },
340
342
  open: {
341
- select: "Select a theme to open",
343
+ select: "Select a theme to open in %s",
342
344
  theme_not_found: "Theme \"%s\" doesn't exist",
343
345
  details: <<~DETAILS,
344
346
  {{*}} {{bold:%s}}
@@ -1,11 +1,14 @@
1
1
  require "shopify_cli"
2
2
  require "shopify_cli/theme/development_theme"
3
+ require "shopify_cli/theme/extension/host_theme"
3
4
 
4
5
  module ShopifyCLI
5
6
  module Commands
6
7
  class Logout < ShopifyCLI::Command
7
8
  def call(*)
8
9
  try_delete_development_theme
10
+ try_delete_host_theme
11
+
9
12
  ShopifyCLI::IdentityAuth.delete_tokens_and_keys
10
13
  ShopifyCLI::DB.del(:shop) if has_shop?
11
14
  ShopifyCLI::DB.del(:organization_id) if has_organization_id?
@@ -31,8 +34,16 @@ module ShopifyCLI
31
34
  return unless has_shop?
32
35
 
33
36
  ShopifyCLI::Theme::DevelopmentTheme.delete(@ctx)
34
- rescue ShopifyCLI::API::APIRequestError, ShopifyCLI::Abort, ShopifyCLI::AbortSilent
35
- # Ignore since we can't delete it
37
+ rescue ShopifyCLI::API::APIRequestError, ShopifyCLI::Abort, ShopifyCLI::AbortSilent => e
38
+ @ctx.debug("[Logout Error]: #{e.message}")
39
+ end
40
+
41
+ def try_delete_host_theme
42
+ return unless has_shop?
43
+
44
+ ShopifyCLI::Theme::Extension::HostTheme.delete(@ctx)
45
+ rescue ShopifyCLI::API::APIRequestError, ShopifyCLI::Abort, ShopifyCLI::AbortSilent => e
46
+ @ctx.debug("[Logout Error]: #{e.message}")
36
47
  end
37
48
  end
38
49
  end
@@ -159,7 +159,7 @@ module ShopifyCLI
159
159
  env_variable_truthy?(
160
160
  Constants::EnvironmentVariables::MONORAIL_REAL_EVENTS,
161
161
  env_variables: env_variables
162
- )
162
+ ) && !run_as_subprocess?(env_variables: env_variables)
163
163
  end
164
164
 
165
165
  def self.auth_token(env_variables: ENV)
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ require "listen"
3
+ require "observer"
4
+
5
+ module ShopifyCLI
6
+ class FileSystemListener
7
+ include Observable
8
+
9
+ def initialize(root:, force_poll:, ignore_regex:)
10
+ @root = root
11
+ @force_poll = force_poll
12
+ @ignore_regex = ignore_regex
13
+
14
+ @listener = Listen.to(@root, force_polling: @force_poll, ignore: @ignore_regex) do |updated, added, removed|
15
+ changed
16
+ notify_observers(updated, added, removed)
17
+ end
18
+ end
19
+
20
+ def start
21
+ @listener.start
22
+ rescue ArgumentError
23
+ # Ignore errors during the transition of 'listen' events
24
+ end
25
+
26
+ def stop
27
+ @listener.stop
28
+ end
29
+ end
30
+ end