shopify-cli 1.4.1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) 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 +3 -2
  5. data/.github/workflows/release.yml +0 -1
  6. data/.github/workflows/triage.yml +22 -0
  7. data/.rubocop.yml +21 -7
  8. data/.rubocop_todo.yml +2 -15
  9. data/.travis.yml +1 -1
  10. data/CHANGELOG.md +28 -0
  11. data/Gemfile +12 -11
  12. data/Gemfile.lock +17 -14
  13. data/README.md +39 -7
  14. data/RELEASING.md +5 -13
  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 +12 -12
  35. data/lib/graphql/fetch_specifications.graphql +14 -0
  36. data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
  37. data/lib/project_types/extension/cli.rb +54 -47
  38. data/lib/project_types/extension/commands/build.rb +3 -3
  39. data/lib/project_types/extension/commands/create.rb +17 -10
  40. data/lib/project_types/extension/commands/extension_command.rb +12 -5
  41. data/lib/project_types/extension/commands/push.rb +8 -8
  42. data/lib/project_types/extension/commands/register.rb +19 -30
  43. data/lib/project_types/extension/commands/serve.rb +31 -3
  44. data/lib/project_types/extension/commands/tunnel.rb +12 -12
  45. data/lib/project_types/extension/extension_project.rb +8 -4
  46. data/lib/project_types/extension/extension_project_keys.rb +4 -4
  47. data/lib/project_types/extension/features/argo.rb +117 -0
  48. data/lib/project_types/extension/features/argo_config.rb +5 -5
  49. data/lib/project_types/extension/features/argo_dependencies.rb +5 -5
  50. data/lib/project_types/extension/features/argo_setup.rb +2 -2
  51. data/lib/project_types/extension/features/argo_setup_steps.rb +4 -4
  52. data/lib/project_types/extension/forms/create.rb +28 -34
  53. data/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
  54. data/lib/project_types/extension/forms/questions/ask_name.rb +40 -0
  55. data/lib/project_types/extension/forms/questions/ask_type.rb +47 -0
  56. data/lib/project_types/extension/messages/messages.rb +55 -52
  57. data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
  58. data/lib/project_types/extension/models/specification.rb +37 -0
  59. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +19 -0
  60. data/lib/project_types/extension/models/specification_handlers/default.rb +67 -0
  61. data/lib/project_types/extension/models/specifications.rb +88 -0
  62. data/lib/project_types/extension/tasks/configure_features.rb +52 -0
  63. data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
  64. data/lib/project_types/extension/tasks/converters/registration_converter.rb +6 -6
  65. data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +4 -4
  66. data/lib/project_types/extension/tasks/converters/version_converter.rb +7 -7
  67. data/lib/project_types/extension/tasks/create_extension.rb +4 -4
  68. data/lib/project_types/extension/tasks/fetch_specifications.rb +18 -0
  69. data/lib/project_types/extension/tasks/get_app.rb +4 -4
  70. data/lib/project_types/extension/tasks/get_apps.rb +3 -3
  71. data/lib/project_types/extension/tasks/update_draft.rb +4 -4
  72. data/lib/project_types/extension/tasks/user_errors.rb +4 -4
  73. data/lib/project_types/node/cli.rb +19 -16
  74. data/lib/project_types/node/commands/connect.rb +15 -0
  75. data/lib/project_types/node/commands/create.rb +44 -41
  76. data/lib/project_types/node/commands/deploy.rb +4 -4
  77. data/lib/project_types/node/commands/deploy/heroku.rb +24 -24
  78. data/lib/project_types/node/commands/generate.rb +9 -18
  79. data/lib/project_types/node/commands/open.rb +2 -2
  80. data/lib/project_types/node/commands/populate.rb +6 -6
  81. data/lib/project_types/node/commands/populate/customer.rb +5 -5
  82. data/lib/project_types/node/commands/populate/draft_order.rb +5 -5
  83. data/lib/project_types/node/commands/populate/product.rb +5 -5
  84. data/lib/project_types/node/commands/serve.rb +9 -9
  85. data/lib/project_types/node/commands/tunnel.rb +7 -7
  86. data/lib/project_types/node/forms/create.rb +17 -8
  87. data/lib/project_types/node/messages/messages.rb +20 -53
  88. data/lib/project_types/rails/cli.rb +21 -18
  89. data/lib/project_types/rails/commands/connect.rb +15 -0
  90. data/lib/project_types/rails/commands/create.rb +58 -57
  91. data/lib/project_types/rails/commands/deploy.rb +4 -4
  92. data/lib/project_types/rails/commands/deploy/heroku.rb +30 -30
  93. data/lib/project_types/rails/commands/generate.rb +7 -7
  94. data/lib/project_types/rails/commands/generate/webhook.rb +6 -6
  95. data/lib/project_types/rails/commands/open.rb +2 -2
  96. data/lib/project_types/rails/commands/populate.rb +6 -6
  97. data/lib/project_types/rails/commands/populate/customer.rb +5 -5
  98. data/lib/project_types/rails/commands/populate/draft_order.rb +5 -5
  99. data/lib/project_types/rails/commands/populate/product.rb +5 -5
  100. data/lib/project_types/rails/commands/serve.rb +11 -11
  101. data/lib/project_types/rails/commands/tunnel.rb +7 -7
  102. data/lib/project_types/rails/forms/create.rb +35 -25
  103. data/lib/project_types/rails/gem.rb +24 -24
  104. data/lib/project_types/rails/messages/messages.rb +13 -9
  105. data/lib/project_types/rails/ruby.rb +2 -2
  106. data/lib/project_types/script/cli.rb +44 -38
  107. data/lib/project_types/script/commands/create.rb +15 -10
  108. data/lib/project_types/script/commands/disable.rb +3 -3
  109. data/lib/project_types/script/commands/enable.rb +19 -9
  110. data/lib/project_types/script/commands/push.rb +10 -17
  111. data/lib/project_types/script/config/extension_points.yml +30 -12
  112. data/lib/project_types/script/errors.rb +22 -0
  113. data/lib/project_types/script/forms/create.rb +29 -5
  114. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +12 -1
  115. data/lib/project_types/script/layers/application/build_script.rb +19 -19
  116. data/lib/project_types/script/layers/application/create_script.rb +45 -12
  117. data/lib/project_types/script/layers/application/disable_script.rb +2 -2
  118. data/lib/project_types/script/layers/application/enable_script.rb +2 -2
  119. data/lib/project_types/script/layers/application/extension_points.rb +24 -0
  120. data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
  121. data/lib/project_types/script/layers/application/push_script.rb +15 -18
  122. data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
  123. data/lib/project_types/script/layers/domain/errors.rb +23 -0
  124. data/lib/project_types/script/layers/domain/extension_point.rb +67 -7
  125. data/lib/project_types/script/layers/domain/metadata.rb +55 -0
  126. data/lib/project_types/script/layers/domain/push_package.rb +29 -6
  127. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +45 -55
  128. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +41 -45
  129. data/lib/project_types/script/layers/infrastructure/config_ui_repository.rb +46 -0
  130. data/lib/project_types/script/layers/infrastructure/errors.rb +32 -5
  131. data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +12 -6
  132. data/lib/project_types/script/layers/infrastructure/project_creator.rb +2 -1
  133. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +20 -13
  134. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +72 -0
  135. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +59 -0
  136. data/lib/project_types/script/layers/infrastructure/script_service.rb +39 -17
  137. data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
  138. data/lib/project_types/script/messages/messages.rb +76 -10
  139. data/lib/project_types/script/script_project.rb +26 -16
  140. data/lib/project_types/script/ui/error_handler.rb +135 -50
  141. data/lib/project_types/script/ui/printing_spinner.rb +1 -1
  142. data/lib/project_types/script/ui/strict_spinner.rb +1 -1
  143. data/lib/project_types/theme/cli.rb +40 -0
  144. data/lib/project_types/theme/commands/connect.rb +54 -0
  145. data/lib/project_types/theme/commands/create.rb +48 -0
  146. data/lib/project_types/theme/commands/deploy.rb +38 -0
  147. data/lib/project_types/theme/commands/generate.rb +20 -0
  148. data/lib/project_types/theme/commands/generate/env.rb +79 -0
  149. data/lib/project_types/theme/commands/push.rb +55 -0
  150. data/lib/project_types/theme/commands/serve.rb +31 -0
  151. data/lib/project_types/theme/forms/connect.rb +34 -0
  152. data/lib/project_types/theme/forms/create.rb +22 -0
  153. data/lib/project_types/theme/messages/messages.rb +147 -0
  154. data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +78 -0
  155. data/lib/project_types/theme/themekit.rb +113 -0
  156. data/lib/rubygems_plugin.rb +3 -3
  157. data/lib/shopify-cli/admin_api.rb +52 -12
  158. data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
  159. data/lib/shopify-cli/admin_api/schema.rb +3 -3
  160. data/lib/shopify-cli/api.rb +36 -31
  161. data/lib/shopify-cli/command.rb +1 -1
  162. data/lib/shopify-cli/commands.rb +9 -9
  163. data/lib/shopify-cli/commands/config.rb +28 -28
  164. data/lib/shopify-cli/commands/connect.rb +35 -18
  165. data/lib/shopify-cli/commands/create.rb +5 -5
  166. data/lib/shopify-cli/commands/help.rb +6 -6
  167. data/lib/shopify-cli/commands/logout.rb +3 -3
  168. data/lib/shopify-cli/commands/system.rb +33 -33
  169. data/lib/shopify-cli/commands/version.rb +2 -2
  170. data/lib/shopify-cli/context.rb +43 -22
  171. data/lib/shopify-cli/core.rb +4 -4
  172. data/lib/shopify-cli/core/entry_point.rb +5 -5
  173. data/lib/shopify-cli/core/executor.rb +1 -1
  174. data/lib/shopify-cli/core/help_resolver.rb +2 -2
  175. data/lib/shopify-cli/core/monorail.rb +17 -16
  176. data/lib/shopify-cli/db.rb +2 -2
  177. data/lib/shopify-cli/feature.rb +1 -3
  178. data/lib/shopify-cli/form.rb +1 -1
  179. data/lib/shopify-cli/git.rb +17 -17
  180. data/lib/shopify-cli/helpers.rb +1 -1
  181. data/lib/shopify-cli/helpers/haikunator.rb +1 -1
  182. data/lib/shopify-cli/heroku.rb +28 -28
  183. data/lib/shopify-cli/http_request.rb +21 -9
  184. data/lib/shopify-cli/js_deps.rb +13 -13
  185. data/lib/shopify-cli/js_system.rb +5 -5
  186. data/lib/shopify-cli/lazy_delegator.rb +55 -0
  187. data/lib/shopify-cli/messages/messages.rb +21 -10
  188. data/lib/shopify-cli/method_object.rb +104 -0
  189. data/lib/shopify-cli/oauth.rb +25 -25
  190. data/lib/shopify-cli/oauth/servlet.rb +9 -9
  191. data/lib/shopify-cli/options.rb +3 -3
  192. data/lib/shopify-cli/packager.rb +24 -24
  193. data/lib/shopify-cli/partners_api.rb +38 -16
  194. data/lib/shopify-cli/partners_api/organizations.rb +10 -10
  195. data/lib/shopify-cli/process_supervision.rb +8 -8
  196. data/lib/shopify-cli/project.rb +27 -23
  197. data/lib/shopify-cli/project_type.rb +21 -5
  198. data/lib/shopify-cli/resolve_constant.rb +25 -0
  199. data/lib/shopify-cli/resources.rb +1 -1
  200. data/lib/shopify-cli/resources/env_file.rb +9 -9
  201. data/lib/shopify-cli/result.rb +432 -0
  202. data/lib/shopify-cli/shopifolk.rb +35 -18
  203. data/lib/shopify-cli/sub_command.rb +1 -1
  204. data/lib/shopify-cli/task.rb +9 -1
  205. data/lib/shopify-cli/tasks.rb +7 -7
  206. data/lib/shopify-cli/tasks/create_api_client.rb +13 -4
  207. data/lib/shopify-cli/tasks/ensure_dev_store.rb +12 -12
  208. data/lib/shopify-cli/tasks/ensure_env.rb +18 -15
  209. data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
  210. data/lib/shopify-cli/tasks/select_org_and_shop.rb +28 -24
  211. data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
  212. data/lib/shopify-cli/transform_data_structure.rb +86 -0
  213. data/lib/shopify-cli/tunnel.rb +36 -30
  214. data/lib/shopify-cli/version.rb +1 -1
  215. data/lib/shopify_cli.rb +57 -52
  216. data/shopify-cli.gemspec +6 -6
  217. data/shopify.fish +1 -1
  218. data/shopify.sh +1 -1
  219. data/vendor/deps/cli-kit/REVISION +1 -1
  220. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +2 -2
  221. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +3 -3
  222. data/vendor/deps/cli-ui/REVISION +1 -1
  223. data/vendor/deps/cli-ui/lib/cli/ui.rb +26 -22
  224. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +4 -6
  225. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -3
  226. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +8 -9
  227. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -1
  228. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +1 -0
  229. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +15 -3
  230. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +4 -11
  231. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -5
  232. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +10 -10
  233. data/vendor/deps/cli-ui/lib/cli/ui/version.rb +1 -1
  234. data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +56 -0
  235. data/vendor/deps/webrick/.gitignore +9 -0
  236. data/vendor/deps/webrick/Gemfile +3 -0
  237. data/vendor/deps/webrick/LICENSE.txt +22 -0
  238. data/vendor/deps/webrick/README.md +61 -0
  239. data/vendor/deps/webrick/Rakefile +10 -0
  240. data/vendor/deps/webrick/lib/webrick.rb +232 -0
  241. data/vendor/deps/webrick/lib/webrick/accesslog.rb +157 -0
  242. data/vendor/deps/webrick/lib/webrick/cgi.rb +313 -0
  243. data/vendor/deps/webrick/lib/webrick/compat.rb +36 -0
  244. data/vendor/deps/webrick/lib/webrick/config.rb +158 -0
  245. data/vendor/deps/webrick/lib/webrick/cookie.rb +172 -0
  246. data/vendor/deps/webrick/lib/webrick/htmlutils.rb +30 -0
  247. data/vendor/deps/webrick/lib/webrick/httpauth.rb +96 -0
  248. data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +117 -0
  249. data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +116 -0
  250. data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +395 -0
  251. data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +132 -0
  252. data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +97 -0
  253. data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +158 -0
  254. data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +53 -0
  255. data/vendor/deps/webrick/lib/webrick/httpproxy.rb +354 -0
  256. data/vendor/deps/webrick/lib/webrick/httprequest.rb +636 -0
  257. data/vendor/deps/webrick/lib/webrick/httpresponse.rb +564 -0
  258. data/vendor/deps/webrick/lib/webrick/https.rb +152 -0
  259. data/vendor/deps/webrick/lib/webrick/httpserver.rb +294 -0
  260. data/vendor/deps/webrick/lib/webrick/httpservlet.rb +23 -0
  261. data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +152 -0
  262. data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +47 -0
  263. data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +126 -0
  264. data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +88 -0
  265. data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +552 -0
  266. data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +47 -0
  267. data/vendor/deps/webrick/lib/webrick/httpstatus.rb +194 -0
  268. data/vendor/deps/webrick/lib/webrick/httputils.rb +512 -0
  269. data/vendor/deps/webrick/lib/webrick/httpversion.rb +76 -0
  270. data/vendor/deps/webrick/lib/webrick/log.rb +156 -0
  271. data/vendor/deps/webrick/lib/webrick/server.rb +381 -0
  272. data/vendor/deps/webrick/lib/webrick/ssl.rb +215 -0
  273. data/vendor/deps/webrick/lib/webrick/utils.rb +265 -0
  274. data/vendor/deps/webrick/lib/webrick/version.rb +18 -0
  275. data/vendor/deps/webrick/webrick.gemspec +74 -0
  276. data/vendor/gen/template/bin/update-deps +9 -9
  277. metadata +83 -29
  278. data/docs/Gemfile +0 -5
  279. data/docs/Gemfile.lock +0 -258
  280. data/docs/_data/nav.yml +0 -35
  281. data/docs/_includes/footer.html +0 -15
  282. data/docs/_includes/head.html +0 -19
  283. data/docs/_includes/sidebar_nav.html +0 -22
  284. data/docs/_includes/toc.html +0 -112
  285. data/docs/_layouts/default.html +0 -79
  286. data/docs/css/docs.css +0 -157
  287. data/docs/images/header.png +0 -0
  288. data/docs/installing-ruby.md +0 -28
  289. data/lib/project_types/extension/features/argo/admin.rb +0 -20
  290. data/lib/project_types/extension/features/argo/base.rb +0 -129
  291. data/lib/project_types/extension/features/argo/checkout.rb +0 -20
  292. data/lib/project_types/extension/forms/register.rb +0 -47
  293. data/lib/project_types/extension/models/type.rb +0 -81
  294. data/lib/project_types/extension/models/types/checkout_post_purchase.rb +0 -23
  295. data/lib/project_types/extension/models/types/product_subscription.rb +0 -24
  296. data/lib/project_types/node/commands/generate/billing.rb +0 -39
  297. data/lib/project_types/node/commands/generate/page.rb +0 -59
  298. data/lib/project_types/node/commands/generate/webhook.rb +0 -37
  299. data/lib/project_types/script/layers/domain/script.rb +0 -18
  300. data/lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb +0 -38
  301. data/lib/project_types/script/layers/infrastructure/script_repository.rb +0 -59
  302. data/lib/project_types/script/templates/ts/as-pect.config.js +0 -27
  303. data/lib/project_types/script/templates/ts/as-pect.d.ts +0 -1
@@ -12,13 +12,13 @@ module Script
12
12
  shop_domain: project.env[:shop],
13
13
  extension_point_type: project.extension_point_type
14
14
  )
15
- @ctx.puts(@ctx.message('script.disable.script_disabled'))
15
+ @ctx.puts(@ctx.message("script.disable.script_disabled"))
16
16
  rescue StandardError => e
17
- UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.disable.error.operation_failed'))
17
+ UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message("script.disable.error.operation_failed"))
18
18
  end
19
19
 
20
20
  def self.help
21
- ShopifyCli::Context.message('script.disable.help', ShopifyCli::TOOL_NAME)
21
+ ShopifyCli::Context.message("script.disable.help", ShopifyCli::TOOL_NAME)
22
22
  end
23
23
  end
24
24
  end
@@ -4,10 +4,10 @@ module Script
4
4
  module Commands
5
5
  class Enable < ShopifyCli::Command
6
6
  options do |parser, flags|
7
- parser.on('--config_props=KEYVALUEPAIRS', Array) do |t|
8
- flags[:config_props] = Hash[t.map { |s| s.split(':') }]
9
- end
10
- parser.on('--config_file=CONFIGFILEPATH') { |t| flags[:config_file] = t }
7
+ parser.on("--config_props=KEYVALUEPAIRS", Array) { |t| flags[:config_props] = t }
8
+ parser.on("--config-props=KEYVALUEPAIRS", Array) { |t| flags[:config_props] = t }
9
+ parser.on("--config_file=CONFIGFILEPATH") { |t| flags[:config_file] = t }
10
+ parser.on("--config-file=CONFIGFILEPATH") { |t| flags[:config_file] = t }
11
11
  end
12
12
 
13
13
  def call(_args, _name)
@@ -25,21 +25,21 @@ module Script
25
25
  title: project.script_name
26
26
  )
27
27
  @ctx.puts(@ctx.message(
28
- 'script.enable.script_enabled',
28
+ "script.enable.script_enabled",
29
29
  api_key: api_key,
30
30
  shop_domain: shop_domain,
31
31
  type: project.extension_point_type.capitalize,
32
32
  title: project.script_name
33
33
  ))
34
- @ctx.puts(@ctx.message('script.enable.info'))
34
+ @ctx.puts(@ctx.message("script.enable.info"))
35
35
  rescue Errors::InvalidConfigYAMLError => e
36
36
  UI::ErrorHandler.pretty_print_and_raise(e)
37
37
  rescue StandardError => e
38
- UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.enable.error.operation_failed'))
38
+ UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message("script.enable.error.operation_failed"))
39
39
  end
40
40
 
41
41
  def self.help
42
- ShopifyCli::Context.message('script.enable.help', ShopifyCli::TOOL_NAME)
42
+ ShopifyCli::Context.message("script.enable.help", ShopifyCli::TOOL_NAME)
43
43
  end
44
44
 
45
45
  private
@@ -47,7 +47,7 @@ module Script
47
47
  def acquire_configuration(config_file: nil, config_props: nil)
48
48
  properties = {}
49
49
  properties = YAML.load(File.read(config_file)) unless config_file.nil?
50
- properties = properties.merge(config_props) unless config_props.nil?
50
+ properties = properties.merge(parse_config_props(config_props)) unless config_props.nil?
51
51
 
52
52
  configuration = { entries: [] }
53
53
  properties.each do |key, value|
@@ -61,6 +61,16 @@ module Script
61
61
  raise Errors::InvalidConfigYAMLError, options.flags[:config_file]
62
62
  end
63
63
 
64
+ def parse_config_props(config_props)
65
+ Hash[
66
+ config_props.map do |s|
67
+ args = s.split(":").map(&:strip)
68
+ raise Errors::InvalidConfigProps unless args.size == 2
69
+ args
70
+ end
71
+ ]
72
+ end
73
+
64
74
  # No slice pre Ruby 2.5 so roll our own
65
75
  def slice(hash, *keys)
66
76
  Hash[hash.to_a - hash.select { |key, _value| !keys.include?(key) }.to_a]
@@ -4,31 +4,24 @@ module Script
4
4
  module Commands
5
5
  class Push < ShopifyCli::Command
6
6
  options do |parser, flags|
7
- parser.on('--force') { |t| flags[:force] = t }
7
+ parser.on("--force") { |t| flags[:force] = t }
8
8
  end
9
9
 
10
10
  def call(_args, _name)
11
11
  ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
12
- project = ScriptProject.current
13
- api_key = project.env[:api_key]
14
- return @ctx.puts(self.class.help) unless api_key &&
15
- ScriptProject::SUPPORTED_LANGUAGES.include?(project.language)
16
- Layers::Application::PushScript.call(
17
- ctx: @ctx,
18
- language: project.language,
19
- extension_point_type: project.extension_point_type,
20
- script_name: project.script_name,
21
- source_file: project.source_file,
22
- api_key: api_key,
23
- force: options.flags.key?(:force)
24
- )
25
- @ctx.puts(@ctx.message('script.push.script_pushed', api_key: api_key))
12
+
13
+ api_key = ScriptProject.current.api_key
14
+ return @ctx.puts(self.class.help) unless api_key
15
+
16
+ Layers::Application::PushScript.call(ctx: @ctx, force: options.flags.key?(:force))
17
+ @ctx.puts(@ctx.message("script.push.script_pushed", api_key: api_key))
26
18
  rescue StandardError => e
27
- UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.push.error.operation_failed'))
19
+ msg = @ctx.message("script.push.error.operation_failed", api_key: ShopifyCli::Project.current.env.api_key)
20
+ UI::ErrorHandler.pretty_print_and_raise(e, failed_op: msg)
28
21
  end
29
22
 
30
23
  def self.help
31
- ShopifyCli::Context.message('script.push.help', ShopifyCli::TOOL_NAME)
24
+ ShopifyCli::Context.message("script.push.help", ShopifyCli::TOOL_NAME)
32
25
  end
33
26
  end
34
27
  end
@@ -1,24 +1,42 @@
1
1
  discount:
2
+ deprecated: true
2
3
  assemblyscript:
3
4
  package: "@shopify/extension-point-as-discount"
4
- version: "^0.3.0"
5
- sdk-version: "^7.0.0"
6
- toolchain-version: "^1.1.0"
5
+ sdk-version: "^9.0.0"
6
+ toolchain-version: "^5.0.0"
7
7
  unit_limit_per_order:
8
8
  assemblyscript:
9
9
  package: "@shopify/extension-point-as-unit-limit-per-order"
10
- version: "^0.2.0"
11
- sdk-version: "^7.0.0"
12
- toolchain-version: "^1.1.0"
10
+ sdk-version: "^9.0.0"
11
+ toolchain-version: "^5.0.0"
13
12
  payment_filter:
14
13
  assemblyscript:
15
14
  package: "@shopify/extension-point-as-payment-filter"
16
- version: "^0.5.0"
17
- sdk-version: "^7.0.0"
18
- toolchain-version: "^1.1.0"
15
+ sdk-version: "^9.0.0"
16
+ toolchain-version: "^5.0.0"
17
+ rust:
18
+ beta: true
19
+ package: "https://github.com/Shopify/scripts-apis-rs"
19
20
  shipping_filter:
20
21
  assemblyscript:
21
22
  package: "@shopify/extension-point-as-shipping-filter"
22
- version: "^0.3.0"
23
- sdk-version: "^7.0.0"
24
- toolchain-version: "^1.1.0"
23
+ sdk-version: "^9.0.0"
24
+ toolchain-version: "^5.0.0"
25
+ tax_filter:
26
+ assemblyscript:
27
+ package: "@shopify/extension-point-as-tax-filter"
28
+ sdk-version: "^9.0.0"
29
+ toolchain-version: "^5.0.0"
30
+ payment_methods:
31
+ domain: 'checkout'
32
+ assemblyscript:
33
+ package: "@shopify/scripts-checkout-apis"
34
+ toolchain-version: "^5.0.0"
35
+ sdk-version: "^9.0.0"
36
+ shipping_methods:
37
+ domain: 'checkout'
38
+ assemblyscript:
39
+ package: "@shopify/scripts-checkout-apis"
40
+ sdk-version: "^9.0.0"
41
+ toolchain-version: "^5.0.0"
42
+
@@ -4,8 +4,10 @@ module Script
4
4
  module Errors
5
5
  class InvalidContextError < ScriptProjectError; end
6
6
  class InvalidScriptNameError < ScriptProjectError; end
7
+
7
8
  class NoExistingAppsError < ScriptProjectError; end
8
9
  class NoExistingOrganizationsError < ScriptProjectError; end
10
+
9
11
  class NoExistingStoresError < ScriptProjectError
10
12
  attr_reader :organization_id
11
13
  def initialize(organization_id)
@@ -13,7 +15,10 @@ module Script
13
15
  @organization_id = organization_id
14
16
  end
15
17
  end
18
+
16
19
  class ScriptProjectAlreadyExistsError < ScriptProjectError; end
20
+ class InvalidConfigProps < ScriptProjectError; end
21
+
17
22
  class InvalidConfigYAMLError < ScriptProjectError
18
23
  attr_reader :config_file
19
24
  def initialize(config_file)
@@ -21,5 +26,22 @@ module Script
21
26
  @config_file = config_file
22
27
  end
23
28
  end
29
+
30
+ class InvalidLanguageError < ScriptProjectError
31
+ attr_reader :language, :extension_point_type
32
+ def initialize(language, extension_point_type)
33
+ super()
34
+ @language = language
35
+ @extension_point_type = extension_point_type
36
+ end
37
+ end
38
+
39
+ class DeprecatedEPError < ScriptProjectError
40
+ attr_reader :ep
41
+ def initialize(ep)
42
+ super()
43
+ @ep = ep
44
+ end
45
+ end
24
46
  end
25
47
  end
@@ -3,31 +3,55 @@
3
3
  module Script
4
4
  module Forms
5
5
  class Create < ShopifyCli::Form
6
- flag_arguments :extension_point, :name
6
+ flag_arguments :extension_point, :name, :language, :description
7
7
 
8
8
  def ask
9
9
  self.name = valid_name
10
+ self.description ||= ask_description
10
11
  self.extension_point ||= ask_extension_point
12
+ self.language = ask_language
11
13
  end
12
14
 
13
15
  private
14
16
 
15
17
  def ask_extension_point
16
18
  CLI::UI::Prompt.ask(
17
- @ctx.message('script.forms.create.select_extension_point'),
18
- options: Script::Layers::Application::ExtensionPoints.types
19
+ @ctx.message("script.forms.create.select_extension_point"),
20
+ options: Layers::Application::ExtensionPoints.non_deprecated_types
19
21
  )
20
22
  end
21
23
 
22
24
  def ask_name
23
- CLI::UI::Prompt.ask(@ctx.message('script.forms.create.script_name'))
25
+ CLI::UI::Prompt.ask(@ctx.message("script.forms.create.script_name"))
26
+ end
27
+
28
+ def ask_description
29
+ CLI::UI::Prompt.ask(@ctx.message("script.forms.create.description"))
24
30
  end
25
31
 
26
32
  def valid_name
27
- n = (name || ask_name).downcase.gsub(' ', '_')
33
+ n = (name || ask_name).downcase.gsub(" ", "_")
28
34
  return n if n.match?(/^[0-9A-Za-z_-]*$/)
29
35
  raise Errors::InvalidScriptNameError
30
36
  end
37
+
38
+ def ask_language
39
+ if language
40
+ if Layers::Application::ExtensionPoints.supported_language?(type: extension_point, language: language)
41
+ return language.downcase
42
+ else
43
+ raise Errors::InvalidLanguageError.new(language, extension_point)
44
+ end
45
+ end
46
+
47
+ all_languages = Layers::Application::ExtensionPoints.languages(type: extension_point)
48
+ return all_languages.first if all_languages.count == 1
49
+
50
+ CLI::UI::Prompt.ask(
51
+ ctx.message("script.forms.create.select_language"),
52
+ options: all_languages
53
+ )
54
+ end
31
55
  end
32
56
  end
33
57
  end
@@ -1,16 +1,26 @@
1
1
  mutation AppScriptUpdateOrCreate(
2
2
  $extensionPointName: ExtensionPointName!,
3
3
  $title: String,
4
+ $description: String,
5
+ $configUi: String,
4
6
  $sourceCode: String,
5
7
  $language: String,
6
- $force: Boolean
8
+ $force: Boolean,
9
+ $schemaMajorVersion: String,
10
+ $schemaMinorVersion: String,
11
+ $useMsgpack: Boolean
7
12
  ) {
8
13
  appScriptUpdateOrCreate(
9
14
  extensionPointName: $extensionPointName
10
15
  title: $title
16
+ description: $description
17
+ configUi: $configUi
11
18
  sourceCode: $sourceCode
12
19
  language: $language
13
20
  force: $force
21
+ schemaMajorVersion: $schemaMajorVersion
22
+ schemaMinorVersion: $schemaMinorVersion
23
+ useMsgpack: $useMsgpack
14
24
  ) {
15
25
  userErrors {
16
26
  field
@@ -22,6 +32,7 @@ mutation AppScriptUpdateOrCreate(
22
32
  configSchema
23
33
  extensionPointName
24
34
  title
35
+ description
25
36
  }
26
37
  }
27
38
  }
@@ -5,33 +5,33 @@ module Script
5
5
  module Application
6
6
  class BuildScript
7
7
  class << self
8
- def call(ctx:, task_runner:, script:)
9
- return if CLI::UI::Frame.open(ctx.message('script.application.building')) do
8
+ def call(ctx:, task_runner:, script_project:, config_ui:)
9
+ CLI::UI::Frame.open(ctx.message("script.application.building")) do
10
10
  begin
11
- UI::StrictSpinner.spin(ctx.message('script.application.building_script')) do |spinner|
12
- build(ctx, task_runner, script)
13
- spinner.update_title(ctx.message('script.application.built'))
11
+ UI::StrictSpinner.spin(ctx.message("script.application.building_script")) do |spinner|
12
+ Infrastructure::PushPackageRepository.new(ctx: ctx).create_push_package(
13
+ script_project: script_project,
14
+ script_content: task_runner.build,
15
+ compiled_type: task_runner.compiled_type,
16
+ metadata: task_runner.metadata,
17
+ config_ui: config_ui,
18
+ )
19
+ spinner.update_title(ctx.message("script.application.built"))
14
20
  end
15
- true
16
21
  rescue StandardError => e
17
22
  CLI::UI::Frame.with_frame_color_override(:red) do
18
23
  ctx.puts("\n{{red:#{e.message}}}")
19
24
  end
20
- false
21
- end
22
- end
23
- raise Infrastructure::Errors::BuildError
24
- end
25
+ errors = [
26
+ Infrastructure::Errors::InvalidBuildScriptError,
27
+ Infrastructure::Errors::BuildScriptNotFoundError,
28
+ Infrastructure::Errors::WebAssemblyBinaryNotFoundError,
29
+ ]
25
30
 
26
- private
27
-
28
- def build(ctx, task_runner, script)
29
- script_repo = Infrastructure::ScriptRepository.new(ctx: ctx)
30
- script_content = script_repo.with_temp_build_context do
31
- task_runner.build
31
+ raise Infrastructure::Errors::BuildError unless errors.any? { |err| e.is_a?(err) }
32
+ raise
33
+ end
32
34
  end
33
- Infrastructure::PushPackageRepository.new(ctx: ctx)
34
- .create_push_package(script, script_content, task_runner.compiled_type)
35
35
  end
36
36
  end
37
37
  end
@@ -7,42 +7,75 @@ module Script
7
7
  module Application
8
8
  class CreateScript
9
9
  class << self
10
- def call(ctx:, language:, script_name:, extension_point_type:)
10
+ def call(ctx:, language:, script_name:, extension_point_type:, description:, no_config_ui:)
11
11
  extension_point = ExtensionPoints.get(type: extension_point_type)
12
- project = setup_project(ctx, script_name, extension_point)
12
+ project = setup_project(
13
+ ctx: ctx,
14
+ language: language,
15
+ script_name: script_name,
16
+ extension_point: extension_point,
17
+ description: description,
18
+ no_config_ui: no_config_ui
19
+ )
13
20
  project_creator = Infrastructure::ProjectCreator
14
21
  .for(ctx, language, extension_point, script_name, project.directory)
15
- install_dependencies(ctx, language, script_name, project.source_file, project_creator)
16
- bootstrap(ctx, project.source_path, project_creator)
22
+ install_dependencies(ctx, language, script_name, project_creator)
23
+ bootstrap(ctx, project_creator)
17
24
  project
18
25
  end
19
26
 
20
27
  private
21
28
 
22
- def setup_project(ctx, script_name, extension_point)
29
+ DEFAULT_CONFIG_UI_FILENAME = "config-ui.yml"
30
+
31
+ def setup_project(ctx:, language:, script_name:, extension_point:, description:, no_config_ui:)
23
32
  ScriptProject.create(ctx, script_name)
33
+
34
+ identifiers = {
35
+ extension_point_type: extension_point.type,
36
+ script_name: script_name,
37
+ language: language,
38
+ description: description,
39
+ }
40
+
41
+ unless no_config_ui
42
+ require "yaml" # takes 20ms, so deferred as late as possible.
43
+ identifiers.merge!(config_ui_file: DEFAULT_CONFIG_UI_FILENAME)
44
+ Infrastructure::ConfigUiRepository
45
+ .new(ctx: ctx)
46
+ .create_config_ui(DEFAULT_CONFIG_UI_FILENAME, default_config_ui_content(script_name))
47
+ end
48
+
24
49
  ScriptProject.write(
25
50
  ctx,
26
51
  project_type: :script,
27
52
  organization_id: nil, # TODO: can you provide this at creation
28
- extension_point_type: extension_point.type,
29
- script_name: script_name
53
+ **identifiers
30
54
  )
31
55
  ScriptProject.current
32
56
  end
33
57
 
34
- def install_dependencies(ctx, language, script_name, source_file, project_creator)
35
- task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name, source_file)
58
+ def install_dependencies(ctx, language, script_name, project_creator)
59
+ task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name)
36
60
  project_creator.setup_dependencies
37
61
  ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
38
62
  end
39
63
 
40
- def bootstrap(ctx, source_path, project_creator)
41
- UI::StrictSpinner.spin(ctx.message('script.create.creating')) do |spinner|
64
+ def bootstrap(ctx, project_creator)
65
+ UI::StrictSpinner.spin(ctx.message("script.create.creating")) do |spinner|
42
66
  project_creator.bootstrap
43
- spinner.update_title(ctx.message('script.create.created', source_path))
67
+ spinner.update_title(ctx.message("script.create.created"))
44
68
  end
45
69
  end
70
+
71
+ def default_config_ui_content(title)
72
+ YAML.dump({
73
+ "version" => 1,
74
+ "type" => "single",
75
+ "title" => title,
76
+ "fields" => [],
77
+ })
78
+ end
46
79
  end
47
80
  end
48
81
  end