shopify-cli 2.25.0 → 2.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/dev.yml +0 -3
- data/lib/project_types/extension/models/specification_handlers/default.rb +6 -1
- data/lib/project_types/script/cli.rb +0 -79
- data/lib/project_types/script/commands/connect.rb +3 -8
- data/lib/project_types/script/commands/create.rb +4 -29
- data/lib/project_types/script/commands/javy.rb +3 -8
- data/lib/project_types/script/commands/push.rb +4 -41
- data/lib/project_types/script/messages/messages.rb +1 -258
- data/lib/project_types/theme/commands/common/shop_helper.rb +13 -0
- data/lib/project_types/theme/commands/delete.rb +4 -1
- data/lib/project_types/theme/commands/list.rb +3 -4
- data/lib/project_types/theme/commands/open.rb +4 -1
- data/lib/project_types/theme/commands/publish.rb +4 -1
- data/lib/project_types/theme/commands/pull.rb +3 -1
- data/lib/project_types/theme/commands/push.rb +3 -1
- data/lib/project_types/theme/commands/serve.rb +2 -1
- data/lib/project_types/theme/messages/messages.rb +5 -5
- data/lib/shopify_cli/messages/messages.rb +1 -1
- data/lib/shopify_cli/packager.rb +12 -3
- data/lib/shopify_cli/release.rb +4 -2
- data/lib/shopify_cli/version.rb +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +1 -1
- metadata +3 -48
- data/lib/project_types/script/config/extension_points.yml +0 -45
- data/lib/project_types/script/errors.rb +0 -10
- data/lib/project_types/script/forms/ask_app.rb +0 -27
- data/lib/project_types/script/forms/ask_org.rb +0 -30
- data/lib/project_types/script/forms/ask_script_uuid.rb +0 -22
- data/lib/project_types/script/forms/create.rb +0 -33
- data/lib/project_types/script/forms/run_against_shopify_org.rb +0 -14
- data/lib/project_types/script/graphql/app_script_set.graphql +0 -46
- data/lib/project_types/script/graphql/get_app_scripts.graphql +0 -6
- data/lib/project_types/script/graphql/module_upload_url_generate.graphql +0 -13
- data/lib/project_types/script/graphql/script_service_proxy.graphql +0 -7
- data/lib/project_types/script/layers/application/build_script.rb +0 -25
- data/lib/project_types/script/layers/application/connect_app.rb +0 -86
- data/lib/project_types/script/layers/application/create_script.rb +0 -90
- data/lib/project_types/script/layers/application/extension_points.rb +0 -66
- data/lib/project_types/script/layers/application/project_dependencies.rb +0 -26
- data/lib/project_types/script/layers/application/push_script.rb +0 -74
- data/lib/project_types/script/layers/domain/app_bridge.rb +0 -16
- data/lib/project_types/script/layers/domain/errors.rb +0 -47
- data/lib/project_types/script/layers/domain/extension_point.rb +0 -81
- data/lib/project_types/script/layers/domain/metadata.rb +0 -46
- data/lib/project_types/script/layers/domain/push_package.rb +0 -41
- data/lib/project_types/script/layers/domain/script_config.rb +0 -32
- data/lib/project_types/script/layers/domain/script_project.rb +0 -61
- data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -53
- data/lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb +0 -35
- data/lib/project_types/script/layers/infrastructure/command_runner.rb +0 -19
- data/lib/project_types/script/layers/infrastructure/errors.rb +0 -211
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +0 -37
- data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +0 -62
- data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +0 -47
- data/lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb +0 -26
- data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +0 -45
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +0 -103
- data/lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb +0 -12
- data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +0 -32
- data/lib/project_types/script/layers/infrastructure/metadata_repository.rb +0 -18
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +0 -36
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +0 -273
- data/lib/project_types/script/layers/infrastructure/script_service.rb +0 -135
- data/lib/project_types/script/layers/infrastructure/script_uploader.rb +0 -40
- data/lib/project_types/script/layers/infrastructure/service_locator.rb +0 -20
- data/lib/project_types/script/layers/infrastructure/sparse_checkout_details.rb +0 -35
- data/lib/project_types/script/ui/error_handler.rb +0 -331
- data/lib/project_types/script/ui/printing_spinner.rb +0 -75
- data/lib/project_types/script/ui/strict_spinner.rb +0 -20
@@ -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
|