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
@@ -1,331 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "cli/ui"
4
-
5
- module Script
6
- module UI
7
- module ErrorHandler
8
- def self.display(failed_op:, cause_of_error:, help_suggestion:)
9
- $stderr.puts(CLI::UI.fmt(ShopifyCLI::Context.message("script.error.generic")))
10
- full_msg = failed_op ? failed_op.dup : String.new
11
- append_msg(full_msg, cause_of_error) if cause_of_error
12
- append_msg(full_msg, help_suggestion) if help_suggestion
13
- $stderr.puts(CLI::UI.fmt(full_msg.strip))
14
- end
15
-
16
- def self.display_and_raise(failed_op: nil, cause_of_error: nil, help_suggestion: nil)
17
- display(failed_op: failed_op, cause_of_error: cause_of_error, help_suggestion: help_suggestion)
18
- raise(ShopifyCLI::AbortSilent)
19
- end
20
-
21
- def self.pretty_print_and_raise(e, failed_op: nil)
22
- messages = error_messages(e)
23
- raise e if messages.nil?
24
- display_and_raise(failed_op: failed_op, **messages)
25
- end
26
-
27
- private_class_method def self.append_msg(full_msg, msg_to_append)
28
- full_msg << " " unless /\s$/.match?(full_msg)
29
- full_msg << msg_to_append
30
- end
31
-
32
- def self.error_messages(e)
33
- case e
34
- when Errno::EACCES
35
- {
36
- cause_of_error: ShopifyCLI::Context.message("script.error.eacces_cause"),
37
- help_suggestion: ShopifyCLI::Context.message("script.error.eacces_help"),
38
- }
39
- when Errno::ENOSPC
40
- {
41
- cause_of_error: ShopifyCLI::Context.message("script.error.enospc_cause"),
42
- help_suggestion: ShopifyCLI::Context.message("script.error.enospc_help"),
43
- }
44
- when ShopifyCLI::IdentityAuth::Error
45
- {
46
- cause_of_error: ShopifyCLI::Context.message("script.error.oauth_cause"),
47
- help_suggestion: ShopifyCLI::Context.message("script.error.oauth_help"),
48
- }
49
- when Layers::Infrastructure::Errors::InvalidContextError
50
- {
51
- cause_of_error: ShopifyCLI::Context.message("script.error.invalid_context_cause"),
52
- help_suggestion: ShopifyCLI::Context.message("script.error.invalid_context_help"),
53
- }
54
- when Layers::Infrastructure::Errors::InvalidLanguageError
55
- {
56
- cause_of_error: ShopifyCLI::Context.message("script.error.invalid_language_cause", e.language),
57
- help_suggestion: ShopifyCLI::Context.message(
58
- "script.error.invalid_language_help",
59
- Script::Layers::Application::ExtensionPoints.languages(type: e.extension_point_type).join(", ")
60
- ),
61
- }
62
- when Errors::InvalidScriptTitleError
63
- {
64
- cause_of_error: ShopifyCLI::Context.message("script.error.invalid_script_title_cause"),
65
- help_suggestion: ShopifyCLI::Context.message("script.error.invalid_script_title_help"),
66
- }
67
- when Errors::NoExistingAppsError
68
- {
69
- cause_of_error: ShopifyCLI::Context.message("script.error.no_existing_apps_cause"),
70
- help_suggestion: ShopifyCLI::Context.message("script.error.no_existing_apps_help"),
71
- }
72
- when Errors::NoExistingOrganizationsError
73
- {
74
- cause_of_error: ShopifyCLI::Context.message("script.error.no_existing_orgs_cause"),
75
- help_suggestion: ShopifyCLI::Context.message("script.error.no_existing_orgs_help"),
76
- }
77
- when Layers::Infrastructure::Errors::ScriptProjectAlreadyExistsError
78
- {
79
- cause_of_error: ShopifyCLI::Context.message("script.error.project_exists_cause"),
80
- help_suggestion: ShopifyCLI::Context.message("script.error.project_exists_help"),
81
- }
82
- when Layers::Infrastructure::Errors::DeprecatedEPError
83
- {
84
- cause_of_error: ShopifyCLI::Context.message("script.error.deprecated_ep", e.extension_point),
85
- help_suggestion: ShopifyCLI::Context.message("script.error.deprecated_ep_cause"),
86
- }
87
- when Layers::Domain::Errors::InvalidExtensionPointError
88
- {
89
- cause_of_error: ShopifyCLI::Context.message("script.error.invalid_extension_cause", e.type),
90
- help_suggestion: ShopifyCLI::Context.message(
91
- "script.error.invalid_extension_help",
92
- Script::Layers::Application::ExtensionPoints.available_types.join(", ")
93
- ),
94
- }
95
- when Layers::Domain::Errors::ScriptNotFoundError
96
- {
97
- cause_of_error: ShopifyCLI::Context.message(
98
- "script.error.script_not_found_cause",
99
- e.title,
100
- e.extension_point_type
101
- ),
102
- }
103
- when Layers::Domain::Errors::MetadataValidationError
104
- {
105
- cause_of_error: ShopifyCLI::Context.message("script.error.metadata_validation_cause"),
106
- help_suggestion: ShopifyCLI::Context.message("script.error.metadata_validation_help"),
107
- }
108
- when Layers::Domain::Errors::MetadataNotFoundError
109
- {
110
- cause_of_error: ShopifyCLI::Context.message("script.error.metadata_not_found_cause", filename: e.filename),
111
- help_suggestion: ShopifyCLI::Context.message("script.error.metadata_not_found_help", filename: e.filename),
112
- }
113
- when Layers::Domain::Errors::MissingScriptConfigFieldError
114
- {
115
- cause_of_error: ShopifyCLI::Context.message(
116
- "script.error.missing_script_config_field_cause",
117
- field: e.field,
118
- filename: e.filename,
119
- ),
120
- help_suggestion: ShopifyCLI::Context.message("script.error.missing_script_config_field_help"),
121
- }
122
- when Layers::Infrastructure::Errors::BuildError
123
- {
124
- cause_of_error: ShopifyCLI::Context.message("script.error.build_error_cause"),
125
- help_suggestion: ShopifyCLI::Context.message("script.error.build_error_help"),
126
- }
127
- when Layers::Infrastructure::Errors::ScriptConfigParseError
128
- {
129
- cause_of_error: ShopifyCLI::Context.message(
130
- "script.error.script_config_parse_error_cause",
131
- filename: e.filename,
132
- serialization_format: e.serialization_format,
133
- ),
134
- help_suggestion: ShopifyCLI::Context.message("script.error.script_config_parse_error_help"),
135
- }
136
- when Layers::Infrastructure::Errors::NoScriptConfigFileError
137
- {
138
- cause_of_error: ShopifyCLI::Context.message(
139
- "script.error.no_script_config_file_cause",
140
- filename: e.filename,
141
- ),
142
- help_suggestion: ShopifyCLI::Context.message("script.error.no_script_config_file_help"),
143
- }
144
- when Layers::Infrastructure::Errors::ScriptConfigurationDefinitionError
145
- if e.messages.count == 1
146
- {
147
- cause_of_error: ShopifyCLI::Context.message(
148
- "script.error.configuration_definition_error_cause",
149
- message: e.messages.fetch(0),
150
- filename: e.filename,
151
- ),
152
- help_suggestion: ShopifyCLI::Context.message("script.error.configuration_definition_error_help"),
153
- }
154
- else
155
- {
156
- cause_of_error: ShopifyCLI::Context.message(
157
- "script.error.configuration_definition_errors_cause",
158
- concatenated_messages: e.messages.map { |m| "{{x}} #{m}" }.join("\n"),
159
- filename: e.filename,
160
- error_count: e.messages.count,
161
- ),
162
- help_suggestion: ShopifyCLI::Context.message("script.error.configuration_definition_errors_help"),
163
- }
164
- end
165
- when Layers::Infrastructure::Errors::ScriptConfigSyntaxError
166
- {
167
- cause_of_error: ShopifyCLI::Context.message(
168
- "script.error.configuration_syntax_error_cause",
169
- filename: e.filename,
170
- ),
171
- help_suggestion: ShopifyCLI::Context.message("script.error.configuration_syntax_error_help"),
172
- }
173
- when Layers::Infrastructure::Errors::ScriptEnvAppNotConnectedError
174
- {
175
- cause_of_error: ShopifyCLI::Context.message("script.error.app_not_connected_cause"),
176
- help_suggestion: ShopifyCLI::Context.message("script.error.app_not_connected_help",
177
- tool_name: ShopifyCLI::TOOL_NAME),
178
- }
179
- when Layers::Infrastructure::Errors::ScriptConfigMissingKeysError
180
- {
181
- cause_of_error: ShopifyCLI::Context.message(
182
- "script.error.configuration_missing_keys_error_cause",
183
- missing_keys: e.missing_keys,
184
- filename: e.filename,
185
- ),
186
- help_suggestion: ShopifyCLI::Context.message("script.error.configuration_missing_keys_error_help"),
187
- }
188
- when Layers::Infrastructure::Errors::ScriptConfigInvalidValueError
189
- {
190
- cause_of_error: ShopifyCLI::Context.message(
191
- "script.error.configuration_invalid_value_error_cause",
192
- valid_input_modes: e.valid_input_modes,
193
- filename: e.filename,
194
- ),
195
- help_suggestion: ShopifyCLI::Context.message("script.error.configuration_invalid_value_error_help"),
196
- }
197
- when Layers::Infrastructure::Errors::ScriptConfigFieldsMissingKeysError
198
- {
199
- cause_of_error: ShopifyCLI::Context.message(
200
- "script.error.configuration_schema_field_missing_keys_error_cause",
201
- missing_keys: e.missing_keys,
202
- filename: e.filename,
203
- ),
204
- help_suggestion: ShopifyCLI::Context.message(
205
- "script.error.configuration_definition_schema_field_missing_keys_error_help"
206
- ),
207
- }
208
- when Layers::Infrastructure::Errors::ScriptConfigFieldsInvalidValueError
209
- {
210
- cause_of_error: ShopifyCLI::Context.message(
211
- "script.error.configuration_schema_field_invalid_value_error_cause",
212
- valid_types: e.valid_types,
213
- filename: e.filename,
214
- ),
215
- help_suggestion: ShopifyCLI::Context.message(
216
- "script.error.configuration_schema_field_invalid_value_error_help"
217
- ),
218
- }
219
- when Layers::Infrastructure::Errors::InvalidInputQueryErrors
220
- {
221
- cause_of_error: ShopifyCLI::Context.message(
222
- "script.error.input_query_error_cause",
223
- messages: e.messages.map { |message| " {{x}} #{message}." }.join("\n"),
224
- ),
225
- help_suggestion: ShopifyCLI::Context.message(
226
- "script.error.input_query_error_help",
227
- input_query_path: e.input_query_path,
228
- ),
229
- }
230
- when Layers::Infrastructure::Errors::DependencyInstallError
231
- {
232
- cause_of_error: ShopifyCLI::Context.message("script.error.dependency_install_cause"),
233
- help_suggestion: ShopifyCLI::Context.message("script.error.dependency_install_help"),
234
- }
235
- when Layers::Infrastructure::Errors::EmptyResponseError
236
- {
237
- cause_of_error: ShopifyCLI::Context.message("script.error.failed_api_request_cause"),
238
- help_suggestion: ShopifyCLI::Context.message("script.error.failed_api_request_help"),
239
- }
240
- when Layers::Infrastructure::Errors::ForbiddenError
241
- {
242
- cause_of_error: ShopifyCLI::Context.message("script.error.forbidden_error_cause"),
243
- }
244
- when Layers::Infrastructure::Errors::GraphqlError
245
- {
246
- cause_of_error: ShopifyCLI::Context.message(
247
- "script.error.graphql_error_cause", JSON.pretty_generate(e.errors)
248
- ),
249
- help_suggestion: ShopifyCLI::Context.message("script.error.graphql_error_help"),
250
- }
251
- when Layers::Infrastructure::Errors::InvalidEnvironmentError
252
- {
253
- cause_of_error: ShopifyCLI::Context.message(
254
- "script.error.invalid_environment_cause",
255
- tool: e.tool,
256
- env_version: e.env_version,
257
- minimum_version: e.minimum_version,
258
- ),
259
- help_suggestion: ShopifyCLI::Context.message(
260
- "script.error.invalid_environment_help",
261
- tool: e.tool,
262
- ),
263
- }
264
- when Layers::Infrastructure::Errors::SystemCallFailureError
265
- {
266
- cause_of_error: ShopifyCLI::Context
267
- .message("script.error.system_call_failure_cause", cmd: e.cmd),
268
- help_suggestion: ShopifyCLI::Context.message("script.error.system_call_failure_help", out: e.out),
269
- }
270
- when Layers::Infrastructure::Errors::ScriptRepushError
271
- {
272
- cause_of_error: ShopifyCLI::Context.message("script.error.script_repush_cause"),
273
- help_suggestion: ShopifyCLI::Context.message("script.error.script_repush_help"),
274
- }
275
- when Layers::Infrastructure::Errors::BuildScriptNotFoundError
276
- {
277
- cause_of_error: ShopifyCLI::Context.message("script.error.build_script_not_found"),
278
- help_suggestion: ShopifyCLI::Context.message("script.error.build_script_suggestion"),
279
- }
280
- when Layers::Infrastructure::Errors::WebAssemblyBinaryNotFoundError
281
- {
282
- cause_of_error: ShopifyCLI::Context.message("script.error.web_assembly_binary_not_found"),
283
- help_suggestion: ShopifyCLI::Context.message("script.error.web_assembly_binary_not_found_suggestion"),
284
- }
285
- when Layers::Infrastructure::Errors::ProjectConfigNotFoundError
286
- {
287
- cause_of_error: ShopifyCLI::Context.message("script.error.project_config_not_found"),
288
- }
289
- when Layers::Infrastructure::Errors::InvalidProjectConfigError
290
- {
291
- cause_of_error: ShopifyCLI::Context.message("script.error.invalid_project_config"),
292
- }
293
- when Layers::Infrastructure::Errors::ScriptUploadError
294
- {
295
- cause_of_error: ShopifyCLI::Context.message("script.error.script_upload_cause"),
296
- help_suggestion: ShopifyCLI::Context.message("script.error.script_upload_help"),
297
- }
298
- when Layers::Infrastructure::Errors::ScriptTooLargeError
299
- {
300
- cause_of_error: ShopifyCLI::Context.message("script.error.script_too_large_cause"),
301
- help_suggestion: ShopifyCLI::Context.message("script.error.script_too_large_help", max_size: e.max_size),
302
- }
303
- when Layers::Infrastructure::Errors::APILibraryNotFoundError
304
- {
305
- cause_of_error: ShopifyCLI::Context
306
- .message("script.error.api_library_not_found_cause", library_name: e.library_name),
307
- help_suggestion: ShopifyCLI::Context.message("script.error.api_library_not_found_help"),
308
- }
309
- when Layers::Infrastructure::Errors::LanguageLibraryForAPINotFoundError
310
- {
311
- cause_of_error: ShopifyCLI::Context
312
- .message(
313
- "script.error.language_library_for_api_not_found_cause",
314
- language: e.language,
315
- api: e.api
316
- ),
317
- help_suggestion: ShopifyCLI::Context.message("script.error.language_library_for_api_not_found_help"),
318
- }
319
- when Layers::Infrastructure::Errors::InvalidAppBridgePathError
320
- {
321
- cause_of_error: ShopifyCLI::Context.message("script.error.invalid_app_bridge_path_cause"),
322
- help_suggestion: ShopifyCLI::Context.message(
323
- "script.error.invalid_app_bridge_path_help",
324
- path_key: e.path_key,
325
- ),
326
- }
327
- end
328
- end
329
- end
330
- end
331
- end
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module Script
5
- module UI
6
- module PrintingSpinner
7
- ##
8
- # Creates a single spinner that runs the provided block.
9
- # The block can take in a ctx argument that formats printed output to support
10
- # printing from within the spin block.
11
- #
12
- # ==== Attributes
13
- #
14
- # * +ctx+ - The current context.
15
- # * +title+ - Title of the spinner to use
16
- #
17
- # ==== Options
18
- #
19
- # * +:auto_debrief+ - Automatically debrief exceptions? Default to true
20
- #
21
- # ==== Block
22
- #
23
- # * +ctx+ - Instance of the PrintingSpinnerContext built from the ctx attribute.
24
- # - +ctx.puts(...)+ formats output to enable support for printing within spinners
25
- # * +spinner+ - Instance of the spinner. Can call +update_title+ to update the user of changes
26
- #
27
- def self.spin(ctx, title, auto_debrief: false)
28
- StrictSpinner.spin(title, auto_debrief: auto_debrief) do |spinner, *args|
29
- Thread.current[:cliui_output_hook] = nil
30
- yield(PrintingSpinnerContext.from(ctx, spinner), spinner, *args)
31
- end
32
- end
33
-
34
- ##
35
- # Printing within spinners requires the manipulation of ANSI escape
36
- # sequences in order to make sure the CLI::UI::Spinner does not overwrite
37
- # previously printed content.
38
- class PrintingSpinnerContext < ShopifyCLI::Context
39
- include SmartProperties
40
- property :spinner, required: true
41
-
42
- def self.from(ctx, spinner)
43
- new_ctx = new(spinner: spinner)
44
- ctx.instance_variables.each do |var|
45
- new_ctx.instance_variable_set(var, ctx.instance_variable_get(var))
46
- end
47
- new_ctx
48
- end
49
-
50
- def puts(*input)
51
- super(encoded_lines(*input) + "\n" + spinner_text)
52
- end
53
-
54
- private
55
-
56
- def encoded_lines(*lines)
57
- lines
58
- .join("\n")
59
- .split("\n")
60
- .map { |line| encode_ansi(line) unless line.nil? }
61
- .join(CLI::UI::ANSI.next_line + "\n")
62
- end
63
-
64
- def encode_ansi(line)
65
- CLI::UI::ANSI.previous_line + line + CLI::UI::ANSI.clear_to_end_of_line
66
- end
67
-
68
- def spinner_text
69
- spinner.render(0, true)
70
- end
71
- end
72
- private_constant(:PrintingSpinnerContext)
73
- end
74
- end
75
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "shopify_cli"
4
-
5
- module Script
6
- module UI
7
- module StrictSpinner
8
- def self.spin(title, auto_debrief: false)
9
- exception = nil
10
- CLI::UI::Spinner.spin(title, auto_debrief: auto_debrief) do |*args|
11
- yield(*args)
12
- rescue StandardError => e
13
- exception = e
14
- CLI::UI::Spinner::TASK_FAILED
15
- end
16
- raise exception if exception
17
- end
18
- end
19
- end
20
- end
@@ -1,194 +0,0 @@
1
- (() => {
2
- function verifySSE() {
3
- if (typeof (EventSource) === "undefined") {
4
- console.error("[HotReload] Error: SSE features are not supported. Try a different browser.");
5
- }
6
- }
7
-
8
- console.log("[HotReload] Initializing...");
9
-
10
- verifySSE();
11
- })();
12
-
13
- (() => {
14
- function connect() {
15
- const eventSource = new EventSource('/hot-reload');
16
-
17
- eventSource.onmessage = onMessage;
18
-
19
- eventSource.onopen = () => console.log('[HotReload] SSE connected.');
20
-
21
- eventSource.onclose = () => {
22
- console.log('[HotReload] SSE closed. Attempting to reconnect...');
23
-
24
- setTimeout(connect, 5000);
25
- }
26
-
27
- eventSource.onerror = () => eventSource.close();
28
- }
29
-
30
- function sectionNamesByType(type) {
31
- const namespace = window.__SHOPIFY_CLI_ENV__;
32
- return namespace.section_names_by_type[type] || [];
33
- }
34
-
35
- function reloadMode() {
36
- const namespace = window.__SHOPIFY_CLI_ENV__;
37
- return namespace.mode;
38
- }
39
-
40
- function querySelectDOMSections(idSuffix) {
41
- const elements = document.querySelectorAll(`[id^='shopify-section'][id$='${idSuffix}']`);
42
- return Array.from(elements);
43
- }
44
-
45
- function fetchDOMSections(name) {
46
- const domSections = sectionNamesByType(name).flatMap((n) => querySelectDOMSections(n));
47
-
48
- if (domSections.length > 0) {
49
- return domSections;
50
- }
51
-
52
- return querySelectDOMSections(name);
53
- }
54
-
55
- function isFullPageReloadMode() {
56
- return reloadMode() === 'full-page';
57
- }
58
-
59
- function isReloadModeActive() {
60
- return reloadMode() !== 'off';
61
- }
62
-
63
- function isRefreshRequired(files) {
64
- if (isFullPageReloadMode()) {
65
- return true;
66
- }
67
- return files.some((file) => !isCssFile(file) && !isSectionFile(file));
68
- }
69
-
70
- function refreshFile(file) {
71
- if (isCssFile(file)) {
72
- reloadCssFile(file);
73
- return;
74
- }
75
-
76
- if (isSectionFile(file)) {
77
- reloadSection(file);
78
- return;
79
- }
80
- }
81
-
82
- function setHotReloadCookie(files) {
83
- var date = new Date();
84
-
85
- // Hot reload cookie expires in 3 seconds
86
- date.setSeconds(date.getSeconds() + 3);
87
-
88
- var sections = files.join(',');
89
- var expires = date.toUTCString();
90
-
91
- document.cookie = `hot_reload_sections=${sections}; expires=${expires}; path=/`;
92
- }
93
-
94
- function refreshPage(files) {
95
- setHotReloadCookie(files);
96
- console.log('[HotReload] Refreshing entire page');
97
- window.location.reload();
98
- }
99
-
100
- function onMessage(message) {
101
- const data = JSON.parse(message.data);
102
- if (data.reload_page) {
103
- refreshPage([]);
104
- return;
105
- }
106
-
107
- handleUpdate(data);
108
- }
109
-
110
- function handleUpdate(data) {
111
- var modifiedFiles = data.modified;
112
-
113
- if (modifiedFiles === undefined) {
114
- return;
115
- }
116
-
117
- if (isRefreshRequired(modifiedFiles)) {
118
- refreshPage(modifiedFiles);
119
- } else {
120
- modifiedFiles.forEach(refreshFile);
121
- }
122
- }
123
-
124
- function isCssFile(filename) {
125
- return filename.endsWith('.css');
126
- }
127
-
128
- function reloadCssFile(filename) {
129
- // Find a stylesheet link starting with /assets (locally-served only) containing the filename
130
- let links = document.querySelectorAll(`link[href^="/assets"][href*="${filename}"][rel="stylesheet"]`);
131
-
132
- if (!links.length) {
133
- console.log(`[HotReload] Could not find link for stylesheet ${filename}`);
134
- } else {
135
- links.forEach(link => {
136
- link.href = new URL(link.href).pathname + `?v=${Date.now()}`;
137
- console.log(`[HotReload] Reloaded stylesheet ${filename}`);
138
- })
139
- }
140
- }
141
-
142
- function isSectionFile(filename) {
143
- return new Section(filename).valid();
144
- }
145
-
146
- function reloadSection(filename) {
147
- new Section(filename).refresh();
148
- }
149
-
150
- class Section {
151
- constructor(filename) {
152
- this.filename = filename;
153
- this.name = filename.split('/').pop().replace('.liquid', '');
154
- this.elements = fetchDOMSections(this.name);
155
- }
156
-
157
- valid() {
158
- return this.filename.startsWith('sections/') && this.elements.length > 0;
159
- }
160
-
161
- async refreshElement(element) {
162
-
163
- const sectionId = element.id.replace(/^shopify-section-/, '');
164
- const url = new URL(window.location.href);
165
-
166
- url.searchParams.append('section_id', sectionId);
167
-
168
- const response = await fetch(url);
169
-
170
- try {
171
- if (response.headers.get('x-templates-from-params') == '1') {
172
- const html = await response.text();
173
- element.outerHTML = html;
174
- } else {
175
- window.location.reload();
176
-
177
- console.log(`[HotReload] Hot-reloading not supported, fully reloading ${this.name} section`);
178
- }
179
-
180
- } catch (e) {
181
- console.log(`[HotReload] Failed to reload ${this.name} section: ${e.message}`);
182
- }
183
- }
184
-
185
- async refresh() {
186
- console.log(`[HotReload] Reloaded ${this.name} sections`);
187
- this.elements.forEach(this.refreshElement);
188
- }
189
- }
190
-
191
- if (isReloadModeActive()) {
192
- connect();
193
- }
194
- })();
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ShopifyCLI
4
- module Theme
5
- class Syncer
6
- module IgnoreHelper
7
- def ignore_operation?(operation)
8
- path = operation.file_path
9
- ignore_path?(path)
10
- end
11
-
12
- def ignore_file?(file)
13
- path = file.relative_path
14
- ignore_path?(path)
15
- end
16
-
17
- def ignore_path?(path)
18
- ignored_by_ignore_filter?(path) || ignored_by_include_filter?(path)
19
- end
20
-
21
- private
22
-
23
- def ignored_by_ignore_filter?(path)
24
- ignore_filter&.ignore?(path)
25
- end
26
-
27
- def ignored_by_include_filter?(path)
28
- !!include_filter && !include_filter.match?(path)
29
- end
30
- end
31
- end
32
- end
33
- end