shopify-cli 1.7.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +28 -0
  3. data/.rubocop_todo.yml +15 -2
  4. data/CHANGELOG.md +21 -0
  5. data/Gemfile.lock +14 -14
  6. data/README.md +2 -1
  7. data/dev.yml +3 -0
  8. data/lib/docgen/markdown.rb +1 -1
  9. data/lib/graphql/extension_create.graphql +17 -2
  10. data/lib/graphql/fetch_specifications.graphql +14 -0
  11. data/lib/project_types/extension/cli.rb +4 -10
  12. data/lib/project_types/extension/commands/create.rb +2 -2
  13. data/lib/project_types/extension/commands/extension_command.rb +10 -6
  14. data/lib/project_types/extension/commands/push.rb +2 -2
  15. data/lib/project_types/extension/commands/register.rb +6 -5
  16. data/lib/project_types/extension/commands/serve.rb +1 -7
  17. data/lib/project_types/extension/extension_project.rb +19 -4
  18. data/lib/project_types/extension/extension_project_keys.rb +2 -1
  19. data/lib/project_types/extension/features/argo.rb +18 -34
  20. data/lib/project_types/extension/features/argo_renderer_package.rb +47 -0
  21. data/lib/project_types/extension/features/argo_serve.rb +69 -0
  22. data/lib/project_types/extension/features/argo_setup.rb +1 -1
  23. data/lib/project_types/extension/forms/questions/ask_type.rb +16 -5
  24. data/lib/project_types/extension/messages/message_loading.rb +3 -1
  25. data/lib/project_types/extension/messages/messages.rb +6 -6
  26. data/lib/project_types/extension/models/registration.rb +1 -0
  27. data/lib/project_types/extension/models/specification.rb +6 -2
  28. data/lib/project_types/extension/models/specification_handlers/default.rb +9 -1
  29. data/lib/project_types/extension/models/specifications.rb +12 -1
  30. data/lib/project_types/extension/models/version.rb +1 -1
  31. data/lib/project_types/extension/tasks/configure_features.rb +3 -1
  32. data/lib/project_types/extension/tasks/converters/registration_converter.rb +2 -0
  33. data/lib/project_types/extension/tasks/fetch_specifications.rb +8 -28
  34. data/lib/project_types/node/commands/generate.rb +0 -22
  35. data/lib/project_types/node/forms/create.rb +10 -1
  36. data/lib/project_types/node/messages/messages.rb +5 -4
  37. data/lib/project_types/rails/forms/create.rb +11 -1
  38. data/lib/project_types/rails/messages/messages.rb +5 -4
  39. data/lib/project_types/script/cli.rb +7 -7
  40. data/lib/project_types/script/commands/create.rb +2 -7
  41. data/lib/project_types/script/commands/push.rb +3 -3
  42. data/lib/project_types/script/config/extension_points.yml +27 -10
  43. data/lib/project_types/script/errors.rb +0 -35
  44. data/lib/project_types/script/forms/create.rb +3 -14
  45. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +5 -5
  46. data/lib/project_types/script/graphql/get_app_scripts.graphql +6 -0
  47. data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
  48. data/lib/project_types/script/layers/application/create_script.rb +32 -22
  49. data/lib/project_types/script/layers/application/extension_points.rb +3 -2
  50. data/lib/project_types/script/layers/application/push_script.rb +6 -3
  51. data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
  52. data/lib/project_types/script/layers/domain/errors.rb +16 -0
  53. data/lib/project_types/script/layers/domain/extension_point.rb +60 -45
  54. data/lib/project_types/script/layers/domain/metadata.rb +18 -25
  55. data/lib/project_types/script/layers/domain/push_package.rb +4 -4
  56. data/lib/project_types/script/layers/domain/script_project.rb +54 -0
  57. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +37 -8
  58. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +5 -40
  59. data/lib/project_types/script/layers/infrastructure/errors.rb +50 -19
  60. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +8 -9
  61. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +1 -1
  62. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +198 -0
  63. data/lib/project_types/script/layers/infrastructure/script_service.rb +27 -66
  64. data/lib/project_types/script/messages/messages.rb +28 -51
  65. data/lib/project_types/script/tasks/ensure_env.rb +77 -0
  66. data/lib/project_types/script/ui/error_handler.rb +63 -47
  67. data/lib/shopify-cli/context.rb +28 -0
  68. data/lib/shopify-cli/js_system.rb +2 -2
  69. data/lib/shopify-cli/messages/messages.rb +3 -2
  70. data/lib/shopify-cli/method_object.rb +1 -1
  71. data/lib/shopify-cli/oauth.rb +2 -2
  72. data/lib/shopify-cli/packager.rb +1 -1
  73. data/lib/shopify-cli/resolve_constant.rb +1 -1
  74. data/lib/shopify-cli/resources/env_file.rb +1 -1
  75. data/lib/shopify-cli/result.rb +3 -3
  76. data/lib/shopify-cli/tasks/ensure_dev_store.rb +1 -1
  77. data/lib/shopify-cli/transform_data_structure.rb +2 -2
  78. data/lib/shopify-cli/version.rb +1 -1
  79. data/lib/shopify_cli.rb +0 -1
  80. data/vendor/deps/smart_properties/REVISION +1 -1
  81. data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
  82. data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
  83. metadata +11 -10
  84. data/.travis.yml +0 -14
  85. data/lib/project_types/script/commands/disable.rb +0 -25
  86. data/lib/project_types/script/commands/enable.rb +0 -80
  87. data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
  88. data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
  89. data/lib/project_types/script/layers/application/disable_script.rb +0 -21
  90. data/lib/project_types/script/layers/application/enable_script.rb +0 -23
  91. data/lib/project_types/script/script_project.rb +0 -85
@@ -11,11 +11,11 @@ module Script
11
11
  property! :ctx, accepts: ShopifyCli::Context
12
12
 
13
13
  def push(
14
+ uuid:,
14
15
  extension_point_type:,
15
16
  script_name:,
16
17
  script_content:,
17
18
  compiled_type:,
18
- description: nil,
19
19
  api_key: nil,
20
20
  force: false,
21
21
  metadata:,
@@ -23,10 +23,10 @@ module Script
23
23
  )
24
24
  query_name = "app_script_update_or_create"
25
25
  variables = {
26
+ uuid: uuid,
26
27
  extensionPointName: extension_point_type.upcase,
27
28
  title: script_name,
28
- description: description,
29
- configUi: config_ui,
29
+ configUi: config_ui&.content,
30
30
  sourceCode: Base64.encode64(script_content),
31
31
  language: compiled_type,
32
32
  force: force,
@@ -37,92 +37,53 @@ module Script
37
37
  resp_hash = script_service_request(query_name: query_name, api_key: api_key, variables: variables)
38
38
  user_errors = resp_hash["data"]["appScriptUpdateOrCreate"]["userErrors"]
39
39
 
40
- return resp_hash if user_errors.empty?
40
+ return resp_hash["data"]["appScriptUpdateOrCreate"]["appScript"]["uuid"] if user_errors.empty?
41
41
 
42
42
  if user_errors.any? { |e| e["tag"] == "already_exists_error" }
43
43
  raise Errors::ScriptRepushError, api_key
44
+ elsif (e = user_errors.any? { |err| err["tag"] == "config_ui_syntax_error" })
45
+ raise Errors::ConfigUiSyntaxError, config_ui&.filename
46
+ elsif (e = user_errors.find { |err| err["tag"] == "config_ui_missing_keys_error" })
47
+ raise Errors::ConfigUiMissingKeysError.new(config_ui&.filename, e["message"])
48
+ elsif (e = user_errors.find { |err| err["tag"] == "config_ui_invalid_input_mode_error" })
49
+ raise Errors::ConfigUiInvalidInputModeError.new(config_ui&.filename, e["message"])
50
+ elsif (e = user_errors.find { |err| err["tag"] == "config_ui_fields_missing_keys_error" })
51
+ raise Errors::ConfigUiFieldsMissingKeysError.new(config_ui&.filename, e["message"])
52
+ elsif (e = user_errors.find { |err| err["tag"] == "config_ui_fields_invalid_type_error" })
53
+ raise Errors::ConfigUiFieldsInvalidTypeError.new(config_ui&.filename, e["message"])
54
+ elsif user_errors.find { |err| %w(not_use_msgpack_error schema_version_argument_error).include?(err["tag"]) }
55
+ raise Domain::Errors::MetadataValidationError
44
56
  else
45
- raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
57
+ raise Errors::GraphqlError, user_errors
46
58
  end
47
59
  end
48
60
 
49
- def enable(api_key:, shop_domain:, configuration:, extension_point_type:, title:)
50
- query_name = "shop_script_update_or_create"
51
- variables = {
52
- extensionPointName: extension_point_type.upcase,
53
- configuration: configuration,
54
- title: title,
55
- }
56
-
57
- resp_hash = script_service_request(
58
- query_name: query_name,
59
- api_key: api_key,
60
- shop_domain: format_shop_domain(shop_domain),
61
- variables: variables,
62
- )
63
- user_errors = resp_hash["data"]["shopScriptUpdateOrCreate"]["userErrors"]
64
-
65
- return resp_hash if user_errors.empty?
66
-
67
- if user_errors.any? { |e| e["tag"] == "app_script_not_found" }
68
- raise Errors::AppScriptUndefinedError, api_key
69
- elsif user_errors.any? { |e| e["tag"] == "shop_script_conflict" }
70
- raise Errors::ShopScriptConflictError
71
- elsif user_errors.any? { |e| e["tag"] == "app_script_not_pushed" }
72
- raise Errors::AppScriptNotPushedError
73
- else
74
- raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
75
- end
76
- end
77
-
78
- def disable(api_key:, shop_domain:, extension_point_type:)
79
- query_name = "shop_script_delete"
80
- variables = {
81
- extensionPointName: extension_point_type.upcase,
82
- }
83
-
84
- resp_hash = script_service_request(
85
- query_name: query_name,
86
- api_key: api_key,
87
- shop_domain: format_shop_domain(shop_domain),
88
- variables: variables,
89
- )
90
- user_errors = resp_hash["data"]["shopScriptDelete"]["userErrors"]
91
- return resp_hash if user_errors.empty?
92
-
93
- if user_errors.any? { |e| e["tag"] == "shop_script_not_found" }
94
- raise Errors::ShopScriptUndefinedError, api_key
95
- else
96
- raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
97
- end
61
+ def get_app_scripts(api_key:, extension_point_type:)
62
+ query_name = "get_app_scripts"
63
+ variables = { appKey: api_key, extensionPointName: extension_point_type.upcase }
64
+ script_service_request(query_name: query_name, api_key: api_key, variables: variables)["data"]["appScripts"]
98
65
  end
99
66
 
100
67
  private
101
68
 
102
- def format_shop_domain(shop_domain)
103
- shop_domain.delete_suffix("/")
104
- end
105
-
106
69
  class ScriptServiceAPI < ShopifyCli::API
107
70
  property(:api_key, accepts: String)
108
- property(:shop_id, accepts: Integer)
109
71
 
110
- def self.query(ctx, query_name, api_key: nil, shop_domain: nil, variables: {})
111
- api_client(ctx, api_key, shop_domain).query(query_name, variables: variables)
72
+ def self.query(ctx, query_name, api_key: nil, variables: {})
73
+ api_client(ctx, api_key).query(query_name, variables: variables)
112
74
  end
113
75
 
114
- def self.api_client(ctx, api_key, shop_domain)
76
+ def self.api_client(ctx, api_key)
115
77
  new(
116
78
  ctx: ctx,
117
79
  url: "https://script-service.myshopify.io/graphql",
118
80
  token: "",
119
- api_key: api_key,
120
- shop_id: shop_domain&.to_i
81
+ api_key: api_key
121
82
  )
122
83
  end
123
84
 
124
85
  def auth_headers(*)
125
- tokens = { "APP_KEY" => api_key, "SHOP_ID" => shop_id }.compact.to_json
86
+ tokens = { "APP_KEY" => api_key }.compact.to_json
126
87
  { "X-Shopify-Authenticated-Tokens" => tokens }
127
88
  end
128
89
  end
@@ -165,7 +126,7 @@ module Script
165
126
  when "app_not_installed_on_shop"
166
127
  raise Errors::AppNotInstalledError
167
128
  else
168
- raise Errors::GraphqlError, response["errors"].map { |e| e["message"] }
129
+ raise Errors::GraphqlError, response["errors"]
169
130
  end
170
131
  end
171
132
 
@@ -57,14 +57,30 @@ module Script
57
57
  missing_config_ui_definition_cause: "You are missing the UI configuration file %s.",
58
58
  missing_config_ui_definition_help: "Create this file and try again.",
59
59
 
60
+ config_ui_syntax_error_cause: "The UI configuration file %{filename} is not formatted properly.",
61
+ config_ui_syntax_error_help: "Fix the errors and try again.",
62
+
63
+ config_ui_missing_keys_error_cause: "The UI configuration file %{filename} is missing required keys: "\
64
+ "%{missing_keys}.",
65
+ config_ui_missing_keys_error_help: "Add the keys and try again.",
66
+
67
+ config_ui_invalid_input_mode_error_cause: "The UI configuration file %{filename} only accept "\
68
+ "one of the following input mode(s): %{valid_input_modes}.",
69
+ config_ui_invalid_input_mode_error_help: "Change the input modes and try again.",
70
+
71
+ config_ui_fields_missing_keys_error_cause: "A field entry in the UI configuration file %{filename} is "\
72
+ "missing required keys: %{missing_keys}.",
73
+ config_ui_fields_missing_keys_error_help: "Add the keys and try again.",
74
+
75
+ config_ui_fields_invalid_type_error_cause: "The UI configuration file %{filename} fields only accept "\
76
+ "one of the following type(s): %{valid_types}.",
77
+ config_ui_fields_invalid_type_error_help: "Change the types and try again.",
78
+
60
79
  script_not_found_cause: "Couldn't find script %s for extension point %s",
61
80
 
62
81
  service_failure_cause: "Internal service error.",
63
82
  service_failure_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date.",
64
83
 
65
- user_error_cause: "Invalid script extension metadata.",
66
- user_error_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date.",
67
-
68
84
  metadata_validation_cause: "Invalid script extension metadata.",
69
85
  metadata_validation_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date.",
70
86
 
@@ -83,8 +99,6 @@ module Script
83
99
  "'--metadata build/metadata.json' argument",
84
100
  app_not_installed_cause: "App not installed on store.",
85
101
 
86
- app_script_not_pushed_help: "Script isn't on the app. Run {{command:shopify push}}, and then try again.",
87
-
88
102
  build_error_cause: "Something went wrong while building the script.",
89
103
  build_error_help: "Correct the errors and try again.",
90
104
 
@@ -105,22 +119,13 @@ module Script
105
119
  shop_auth_cause: "Unable to authenticate with the store.",
106
120
  shop_auth_help: "Try again.",
107
121
 
108
- shop_script_conflict_cause: "Another app in this store has already enabled a script "\
109
- "on this extension point.",
110
- shop_script_conflict_help: "Disable that script or uninstall that app and try again.",
111
-
112
- shop_script_undefined_cause: "Script is already turned off in store.",
113
-
114
- packages_outdated_cause: "These npm packages are out of date: %s.",
115
- packages_outdated_help: "To update them, run {{cyan:npm install --save-dev %s}}.",
116
-
117
122
  invalid_build_script: "The root package.json contains an invalid build command that " \
118
123
  "is needed to compile your script to WebAssembly.",
119
124
  build_script_not_found: "The root package.json is missing the build command that " \
120
125
  "is needed to compile your script to WebAssembly.",
121
126
  # rubocop:disable Layout/LineLength
122
127
  build_script_suggestion: "\n\nFor example, your package.json needs the following command:" \
123
- "\nbuild: npx shopify-scripts-toolchain-as build --src src/script.ts --binary build/<script_name>.wasm --metadata build/metadata.json -- --lib node_modules --optimize --use Date=",
128
+ "\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=",
124
129
 
125
130
  web_assembly_binary_not_found: "WebAssembly binary not found.",
126
131
  web_assembly_binary_not_found_suggestion: "No WebAssembly binary found." \
@@ -134,8 +139,8 @@ module Script
134
139
  Usage: {{command:%1$s create script}}
135
140
  Options:
136
141
  {{command:--name=NAME}} Script project name. Use any string.
137
- {{command:--description=DESCRIPTION}} Description of the project. Use any string.
138
142
  {{command:--extension-point=TYPE}} Extension point name. Allowed values: %2$s.
143
+ {{command:--no-config-ui}} Specify this option if you don’t want Scripts to render an interface in the Shopify admin.
139
144
  HELP
140
145
 
141
146
  error: {
@@ -162,40 +167,6 @@ module Script
162
167
  script_pushed: "{{v}} Script pushed to app (API key: %{api_key}).",
163
168
  },
164
169
 
165
- disable: {
166
- help: <<~HELP,
167
- Turn off script in store.
168
- Usage: {{command:%s disable}}
169
- HELP
170
-
171
- error: {
172
- operation_failed: "Can't disable script.",
173
- },
174
-
175
- script_disabled: "{{v}} Script disabled. Script is turned off in store.",
176
- },
177
-
178
- enable: {
179
- help: <<~HELP,
180
- Turn on script in store.
181
- Usage: {{command:%s enable}}
182
- Options:
183
- {{command:--config-props='name1:value1, name2:value2'}} Optional. Define the configuration of your script by passing individual name and value pairs. If used with --config_file, then matching values in --config-props will override those set in the file.
184
- {{command:--config_file=<path/to/YAMLFilename>}} Optional. Define the configuration of your script using a YAML formatted file. --config-props values override properties in this file.
185
- HELP
186
-
187
- info: "{{*}} A script always remains enabled until you disable it - even after pushing "\
188
- "script changes with the same extension point to an app. To disable a script, use "\
189
- "the 'disable' command.",
190
-
191
- error: {
192
- operation_failed: "Can't enable script.",
193
- },
194
-
195
- script_enabled: "{{v}} Script enabled. %{type} script %{title} in app (API key: %{api_key}) "\
196
- "is turned on in store {{green:%{shop_domain}}}",
197
- },
198
-
199
170
  project_deps: {
200
171
  none_required: "{{v}} None required",
201
172
  checking_with_npm: "Checking dependencies with npm",
@@ -208,7 +179,6 @@ module Script
208
179
  select_extension_point: "Which extension point do you want to use?",
209
180
  select_language: "Which language do you want to use?",
210
181
  script_name: "Script Name",
211
- description: "Description",
212
182
  },
213
183
  },
214
184
 
@@ -222,6 +192,13 @@ module Script
222
192
  disabled: "Disabled",
223
193
  enabling: "Enabling",
224
194
  enabled: "Enabled",
195
+ ensure_env: {
196
+ organization_select: "Which partner organization do you want to use?",
197
+ app_select: "Which app do you want to push this script to?",
198
+ ask_connect_to_existing_script: "This app has some scripts. Do you want to replace any of the "\
199
+ "existing scripts with the current script?",
200
+ ask_which_script_to_connect_to: "Which script do you want to replace?",
201
+ },
225
202
  },
226
203
  },
227
204
  }.freeze
@@ -0,0 +1,77 @@
1
+ require "shopify_cli"
2
+
3
+ module Script
4
+ module Tasks
5
+ class EnsureEnv < ShopifyCli::Task
6
+ attr_accessor :ctx
7
+
8
+ def call(ctx)
9
+ self.ctx = ctx
10
+
11
+ script_project_repo = Layers::Infrastructure::ScriptProjectRepository.new(ctx: ctx)
12
+ script_project = script_project_repo.get
13
+
14
+ return if script_project.api_key && script_project.api_secret && script_project.uuid_defined?
15
+
16
+ org = ask_org
17
+ app = ask_app(org["apps"])
18
+ uuid = ask_script_uuid(app, script_project.extension_point_type)
19
+
20
+ script_project_repo.create_env(
21
+ api_key: app["apiKey"],
22
+ secret: app["apiSecretKeys"].first["secret"],
23
+ uuid: uuid
24
+ )
25
+ end
26
+
27
+ private
28
+
29
+ def ask_org
30
+ if ShopifyCli::Shopifolk.check && wants_to_run_against_shopify_org?
31
+ ShopifyCli::Shopifolk.act_as_shopify_organization
32
+ end
33
+
34
+ orgs = ShopifyCli::PartnersAPI::Organizations.fetch_with_app(ctx)
35
+ if orgs.count == 1
36
+ orgs.first
37
+ elsif orgs.count > 0
38
+ CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.organization_select")) do |handler|
39
+ orgs.each do |org|
40
+ handler.option("#{org["businessName"]} (#{org["id"]})") { org }
41
+ end
42
+ end
43
+ else
44
+ raise Errors::NoExistingOrganizationsError
45
+ end
46
+ end
47
+
48
+ def ask_app(apps)
49
+ if apps.count == 1
50
+ apps.first
51
+ elsif apps.count > 0
52
+ CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.app_select")) do |handler|
53
+ apps.each do |app|
54
+ handler.option(app["title"]) { app }
55
+ end
56
+ end
57
+ else
58
+ raise Errors::NoExistingAppsError
59
+ end
60
+ end
61
+
62
+ def ask_script_uuid(app, extension_point_type)
63
+ script_service = Layers::Infrastructure::ScriptService.new(ctx: ctx)
64
+ scripts = script_service.get_app_scripts(api_key: app["apiKey"], extension_point_type: extension_point_type)
65
+
66
+ return nil unless scripts.count > 0 &&
67
+ CLI::UI::Prompt.confirm(ctx.message("script.application.ensure_env.ask_connect_to_existing_script"))
68
+
69
+ CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.ask_which_script_to_connect_to")) do |handler|
70
+ scripts.each do |script|
71
+ handler.option("#{script["title"]} (#{script["uuid"]})") { script["uuid"] }
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -39,7 +39,7 @@ module Script
39
39
  cause_of_error: ShopifyCli::Context.message("script.error.oauth_cause"),
40
40
  help_suggestion: ShopifyCli::Context.message("script.error.oauth_help"),
41
41
  }
42
- when Errors::InvalidContextError
42
+ when Layers::Infrastructure::Errors::InvalidContextError
43
43
  {
44
44
  cause_of_error: ShopifyCli::Context.message("script.error.invalid_context_cause"),
45
45
  help_suggestion: ShopifyCli::Context.message("script.error.invalid_context_help"),
@@ -53,7 +53,7 @@ module Script
53
53
  {
54
54
  cause_of_error: ShopifyCli::Context.message("script.error.invalid_config", e.config_file),
55
55
  }
56
- when Errors::InvalidLanguageError
56
+ when Layers::Infrastructure::Errors::InvalidLanguageError
57
57
  {
58
58
  cause_of_error: ShopifyCli::Context.message("script.error.invalid_language_cause", e.language),
59
59
  help_suggestion: ShopifyCli::Context.message(
@@ -61,18 +61,6 @@ module Script
61
61
  Script::Layers::Application::ExtensionPoints.languages(type: e.extension_point_type).join(", ")
62
62
  ),
63
63
  }
64
- when Errors::InvalidConfigUiDefinitionError
65
- {
66
- cause_of_error: ShopifyCli::Context
67
- .message("script.error.invalid_config_ui_definition_cause", e.filename),
68
- help_suggestion: ShopifyCli::Context.message("script.error.invalid_config_ui_definition_help"),
69
- }
70
- when Errors::MissingSpecifiedConfigUiDefinitionError
71
- {
72
- cause_of_error: ShopifyCli::Context
73
- .message("script.error.missing_config_ui_definition_cause", e.filename),
74
- help_suggestion: ShopifyCli::Context.message("script.error.missing_config_ui_definition_help"),
75
- }
76
64
  when Errors::InvalidScriptNameError
77
65
  {
78
66
  cause_of_error: ShopifyCli::Context.message("script.error.invalid_script_name_cause"),
@@ -96,12 +84,12 @@ module Script
96
84
  organization_id: e.organization_id
97
85
  ),
98
86
  }
99
- when Errors::ScriptProjectAlreadyExistsError
87
+ when Layers::Infrastructure::Errors::ScriptProjectAlreadyExistsError
100
88
  {
101
89
  cause_of_error: ShopifyCli::Context.message("script.error.project_exists_cause"),
102
90
  help_suggestion: ShopifyCli::Context.message("script.error.project_exists_help"),
103
91
  }
104
- when Errors::DeprecatedEPError
92
+ when Layers::Infrastructure::Errors::DeprecatedEPError
105
93
  {
106
94
  cause_of_error: ShopifyCli::Context.message("script.error.deprecated_ep", e.ep),
107
95
  help_suggestion: ShopifyCli::Context.message("script.error.deprecated_ep_cause"),
@@ -137,20 +125,71 @@ module Script
137
125
  cause_of_error: ShopifyCli::Context.message("script.error.metadata_not_found_cause"),
138
126
  help_suggestion: ShopifyCli::Context.message("script.error.metadata_not_found_help"),
139
127
  }
140
- when Layers::Infrastructure::Errors::AppNotInstalledError
128
+ when Layers::Domain::Errors::InvalidConfigUiDefinitionError
141
129
  {
142
- cause_of_error: ShopifyCli::Context.message("script.error.app_not_installed_cause"),
130
+ cause_of_error: ShopifyCli::Context
131
+ .message("script.error.invalid_config_ui_definition_cause", e.filename),
132
+ help_suggestion: ShopifyCli::Context.message("script.error.invalid_config_ui_definition_help"),
143
133
  }
144
- when Layers::Infrastructure::Errors::AppScriptNotPushedError,
145
- Layers::Infrastructure::Errors::AppScriptUndefinedError
134
+ when Layers::Domain::Errors::MissingSpecifiedConfigUiDefinitionError
135
+ {
136
+ cause_of_error: ShopifyCli::Context
137
+ .message("script.error.missing_config_ui_definition_cause", e.filename),
138
+ help_suggestion: ShopifyCli::Context.message("script.error.missing_config_ui_definition_help"),
139
+ }
140
+ when Layers::Infrastructure::Errors::AppNotInstalledError
146
141
  {
147
- cause_of_error: ShopifyCli::Context.message("script.error.app_script_not_pushed_help"),
142
+ cause_of_error: ShopifyCli::Context.message("script.error.app_not_installed_cause"),
148
143
  }
149
144
  when Layers::Infrastructure::Errors::BuildError
150
145
  {
151
146
  cause_of_error: ShopifyCli::Context.message("script.error.build_error_cause"),
152
147
  help_suggestion: ShopifyCli::Context.message("script.error.build_error_help"),
153
148
  }
149
+ when Layers::Infrastructure::Errors::ConfigUiSyntaxError
150
+ {
151
+ cause_of_error: ShopifyCli::Context.message(
152
+ "script.error.config_ui_syntax_error_cause",
153
+ filename: e.message
154
+ ),
155
+ help_suggestion: ShopifyCli::Context.message("script.error.config_ui_syntax_error_help"),
156
+ }
157
+ when Layers::Infrastructure::Errors::ConfigUiMissingKeysError
158
+ {
159
+ cause_of_error: ShopifyCli::Context.message(
160
+ "script.error.config_ui_missing_keys_error_cause",
161
+ filename: e.filename,
162
+ missing_keys: e.missing_keys
163
+ ),
164
+ help_suggestion: ShopifyCli::Context.message("script.error.config_ui_missing_keys_error_help"),
165
+ }
166
+ when Layers::Infrastructure::Errors::ConfigUiInvalidInputModeError
167
+ {
168
+ cause_of_error: ShopifyCli::Context.message(
169
+ "script.error.config_ui_invalid_input_mode_error_cause",
170
+ filename: e.filename,
171
+ valid_input_modes: e.valid_input_modes
172
+ ),
173
+ help_suggestion: ShopifyCli::Context.message("script.error.config_ui_invalid_input_mode_error_help"),
174
+ }
175
+ when Layers::Infrastructure::Errors::ConfigUiFieldsMissingKeysError
176
+ {
177
+ cause_of_error: ShopifyCli::Context.message(
178
+ "script.error.config_ui_fields_missing_keys_error_cause",
179
+ filename: e.filename,
180
+ missing_keys: e.missing_keys
181
+ ),
182
+ help_suggestion: ShopifyCli::Context.message("script.error.config_ui_fields_missing_keys_error_help"),
183
+ }
184
+ when Layers::Infrastructure::Errors::ConfigUiFieldsInvalidTypeError
185
+ {
186
+ cause_of_error: ShopifyCli::Context.message(
187
+ "script.error.config_ui_fields_invalid_type_error_cause",
188
+ filename: e.filename,
189
+ valid_types: e.valid_types
190
+ ),
191
+ help_suggestion: ShopifyCli::Context.message("script.error.config_ui_fields_invalid_type_error_help"),
192
+ }
154
193
  when Layers::Infrastructure::Errors::DependencyInstallError
155
194
  {
156
195
  cause_of_error: ShopifyCli::Context.message("script.error.dependency_install_cause"),
@@ -167,7 +206,9 @@ module Script
167
206
  }
168
207
  when Layers::Infrastructure::Errors::GraphqlError
169
208
  {
170
- cause_of_error: ShopifyCli::Context.message("script.error.graphql_error_cause", e.errors.join(", ")),
209
+ cause_of_error: ShopifyCli::Context.message(
210
+ "script.error.graphql_error_cause", JSON.pretty_generate(e.errors)
211
+ ),
171
212
  help_suggestion: ShopifyCli::Context.message("script.error.graphql_error_help"),
172
213
  }
173
214
  when Layers::Infrastructure::Errors::ScriptRepushError
@@ -175,36 +216,11 @@ module Script
175
216
  cause_of_error: ShopifyCli::Context.message("script.error.script_repush_cause", e.api_key),
176
217
  help_suggestion: ShopifyCli::Context.message("script.error.script_repush_help"),
177
218
  }
178
- when Layers::Infrastructure::Errors::ScriptServiceUserError
179
- {
180
- cause_of_error: ShopifyCli::Context.message("script.error.user_error_cause"),
181
- help_suggestion: ShopifyCli::Context.message("script.error.user_error_help"),
182
- }
183
219
  when Layers::Infrastructure::Errors::ShopAuthenticationError
184
220
  {
185
221
  cause_of_error: ShopifyCli::Context.message("script.error.shop_auth_cause"),
186
222
  help_suggestion: ShopifyCli::Context.message("script.error.shop_auth_help"),
187
223
  }
188
- when Layers::Infrastructure::Errors::ShopScriptConflictError
189
- {
190
- cause_of_error: ShopifyCli::Context.message("script.error.shop_script_conflict_cause"),
191
- help_suggestion: ShopifyCli::Context.message("script.error.shop_script_conflict_help"),
192
- }
193
- when Layers::Infrastructure::Errors::ShopScriptUndefinedError
194
- {
195
- cause_of_error: ShopifyCli::Context.message("script.error.shop_script_undefined_cause"),
196
- }
197
- when Layers::Infrastructure::Errors::PackagesOutdatedError
198
- {
199
- cause_of_error: ShopifyCli::Context.message(
200
- "script.error.packages_outdated_cause",
201
- e.outdated_packages.join(", ")
202
- ),
203
- help_suggestion: ShopifyCli::Context.message(
204
- "script.error.packages_outdated_help",
205
- e.outdated_packages.collect { |package| "#{package}@latest" }.join(" ")
206
- ),
207
- }
208
224
  when Layers::Infrastructure::Errors::BuildScriptNotFoundError
209
225
  {
210
226
  cause_of_error: ShopifyCli::Context.message("script.error.build_script_not_found"),