shopify-cli 1.3.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) 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/.gitignore +0 -1
  8. data/.rubocop.yml +61 -8
  9. data/.rubocop_todo.yml +11 -0
  10. data/.travis.yml +1 -0
  11. data/CHANGELOG.md +30 -0
  12. data/Gemfile +12 -11
  13. data/Gemfile.lock +39 -37
  14. data/README.md +39 -7
  15. data/RELEASING.md +19 -29
  16. data/Rakefile +32 -28
  17. data/bin/load_shopify.rb +6 -6
  18. data/bin/shopify +2 -2
  19. data/dev.yml +2 -2
  20. data/docs/_config.yml +1 -18
  21. data/docs/app/node/commands/index.md +2 -80
  22. data/docs/app/node/index.md +2 -33
  23. data/docs/app/rails/commands/index.md +2 -78
  24. data/docs/app/rails/index.md +2 -34
  25. data/docs/core/index.md +2 -84
  26. data/docs/getting-started/index.md +2 -25
  27. data/docs/getting-started/install/index.md +1 -118
  28. data/docs/getting-started/migrate/index.md +2 -94
  29. data/docs/getting-started/uninstall/index.md +2 -35
  30. data/docs/getting-started/upgrade/index.md +2 -39
  31. data/docs/help/start-app/index.md +2 -4
  32. data/docs/index.md +2 -24
  33. data/ext/shopify-cli/extconf.rb +7 -7
  34. data/install.sh +1 -1
  35. data/lib/docgen/markdown.rb +11 -11
  36. data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
  37. data/lib/project_types/extension/cli.rb +64 -47
  38. data/lib/project_types/extension/commands/build.rb +3 -3
  39. data/lib/project_types/extension/commands/create.rb +16 -9
  40. data/lib/project_types/extension/commands/extension_command.rb +8 -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 +2 -2
  44. data/lib/project_types/extension/commands/tunnel.rb +12 -12
  45. data/lib/project_types/extension/extension_project.rb +4 -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 +36 -0
  56. data/lib/project_types/extension/messages/messages.rb +53 -52
  57. data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
  58. data/lib/project_types/extension/models/specification.rb +35 -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 +77 -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 +38 -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 +46 -38
  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 +7 -7
  87. data/lib/project_types/node/messages/messages.rb +19 -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 +60 -54
  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 +24 -24
  103. data/lib/project_types/rails/gem.rb +24 -24
  104. data/lib/project_types/rails/messages/messages.rb +12 -9
  105. data/lib/project_types/rails/ruby.rb +2 -2
  106. data/lib/project_types/script/cli.rb +42 -38
  107. data/lib/project_types/script/commands/create.rb +13 -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 +17 -12
  112. data/lib/project_types/script/errors.rb +38 -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 +18 -19
  116. data/lib/project_types/script/layers/application/create_script.rb +13 -11
  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 +12 -18
  122. data/lib/project_types/script/layers/domain/errors.rb +7 -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 -54
  127. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +49 -18
  128. data/lib/project_types/script/layers/infrastructure/errors.rb +17 -1
  129. data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +12 -6
  130. data/lib/project_types/script/layers/infrastructure/project_creator.rb +2 -1
  131. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +20 -13
  132. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +72 -0
  133. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +59 -0
  134. data/lib/project_types/script/layers/infrastructure/script_service.rb +26 -16
  135. data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
  136. data/lib/project_types/script/messages/messages.rb +67 -10
  137. data/lib/project_types/script/script_project.rb +47 -16
  138. data/lib/project_types/script/ui/error_handler.rb +115 -45
  139. data/lib/project_types/script/ui/printing_spinner.rb +1 -1
  140. data/lib/project_types/script/ui/strict_spinner.rb +1 -1
  141. data/lib/project_types/theme/cli.rb +40 -0
  142. data/lib/project_types/theme/commands/connect.rb +54 -0
  143. data/lib/project_types/theme/commands/create.rb +48 -0
  144. data/lib/project_types/theme/commands/deploy.rb +38 -0
  145. data/lib/project_types/theme/commands/generate.rb +20 -0
  146. data/lib/project_types/theme/commands/generate/env.rb +79 -0
  147. data/lib/project_types/theme/commands/push.rb +55 -0
  148. data/lib/project_types/theme/commands/serve.rb +31 -0
  149. data/lib/project_types/theme/forms/connect.rb +34 -0
  150. data/lib/project_types/theme/forms/create.rb +22 -0
  151. data/lib/project_types/theme/messages/messages.rb +147 -0
  152. data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +78 -0
  153. data/lib/project_types/theme/themekit.rb +113 -0
  154. data/lib/rubygems_plugin.rb +3 -3
  155. data/lib/shopify-cli/admin_api.rb +52 -12
  156. data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
  157. data/lib/shopify-cli/admin_api/schema.rb +3 -3
  158. data/lib/shopify-cli/api.rb +38 -37
  159. data/lib/shopify-cli/command.rb +1 -1
  160. data/lib/shopify-cli/commands.rb +9 -9
  161. data/lib/shopify-cli/commands/config.rb +28 -28
  162. data/lib/shopify-cli/commands/connect.rb +35 -18
  163. data/lib/shopify-cli/commands/create.rb +5 -5
  164. data/lib/shopify-cli/commands/help.rb +6 -6
  165. data/lib/shopify-cli/commands/logout.rb +3 -3
  166. data/lib/shopify-cli/commands/system.rb +40 -31
  167. data/lib/shopify-cli/commands/version.rb +2 -2
  168. data/lib/shopify-cli/context.rb +43 -22
  169. data/lib/shopify-cli/core.rb +4 -4
  170. data/lib/shopify-cli/core/entry_point.rb +6 -6
  171. data/lib/shopify-cli/core/executor.rb +1 -1
  172. data/lib/shopify-cli/core/help_resolver.rb +2 -2
  173. data/lib/shopify-cli/core/monorail.rb +21 -19
  174. data/lib/shopify-cli/db.rb +2 -2
  175. data/lib/shopify-cli/feature.rb +1 -3
  176. data/lib/shopify-cli/form.rb +1 -1
  177. data/lib/shopify-cli/git.rb +17 -17
  178. data/lib/shopify-cli/helpers.rb +1 -1
  179. data/lib/shopify-cli/helpers/haikunator.rb +1 -1
  180. data/lib/shopify-cli/heroku.rb +28 -28
  181. data/lib/shopify-cli/http_request.rb +27 -0
  182. data/lib/shopify-cli/js_deps.rb +13 -13
  183. data/lib/shopify-cli/js_system.rb +5 -5
  184. data/lib/shopify-cli/lazy_delegator.rb +55 -0
  185. data/lib/shopify-cli/messages/messages.rb +24 -10
  186. data/lib/shopify-cli/method_object.rb +104 -0
  187. data/lib/shopify-cli/oauth.rb +25 -25
  188. data/lib/shopify-cli/oauth/servlet.rb +9 -9
  189. data/lib/shopify-cli/options.rb +3 -3
  190. data/lib/shopify-cli/packager.rb +24 -24
  191. data/lib/shopify-cli/partners_api.rb +38 -16
  192. data/lib/shopify-cli/partners_api/organizations.rb +10 -10
  193. data/lib/shopify-cli/process_supervision.rb +8 -8
  194. data/lib/shopify-cli/project.rb +27 -23
  195. data/lib/shopify-cli/project_type.rb +21 -5
  196. data/lib/shopify-cli/resolve_constant.rb +25 -0
  197. data/lib/shopify-cli/resources.rb +1 -1
  198. data/lib/shopify-cli/resources/env_file.rb +9 -9
  199. data/lib/shopify-cli/result.rb +432 -0
  200. data/lib/shopify-cli/shopifolk.rb +84 -0
  201. data/lib/shopify-cli/sub_command.rb +1 -1
  202. data/lib/shopify-cli/task.rb +9 -1
  203. data/lib/shopify-cli/tasks.rb +7 -7
  204. data/lib/shopify-cli/tasks/create_api_client.rb +17 -6
  205. data/lib/shopify-cli/tasks/ensure_dev_store.rb +11 -11
  206. data/lib/shopify-cli/tasks/ensure_env.rb +18 -15
  207. data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
  208. data/lib/shopify-cli/tasks/select_org_and_shop.rb +29 -24
  209. data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
  210. data/lib/shopify-cli/transform_data_structure.rb +86 -0
  211. data/lib/shopify-cli/tunnel.rb +36 -30
  212. data/lib/shopify-cli/version.rb +1 -1
  213. data/lib/shopify_cli.rb +57 -51
  214. data/shopify-cli.gemspec +6 -6
  215. data/shopify.fish +1 -1
  216. data/shopify.sh +1 -1
  217. data/vendor/deps/cli-kit/REVISION +1 -1
  218. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +2 -2
  219. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +3 -3
  220. data/vendor/deps/cli-ui/REVISION +1 -1
  221. data/vendor/deps/cli-ui/lib/cli/ui.rb +26 -22
  222. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +4 -6
  223. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -3
  224. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +8 -9
  225. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -1
  226. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +1 -0
  227. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +15 -3
  228. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +4 -11
  229. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -5
  230. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +10 -10
  231. data/vendor/deps/cli-ui/lib/cli/ui/version.rb +1 -1
  232. data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +56 -0
  233. data/vendor/deps/webrick/.gitignore +9 -0
  234. data/vendor/deps/webrick/Gemfile +3 -0
  235. data/vendor/deps/webrick/LICENSE.txt +22 -0
  236. data/vendor/deps/webrick/README.md +61 -0
  237. data/vendor/deps/webrick/Rakefile +10 -0
  238. data/vendor/deps/webrick/lib/webrick.rb +232 -0
  239. data/vendor/deps/webrick/lib/webrick/accesslog.rb +157 -0
  240. data/vendor/deps/webrick/lib/webrick/cgi.rb +313 -0
  241. data/vendor/deps/webrick/lib/webrick/compat.rb +36 -0
  242. data/vendor/deps/webrick/lib/webrick/config.rb +158 -0
  243. data/vendor/deps/webrick/lib/webrick/cookie.rb +172 -0
  244. data/vendor/deps/webrick/lib/webrick/htmlutils.rb +30 -0
  245. data/vendor/deps/webrick/lib/webrick/httpauth.rb +96 -0
  246. data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +117 -0
  247. data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +116 -0
  248. data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +395 -0
  249. data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +132 -0
  250. data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +97 -0
  251. data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +158 -0
  252. data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +53 -0
  253. data/vendor/deps/webrick/lib/webrick/httpproxy.rb +354 -0
  254. data/vendor/deps/webrick/lib/webrick/httprequest.rb +636 -0
  255. data/vendor/deps/webrick/lib/webrick/httpresponse.rb +564 -0
  256. data/vendor/deps/webrick/lib/webrick/https.rb +152 -0
  257. data/vendor/deps/webrick/lib/webrick/httpserver.rb +294 -0
  258. data/vendor/deps/webrick/lib/webrick/httpservlet.rb +23 -0
  259. data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +152 -0
  260. data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +47 -0
  261. data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +126 -0
  262. data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +88 -0
  263. data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +552 -0
  264. data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +47 -0
  265. data/vendor/deps/webrick/lib/webrick/httpstatus.rb +194 -0
  266. data/vendor/deps/webrick/lib/webrick/httputils.rb +512 -0
  267. data/vendor/deps/webrick/lib/webrick/httpversion.rb +76 -0
  268. data/vendor/deps/webrick/lib/webrick/log.rb +156 -0
  269. data/vendor/deps/webrick/lib/webrick/server.rb +381 -0
  270. data/vendor/deps/webrick/lib/webrick/ssl.rb +215 -0
  271. data/vendor/deps/webrick/lib/webrick/utils.rb +265 -0
  272. data/vendor/deps/webrick/lib/webrick/version.rb +18 -0
  273. data/vendor/deps/webrick/webrick.gemspec +74 -0
  274. data/vendor/gen/template/bin/update-deps +9 -9
  275. metadata +84 -29
  276. data/docs/Gemfile +0 -5
  277. data/docs/Gemfile.lock +0 -258
  278. data/docs/_data/nav.yml +0 -35
  279. data/docs/_includes/footer.html +0 -15
  280. data/docs/_includes/head.html +0 -19
  281. data/docs/_includes/sidebar_nav.html +0 -22
  282. data/docs/_includes/toc.html +0 -112
  283. data/docs/_layouts/default.html +0 -79
  284. data/docs/css/docs.css +0 -157
  285. data/docs/images/header.png +0 -0
  286. data/docs/installing-ruby.md +0 -28
  287. data/lib/project_types/extension/features/argo/admin.rb +0 -20
  288. data/lib/project_types/extension/features/argo/base.rb +0 -129
  289. data/lib/project_types/extension/features/argo/checkout.rb +0 -20
  290. data/lib/project_types/extension/forms/register.rb +0 -47
  291. data/lib/project_types/extension/models/type.rb +0 -81
  292. data/lib/project_types/extension/models/types/checkout_post_purchase.rb +0 -23
  293. data/lib/project_types/extension/models/types/product_subscription.rb +0 -24
  294. data/lib/project_types/node/commands/generate/billing.rb +0 -39
  295. data/lib/project_types/node/commands/generate/page.rb +0 -59
  296. data/lib/project_types/node/commands/generate/webhook.rb +0 -37
  297. data/lib/project_types/script/layers/domain/script.rb +0 -18
  298. data/lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb +0 -38
  299. data/lib/project_types/script/layers/infrastructure/script_repository.rb +0 -59
  300. data/lib/project_types/script/templates/ts/as-pect.config.js +0 -27
  301. data/lib/project_types/script/templates/ts/as-pect.d.ts +0 -1
@@ -1,5 +1,5 @@
1
1
  module ShopifyCli
2
2
  module Helpers
3
- autoload :Haikunator, 'shopify-cli/helpers/haikunator'
3
+ autoload :Haikunator, "shopify-cli/helpers/haikunator"
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ module ShopifyCli
28
28
  module Haikunator
29
29
  class << self
30
30
  def title
31
- build(0, ' ')
31
+ build(0, " ")
32
32
  end
33
33
 
34
34
  def haikunate(token_range = 9999, delimiter = "-")
@@ -1,9 +1,9 @@
1
1
  module ShopifyCli
2
2
  class Heroku
3
3
  DOWNLOAD_URLS = {
4
- linux: 'https://cli-assets.heroku.com/heroku-linux-x64.tar.gz',
5
- mac: 'https://cli-assets.heroku.com/heroku-darwin-x64.tar.gz',
6
- windows: 'https://cli-assets.heroku.com/heroku-x64.exe',
4
+ linux: "https://cli-assets.heroku.com/heroku-linux-x64.tar.gz",
5
+ mac: "https://cli-assets.heroku.com/heroku-darwin-x64.tar.gz",
6
+ windows: "https://cli-assets.heroku.com/heroku-x64.exe",
7
7
  }
8
8
 
9
9
  def initialize(ctx)
@@ -12,33 +12,33 @@ module ShopifyCli
12
12
 
13
13
  def app
14
14
  return nil unless (app = git_remote)
15
- app = app.split('/').last
16
- app = app.split('.').first
15
+ app = app.split("/").last
16
+ app = app.split(".").first
17
17
  app
18
18
  end
19
19
 
20
20
  def authenticate
21
- result = @ctx.system(heroku_command, 'login')
22
- @ctx.abort(@ctx.message('core.heroku.error.authentication')) unless result.success?
21
+ result = @ctx.system(heroku_command, "login")
22
+ @ctx.abort(@ctx.message("core.heroku.error.authentication")) unless result.success?
23
23
  end
24
24
 
25
25
  def create_new_app
26
- output, status = @ctx.capture2e(heroku_command, 'create')
27
- @ctx.abort(@ctx.message('core.heroku.error.creation')) unless status.success?
26
+ output, status = @ctx.capture2e(heroku_command, "create")
27
+ @ctx.abort(@ctx.message("core.heroku.error.creation")) unless status.success?
28
28
  @ctx.puts(output)
29
29
  end
30
30
 
31
31
  def deploy(branch_to_deploy)
32
- result = @ctx.system('git', 'push', '-u', 'heroku', "#{branch_to_deploy}:master")
33
- @ctx.abort(@ctx.message('core.heroku.error.deploy')) unless result.success?
32
+ result = @ctx.system("git", "push", "-u", "heroku", "#{branch_to_deploy}:master")
33
+ @ctx.abort(@ctx.message("core.heroku.error.deploy")) unless result.success?
34
34
  end
35
35
 
36
36
  def download
37
37
  return if installed?
38
38
 
39
- result = @ctx.system('curl', '-o', download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCli.cache_dir)
40
- @ctx.abort(@ctx.message('core.heroku.error.download')) unless result.success?
41
- @ctx.abort(@ctx.message('core.heroku.error.download')) unless File.exist?(download_path)
39
+ result = @ctx.system("curl", "-o", download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCli.cache_dir)
40
+ @ctx.abort(@ctx.message("core.heroku.error.download")) unless result.success?
41
+ @ctx.abort(@ctx.message("core.heroku.error.download")) unless File.exist?(download_path)
42
42
  end
43
43
 
44
44
  def install
@@ -47,22 +47,22 @@ module ShopifyCli
47
47
  result = if @ctx.windows?
48
48
  @ctx.system("\"#{download_path}\"")
49
49
  else
50
- @ctx.system('tar', '-xf', download_path, chdir: ShopifyCli.cache_dir)
50
+ @ctx.system("tar", "-xf", download_path, chdir: ShopifyCli.cache_dir)
51
51
  end
52
- @ctx.abort(@ctx.message('core.heroku.error.install')) unless result.success?
52
+ @ctx.abort(@ctx.message("core.heroku.error.install")) unless result.success?
53
53
 
54
54
  @ctx.rm(download_path)
55
55
  end
56
56
 
57
57
  def select_existing_app(app_name)
58
- result = @ctx.system(heroku_command, 'git:remote', '-a', app_name)
58
+ result = @ctx.system(heroku_command, "git:remote", "-a", app_name)
59
59
 
60
- msg = @ctx.message('core.heroku.error.could_not_select_app', app_name)
60
+ msg = @ctx.message("core.heroku.error.could_not_select_app", app_name)
61
61
  @ctx.abort(msg) unless result.success?
62
62
  end
63
63
 
64
64
  def whoami
65
- output, status = @ctx.capture2e(heroku_command, 'whoami')
65
+ output, status = @ctx.capture2e(heroku_command, "whoami")
66
66
  return output.strip if status.success?
67
67
  nil
68
68
  end
@@ -70,7 +70,7 @@ module ShopifyCli
70
70
  private
71
71
 
72
72
  def download_filename
73
- URI.parse(DOWNLOAD_URLS[@ctx.os]).path.split('/').last
73
+ URI.parse(DOWNLOAD_URLS[@ctx.os]).path.split("/").last
74
74
  end
75
75
 
76
76
  def download_path
@@ -78,33 +78,33 @@ module ShopifyCli
78
78
  end
79
79
 
80
80
  def git_remote
81
- output, status = @ctx.capture2e('git', 'remote', 'get-url', 'heroku')
81
+ output, status = @ctx.capture2e("git", "remote", "get-url", "heroku")
82
82
  status.success? ? output : nil
83
83
  end
84
84
 
85
85
  def heroku_command
86
- local_path = File.join(ShopifyCli.cache_dir, 'heroku', 'bin', 'heroku').to_s
86
+ local_path = File.join(ShopifyCli.cache_dir, "heroku", "bin", "heroku").to_s
87
87
  if File.exist?(local_path)
88
88
  local_path
89
89
  elsif @ctx.windows?
90
90
  # Check if Heroku exists in the Windows registry and run it from there
91
- require 'win32/registry'
91
+ require "win32/registry"
92
92
  begin
93
93
  windows_path = Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\heroku') do |reg|
94
- reg[''] # This reads the 'Default' registry key
94
+ reg[""] # This reads the 'Default' registry key
95
95
  end
96
96
 
97
- File.join(windows_path, 'bin', 'heroku').to_s
97
+ File.join(windows_path, "bin", "heroku").to_s
98
98
  rescue
99
- 'heroku'
99
+ "heroku"
100
100
  end
101
101
  else
102
- 'heroku'
102
+ "heroku"
103
103
  end
104
104
  end
105
105
 
106
106
  def installed?
107
- _output, status = @ctx.capture2e(heroku_command, '--version')
107
+ _output, status = @ctx.capture2e(heroku_command, "--version")
108
108
  status.success?
109
109
  rescue
110
110
  false
@@ -0,0 +1,27 @@
1
+ require "net/http"
2
+
3
+ module ShopifyCli
4
+ class HttpRequest
5
+ class << self
6
+ def post(uri, body, headers)
7
+ req = ::Net::HTTP::Post.new(uri.request_uri)
8
+ request(uri, body, headers, req)
9
+ end
10
+
11
+ def get(uri, body, headers)
12
+ req = ::Net::HTTP::Get.new(uri.request_uri)
13
+ request(uri, body, headers, req)
14
+ end
15
+
16
+ def request(uri, body, headers, req)
17
+ http = ::Net::HTTP.new(uri.host, uri.port)
18
+ http.use_ssl = true
19
+
20
+ req.body = body unless body.nil?
21
+ req["Content-Type"] = "application/json"
22
+ headers.each { |header, value| req[header] = value }
23
+ http.request(req)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,4 +1,4 @@
1
- require 'shopify_cli'
1
+ require "shopify_cli"
2
2
 
3
3
  module ShopifyCli
4
4
  ##
@@ -37,9 +37,9 @@ module ShopifyCli
37
37
  # ShopifyCli::JsDeps.new(context).install(true)
38
38
  #
39
39
  def install(verbose = false)
40
- title = ctx.message('core.js_deps.installing', @system.package_manager)
41
- success = ctx.message('core.js_deps.installed')
42
- failure = ctx.message('core.js_deps.error.install_error', @system.package_manager)
40
+ title = ctx.message("core.js_deps.installing", @system.package_manager)
41
+ success = ctx.message("core.js_deps.installed")
42
+ failure = ctx.message("core.js_deps.error.install_error", @system.package_manager)
43
43
 
44
44
  CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do
45
45
  @system.call(
@@ -53,14 +53,14 @@ module ShopifyCli
53
53
 
54
54
  def yarn(verbose = false)
55
55
  cmd = %w(yarn install)
56
- cmd << '--silent' unless verbose
56
+ cmd << "--silent" unless verbose
57
57
 
58
58
  run_install_command(cmd)
59
59
  end
60
60
 
61
61
  def npm(verbose = false)
62
- cmd = %w(npm install --no-audit --no-optional)
63
- cmd << '--quiet' unless verbose
62
+ cmd = %w(npm install --no-audit)
63
+ cmd << "--quiet" unless verbose
64
64
 
65
65
  run_install_command(cmd)
66
66
  end
@@ -69,7 +69,7 @@ module ShopifyCli
69
69
  deps = parse_dependencies
70
70
  errors = nil
71
71
 
72
- spinner_title = ctx.message('core.js_deps.installing', @system.package_manager)
72
+ spinner_title = ctx.message("core.js_deps.installing", @system.package_manager)
73
73
  success = CLI::UI::Spinner.spin(spinner_title, auto_debrief: false) do |spinner|
74
74
  _, errors, status = CLI::Kit::System.capture3(*cmd, env: @ctx.env, chdir: ctx.root)
75
75
  update_spinner_title_and_status(spinner, status, deps)
@@ -81,19 +81,19 @@ module ShopifyCli
81
81
 
82
82
  def update_spinner_title_and_status(spinner, status, deps)
83
83
  if status.success?
84
- spinner.update_title(ctx.message('core.js_deps.installed', deps.size))
84
+ spinner.update_title(ctx.message("core.js_deps.installed", deps.size))
85
85
  else
86
- spinner.update_title(ctx.message('core.js_deps.error.install_spinner_error', deps.size))
86
+ spinner.update_title(ctx.message("core.js_deps.error.install_spinner_error", deps.size))
87
87
  CLI::UI::Spinner::TASK_FAILED
88
88
  end
89
89
  end
90
90
 
91
91
  def parse_dependencies
92
- package_json = File.join(ctx.root, 'package.json')
92
+ package_json = File.join(ctx.root, "package.json")
93
93
  pkg = begin
94
94
  JSON.parse(File.read(package_json))
95
95
  rescue Errno::ENOENT, Errno::ENOTDIR
96
- ctx.abort(ctx.message('core.js_deps.error.missing_package', package_json))
96
+ ctx.abort(ctx.message("core.js_deps.error.missing_package", package_json))
97
97
  end
98
98
 
99
99
  %w(dependencies devDependencies).map do |key|
@@ -101,7 +101,7 @@ module ShopifyCli
101
101
  end.flatten
102
102
  rescue JSON::ParserError
103
103
  ctx.puts(
104
- ctx.message('core.js_deps.error.invalid_package', File.read(File.join(path, 'package.json'))),
104
+ ctx.message("core.js_deps.error.invalid_package", File.read(File.join(path, "package.json"))),
105
105
  error: true
106
106
  )
107
107
  raise ShopifyCli::AbortSilent
@@ -1,4 +1,4 @@
1
- require 'shopify_cli'
1
+ require "shopify_cli"
2
2
 
3
3
  module ShopifyCli
4
4
  ##
@@ -7,8 +7,8 @@ module ShopifyCli
7
7
  class JsSystem
8
8
  include SmartProperties
9
9
 
10
- YARN_CORE_COMMAND = 'yarn'
11
- NPM_CORE_COMMAND = 'npm'
10
+ YARN_CORE_COMMAND = "yarn"
11
+ NPM_CORE_COMMAND = "npm"
12
12
 
13
13
  class << self
14
14
  ##
@@ -64,8 +64,8 @@ module ShopifyCli
64
64
  #
65
65
  def yarn?
66
66
  @has_yarn ||= begin
67
- cmd_path = @ctx.which('yarn')
68
- File.exist?(File.join(ctx.root, 'yarn.lock')) && !cmd_path.nil?
67
+ cmd_path = @ctx.which("yarn")
68
+ File.exist?(File.join(ctx.root, "yarn.lock")) && !cmd_path.nil?
69
69
  end
70
70
  end
71
71
 
@@ -0,0 +1,55 @@
1
+ require "delegate"
2
+
3
+ module ShopifyCli
4
+ ##
5
+ # `LazyDelegator` defers initialization of its underlying delegatee until the
6
+ # latter is accessed for the first time due to a method call that the
7
+ # delegator cannot handle itself:
8
+ #
9
+ # result = LazyDelegator.new do
10
+ # # carry out costly operation ...
11
+ # end
12
+ #
13
+ # result # referencing the object itself does not result in Proc evaluation
14
+ # result.to_h # however, calling a method on it will result in Proc evaluation
15
+ #
16
+ # LazyDelegator lends itself to being subclassed in scenarios where some
17
+ # facts are known and others are costly to compute:
18
+ #
19
+ # class LazySpecificationHandler < ShopifyCli::LazyDelegator
20
+ # attr_reader :identifier
21
+ #
22
+ # def initialize(identifier, &initializer)
23
+ # super(&initializer)
24
+ # @identifier = identifier
25
+ # end
26
+ # end
27
+ #
28
+ # handler = LazySpecificationHandler.new(:product_subscription) do
29
+ # # fetch specification from the Partners Dashboard API ...
30
+ # end
31
+ #
32
+ # # Accessing identifier will not result in Proc evaluation as it is
33
+ # # available as an attribute of the delegator itself
34
+ # handler.identifier # => :product_subscription
35
+ #
36
+ # # Accessing the specification will result in evaluation of the Proc
37
+ # # and in our example in a subsequent network call
38
+ # handler.specification # => <Extension::Models::Specifcation:...>
39
+ #
40
+ class LazyDelegator < SimpleDelegator
41
+ def initialize(&delegatee_initializer)
42
+ super([false, delegatee_initializer])
43
+ end
44
+
45
+ protected
46
+
47
+ def __getobj__(*)
48
+ initialized, value_or_initializer = super
49
+ return value_or_initializer if initialized
50
+ value_or_initializer.call.tap do |value|
51
+ __setobj__([true, value])
52
+ end
53
+ end
54
+ end
55
+ end
@@ -3,6 +3,16 @@
3
3
  module ShopifyCli
4
4
  module Messages
5
5
  MESSAGES = {
6
+ apps: {
7
+ create: {
8
+ info: {
9
+ created: "{{v}} {{green:%s}} was created in the organization's Partner Dashboard {{underline:%s}}",
10
+ serve: "{{*}} Change directories to your new project folder {{green:%s}} and run {{command:%s serve}} " \
11
+ "to start a local server",
12
+ install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
13
+ },
14
+ },
15
+ },
6
16
  core: {
7
17
  connect: {
8
18
  help: <<~HELP,
@@ -10,11 +20,7 @@ module ShopifyCli
10
20
  Usage: {{command:%s connect}}
11
21
  HELP
12
22
 
13
- production_warning: <<~MESSAGE,
14
- {{yellow:! Warning: if you have connected to an {{bold:app in production}}, running {{command:serve}} may update the app URL and cause an outage.
15
- MESSAGE
16
23
  already_connected_warning: "{{yellow:! This app appears to be already connected}}",
17
- connected: "{{v}} Project now connected to {{green:%s}}",
18
24
  project_type_select: "What type of project would you like to connect?",
19
25
  cli_yml_saved: ".shopify-cli.yml saved to project root",
20
26
  },
@@ -113,7 +119,7 @@ module ShopifyCli
113
119
  missing_package: "expected to have a file at: %s",
114
120
  invalid_package: "{{info:%s}} was not valid JSON. Fix this then try again",
115
121
  install_spinner_error: "Unable to install all %d dependencies",
116
- install_error: 'An error occurred while installing dependencies',
122
+ install_error: "An error occurred while installing dependencies",
117
123
  },
118
124
 
119
125
  installing: "Installing dependencies with %s...",
@@ -176,7 +182,9 @@ module ShopifyCli
176
182
 
177
183
  api: {
178
184
  error: {
179
- internal_server_error: '{{red:{{x}} An unexpected error occurred on Shopify.}}',
185
+ internal_server_error: "{{red:{{x}} An unexpected error occurred on Shopify.}}",
186
+ internal_server_error_debug: "\n{{red:Response details:}}\n%s\n\n",
187
+ invalid_url: "Invalid URL: %s",
180
188
  },
181
189
  },
182
190
 
@@ -251,6 +259,8 @@ module ShopifyCli
251
259
  },
252
260
  environment_header: "{{bold:Environment}}",
253
261
  env: "%-17s = %s",
262
+ identity_header: "{{bold:Identity}}",
263
+ identity_is_shopifolk: "{{v}} Checked user settings: you’re Shopify staff!",
254
264
  },
255
265
 
256
266
  tasks: {
@@ -262,7 +272,7 @@ module ShopifyCli
262
272
  MESSAGE
263
273
  development_store_select: "Which development store would you like to use?",
264
274
  app_select: "To which app does this project belong?",
265
- no_apps: 'You have no apps to connect to, creating a new app.',
275
+ no_apps: "You have no apps to connect to, creating a new app.",
266
276
  app_name: "App name",
267
277
  app_type: {
268
278
  select: "What type of app are you building?",
@@ -297,6 +307,8 @@ module ShopifyCli
297
307
  organization_not_found: "Cannot find a partner organization with that ID",
298
308
  partners_notice: "Please visit https://partners.shopify.com/ to create a partners account",
299
309
  },
310
+ first_party: "Are you working on a 1P (1st Party) app?",
311
+ identified_as_shopify: "We've identified you as a {{green:Shopify}} employee.",
300
312
  organization: "Partner organization {{green:%s (%s)}}",
301
313
  organization_select: "Select partner organization",
302
314
  },
@@ -308,6 +320,8 @@ module ShopifyCli
308
320
  url_fetch_failure: "Unable to fetch external url",
309
321
  prereq_command_required: "%1$s is required for installing ngrok. Please install %1$s using the appropriate"\
310
322
  " package manager for your system.",
323
+ ngrok: "Something went wrong with ngrok installation,"\
324
+ "please make sure %s exists within %s before trying again",
311
325
  },
312
326
 
313
327
  not_running: "{{green:x}} ngrok tunnel not running",
@@ -342,15 +356,15 @@ module ShopifyCli
342
356
  {{x}} This version of Shopify App CLI is no longer supported. You’ll need to migrate to the new CLI version to continue.
343
357
 
344
358
  Please visit this page for complete instructions:
345
- {{underline:https://shopify.github.io/shopify-app-cli/migrate/}}
359
+ {{underline:https://shopify.dev/tools/cli/troubleshooting#migrate-from-a-legacy-version}}
346
360
 
347
361
  MESSAGE
348
362
 
349
363
  new_version: <<~MESSAGE,
350
- {{*}} {{yellow:A new version of the Shopify App CLI is available! You have version %s and the latest version is %s.
364
+ {{*}} {{yellow:A new version of Shopify App CLI is available! You have version %s and the latest version is %s.
351
365
 
352
366
  To upgrade, follow the instructions for the package manager you’re using:
353
- {{underline:https://shopify.github.io/shopify-app-cli/getting-started/upgrade/}}}}
367
+ {{underline:https://shopify.dev/tools/cli/troubleshooting#upgrade-shopify-app-cli}}}}
354
368
 
355
369
  MESSAGE
356
370
  },
@@ -0,0 +1,104 @@
1
+ module ShopifyCli
2
+ ##
3
+ # The `MethodObject` mixin can be included in any class that implements `call`
4
+ # to ensure that
5
+ #
6
+ # * `call` will always return a `ShopifyCli::Result` by prepending a module
7
+ # that takes care of the result wrapping and
8
+ # * a `to_proc` method that allows instances of this class to be passed as a
9
+ # block.
10
+ #
11
+ # For convenience, this mixin also adds the corresponding class methods:
12
+ # `call` and `to_proc`. Method and result objects pair nicely as they greatly
13
+ # simplify the creation of complex processing chains:
14
+ #
15
+ # class Serialize
16
+ # include MethodObject
17
+ #
18
+ # def call(attrs)
19
+ # attrs.to_json
20
+ # end
21
+ # end
22
+ #
23
+ # class Deserialize
24
+ # include MethodObject
25
+ #
26
+ # def call(json)
27
+ # JSON.parse(json)
28
+ # end
29
+ # end
30
+ #
31
+ # Serialize
32
+ # .call(firstname: "John", lastname: "Doe")
33
+ # .then(&Deserialize)
34
+ # .map { |attrs| OpenStruct.new(attrs) }
35
+ # .unwrap(nil)
36
+ #
37
+ # While this example is contrived, it still illustrates some key advantages of
38
+ # this programming paradigm:
39
+ #
40
+ # * chaining operations is as simple as repeatedly calling `then` or `map`,
41
+ # * method objects don't have to be manually instantiated but can be
42
+ # constructed using the `&` operator,
43
+ # * error handling is deferred until the result is unwrapped.
44
+ #
45
+ # Please see the section for `ShopifyCli::Result`,
46
+ # `ShopifyCli::Result::Success`, and `ShopifyCli::Result::Failure` for more
47
+ # information on the API of result objects.
48
+ #
49
+ module MethodObject
50
+ module AutoCreateResultObject
51
+ ##
52
+ # invokes the original `call` implementation and wraps its return value
53
+ # into a result object.
54
+ #
55
+ def call(*args, **kwargs)
56
+ Result.wrap { super(*args, **kwargs) }.call
57
+ end
58
+ end
59
+
60
+ module ClassMethods
61
+ ##
62
+ # creates a new instance and invokes `call`. Any positional argument
63
+ # is forward to `call`. Keyword arguments are either forwarded to the
64
+ # inializer or to `call`. If the keyword argument matches the name of
65
+ # property, it is forwarded to the initializer, otherwise to call.
66
+ #
67
+ def call(*args, **kwargs)
68
+ properties.keys.yield_self do |properties|
69
+ new(**kwargs.slice(*properties))
70
+ .call(*args, **kwargs.slice(*(kwargs.keys - properties)))
71
+ end
72
+ end
73
+
74
+ ##
75
+ # returns a proc that invokes `call` with all arguments it receives when
76
+ # called itself.
77
+ #
78
+ def to_proc
79
+ method(:call).to_proc
80
+ end
81
+ end
82
+
83
+ ##
84
+ # is invoked when this mixin is included into a class. This results in
85
+ #
86
+ # * including `SmartProperties`,
87
+ # * prepending the result wrapping mechanism, and
88
+ # * adding the class methods `.call` and `.to_proc`.
89
+ #
90
+ def self.included(method_object_implementation)
91
+ method_object_implementation.prepend(AutoCreateResultObject)
92
+ method_object_implementation.include(SmartProperties)
93
+ method_object_implementation.extend(ClassMethods)
94
+ end
95
+
96
+ ##
97
+ # returns a proc that invokes `call` with all arguments it receives when
98
+ # called itself.
99
+ #
100
+ def to_proc
101
+ method(:call).to_proc
102
+ end
103
+ end
104
+ end