shopify-cli 1.5.0 → 1.9.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 (305) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
  3. data/.rubocop_todo.yml +15 -2
  4. data/.travis.yml +1 -0
  5. data/CHANGELOG.md +26 -0
  6. data/Gemfile +12 -12
  7. data/Gemfile.lock +14 -14
  8. data/README.md +39 -7
  9. data/Rakefile +32 -28
  10. data/bin/load_shopify.rb +6 -6
  11. data/bin/shopify +2 -2
  12. data/dev.yml +5 -2
  13. data/docs/_config.yml +1 -18
  14. data/docs/app/node/commands/index.md +2 -80
  15. data/docs/app/node/index.md +2 -33
  16. data/docs/app/rails/commands/index.md +2 -78
  17. data/docs/app/rails/index.md +2 -34
  18. data/docs/core/index.md +2 -84
  19. data/docs/getting-started/index.md +2 -25
  20. data/docs/getting-started/install/index.md +1 -118
  21. data/docs/getting-started/migrate/index.md +2 -94
  22. data/docs/getting-started/uninstall/index.md +2 -35
  23. data/docs/getting-started/upgrade/index.md +2 -39
  24. data/docs/help/start-app/index.md +2 -4
  25. data/docs/index.md +2 -24
  26. data/ext/shopify-cli/extconf.rb +7 -7
  27. data/install.sh +1 -1
  28. data/lib/docgen/markdown.rb +12 -12
  29. data/lib/graphql/extension_create.graphql +17 -2
  30. data/lib/graphql/fetch_specifications.graphql +14 -0
  31. data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
  32. data/lib/project_types/extension/cli.rb +56 -48
  33. data/lib/project_types/extension/commands/build.rb +3 -3
  34. data/lib/project_types/extension/commands/create.rb +17 -10
  35. data/lib/project_types/extension/commands/extension_command.rb +14 -7
  36. data/lib/project_types/extension/commands/push.rb +10 -10
  37. data/lib/project_types/extension/commands/register.rb +22 -32
  38. data/lib/project_types/extension/commands/serve.rb +1 -7
  39. data/lib/project_types/extension/commands/tunnel.rb +12 -12
  40. data/lib/project_types/extension/extension_project.rb +22 -7
  41. data/lib/project_types/extension/extension_project_keys.rb +5 -4
  42. data/lib/project_types/extension/features/argo.rb +123 -0
  43. data/lib/project_types/extension/features/argo_config.rb +5 -5
  44. data/lib/project_types/extension/features/argo_dependencies.rb +5 -5
  45. data/lib/project_types/extension/features/argo_renderer_package.rb +32 -0
  46. data/lib/project_types/extension/features/argo_serve.rb +69 -0
  47. data/lib/project_types/extension/features/argo_setup.rb +2 -2
  48. data/lib/project_types/extension/features/argo_setup_steps.rb +4 -4
  49. data/lib/project_types/extension/forms/create.rb +28 -34
  50. data/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
  51. data/lib/project_types/extension/forms/questions/ask_name.rb +40 -0
  52. data/lib/project_types/extension/forms/questions/ask_type.rb +47 -0
  53. data/lib/project_types/extension/messages/message_loading.rb +3 -1
  54. data/lib/project_types/extension/messages/messages.rb +55 -52
  55. data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
  56. data/lib/project_types/extension/models/registration.rb +1 -0
  57. data/lib/project_types/extension/models/specification.rb +39 -0
  58. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +19 -0
  59. data/lib/project_types/extension/models/specification_handlers/default.rb +75 -0
  60. data/lib/project_types/extension/models/specifications.rb +88 -0
  61. data/lib/project_types/extension/tasks/configure_features.rb +54 -0
  62. data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
  63. data/lib/project_types/extension/tasks/converters/registration_converter.rb +8 -6
  64. data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +4 -4
  65. data/lib/project_types/extension/tasks/converters/version_converter.rb +7 -7
  66. data/lib/project_types/extension/tasks/create_extension.rb +4 -4
  67. data/lib/project_types/extension/tasks/fetch_specifications.rb +18 -0
  68. data/lib/project_types/extension/tasks/get_app.rb +4 -4
  69. data/lib/project_types/extension/tasks/get_apps.rb +3 -3
  70. data/lib/project_types/extension/tasks/update_draft.rb +4 -4
  71. data/lib/project_types/extension/tasks/user_errors.rb +4 -4
  72. data/lib/project_types/node/cli.rb +19 -19
  73. data/lib/project_types/node/commands/connect.rb +3 -3
  74. data/lib/project_types/node/commands/create.rb +42 -38
  75. data/lib/project_types/node/commands/deploy.rb +4 -4
  76. data/lib/project_types/node/commands/deploy/heroku.rb +24 -24
  77. data/lib/project_types/node/commands/generate.rb +3 -34
  78. data/lib/project_types/node/commands/open.rb +2 -2
  79. data/lib/project_types/node/commands/populate.rb +6 -6
  80. data/lib/project_types/node/commands/populate/customer.rb +5 -5
  81. data/lib/project_types/node/commands/populate/draft_order.rb +5 -5
  82. data/lib/project_types/node/commands/populate/product.rb +5 -5
  83. data/lib/project_types/node/commands/serve.rb +9 -9
  84. data/lib/project_types/node/commands/tunnel.rb +7 -7
  85. data/lib/project_types/node/forms/create.rb +17 -8
  86. data/lib/project_types/node/messages/messages.rb +13 -47
  87. data/lib/project_types/rails/cli.rb +21 -21
  88. data/lib/project_types/rails/commands/connect.rb +3 -3
  89. data/lib/project_types/rails/commands/create.rb +56 -54
  90. data/lib/project_types/rails/commands/deploy.rb +4 -4
  91. data/lib/project_types/rails/commands/deploy/heroku.rb +30 -30
  92. data/lib/project_types/rails/commands/generate.rb +7 -7
  93. data/lib/project_types/rails/commands/generate/webhook.rb +6 -6
  94. data/lib/project_types/rails/commands/open.rb +2 -2
  95. data/lib/project_types/rails/commands/populate.rb +6 -6
  96. data/lib/project_types/rails/commands/populate/customer.rb +5 -5
  97. data/lib/project_types/rails/commands/populate/draft_order.rb +5 -5
  98. data/lib/project_types/rails/commands/populate/product.rb +5 -5
  99. data/lib/project_types/rails/commands/serve.rb +11 -11
  100. data/lib/project_types/rails/commands/tunnel.rb +7 -7
  101. data/lib/project_types/rails/forms/create.rb +35 -25
  102. data/lib/project_types/rails/gem.rb +24 -24
  103. data/lib/project_types/rails/messages/messages.rb +6 -5
  104. data/lib/project_types/rails/ruby.rb +2 -2
  105. data/lib/project_types/script/cli.rb +38 -39
  106. data/lib/project_types/script/commands/create.rb +12 -14
  107. data/lib/project_types/script/commands/push.rb +10 -17
  108. data/lib/project_types/script/config/extension_points.yml +29 -10
  109. data/lib/project_types/script/errors.rb +1 -2
  110. data/lib/project_types/script/forms/create.rb +18 -5
  111. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +9 -1
  112. data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
  113. data/lib/project_types/script/layers/application/build_script.rb +10 -7
  114. data/lib/project_types/script/layers/application/create_script.rb +37 -25
  115. data/lib/project_types/script/layers/application/extension_points.rb +25 -0
  116. data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
  117. data/lib/project_types/script/layers/application/push_script.rb +13 -18
  118. data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
  119. data/lib/project_types/script/layers/domain/errors.rb +20 -0
  120. data/lib/project_types/script/layers/domain/extension_point.rb +82 -11
  121. data/lib/project_types/script/layers/domain/metadata.rb +48 -0
  122. data/lib/project_types/script/layers/domain/push_package.rb +25 -6
  123. data/lib/project_types/script/layers/domain/script_project.rb +34 -0
  124. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +42 -13
  125. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +24 -49
  126. data/lib/project_types/script/layers/infrastructure/errors.rb +32 -19
  127. data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +12 -6
  128. data/lib/project_types/script/layers/infrastructure/project_creator.rb +2 -1
  129. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +22 -17
  130. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +72 -0
  131. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +59 -0
  132. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +145 -0
  133. data/lib/project_types/script/layers/infrastructure/script_service.rb +32 -75
  134. data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
  135. data/lib/project_types/script/messages/messages.rb +58 -59
  136. data/lib/project_types/script/ui/error_handler.rb +115 -72
  137. data/lib/project_types/script/ui/printing_spinner.rb +1 -1
  138. data/lib/project_types/script/ui/strict_spinner.rb +1 -1
  139. data/lib/project_types/theme/cli.rb +40 -0
  140. data/lib/project_types/theme/commands/connect.rb +54 -0
  141. data/lib/project_types/theme/commands/create.rb +48 -0
  142. data/lib/project_types/theme/commands/deploy.rb +38 -0
  143. data/lib/project_types/theme/commands/generate.rb +20 -0
  144. data/lib/project_types/theme/commands/generate/env.rb +79 -0
  145. data/lib/project_types/theme/commands/push.rb +55 -0
  146. data/lib/project_types/theme/commands/serve.rb +31 -0
  147. data/lib/project_types/theme/forms/connect.rb +34 -0
  148. data/lib/project_types/theme/forms/create.rb +22 -0
  149. data/lib/project_types/theme/messages/messages.rb +147 -0
  150. data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +78 -0
  151. data/lib/project_types/theme/themekit.rb +113 -0
  152. data/lib/rubygems_plugin.rb +3 -3
  153. data/lib/shopify-cli/admin_api.rb +52 -12
  154. data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
  155. data/lib/shopify-cli/admin_api/schema.rb +3 -3
  156. data/lib/shopify-cli/api.rb +34 -31
  157. data/lib/shopify-cli/command.rb +1 -1
  158. data/lib/shopify-cli/commands.rb +9 -9
  159. data/lib/shopify-cli/commands/config.rb +28 -52
  160. data/lib/shopify-cli/commands/connect.rb +10 -10
  161. data/lib/shopify-cli/commands/create.rb +5 -5
  162. data/lib/shopify-cli/commands/help.rb +6 -6
  163. data/lib/shopify-cli/commands/logout.rb +3 -3
  164. data/lib/shopify-cli/commands/system.rb +33 -33
  165. data/lib/shopify-cli/commands/version.rb +2 -2
  166. data/lib/shopify-cli/context.rb +71 -22
  167. data/lib/shopify-cli/core.rb +4 -4
  168. data/lib/shopify-cli/core/entry_point.rb +5 -5
  169. data/lib/shopify-cli/core/executor.rb +1 -1
  170. data/lib/shopify-cli/core/help_resolver.rb +2 -2
  171. data/lib/shopify-cli/core/monorail.rb +16 -16
  172. data/lib/shopify-cli/db.rb +2 -2
  173. data/lib/shopify-cli/feature.rb +1 -3
  174. data/lib/shopify-cli/form.rb +1 -1
  175. data/lib/shopify-cli/git.rb +17 -17
  176. data/lib/shopify-cli/helpers.rb +1 -1
  177. data/lib/shopify-cli/helpers/haikunator.rb +1 -1
  178. data/lib/shopify-cli/heroku.rb +28 -28
  179. data/lib/shopify-cli/http_request.rb +21 -9
  180. data/lib/shopify-cli/js_deps.rb +12 -12
  181. data/lib/shopify-cli/js_system.rb +5 -5
  182. data/lib/shopify-cli/lazy_delegator.rb +55 -0
  183. data/lib/shopify-cli/messages/messages.rb +9 -16
  184. data/lib/shopify-cli/method_object.rb +104 -0
  185. data/lib/shopify-cli/oauth.rb +25 -25
  186. data/lib/shopify-cli/oauth/servlet.rb +9 -9
  187. data/lib/shopify-cli/options.rb +3 -3
  188. data/lib/shopify-cli/packager.rb +24 -24
  189. data/lib/shopify-cli/partners_api.rb +24 -18
  190. data/lib/shopify-cli/partners_api/organizations.rb +10 -10
  191. data/lib/shopify-cli/process_supervision.rb +7 -7
  192. data/lib/shopify-cli/project.rb +16 -16
  193. data/lib/shopify-cli/project_type.rb +4 -4
  194. data/lib/shopify-cli/resolve_constant.rb +25 -0
  195. data/lib/shopify-cli/resources.rb +1 -1
  196. data/lib/shopify-cli/resources/env_file.rb +9 -9
  197. data/lib/shopify-cli/result.rb +432 -0
  198. data/lib/shopify-cli/shopifolk.rb +6 -8
  199. data/lib/shopify-cli/sub_command.rb +1 -1
  200. data/lib/shopify-cli/task.rb +3 -3
  201. data/lib/shopify-cli/tasks.rb +7 -7
  202. data/lib/shopify-cli/tasks/create_api_client.rb +5 -5
  203. data/lib/shopify-cli/tasks/ensure_dev_store.rb +12 -12
  204. data/lib/shopify-cli/tasks/ensure_env.rb +15 -15
  205. data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
  206. data/lib/shopify-cli/tasks/select_org_and_shop.rb +25 -24
  207. data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
  208. data/lib/shopify-cli/transform_data_structure.rb +86 -0
  209. data/lib/shopify-cli/tunnel.rb +36 -30
  210. data/lib/shopify-cli/version.rb +1 -1
  211. data/lib/shopify_cli.rb +57 -52
  212. data/shopify-cli.gemspec +6 -6
  213. data/shopify.fish +1 -1
  214. data/shopify.sh +1 -1
  215. data/vendor/deps/cli-kit/REVISION +1 -1
  216. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +2 -2
  217. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +3 -3
  218. data/vendor/deps/cli-ui/REVISION +1 -1
  219. data/vendor/deps/cli-ui/lib/cli/ui.rb +26 -22
  220. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +4 -6
  221. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -3
  222. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +8 -9
  223. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -1
  224. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +1 -0
  225. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +15 -3
  226. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +4 -11
  227. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -5
  228. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +10 -10
  229. data/vendor/deps/cli-ui/lib/cli/ui/version.rb +1 -1
  230. data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +56 -0
  231. data/vendor/deps/webrick/.gitignore +9 -0
  232. data/vendor/deps/webrick/Gemfile +3 -0
  233. data/vendor/deps/webrick/LICENSE.txt +22 -0
  234. data/vendor/deps/webrick/README.md +61 -0
  235. data/vendor/deps/webrick/Rakefile +10 -0
  236. data/vendor/deps/webrick/lib/webrick.rb +232 -0
  237. data/vendor/deps/webrick/lib/webrick/accesslog.rb +157 -0
  238. data/vendor/deps/webrick/lib/webrick/cgi.rb +313 -0
  239. data/vendor/deps/webrick/lib/webrick/compat.rb +36 -0
  240. data/vendor/deps/webrick/lib/webrick/config.rb +158 -0
  241. data/vendor/deps/webrick/lib/webrick/cookie.rb +172 -0
  242. data/vendor/deps/webrick/lib/webrick/htmlutils.rb +30 -0
  243. data/vendor/deps/webrick/lib/webrick/httpauth.rb +96 -0
  244. data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +117 -0
  245. data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +116 -0
  246. data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +395 -0
  247. data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +132 -0
  248. data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +97 -0
  249. data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +158 -0
  250. data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +53 -0
  251. data/vendor/deps/webrick/lib/webrick/httpproxy.rb +354 -0
  252. data/vendor/deps/webrick/lib/webrick/httprequest.rb +636 -0
  253. data/vendor/deps/webrick/lib/webrick/httpresponse.rb +564 -0
  254. data/vendor/deps/webrick/lib/webrick/https.rb +152 -0
  255. data/vendor/deps/webrick/lib/webrick/httpserver.rb +294 -0
  256. data/vendor/deps/webrick/lib/webrick/httpservlet.rb +23 -0
  257. data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +152 -0
  258. data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +47 -0
  259. data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +126 -0
  260. data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +88 -0
  261. data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +552 -0
  262. data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +47 -0
  263. data/vendor/deps/webrick/lib/webrick/httpstatus.rb +194 -0
  264. data/vendor/deps/webrick/lib/webrick/httputils.rb +512 -0
  265. data/vendor/deps/webrick/lib/webrick/httpversion.rb +76 -0
  266. data/vendor/deps/webrick/lib/webrick/log.rb +156 -0
  267. data/vendor/deps/webrick/lib/webrick/server.rb +381 -0
  268. data/vendor/deps/webrick/lib/webrick/ssl.rb +215 -0
  269. data/vendor/deps/webrick/lib/webrick/utils.rb +265 -0
  270. data/vendor/deps/webrick/lib/webrick/version.rb +18 -0
  271. data/vendor/deps/webrick/webrick.gemspec +74 -0
  272. data/vendor/gen/template/bin/update-deps +9 -9
  273. metadata +83 -35
  274. data/docs/Gemfile +0 -5
  275. data/docs/Gemfile.lock +0 -258
  276. data/docs/_data/nav.yml +0 -35
  277. data/docs/_includes/footer.html +0 -15
  278. data/docs/_includes/head.html +0 -19
  279. data/docs/_includes/sidebar_nav.html +0 -22
  280. data/docs/_includes/toc.html +0 -112
  281. data/docs/_layouts/default.html +0 -79
  282. data/docs/css/docs.css +0 -157
  283. data/docs/images/header.png +0 -0
  284. data/docs/installing-ruby.md +0 -28
  285. data/lib/project_types/extension/features/argo/admin.rb +0 -20
  286. data/lib/project_types/extension/features/argo/base.rb +0 -129
  287. data/lib/project_types/extension/features/argo/checkout.rb +0 -20
  288. data/lib/project_types/extension/forms/register.rb +0 -47
  289. data/lib/project_types/extension/models/type.rb +0 -81
  290. data/lib/project_types/extension/models/types/checkout_post_purchase.rb +0 -23
  291. data/lib/project_types/extension/models/types/product_subscription.rb +0 -24
  292. data/lib/project_types/node/commands/generate/billing.rb +0 -39
  293. data/lib/project_types/node/commands/generate/page.rb +0 -59
  294. data/lib/project_types/node/commands/generate/webhook.rb +0 -37
  295. data/lib/project_types/script/commands/disable.rb +0 -25
  296. data/lib/project_types/script/commands/enable.rb +0 -78
  297. data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
  298. data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
  299. data/lib/project_types/script/layers/application/disable_script.rb +0 -21
  300. data/lib/project_types/script/layers/application/enable_script.rb +0 -23
  301. data/lib/project_types/script/layers/domain/script.rb +0 -18
  302. data/lib/project_types/script/layers/infrastructure/script_repository.rb +0 -47
  303. data/lib/project_types/script/script_project.rb +0 -54
  304. data/lib/project_types/script/templates/ts/as-pect.config.js +0 -27
  305. data/lib/project_types/script/templates/ts/as-pect.d.ts +0 -1
@@ -16,105 +16,62 @@ module Script
16
16
  script_content:,
17
17
  compiled_type:,
18
18
  api_key: nil,
19
- force: false
19
+ force: false,
20
+ metadata:,
21
+ config_ui:
20
22
  )
21
23
  query_name = "app_script_update_or_create"
22
24
  variables = {
23
25
  extensionPointName: extension_point_type.upcase,
24
26
  title: script_name,
27
+ configUi: config_ui&.content,
25
28
  sourceCode: Base64.encode64(script_content),
26
29
  language: compiled_type,
27
30
  force: force,
31
+ schemaMajorVersion: metadata.schema_major_version.to_s, # API expects string value
32
+ schemaMinorVersion: metadata.schema_minor_version.to_s, # API expects string value
33
+ useMsgpack: metadata.use_msgpack,
28
34
  }
29
35
  resp_hash = script_service_request(query_name: query_name, api_key: api_key, variables: variables)
30
36
  user_errors = resp_hash["data"]["appScriptUpdateOrCreate"]["userErrors"]
31
37
 
32
38
  return resp_hash if user_errors.empty?
33
39
 
34
- if user_errors.any? { |e| e['tag'] == 'already_exists_error' }
40
+ if user_errors.any? { |e| e["tag"] == "already_exists_error" }
35
41
  raise Errors::ScriptRepushError, api_key
42
+ elsif (e = user_errors.any? { |err| err["tag"] == "config_ui_syntax_error" })
43
+ raise Errors::ConfigUiSyntaxError, config_ui&.filename
44
+ elsif (e = user_errors.find { |err| err["tag"] == "config_ui_missing_keys_error" })
45
+ raise Errors::ConfigUiMissingKeysError.new(config_ui&.filename, e["message"])
46
+ elsif (e = user_errors.find { |err| err["tag"] == "config_ui_fields_missing_keys_error" })
47
+ raise Errors::ConfigUiFieldsMissingKeysError.new(config_ui&.filename, e["message"])
48
+ elsif user_errors.find { |err| %w(not_use_msgpack_error schema_version_argument_error).include?(err["tag"]) }
49
+ raise Domain::Errors::MetadataValidationError
36
50
  else
37
- raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
38
- end
39
- end
40
-
41
- def enable(api_key:, shop_domain:, configuration:, extension_point_type:, title:)
42
- query_name = "shop_script_update_or_create"
43
- variables = {
44
- extensionPointName: extension_point_type.upcase,
45
- configuration: configuration,
46
- title: title,
47
- }
48
-
49
- resp_hash = script_service_request(
50
- query_name: query_name,
51
- api_key: api_key,
52
- shop_domain: format_shop_domain(shop_domain),
53
- variables: variables,
54
- )
55
- user_errors = resp_hash["data"]["shopScriptUpdateOrCreate"]["userErrors"]
56
-
57
- return resp_hash if user_errors.empty?
58
-
59
- if user_errors.any? { |e| e['tag'] == 'app_script_not_found' }
60
- raise Errors::AppScriptUndefinedError, api_key
61
- elsif user_errors.any? { |e| e['tag'] == 'shop_script_conflict' }
62
- raise Errors::ShopScriptConflictError
63
- elsif user_errors.any? { |e| e['tag'] == 'app_script_not_pushed' }
64
- raise Errors::AppScriptNotPushedError
65
- else
66
- raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
67
- end
68
- end
69
-
70
- def disable(api_key:, shop_domain:, extension_point_type:)
71
- query_name = "shop_script_delete"
72
- variables = {
73
- extensionPointName: extension_point_type.upcase,
74
- }
75
-
76
- resp_hash = script_service_request(
77
- query_name: query_name,
78
- api_key: api_key,
79
- shop_domain: format_shop_domain(shop_domain),
80
- variables: variables,
81
- )
82
- user_errors = resp_hash["data"]["shopScriptDelete"]["userErrors"]
83
- return resp_hash if user_errors.empty?
84
-
85
- if user_errors.any? { |e| e['tag'] == 'shop_script_not_found' }
86
- raise Errors::ShopScriptUndefinedError, api_key
87
- else
88
- raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
51
+ raise Errors::GraphqlError, user_errors
89
52
  end
90
53
  end
91
54
 
92
55
  private
93
56
 
94
- def format_shop_domain(shop_domain)
95
- shop_domain.delete_suffix("/")
96
- end
97
-
98
57
  class ScriptServiceAPI < ShopifyCli::API
99
58
  property(:api_key, accepts: String)
100
- property(:shop_id, accepts: Integer)
101
59
 
102
- def self.query(ctx, query_name, api_key: nil, shop_domain: nil, variables: {})
103
- api_client(ctx, api_key, shop_domain).query(query_name, variables: variables)
60
+ def self.query(ctx, query_name, api_key: nil, variables: {})
61
+ api_client(ctx, api_key).query(query_name, variables: variables)
104
62
  end
105
63
 
106
- def self.api_client(ctx, api_key, shop_domain)
64
+ def self.api_client(ctx, api_key)
107
65
  new(
108
66
  ctx: ctx,
109
- url: 'https://script-service.myshopify.io/graphql',
110
- token: '',
111
- api_key: api_key,
112
- shop_id: shop_domain&.to_i
67
+ url: "https://script-service.myshopify.io/graphql",
68
+ token: "",
69
+ api_key: api_key
113
70
  )
114
71
  end
115
72
 
116
73
  def auth_headers(*)
117
- tokens = { "APP_KEY" => api_key, "SHOP_ID" => shop_id }.compact.to_json
74
+ tokens = { "APP_KEY" => api_key }.compact.to_json
118
75
  { "X-Shopify-Authenticated-Tokens" => tokens }
119
76
  end
120
77
  end
@@ -142,28 +99,28 @@ module Script
142
99
  options[:variables] = variables.to_json if variables
143
100
  resp = PartnersProxyAPI.query(ctx, query_name, **options)
144
101
  raise_if_graphql_failed(resp)
145
- JSON.parse(resp['data']['scriptServiceProxy'])
102
+ JSON.parse(resp["data"]["scriptServiceProxy"])
146
103
  end
147
104
 
148
105
  def raise_if_graphql_failed(response)
149
106
  raise Errors::EmptyResponseError if response.nil?
150
107
 
151
- return unless response.key?('errors')
152
- case error_code(response['errors'])
153
- when 'forbidden'
108
+ return unless response.key?("errors")
109
+ case error_code(response["errors"])
110
+ when "forbidden"
154
111
  raise Errors::ForbiddenError
155
- when 'forbidden_on_shop'
112
+ when "forbidden_on_shop"
156
113
  raise Errors::ShopAuthenticationError
157
- when 'app_not_installed_on_shop'
114
+ when "app_not_installed_on_shop"
158
115
  raise Errors::AppNotInstalledError
159
116
  else
160
- raise Errors::GraphqlError, response['errors'].map { |e| e['message'] }
117
+ raise Errors::GraphqlError, response["errors"]
161
118
  end
162
119
  end
163
120
 
164
121
  def error_code(errors)
165
122
  errors.map do |e|
166
- code = e.dig('extensions', 'code')
123
+ code = e.dig("extensions", "code")
167
124
  return code if code
168
125
  end
169
126
  end
@@ -5,12 +5,13 @@ module Script
5
5
  module Infrastructure
6
6
  class TaskRunner
7
7
  TASK_RUNNERS = {
8
- "ts" => Infrastructure::AssemblyScriptTaskRunner,
8
+ "assemblyscript" => Infrastructure::AssemblyScriptTaskRunner,
9
+ "rust" => Infrastructure::RustTaskRunner,
9
10
  }
10
11
 
11
- def self.for(ctx, language, script_name, script_source_file)
12
+ def self.for(ctx, language, script_name)
12
13
  raise Errors::TaskRunnerNotFoundError unless TASK_RUNNERS[language]
13
- TASK_RUNNERS[language].new(ctx, script_name, script_source_file)
14
+ TASK_RUNNERS[language].new(ctx, script_name)
14
15
  end
15
16
  end
16
17
  end
@@ -5,6 +5,9 @@ module Script
5
5
  MESSAGES = {
6
6
  script: {
7
7
  error: {
8
+ deprecated_ep: "This project uses an extension point %s which has been deprecated. "\
9
+ "This Script will no longer function in production.",
10
+ deprecated_ep_cause: "Try using a different extension point.",
8
11
  generic: "{{red:{{x}} Error}}",
9
12
  eacces_cause: "You don't have permission to write to this directory.",
10
13
  eacces_help: "Change your directory permissions and try again.",
@@ -18,20 +21,20 @@ module Script
18
21
  invalid_context_cause: "Your .shopify-cli.yml file is not correct.",
19
22
  invalid_context_help: "See https://help.shopify.com",
20
23
 
21
- invalid_config_props_cause: "{{command:--config_props}} is formatted incorrectly.",
24
+ invalid_config_props_cause: "{{command:--config-props}} is formatted incorrectly.",
22
25
  invalid_config_props_help: "Try again using this format: "\
23
- "{{cyan:--config_props='name1:value1, name2:value2'}}",
26
+ "{{cyan:--config-props='name1:value1, name2:value2'}}",
24
27
 
25
28
  invalid_script_name_cause: "Invalid script name.",
26
29
  invalid_script_name_help: "Replace or remove unsupported characters. Valid characters "\
27
30
  "are numbers, letters, hyphens, or underscores.",
28
31
 
29
32
  no_existing_apps_cause: "You don't have any apps.",
30
- no_existing_apps_help: "Please create an app with {{command:shopify create}} or "\
33
+ no_existing_apps_help: "Create an app with {{command:shopify create}} or "\
31
34
  "visit https://partners.shopify.com/.",
32
35
 
33
36
  no_existing_orgs_cause: "You don't have any partner organizations.",
34
- no_existing_orgs_help: "Please visit https://partners.shopify.com/ to create a partners account.",
37
+ no_existing_orgs_help: "Visit https://partners.shopify.com/ to create a partners account.",
35
38
 
36
39
  no_existing_stores_cause: "You don't have any stores.",
37
40
  no_existing_stores_help: "Visit https://partners.shopify.com/%{organization_id}/stores/ to create one.",
@@ -39,18 +42,55 @@ module Script
39
42
  project_exists_cause: "Directory with the same name as the script already exists.",
40
43
  project_exists_help: "Use different script name and try again.",
41
44
 
42
- invalid_extension_cause: "Invalid extension point %s",
45
+ invalid_extension_cause: "Invalid extension point %s.",
43
46
  invalid_extension_help: "Allowed values: %s.",
44
47
 
48
+ invalid_language_cause: "Invalid language %s.",
49
+ invalid_language_help: "Allowed values: %s.",
50
+
45
51
  invalid_config: "Can't change the configuration values because %1$s is missing or "\
46
52
  "it is not formatted properly.",
47
53
 
54
+ invalid_config_ui_definition_cause: "The UI configuration file %s contains invalid YAML.",
55
+ invalid_config_ui_definition_help: "Fix the errors and try again.",
56
+
57
+ missing_config_ui_definition_cause: "You are missing the UI configuration file %s.",
58
+ missing_config_ui_definition_help: "Create this file and try again.",
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_fields_missing_keys_error_cause: "A field entry in the UI configuration file %{filename} is "\
68
+ "missing required keys: %{missing_keys}.",
69
+ config_ui_fields_missing_keys_error_help: "Add the keys and try again.",
70
+
48
71
  script_not_found_cause: "Couldn't find script %s for extension point %s",
49
72
 
73
+ service_failure_cause: "Internal service error.",
74
+ service_failure_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date.",
75
+
76
+ metadata_validation_cause: "Invalid script extension metadata.",
77
+ metadata_validation_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date.",
78
+
79
+ metadata_schema_versions_missing: "Invalid script metadata:" \
80
+ " 'schemaVersions' field is missing",
81
+ metadata_schema_versions_single_key: "Invalid script extension metadata:" \
82
+ " 'schemaVersions' can have only one extension point name.",
83
+ metadata_schema_versions_missing_major: "Invalid script extension metadata:" \
84
+ " 'schemaVersions' is missing the 'major' field",
85
+ metadata_schema_versions_missing_minor: "Invalid script extension metadata:" \
86
+ " 'schemaVersions' is missing the 'minor' field",
87
+
88
+ metadata_not_found_cause: "Script version file (%s) cannot be found.",
89
+ metadata_not_found_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date and " \
90
+ "'package.json' contains a 'scripts/build' entry with a " \
91
+ "'--metadata build/metadata.json' argument",
50
92
  app_not_installed_cause: "App not installed on store.",
51
93
 
52
- app_script_not_pushed_help: "Script isn't on the app. Run {{command:shopify push}}, and then try again.",
53
-
54
94
  build_error_cause: "Something went wrong while building the script.",
55
95
  build_error_help: "Correct the errors and try again.",
56
96
 
@@ -71,22 +111,13 @@ module Script
71
111
  shop_auth_cause: "Unable to authenticate with the store.",
72
112
  shop_auth_help: "Try again.",
73
113
 
74
- shop_script_conflict_cause: "Another app in this store has already enabled a script "\
75
- "on this extension point.",
76
- shop_script_conflict_help: "Disable that script or uninstall that app and try again.",
77
-
78
- shop_script_undefined_cause: "Script is already turned off in store.",
79
-
80
- packages_outdated_cause: "These npm packages are out of date: %s.",
81
- packages_outdated_help: "To update them, run {{cyan:npm install --save-dev %s}}.",
82
-
83
- invalid_build_script: "Invalid build script.",
84
- build_script_not_found: "Build script not found.",
114
+ invalid_build_script: "The root package.json contains an invalid build command that " \
115
+ "is needed to compile your script to WebAssembly.",
116
+ build_script_not_found: "The root package.json is missing the build command that " \
117
+ "is needed to compile your script to WebAssembly.",
85
118
  # rubocop:disable Layout/LineLength
86
- build_script_suggestion: "Root package.json needs a script named build, which" \
87
- "uses @shopify/scripts-toolchain-as to compile to WebAssembly.\n" \
88
- "Example:\n" \
89
- "build: npx shopify-scripts-toolchain-as build --src src/script.ts --binary <script_name>.wasm -- --lib node_modules --optimize --use Date=",
119
+ build_script_suggestion: "\n\nFor example, your package.json needs the following command:" \
120
+ "\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=",
90
121
 
91
122
  web_assembly_binary_not_found: "WebAssembly binary not found.",
92
123
  web_assembly_binary_not_found_suggestion: "No WebAssembly binary found." \
@@ -100,7 +131,8 @@ module Script
100
131
  Usage: {{command:%1$s create script}}
101
132
  Options:
102
133
  {{command:--name=NAME}} Script project name. Use any string.
103
- {{command:--extension_point=TYPE}} Extension point name. Allowed values: %2$s.
134
+ {{command:--extension-point=TYPE}} Extension point name. Allowed values: %2$s.
135
+ {{command:--no-config-ui}} Specify this option if you don’t want Scripts to render an interface in the Shopify admin.
104
136
  HELP
105
137
 
106
138
  error: {
@@ -109,7 +141,7 @@ module Script
109
141
 
110
142
  change_directory_notice: "{{*}} Change directories to {{green:%s}} to run script commands",
111
143
  creating: "Creating script",
112
- created: "Created script: {{green:%s}}",
144
+ created: "Created script",
113
145
  },
114
146
 
115
147
  push: {
@@ -121,46 +153,12 @@ module Script
121
153
  HELP
122
154
 
123
155
  error: {
124
- operation_failed: "Couldn't push script to app.",
156
+ operation_failed: "Couldn't push script to app (API key: %{api_key}).",
125
157
  },
126
158
 
127
159
  script_pushed: "{{v}} Script pushed to app (API key: %{api_key}).",
128
160
  },
129
161
 
130
- disable: {
131
- help: <<~HELP,
132
- Turn off script in store.
133
- Usage: {{command:%s disable}}
134
- HELP
135
-
136
- error: {
137
- operation_failed: "Can't disable script.",
138
- },
139
-
140
- script_disabled: "{{v}} Script disabled. Script is turned off in store.",
141
- },
142
-
143
- enable: {
144
- help: <<~HELP,
145
- Turn on script in store.
146
- Usage: {{command:%s enable}}
147
- Options:
148
- {{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.
149
- {{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.
150
- HELP
151
-
152
- info: "{{*}} A script always remains enabled until you disable it - even after pushing "\
153
- "script changes with the same extension point to an app. To disable a script, use "\
154
- "the 'disable' command.",
155
-
156
- error: {
157
- operation_failed: "Can't enable script.",
158
- },
159
-
160
- script_enabled: "{{v}} Script enabled. %{type} script %{title} in app (API key: %{api_key}) "\
161
- "is turned on in store {{green:%{shop_domain}}}",
162
- },
163
-
164
162
  project_deps: {
165
163
  none_required: "{{v}} None required",
166
164
  checking_with_npm: "Checking dependencies with npm",
@@ -171,6 +169,7 @@ module Script
171
169
  forms: {
172
170
  create: {
173
171
  select_extension_point: "Which extension point do you want to use?",
172
+ select_language: "Which language do you want to use?",
174
173
  script_name: "Script Name",
175
174
  },
176
175
  },
@@ -1,10 +1,10 @@
1
- require 'cli/ui'
1
+ require "cli/ui"
2
2
 
3
3
  module Script
4
4
  module UI
5
5
  module ErrorHandler
6
6
  def self.display(failed_op:, cause_of_error:, help_suggestion:)
7
- $stderr.puts(CLI::UI.fmt(ShopifyCli::Context.message('script.error.generic')))
7
+ $stderr.puts(CLI::UI.fmt(ShopifyCli::Context.message("script.error.generic")))
8
8
  full_msg = failed_op ? failed_op.dup : ""
9
9
  full_msg << " #{cause_of_error}" if cause_of_error
10
10
  full_msg << " #{help_suggestion}" if help_suggestion
@@ -26,154 +26,197 @@ module Script
26
26
  case e
27
27
  when Errno::EACCES
28
28
  {
29
- cause_of_error: ShopifyCli::Context.message('script.error.eacces_cause'),
30
- help_suggestion: ShopifyCli::Context.message('script.error.eacces_help'),
29
+ cause_of_error: ShopifyCli::Context.message("script.error.eacces_cause"),
30
+ help_suggestion: ShopifyCli::Context.message("script.error.eacces_help"),
31
31
  }
32
32
  when Errno::ENOSPC
33
33
  {
34
- cause_of_error: ShopifyCli::Context.message('script.error.enospc_cause'),
35
- help_suggestion: ShopifyCli::Context.message('script.error.enospc_help'),
34
+ cause_of_error: ShopifyCli::Context.message("script.error.enospc_cause"),
35
+ help_suggestion: ShopifyCli::Context.message("script.error.enospc_help"),
36
36
  }
37
37
  when ShopifyCli::OAuth::Error
38
38
  {
39
- cause_of_error: ShopifyCli::Context.message('script.error.oauth_cause'),
40
- help_suggestion: ShopifyCli::Context.message('script.error.oauth_help'),
39
+ cause_of_error: ShopifyCli::Context.message("script.error.oauth_cause"),
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
- cause_of_error: ShopifyCli::Context.message('script.error.invalid_context_cause'),
45
- help_suggestion: ShopifyCli::Context.message('script.error.invalid_context_help'),
44
+ cause_of_error: ShopifyCli::Context.message("script.error.invalid_context_cause"),
45
+ help_suggestion: ShopifyCli::Context.message("script.error.invalid_context_help"),
46
46
  }
47
47
  when Errors::InvalidConfigProps
48
48
  {
49
- cause_of_error: ShopifyCli::Context.message('script.error.invalid_config_props_cause'),
50
- help_suggestion: ShopifyCli::Context.message('script.error.invalid_config_props_help'),
49
+ cause_of_error: ShopifyCli::Context.message("script.error.invalid_config_props_cause"),
50
+ help_suggestion: ShopifyCli::Context.message("script.error.invalid_config_props_help"),
51
51
  }
52
52
  when Errors::InvalidConfigYAMLError
53
53
  {
54
- cause_of_error: ShopifyCli::Context.message('script.error.invalid_config', e.config_file),
54
+ cause_of_error: ShopifyCli::Context.message("script.error.invalid_config", e.config_file),
55
+ }
56
+ when Layers::Infrastructure::Errors::InvalidLanguageError
57
+ {
58
+ cause_of_error: ShopifyCli::Context.message("script.error.invalid_language_cause", e.language),
59
+ help_suggestion: ShopifyCli::Context.message(
60
+ "script.error.invalid_language_help",
61
+ Script::Layers::Application::ExtensionPoints.languages(type: e.extension_point_type).join(", ")
62
+ ),
55
63
  }
56
64
  when Errors::InvalidScriptNameError
57
65
  {
58
- cause_of_error: ShopifyCli::Context.message('script.error.invalid_script_name_cause'),
59
- help_suggestion: ShopifyCli::Context.message('script.error.invalid_script_name_help'),
66
+ cause_of_error: ShopifyCli::Context.message("script.error.invalid_script_name_cause"),
67
+ help_suggestion: ShopifyCli::Context.message("script.error.invalid_script_name_help"),
60
68
  }
61
69
  when Errors::NoExistingAppsError
62
70
  {
63
- cause_of_error: ShopifyCli::Context.message('script.error.no_existing_apps_cause'),
64
- help_suggestion: ShopifyCli::Context.message('script.error.no_existing_apps_help'),
71
+ cause_of_error: ShopifyCli::Context.message("script.error.no_existing_apps_cause"),
72
+ help_suggestion: ShopifyCli::Context.message("script.error.no_existing_apps_help"),
65
73
  }
66
74
  when Errors::NoExistingOrganizationsError
67
75
  {
68
- cause_of_error: ShopifyCli::Context.message('script.error.no_existing_orgs_cause'),
69
- help_suggestion: ShopifyCli::Context.message('script.error.no_existing_orgs_help'),
76
+ cause_of_error: ShopifyCli::Context.message("script.error.no_existing_orgs_cause"),
77
+ help_suggestion: ShopifyCli::Context.message("script.error.no_existing_orgs_help"),
70
78
  }
71
79
  when Errors::NoExistingStoresError
72
80
  {
73
- cause_of_error: ShopifyCli::Context.message('script.error.no_existing_stores_cause'),
81
+ cause_of_error: ShopifyCli::Context.message("script.error.no_existing_stores_cause"),
74
82
  help_suggestion: ShopifyCli::Context.message(
75
- 'script.error.no_existing_stores_help',
83
+ "script.error.no_existing_stores_help",
76
84
  organization_id: e.organization_id
77
85
  ),
78
86
  }
79
- when Errors::ScriptProjectAlreadyExistsError
87
+ when Layers::Infrastructure::Errors::ScriptProjectAlreadyExistsError
88
+ {
89
+ cause_of_error: ShopifyCli::Context.message("script.error.project_exists_cause"),
90
+ help_suggestion: ShopifyCli::Context.message("script.error.project_exists_help"),
91
+ }
92
+ when Layers::Infrastructure::Errors::DeprecatedEPError
80
93
  {
81
- cause_of_error: ShopifyCli::Context.message('script.error.project_exists_cause'),
82
- help_suggestion: ShopifyCli::Context.message('script.error.project_exists_help'),
94
+ cause_of_error: ShopifyCli::Context.message("script.error.deprecated_ep", e.ep),
95
+ help_suggestion: ShopifyCli::Context.message("script.error.deprecated_ep_cause"),
83
96
  }
84
97
  when Layers::Domain::Errors::InvalidExtensionPointError
85
98
  {
86
- cause_of_error: ShopifyCli::Context.message('script.error.invalid_extension_cause', e.type),
99
+ cause_of_error: ShopifyCli::Context.message("script.error.invalid_extension_cause", e.type),
87
100
  help_suggestion: ShopifyCli::Context.message(
88
- 'script.error.invalid_extension_help',
89
- Script::Layers::Application::ExtensionPoints.types.join(', ')
101
+ "script.error.invalid_extension_help",
102
+ Script::Layers::Application::ExtensionPoints.types.join(", ")
90
103
  ),
91
104
  }
92
105
  when Layers::Domain::Errors::ScriptNotFoundError
93
106
  {
94
107
  cause_of_error: ShopifyCli::Context.message(
95
- 'script.error.script_not_found_cause',
108
+ "script.error.script_not_found_cause",
96
109
  e.script_name,
97
110
  e.extension_point_type
98
111
  ),
99
112
  }
100
- when Layers::Infrastructure::Errors::AppNotInstalledError
113
+ when Layers::Domain::Errors::ServiceFailureError
101
114
  {
102
- cause_of_error: ShopifyCli::Context.message('script.error.app_not_installed_cause'),
115
+ cause_of_error: ShopifyCli::Context.message("script.error.service_failure_cause"),
116
+ help_suggestion: ShopifyCli::Context.message("script.error.service_failure_help"),
103
117
  }
104
- when Layers::Infrastructure::Errors::AppScriptNotPushedError,
105
- Layers::Infrastructure::Errors::AppScriptUndefinedError
118
+ when Layers::Domain::Errors::MetadataValidationError
106
119
  {
107
- cause_of_error: ShopifyCli::Context.message('script.error.app_script_not_pushed_help'),
120
+ cause_of_error: ShopifyCli::Context.message("script.error.metadata_validation_cause"),
121
+ help_suggestion: ShopifyCli::Context.message("script.error.metadata_validation_help"),
108
122
  }
109
- when Layers::Infrastructure::Errors::BuildError
123
+ when Layers::Domain::Errors::MetadataNotFoundError
110
124
  {
111
- cause_of_error: ShopifyCli::Context.message('script.error.build_error_cause'),
112
- help_suggestion: ShopifyCli::Context.message('script.error.build_error_help'),
125
+ cause_of_error: ShopifyCli::Context.message("script.error.metadata_not_found_cause"),
126
+ help_suggestion: ShopifyCli::Context.message("script.error.metadata_not_found_help"),
113
127
  }
114
- when Layers::Infrastructure::Errors::DependencyInstallError
128
+ when Layers::Domain::Errors::InvalidConfigUiDefinitionError
115
129
  {
116
- cause_of_error: ShopifyCli::Context.message('script.error.dependency_install_cause'),
117
- help_suggestion: ShopifyCli::Context.message('script.error.dependency_install_help'),
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"),
118
133
  }
119
- when Layers::Infrastructure::Errors::EmptyResponseError
134
+ when Layers::Domain::Errors::MissingSpecifiedConfigUiDefinitionError
120
135
  {
121
- cause_of_error: ShopifyCli::Context.message('script.error.failed_api_request_cause'),
122
- help_suggestion: ShopifyCli::Context.message('script.error.failed_api_request_help'),
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"),
123
139
  }
124
- when Layers::Infrastructure::Errors::ForbiddenError
140
+ when Layers::Infrastructure::Errors::AppNotInstalledError
125
141
  {
126
- cause_of_error: ShopifyCli::Context.message('script.error.forbidden_error_cause'),
142
+ cause_of_error: ShopifyCli::Context.message("script.error.app_not_installed_cause"),
127
143
  }
128
- when Layers::Infrastructure::Errors::GraphqlError
144
+ when Layers::Infrastructure::Errors::BuildError
129
145
  {
130
- cause_of_error: ShopifyCli::Context.message('script.error.graphql_error_cause', e.errors.join(', ')),
131
- help_suggestion: ShopifyCli::Context.message('script.error.graphql_error_help'),
146
+ cause_of_error: ShopifyCli::Context.message("script.error.build_error_cause"),
147
+ help_suggestion: ShopifyCli::Context.message("script.error.build_error_help"),
132
148
  }
133
- when Layers::Infrastructure::Errors::ScriptRepushError
149
+ when Layers::Infrastructure::Errors::ConfigUiSyntaxError
134
150
  {
135
- cause_of_error: ShopifyCli::Context.message('script.error.script_repush_cause', e.api_key),
136
- help_suggestion: ShopifyCli::Context.message('script.error.script_repush_help'),
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"),
137
156
  }
138
- when Layers::Infrastructure::Errors::ShopAuthenticationError
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::ConfigUiFieldsMissingKeysError
139
167
  {
140
- cause_of_error: ShopifyCli::Context.message('script.error.shop_auth_cause'),
141
- help_suggestion: ShopifyCli::Context.message('script.error.shop_auth_help'),
168
+ cause_of_error: ShopifyCli::Context.message(
169
+ "script.error.config_ui_fields_missing_keys_error_cause",
170
+ filename: e.filename,
171
+ missing_keys: e.missing_keys
172
+ ),
173
+ help_suggestion: ShopifyCli::Context.message("script.error.config_ui_fields_missing_keys_error_help"),
142
174
  }
143
- when Layers::Infrastructure::Errors::ShopScriptConflictError
175
+ when Layers::Infrastructure::Errors::DependencyInstallError
144
176
  {
145
- cause_of_error: ShopifyCli::Context.message('script.error.shop_script_conflict_cause'),
146
- help_suggestion: ShopifyCli::Context.message('script.error.shop_script_conflict_help'),
177
+ cause_of_error: ShopifyCli::Context.message("script.error.dependency_install_cause"),
178
+ help_suggestion: ShopifyCli::Context.message("script.error.dependency_install_help"),
147
179
  }
148
- when Layers::Infrastructure::Errors::ShopScriptUndefinedError
180
+ when Layers::Infrastructure::Errors::EmptyResponseError
149
181
  {
150
- cause_of_error: ShopifyCli::Context.message('script.error.shop_script_undefined_cause'),
182
+ cause_of_error: ShopifyCli::Context.message("script.error.failed_api_request_cause"),
183
+ help_suggestion: ShopifyCli::Context.message("script.error.failed_api_request_help"),
151
184
  }
152
- when Layers::Infrastructure::Errors::PackagesOutdatedError
185
+ when Layers::Infrastructure::Errors::ForbiddenError
186
+ {
187
+ cause_of_error: ShopifyCli::Context.message("script.error.forbidden_error_cause"),
188
+ }
189
+ when Layers::Infrastructure::Errors::GraphqlError
153
190
  {
154
191
  cause_of_error: ShopifyCli::Context.message(
155
- 'script.error.packages_outdated_cause',
156
- e.outdated_packages.join(', ')
157
- ),
158
- help_suggestion: ShopifyCli::Context.message(
159
- 'script.error.packages_outdated_help',
160
- e.outdated_packages.collect { |package| "#{package}@latest" }.join(' ')
192
+ "script.error.graphql_error_cause", JSON.pretty_generate(e.errors)
161
193
  ),
194
+ help_suggestion: ShopifyCli::Context.message("script.error.graphql_error_help"),
195
+ }
196
+ when Layers::Infrastructure::Errors::ScriptRepushError
197
+ {
198
+ cause_of_error: ShopifyCli::Context.message("script.error.script_repush_cause", e.api_key),
199
+ help_suggestion: ShopifyCli::Context.message("script.error.script_repush_help"),
200
+ }
201
+ when Layers::Infrastructure::Errors::ShopAuthenticationError
202
+ {
203
+ cause_of_error: ShopifyCli::Context.message("script.error.shop_auth_cause"),
204
+ help_suggestion: ShopifyCli::Context.message("script.error.shop_auth_help"),
162
205
  }
163
206
  when Layers::Infrastructure::Errors::BuildScriptNotFoundError
164
207
  {
165
- cause_of_error: ShopifyCli::Context.message('script.error.build_script_not_found'),
166
- help_suggestion: ShopifyCli::Context.message('script.error.build_script_suggestion'),
208
+ cause_of_error: ShopifyCli::Context.message("script.error.build_script_not_found"),
209
+ help_suggestion: ShopifyCli::Context.message("script.error.build_script_suggestion"),
167
210
  }
168
211
  when Layers::Infrastructure::Errors::InvalidBuildScriptError
169
212
  {
170
- cause_of_error: ShopifyCli::Context.message('script.error.invalid_build_script'),
171
- help_suggestion: ShopifyCli::Context.message('script.error.build_script_suggestion'),
213
+ cause_of_error: ShopifyCli::Context.message("script.error.invalid_build_script"),
214
+ help_suggestion: ShopifyCli::Context.message("script.error.build_script_suggestion"),
172
215
  }
173
216
  when Layers::Infrastructure::Errors::WebAssemblyBinaryNotFoundError
174
217
  {
175
- cause_of_error: ShopifyCli::Context.message('script.error.web_assembly_binary_not_found'),
176
- help_suggestion: ShopifyCli::Context.message('script.error.web_assembly_binary_not_found_suggestion'),
218
+ cause_of_error: ShopifyCli::Context.message("script.error.web_assembly_binary_not_found"),
219
+ help_suggestion: ShopifyCli::Context.message("script.error.web_assembly_binary_not_found_suggestion"),
177
220
  }
178
221
  end
179
222
  end