shopify-cli 1.4.0 → 1.7.1

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