shopify-cli 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/shopify.yml +0 -2
  3. data/.rubocop.yml +14 -14
  4. data/.rubocop_todo.yml +3 -3
  5. data/CHANGELOG.md +5 -0
  6. data/Dockerfile +1 -1
  7. data/Gemfile.lock +1 -1
  8. data/RELEASING.md +1 -1
  9. data/Rakefile +18 -18
  10. data/bin/shopify +3 -3
  11. data/lib/project_types/extension/cli.rb +3 -3
  12. data/lib/project_types/extension/commands/build.rb +2 -2
  13. data/lib/project_types/extension/commands/check.rb +2 -2
  14. data/lib/project_types/extension/commands/connect.rb +1 -1
  15. data/lib/project_types/extension/commands/create.rb +41 -23
  16. data/lib/project_types/extension/commands/extension_command.rb +1 -1
  17. data/lib/project_types/extension/commands/info.rb +1 -1
  18. data/lib/project_types/extension/commands/push.rb +1 -1
  19. data/lib/project_types/extension/commands/register.rb +2 -2
  20. data/lib/project_types/extension/commands/serve.rb +5 -5
  21. data/lib/project_types/extension/commands/tunnel.rb +6 -6
  22. data/lib/project_types/extension/extension_project.rb +4 -4
  23. data/lib/project_types/extension/features/argo.rb +2 -2
  24. data/lib/project_types/extension/features/argo_config.rb +5 -5
  25. data/lib/project_types/extension/features/argo_serve.rb +20 -6
  26. data/lib/project_types/extension/features/argo_setup.rb +1 -1
  27. data/lib/project_types/extension/features/argo_setup_step.rb +1 -1
  28. data/lib/project_types/extension/features/argo_setup_steps.rb +2 -2
  29. data/lib/project_types/extension/forms/connect.rb +2 -2
  30. data/lib/project_types/extension/forms/create.rb +2 -2
  31. data/lib/project_types/extension/forms/questions/ask_app.rb +2 -2
  32. data/lib/project_types/extension/forms/questions/ask_name.rb +1 -1
  33. data/lib/project_types/extension/forms/questions/ask_registration.rb +2 -2
  34. data/lib/project_types/extension/forms/questions/ask_template.rb +2 -2
  35. data/lib/project_types/extension/forms/questions/ask_type.rb +2 -2
  36. data/lib/project_types/extension/messages/message_loading.rb +2 -2
  37. data/lib/project_types/extension/models/development_server.rb +45 -6
  38. data/lib/project_types/extension/models/development_server_requirements.rb +22 -3
  39. data/lib/project_types/extension/models/lazy_specification_handler.rb +1 -1
  40. data/lib/project_types/extension/models/specification.rb +1 -1
  41. data/lib/project_types/extension/models/specification_handlers/default.rb +10 -2
  42. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +1 -1
  43. data/lib/project_types/extension/models/specifications.rb +4 -4
  44. data/lib/project_types/extension/tasks/choose_next_available_port.rb +1 -1
  45. data/lib/project_types/extension/tasks/configure_features.rb +1 -1
  46. data/lib/project_types/extension/tasks/configure_options.rb +1 -1
  47. data/lib/project_types/extension/tasks/converters/product_converter.rb +1 -1
  48. data/lib/project_types/extension/tasks/create_extension.rb +2 -2
  49. data/lib/project_types/extension/tasks/fetch_specifications.rb +2 -2
  50. data/lib/project_types/extension/tasks/find_npm_packages.rb +3 -3
  51. data/lib/project_types/extension/tasks/get_app.rb +2 -2
  52. data/lib/project_types/extension/tasks/get_apps.rb +2 -2
  53. data/lib/project_types/extension/tasks/get_extensions.rb +2 -2
  54. data/lib/project_types/extension/tasks/get_product.rb +2 -2
  55. data/lib/project_types/extension/tasks/run_extension_command.rb +10 -3
  56. data/lib/project_types/extension/tasks/update_draft.rb +2 -2
  57. data/lib/project_types/node/cli.rb +3 -3
  58. data/lib/project_types/node/commands/connect.rb +4 -4
  59. data/lib/project_types/node/commands/create.rb +10 -10
  60. data/lib/project_types/node/commands/deploy/heroku.rb +4 -4
  61. data/lib/project_types/node/commands/deploy.rb +3 -3
  62. data/lib/project_types/node/commands/generate.rb +2 -2
  63. data/lib/project_types/node/commands/open.rb +3 -3
  64. data/lib/project_types/node/commands/serve.rb +7 -7
  65. data/lib/project_types/node/commands/tunnel.rb +6 -6
  66. data/lib/project_types/node/forms/create.rb +3 -3
  67. data/lib/project_types/php/cli.rb +27 -0
  68. data/lib/project_types/php/commands/connect.rb +19 -0
  69. data/lib/project_types/php/commands/create.rb +143 -0
  70. data/lib/project_types/php/commands/deploy/heroku.rb +129 -0
  71. data/lib/project_types/php/commands/deploy.rb +32 -0
  72. data/lib/project_types/php/commands/open.rb +16 -0
  73. data/lib/project_types/php/commands/serve.rb +51 -0
  74. data/lib/project_types/php/commands/tunnel.rb +37 -0
  75. data/lib/project_types/php/forms/create.rb +45 -0
  76. data/lib/project_types/php/messages/messages.rb +191 -0
  77. data/lib/project_types/rails/cli.rb +3 -3
  78. data/lib/project_types/rails/commands/connect.rb +4 -4
  79. data/lib/project_types/rails/commands/create.rb +12 -12
  80. data/lib/project_types/rails/commands/deploy/heroku.rb +4 -4
  81. data/lib/project_types/rails/commands/deploy.rb +3 -3
  82. data/lib/project_types/rails/commands/generate/webhook.rb +3 -3
  83. data/lib/project_types/rails/commands/generate.rb +3 -3
  84. data/lib/project_types/rails/commands/open.rb +3 -3
  85. data/lib/project_types/rails/commands/serve.rb +8 -8
  86. data/lib/project_types/rails/commands/tunnel.rb +6 -6
  87. data/lib/project_types/rails/forms/create.rb +3 -3
  88. data/lib/project_types/rails/gem.rb +1 -1
  89. data/lib/project_types/rails/ruby.rb +1 -1
  90. data/lib/project_types/script/cli.rb +11 -4
  91. data/lib/project_types/script/commands/create.rb +2 -2
  92. data/lib/project_types/script/commands/push.rb +2 -2
  93. data/lib/project_types/script/forms/create.rb +1 -1
  94. data/lib/project_types/script/layers/application/extension_points.rb +2 -2
  95. data/lib/project_types/script/layers/application/push_script.rb +4 -1
  96. data/lib/project_types/script/layers/domain/script_project.rb +2 -2
  97. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +55 -0
  98. data/lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb +35 -0
  99. data/lib/project_types/script/layers/infrastructure/command_runner.rb +1 -1
  100. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +1 -1
  101. data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +1 -1
  102. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +1 -1
  103. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +5 -5
  104. data/lib/project_types/script/layers/infrastructure/script_service.rb +4 -8
  105. data/lib/project_types/script/layers/infrastructure/service_locator.rb +20 -0
  106. data/lib/project_types/script/tasks/ensure_env.rb +6 -6
  107. data/lib/project_types/script/ui/error_handler.rb +75 -75
  108. data/lib/project_types/script/ui/printing_spinner.rb +1 -1
  109. data/lib/project_types/theme/cli.rb +3 -3
  110. data/lib/project_types/theme/commands/check.rb +3 -3
  111. data/lib/project_types/theme/commands/delete.rb +7 -7
  112. data/lib/project_types/theme/commands/init.rb +3 -3
  113. data/lib/project_types/theme/commands/language_server.rb +2 -2
  114. data/lib/project_types/theme/commands/package.rb +2 -2
  115. data/lib/project_types/theme/commands/publish.rb +5 -5
  116. data/lib/project_types/theme/commands/pull.rb +9 -9
  117. data/lib/project_types/theme/commands/push.rb +12 -12
  118. data/lib/project_types/theme/commands/serve.rb +4 -4
  119. data/lib/project_types/theme/forms/confirm_store.rb +1 -1
  120. data/lib/project_types/theme/forms/select.rb +2 -2
  121. data/lib/{shopify-cli → shopify_cli}/admin_api/populate_resource_command.rb +3 -3
  122. data/lib/{shopify-cli → shopify_cli}/admin_api/schema.rb +4 -4
  123. data/lib/{shopify-cli → shopify_cli}/admin_api.rb +27 -27
  124. data/lib/{shopify-cli → shopify_cli}/api.rb +8 -8
  125. data/lib/{shopify-cli → shopify_cli}/command.rb +3 -3
  126. data/lib/{shopify-cli → shopify_cli}/commands/config.rb +14 -14
  127. data/lib/{shopify-cli → shopify_cli}/commands/help.rb +4 -4
  128. data/lib/{shopify-cli → shopify_cli}/commands/login.rb +7 -7
  129. data/lib/shopify_cli/commands/logout.rb +39 -0
  130. data/lib/{shopify-cli → shopify_cli}/commands/populate/customer.rb +4 -4
  131. data/lib/{shopify-cli → shopify_cli}/commands/populate/draft_order.rb +4 -4
  132. data/lib/{shopify-cli → shopify_cli}/commands/populate/product.rb +4 -4
  133. data/lib/shopify_cli/commands/populate.rb +23 -0
  134. data/lib/shopify_cli/commands/store.rb +15 -0
  135. data/lib/{shopify-cli → shopify_cli}/commands/switch.rb +5 -5
  136. data/lib/{shopify-cli → shopify_cli}/commands/system.rb +10 -10
  137. data/lib/shopify_cli/commands/version.rb +15 -0
  138. data/lib/{shopify-cli → shopify_cli}/commands/whoami.rb +7 -7
  139. data/lib/shopify_cli/commands.rb +34 -0
  140. data/lib/{shopify-cli → shopify_cli}/connect.rb +3 -3
  141. data/lib/{shopify-cli → shopify_cli}/constants.rb +1 -1
  142. data/lib/{shopify-cli → shopify_cli}/context.rb +6 -6
  143. data/lib/{shopify-cli → shopify_cli}/core/entry_point.rb +7 -7
  144. data/lib/{shopify-cli → shopify_cli}/core/executor.rb +3 -3
  145. data/lib/{shopify-cli → shopify_cli}/core/finalize.rb +1 -1
  146. data/lib/{shopify-cli → shopify_cli}/core/help_resolver.rb +2 -2
  147. data/lib/{shopify-cli → shopify_cli}/core/monorail.rb +8 -8
  148. data/lib/shopify_cli/core.rb +8 -0
  149. data/lib/{shopify-cli → shopify_cli}/db.rb +8 -8
  150. data/lib/{shopify-cli → shopify_cli}/environment.rb +1 -1
  151. data/lib/{shopify-cli → shopify_cli}/feature.rb +8 -8
  152. data/lib/{shopify-cli → shopify_cli}/form.rb +2 -2
  153. data/lib/{shopify-cli → shopify_cli}/git.rb +6 -6
  154. data/lib/{shopify-cli → shopify_cli}/helpers/haikunator.rb +1 -1
  155. data/lib/shopify_cli/helpers.rb +5 -0
  156. data/lib/{shopify-cli → shopify_cli}/heroku.rb +38 -13
  157. data/lib/{shopify-cli → shopify_cli}/http_request.rb +1 -1
  158. data/lib/{shopify-cli → shopify_cli}/identity_auth/servlet.rb +1 -1
  159. data/lib/{shopify-cli → shopify_cli}/identity_auth.rb +8 -8
  160. data/lib/{shopify-cli → shopify_cli}/js_deps.rb +7 -7
  161. data/lib/{shopify-cli → shopify_cli}/js_system.rb +10 -10
  162. data/lib/{shopify-cli → shopify_cli}/lazy_delegator.rb +2 -2
  163. data/lib/{shopify-cli → shopify_cli}/messages/messages.rb +17 -1
  164. data/lib/{shopify-cli → shopify_cli}/method_object.rb +4 -4
  165. data/lib/{shopify-cli → shopify_cli}/options.rb +1 -1
  166. data/lib/{shopify-cli → shopify_cli}/packager.rb +8 -8
  167. data/lib/{shopify-cli → shopify_cli}/partners_api/organizations.rb +1 -1
  168. data/lib/{shopify-cli → shopify_cli}/partners_api.rb +13 -13
  169. data/lib/shopify_cli/php_deps.rb +102 -0
  170. data/lib/{shopify-cli → shopify_cli}/process_supervision.rb +10 -8
  171. data/lib/{shopify-cli → shopify_cli}/project.rb +15 -15
  172. data/lib/{shopify-cli → shopify_cli}/project_commands.rb +3 -3
  173. data/lib/{shopify-cli → shopify_cli}/project_type.rb +5 -5
  174. data/lib/{shopify-cli → shopify_cli}/resolve_constant.rb +5 -5
  175. data/lib/{shopify-cli → shopify_cli}/resources/env_file.rb +1 -1
  176. data/lib/shopify_cli/resources.rb +5 -0
  177. data/lib/{shopify-cli → shopify_cli}/result.rb +11 -11
  178. data/lib/{shopify-cli → shopify_cli}/shopifolk.rb +6 -6
  179. data/lib/{shopify-cli → shopify_cli}/sub_command.rb +1 -1
  180. data/lib/{shopify-cli → shopify_cli}/task.rb +1 -1
  181. data/lib/{shopify-cli → shopify_cli}/tasks/confirm_store.rb +3 -3
  182. data/lib/{shopify-cli → shopify_cli}/tasks/create_api_client.rb +4 -4
  183. data/lib/shopify_cli/tasks/ensure_authenticated.rb +13 -0
  184. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_dev_store.rb +5 -5
  185. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_env.rb +3 -3
  186. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_loopback_url.rb +4 -4
  187. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_project_type.rb +3 -3
  188. data/lib/{shopify-cli → shopify_cli}/tasks/select_org_and_shop.rb +8 -8
  189. data/lib/{shopify-cli → shopify_cli}/tasks/update_dashboard_urls.rb +6 -6
  190. data/lib/{shopify-cli → shopify_cli}/tasks.rb +10 -10
  191. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/certificate_manager.rb +5 -5
  192. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/header_hash.rb +1 -1
  193. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/hot-reload.js +0 -0
  194. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/hot_reload.rb +1 -1
  195. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/local_assets.rb +1 -1
  196. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/proxy.rb +2 -2
  197. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/sse.rb +1 -1
  198. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/watcher.rb +1 -1
  199. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/web_server.rb +1 -1
  200. data/lib/{shopify-cli → shopify_cli}/theme/dev_server.rb +3 -3
  201. data/lib/{shopify-cli → shopify_cli}/theme/development_theme.rb +9 -9
  202. data/lib/{shopify-cli → shopify_cli}/theme/file.rb +1 -1
  203. data/lib/{shopify-cli → shopify_cli}/theme/ignore_filter.rb +1 -1
  204. data/lib/{shopify-cli → shopify_cli}/theme/mime_type.rb +1 -1
  205. data/lib/{shopify-cli → shopify_cli}/theme/syncer.rb +6 -6
  206. data/lib/{shopify-cli → shopify_cli}/theme/theme.rb +4 -4
  207. data/lib/{shopify-cli → shopify_cli}/transform_data_structure.rb +4 -4
  208. data/lib/{shopify-cli → shopify_cli}/tunnel.rb +14 -14
  209. data/lib/shopify_cli/version.rb +3 -0
  210. data/lib/shopify_cli.rb +50 -49
  211. data/shopify-cli.gemspec +2 -2
  212. metadata +104 -91
  213. data/lib/project_types/script/layers/infrastructure/api_clients.rb +0 -89
  214. data/lib/shopify-cli/commands/logout.rb +0 -39
  215. data/lib/shopify-cli/commands/populate.rb +0 -23
  216. data/lib/shopify-cli/commands/store.rb +0 -15
  217. data/lib/shopify-cli/commands/version.rb +0 -15
  218. data/lib/shopify-cli/commands.rb +0 -34
  219. data/lib/shopify-cli/core.rb +0 -8
  220. data/lib/shopify-cli/helpers.rb +0 -5
  221. data/lib/shopify-cli/resources.rb +0 -5
  222. data/lib/shopify-cli/tasks/ensure_authenticated.rb +0 -13
  223. data/lib/shopify-cli/version.rb +0 -3
@@ -1,7 +1,7 @@
1
1
  require "net/http"
2
2
  require "openssl"
3
3
 
4
- module ShopifyCli
4
+ module ShopifyCLI
5
5
  class HttpRequest
6
6
  class << self
7
7
  def post(uri, body, headers)
@@ -1,4 +1,4 @@
1
- module ShopifyCli
1
+ module ShopifyCLI
2
2
  class IdentityAuth
3
3
  class Servlet < WEBrick::HTTPServlet::AbstractServlet
4
4
  TEMPLATE = %{<!DOCTYPE html>
@@ -8,11 +8,11 @@ require "shopify_cli"
8
8
  require "uri"
9
9
  require "webrick"
10
10
 
11
- module ShopifyCli
11
+ module ShopifyCLI
12
12
  class IdentityAuth
13
13
  include SmartProperties
14
14
 
15
- autoload :Servlet, "shopify-cli/identity_auth/servlet"
15
+ autoload :Servlet, "shopify_cli/identity_auth/servlet"
16
16
 
17
17
  class Error < StandardError; end
18
18
  class Timeout < StandardError; end
@@ -49,7 +49,7 @@ module ShopifyCli
49
49
  ]
50
50
 
51
51
  property! :ctx
52
- property :store, default: -> { ShopifyCli::DB.new }
52
+ property :store, default: -> { ShopifyCLI::DB.new }
53
53
  property :state_token, accepts: String, default: SecureRandom.hex(30)
54
54
  property :code_verifier, accepts: String, default: SecureRandom.hex(30)
55
55
 
@@ -70,7 +70,7 @@ module ShopifyCli
70
70
 
71
71
  def reauthenticate
72
72
  return if refresh_exchange_tokens || refresh_access_tokens
73
- ctx.abort(ctx.message("core.identity_auth.error.reauthenticate", ShopifyCli::TOOL_NAME))
73
+ ctx.abort(ctx.message("core.identity_auth.error.reauthenticate", ShopifyCLI::TOOL_NAME))
74
74
  end
75
75
 
76
76
  def code_challenge
@@ -93,8 +93,8 @@ module ShopifyCli
93
93
  end
94
94
 
95
95
  def self.delete_tokens_and_keys
96
- ShopifyCli::DB.del(*IDENTITY_ACCESS_TOKENS)
97
- ShopifyCli::DB.del(*EXCHANGE_TOKENS)
96
+ ShopifyCLI::DB.del(*IDENTITY_ACCESS_TOKENS)
97
+ ShopifyCLI::DB.del(*EXCHANGE_TOKENS)
98
98
  end
99
99
 
100
100
  private
@@ -212,7 +212,7 @@ module ShopifyCli
212
212
  https = Net::HTTP.new(uri.host, uri.port)
213
213
  https.use_ssl = true
214
214
  request = Net::HTTP::Post.new(uri.path)
215
- request["User-Agent"] = "Shopify CLI #{::ShopifyCli::VERSION}"
215
+ request["User-Agent"] = "Shopify CLI #{::ShopifyCLI::VERSION}"
216
216
  request.body = URI.encode_www_form(params)
217
217
  res = https.request(request)
218
218
  unless res.is_a?(Net::HTTPSuccess)
@@ -256,7 +256,7 @@ module ShopifyCli
256
256
 
257
257
  def scopes(additional_scopes = [])
258
258
  (["openid"] + additional_scopes).tap do |result|
259
- result << "employee" if ShopifyCli::Shopifolk.acting_as_shopify_organization?
259
+ result << "employee" if ShopifyCLI::Shopifolk.acting_as_shopify_organization?
260
260
  end.join(" ")
261
261
  end
262
262
 
@@ -1,17 +1,17 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  ##
5
- # ShopifyCli::JsDeps ensures that all JavaScript dependencies are installed for projects.
5
+ # ShopifyCLI::JsDeps ensures that all JavaScript dependencies are installed for projects.
6
6
  #
7
7
  class JsDeps
8
8
  include SmartProperties
9
9
 
10
- property! :ctx, accepts: ShopifyCli::Context
10
+ property! :ctx, accepts: ShopifyCLI::Context
11
11
  property! :system, accepts: JsSystem, default: -> { JsSystem.new(ctx: ctx) }
12
12
 
13
13
  ##
14
- # Proxy to instance method ShopifyCli::JsDeps.new.install.
14
+ # Proxy to instance method ShopifyCLI::JsDeps.new.install.
15
15
  #
16
16
  # #### Parameters
17
17
  # - `ctx`: running context from your command
@@ -19,7 +19,7 @@ module ShopifyCli
19
19
  #
20
20
  # #### Example
21
21
  #
22
- # ShopifyCli::JsDeps.install(ctx)
22
+ # ShopifyCLI::JsDeps.install(ctx)
23
23
  #
24
24
  def self.install(ctx, verbose = false)
25
25
  new(ctx: ctx).install(verbose)
@@ -34,7 +34,7 @@ module ShopifyCli
34
34
  # #### Example
35
35
  #
36
36
  # # context is the running context for the command
37
- # ShopifyCli::JsDeps.new(context).install(true)
37
+ # ShopifyCLI::JsDeps.new(context).install(true)
38
38
  #
39
39
  def install(verbose = false)
40
40
  title = ctx.message("core.js_deps.installing", @system.package_manager)
@@ -104,7 +104,7 @@ module ShopifyCli
104
104
  ctx.message("core.js_deps.error.invalid_package", File.read(File.join(path, "package.json"))),
105
105
  error: true
106
106
  )
107
- raise ShopifyCli::AbortSilent
107
+ raise ShopifyCLI::AbortSilent
108
108
  end
109
109
  end
110
110
  end
@@ -1,8 +1,8 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  ##
5
- # ShopifyCli::JsSystem allows conditional system calls of npm or yarn commands.
5
+ # ShopifyCLI::JsSystem allows conditional system calls of npm or yarn commands.
6
6
  #
7
7
  class JsSystem
8
8
  include SmartProperties
@@ -12,21 +12,21 @@ module ShopifyCli
12
12
 
13
13
  class << self
14
14
  ##
15
- # Proxy to instance method `ShopifyCli::JsSystem.new.yarn?`
15
+ # Proxy to instance method `ShopifyCLI::JsSystem.new.yarn?`
16
16
  #
17
17
  # #### Parameters
18
18
  # - `ctx`: running context from your command
19
19
  #
20
20
  # #### Example
21
21
  #
22
- # ShopifyCli::JsSystem.yarn?(ctx)
22
+ # ShopifyCLI::JsSystem.yarn?(ctx)
23
23
  #
24
24
  def yarn?(ctx)
25
25
  JsSystem.new(ctx: ctx).yarn?
26
26
  end
27
27
 
28
28
  ##
29
- # Proxy to instance method `ShopifyCli::JsSystem.new.call`
29
+ # Proxy to instance method `ShopifyCLI::JsSystem.new.call`
30
30
  #
31
31
  # #### Parameters
32
32
  # - `ctx`: running context from your command
@@ -35,21 +35,21 @@ module ShopifyCli
35
35
  #
36
36
  # #### Example
37
37
  #
38
- # ShopifyCli::JsSystem.call(ctx, yarn: ['install', '--silent'], npm: ['install', '--no-audit'])
38
+ # ShopifyCLI::JsSystem.call(ctx, yarn: ['install', '--silent'], npm: ['install', '--no-audit'])
39
39
  #
40
40
  def call(ctx, yarn:, npm:, capture_response: false)
41
41
  JsSystem.new(ctx: ctx).call(yarn: yarn, npm: npm, capture_response: capture_response)
42
42
  end
43
43
  end
44
44
 
45
- property :ctx, accepts: ShopifyCli::Context
45
+ property :ctx, accepts: ShopifyCLI::Context
46
46
 
47
47
  ##
48
48
  # Returns the name of the JS package manager being used
49
49
  #
50
50
  # #### Example
51
51
  #
52
- # ShopifyCli::JsSystem.new(ctx: ctx).package_manager
52
+ # ShopifyCLI::JsSystem.new(ctx: ctx).package_manager
53
53
  #
54
54
  def package_manager
55
55
  yarn? ? YARN_CORE_COMMAND : NPM_CORE_COMMAND
@@ -60,7 +60,7 @@ module ShopifyCli
60
60
  #
61
61
  # #### Example
62
62
  #
63
- # ShopifyCli::JsSystem.new(ctx: ctx).yarn?
63
+ # ShopifyCLI::JsSystem.new(ctx: ctx).yarn?
64
64
  #
65
65
  def yarn?
66
66
  @has_yarn ||= begin
@@ -80,7 +80,7 @@ module ShopifyCli
80
80
  #
81
81
  # #### Example
82
82
  #
83
- # ShopifyCli::JsSystem.new(ctx: ctx).call(
83
+ # ShopifyCLI::JsSystem.new(ctx: ctx).call(
84
84
  # yarn: ['install', '--silent'],
85
85
  # npm: ['install', '--no-audit'],
86
86
  # capture_response: false
@@ -1,6 +1,6 @@
1
1
  require "delegate"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  ##
5
5
  # `LazyDelegator` defers initialization of its underlying delegatee until the
6
6
  # latter is accessed for the first time due to a method call that the
@@ -16,7 +16,7 @@ module ShopifyCli
16
16
  # LazyDelegator lends itself to being subclassed in scenarios where some
17
17
  # facts are known and others are costly to compute:
18
18
  #
19
- # class LazySpecificationHandler < ShopifyCli::LazyDelegator
19
+ # class LazySpecificationHandler < ShopifyCLI::LazyDelegator
20
20
  # attr_reader :identifier
21
21
  #
22
22
  # def initialize(identifier, &initializer)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  module Messages
5
5
  MESSAGES = {
6
6
  apps: {
@@ -92,6 +92,8 @@ module ShopifyCli
92
92
  download: "Heroku CLI could not be downloaded",
93
93
  install: "Could not install Heroku CLI",
94
94
  could_not_select_app: "Heroku app {{green:%s}} could not be selected",
95
+ set_config: "Failed to set config %s to %s in Heroku app",
96
+ add_buildpacks: "Failed to add buildpacks in Heroku app",
95
97
  },
96
98
  },
97
99
 
@@ -188,6 +190,20 @@ module ShopifyCli
188
190
  },
189
191
  },
190
192
 
193
+ php_deps: {
194
+ error: {
195
+ missing_package: "Expected to have a file at: %s",
196
+ invalid_package: "{{info:%s}} was not valid JSON. Fix this then try again",
197
+ install: "Failed to install %s packages",
198
+ install_spinner_error: "Unable to install all %d dependencies",
199
+ install_error: "An error occurred while installing dependencies",
200
+ },
201
+
202
+ installing: "Installing Composer dependencies…",
203
+ installed: "Dependencies installed",
204
+ installed_count: "%d dependencies installed",
205
+ },
206
+
191
207
  api: {
192
208
  error: {
193
209
  failed_auth: "Failed to authenticate with Shopify. Please try again later.",
@@ -1,9 +1,9 @@
1
- module ShopifyCli
1
+ module ShopifyCLI
2
2
  ##
3
3
  # The `MethodObject` mixin can be included in any class that implements `call`
4
4
  # to ensure that
5
5
  #
6
- # * `call` will always return a `ShopifyCli::Result` by prepending a module
6
+ # * `call` will always return a `ShopifyCLI::Result` by prepending a module
7
7
  # that takes care of the result wrapping and
8
8
  # * a `to_proc` method that allows instances of this class to be passed as a
9
9
  # block.
@@ -42,8 +42,8 @@ module ShopifyCli
42
42
  # constructed using the `&` operator,
43
43
  # * error handling is deferred until the result is unwrapped.
44
44
  #
45
- # Please see the section for `ShopifyCli::Result`,
46
- # `ShopifyCli::Result::Success`, and `ShopifyCli::Result::Failure` for more
45
+ # Please see the section for `ShopifyCLI::Result`,
46
+ # `ShopifyCLI::Result::Success`, and `ShopifyCLI::Result::Failure` for more
47
47
  # information on the API of result objects.
48
48
  #
49
49
  module MethodObject
@@ -2,7 +2,7 @@
2
2
  require "shopify_cli"
3
3
  require "optparse"
4
4
 
5
- module ShopifyCli
5
+ module ShopifyCLI
6
6
  class Options
7
7
  include SmartProperties
8
8
 
@@ -1,7 +1,7 @@
1
- module ShopifyCli
1
+ module ShopifyCLI
2
2
  class Packager
3
- PACKAGING_DIR = File.join(ShopifyCli::ROOT, "packaging")
4
- BUILDS_DIR = File.join(PACKAGING_DIR, "builds", ShopifyCli::VERSION)
3
+ PACKAGING_DIR = File.join(ShopifyCLI::ROOT, "packaging")
4
+ BUILDS_DIR = File.join(PACKAGING_DIR, "builds", ShopifyCLI::VERSION)
5
5
 
6
6
  def initialize
7
7
  FileUtils.mkdir_p(BUILDS_DIR)
@@ -24,7 +24,7 @@ module ShopifyCli
24
24
  file_path = File.join(debian_dir, file)
25
25
 
26
26
  file_contents = File.read(File.join(root_dir, "#{file}.base"))
27
- file_contents = file_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCli::VERSION)
27
+ file_contents = file_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCLI::VERSION)
28
28
  File.open(file_path, "w", 0775) { |f| f.write(file_contents) }
29
29
  end
30
30
 
@@ -33,7 +33,7 @@ module ShopifyCli
33
33
  raise "Failed to build package" unless system("dpkg-deb", "-b", "shopify-cli")
34
34
 
35
35
  output_path = File.join(root_dir, "shopify-cli.deb")
36
- final_path = File.join(BUILDS_DIR, "shopify-cli-#{ShopifyCli::VERSION}.deb")
36
+ final_path = File.join(BUILDS_DIR, "shopify-cli-#{ShopifyCLI::VERSION}.deb")
37
37
 
38
38
  puts "Moving generated package: \n From: #{output_path}\n To: #{final_path}\n\n"
39
39
  FileUtils.mv(output_path, final_path)
@@ -53,7 +53,7 @@ module ShopifyCli
53
53
  File.delete(spec_path) if File.exist?(spec_path)
54
54
 
55
55
  spec_contents = File.read(File.join(root_dir, "shopify-cli.spec.base"))
56
- spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCli::VERSION)
56
+ spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCLI::VERSION)
57
57
  File.write(spec_path, spec_contents)
58
58
 
59
59
  puts "Building package…"
@@ -76,12 +76,12 @@ module ShopifyCli
76
76
  File.delete(build_path) if File.exist?(build_path)
77
77
 
78
78
  spec_contents = File.read(File.join(root_dir, "shopify-cli.base.rb"))
79
- spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCli::VERSION)
79
+ spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCLI::VERSION)
80
80
 
81
81
  puts "Grabbing sha256 checksum from Rubygems.org"
82
82
  require "digest/sha2"
83
83
  require "open-uri"
84
- gem_checksum = open("https://rubygems.org/downloads/shopify-cli-#{ShopifyCli::VERSION}.gem") do |io|
84
+ gem_checksum = open("https://rubygems.org/downloads/shopify-cli-#{ShopifyCLI::VERSION}.gem") do |io|
85
85
  Digest::SHA256.new.hexdigest(io.read)
86
86
  end
87
87
 
@@ -1,4 +1,4 @@
1
- module ShopifyCli
1
+ module ShopifyCLI
2
2
  class PartnersAPI
3
3
  class Organizations
4
4
  class << self
@@ -1,12 +1,12 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  ##
5
- # ShopifyCli::PartnersAPI provides easy access to the partners dashboard CLI
5
+ # ShopifyCLI::PartnersAPI provides easy access to the partners dashboard CLI
6
6
  # schema.
7
7
  #
8
8
  class PartnersAPI < API
9
- autoload :Organizations, "shopify-cli/partners_api/organizations"
9
+ autoload :Organizations, "shopify_cli/partners_api/organizations"
10
10
 
11
11
  class << self
12
12
  ##
@@ -21,10 +21,10 @@ module ShopifyCli
21
21
  #
22
22
  # #### Raises
23
23
  #
24
- # * http 404 will raise a ShopifyCli::API::APIRequestNotFoundError
25
- # * http 400..499 will raise a ShopifyCli::API::APIRequestClientError
26
- # * http 500..599 will raise a ShopifyCli::API::APIRequestServerError
27
- # * All other codes will raise ShopifyCli::API::APIRequestUnexpectedError
24
+ # * http 404 will raise a ShopifyCLI::API::APIRequestNotFoundError
25
+ # * http 400..499 will raise a ShopifyCLI::API::APIRequestClientError
26
+ # * http 500..599 will raise a ShopifyCLI::API::APIRequestServerError
27
+ # * All other codes will raise ShopifyCLI::API::APIRequestUnexpectedError
28
28
  #
29
29
  # #### Returns
30
30
  #
@@ -32,13 +32,13 @@ module ShopifyCli
32
32
  #
33
33
  # #### Example
34
34
  #
35
- # ShopifyCli::PartnersAPI.query(@ctx, 'all_organizations')
35
+ # ShopifyCLI::PartnersAPI.query(@ctx, 'all_organizations')
36
36
  #
37
37
  def query(ctx, query_name, **variables)
38
38
  CLI::Kit::Util.begin do
39
39
  api_client(ctx).query(query_name, variables: variables)
40
40
  end.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
41
- ShopifyCli::IdentityAuth.new(ctx: ctx).reauthenticate
41
+ ShopifyCLI::IdentityAuth.new(ctx: ctx).reauthenticate
42
42
  end
43
43
  rescue API::APIRequestUnauthorizedError => e
44
44
  if (request_info = auth_failure_info(ctx, e))
@@ -46,11 +46,11 @@ module ShopifyCli
46
46
  end
47
47
  ctx.abort(ctx.message("core.api.error.failed_auth"))
48
48
  rescue API::APIRequestNotFoundError
49
- ctx.puts(ctx.message("core.partners_api.error.account_not_found", ShopifyCli::TOOL_NAME))
49
+ ctx.puts(ctx.message("core.partners_api.error.account_not_found", ShopifyCLI::TOOL_NAME))
50
50
  end
51
51
 
52
52
  def partners_url_for(organization_id, api_client_id)
53
- if ShopifyCli::Shopifolk.acting_as_shopify_organization?
53
+ if ShopifyCLI::Shopifolk.acting_as_shopify_organization?
54
54
  organization_id = "internal"
55
55
  end
56
56
  "https://#{Environment.partners_domain}/#{organization_id}/apps/#{api_client_id}"
@@ -67,9 +67,9 @@ module ShopifyCli
67
67
  end
68
68
 
69
69
  def access_token(ctx)
70
- ShopifyCli::DB.get(:partners_exchange_token) do
70
+ ShopifyCLI::DB.get(:partners_exchange_token) do
71
71
  IdentityAuth.new(ctx: ctx).authenticate
72
- ShopifyCli::DB.get(:partners_exchange_token)
72
+ ShopifyCLI::DB.get(:partners_exchange_token)
73
73
  end
74
74
  end
75
75
 
@@ -0,0 +1,102 @@
1
+ require "shopify_cli"
2
+
3
+ module ShopifyCLI
4
+ ##
5
+ # ShopifyCLI::PHPDeps ensures that all PHP dependencies are installed for projects.
6
+ #
7
+ class PHPDeps
8
+ include SmartProperties
9
+
10
+ property! :ctx, accepts: ShopifyCLI::Context
11
+
12
+ ##
13
+ # Proxy to instance method ShopifyCLI::PHPDeps.new.install.
14
+ #
15
+ # #### Parameters
16
+ # - `ctx`: running context from your command
17
+ # - `verbose`: whether to run the installation tools in verbose mode
18
+ #
19
+ # #### Example
20
+ #
21
+ # ShopifyCLI::PHPDeps.install(ctx)
22
+ #
23
+ def self.install(ctx, verbose = false)
24
+ new(ctx: ctx).install(verbose)
25
+ end
26
+
27
+ ##
28
+ # Installs all of a project's PHP dependencies using Composer.
29
+ #
30
+ # #### Parameters
31
+ # - `verbose`: whether to run the installation tools in verbose mode
32
+ #
33
+ # #### Example
34
+ #
35
+ # # context is the running context for the command
36
+ # ShopifyCLI::PHPDeps.new(context).install(true)
37
+ #
38
+ def install(verbose = false)
39
+ title = ctx.message("core.php_deps.installing")
40
+ success = ctx.message("core.php_deps.installed")
41
+ failure = ctx.message("core.php_deps.error.install_error")
42
+
43
+ CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do
44
+ composer(verbose)
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def composer(verbose = false)
51
+ cmd = %w(composer install)
52
+ cmd << "--quiet" unless verbose
53
+
54
+ run_install_command(cmd)
55
+ end
56
+
57
+ def run_install_command(cmd)
58
+ deps = parse_dependencies
59
+ errors = nil
60
+
61
+ spinner_title = ctx.message("core.php_deps.installing")
62
+ success = CLI::UI::Spinner.spin(spinner_title, auto_debrief: false) do |spinner|
63
+ _out, errors, status = CLI::Kit::System.capture3(*cmd, env: @ctx.env, chdir: ctx.root)
64
+ update_spinner_title_and_status(spinner, status, deps)
65
+ end
66
+
67
+ errors.lines.each { |e| ctx.puts e } unless success || errors.nil?
68
+
69
+ ctx.abort(ctx.message("core.php_deps.error.install", "Composer")) unless success
70
+ success
71
+ end
72
+
73
+ def update_spinner_title_and_status(spinner, status, deps)
74
+ if status.success?
75
+ spinner.update_title(ctx.message("core.php_deps.installed_count", deps.size))
76
+ else
77
+ spinner.update_title(ctx.message("core.php_deps.error.install_spinner_error", deps.size))
78
+ CLI::UI::Spinner::TASK_FAILED
79
+ end
80
+ end
81
+
82
+ def parse_dependencies
83
+ composer_json = File.join(ctx.root, "composer.json")
84
+ pkg =
85
+ begin
86
+ JSON.parse(File.read(composer_json))
87
+ rescue Errno::ENOENT, Errno::ENOTDIR
88
+ ctx.abort(ctx.message("core.php_deps.error.missing_package", composer_json))
89
+ end
90
+
91
+ %w(require require-dev).map do |key|
92
+ pkg.fetch(key, []).keys
93
+ end.flatten
94
+ rescue JSON::ParserError
95
+ ctx.puts(
96
+ ctx.message("core.php_deps.error.invalid_package", File.read(File.join(path, "composer.json"))),
97
+ error: true
98
+ )
99
+ raise ShopifyCLI::AbortSilent
100
+ end
101
+ end
102
+ end
@@ -1,6 +1,6 @@
1
1
  require "fileutils"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  ##
5
5
  # ProcessSupervision wraps a running process spawned by `exec` and keeps track
6
6
  # if its `pid` and keeps a log file for it as well
@@ -19,7 +19,7 @@ module ShopifyCli
19
19
  class << self
20
20
  def run_dir
21
21
  # is the directory where the pid and logfile are kept
22
- File.join(ShopifyCli.cache_dir, "sv")
22
+ File.join(ShopifyCLI.cache_dir, "sv")
23
23
  end
24
24
 
25
25
  ##
@@ -36,7 +36,7 @@ module ShopifyCli
36
36
  # will be nil if the process is not running.
37
37
  #
38
38
  def for_ident(identifier)
39
- pid, time = File.read(File.join(ShopifyCli::ProcessSupervision.run_dir, "#{identifier}.pid")).split(":")
39
+ pid, time = File.read(File.join(ShopifyCLI::ProcessSupervision.run_dir, "#{identifier}.pid")).split(":")
40
40
  new(identifier, pid: Integer(pid), time: time)
41
41
  rescue Errno::ENOENT
42
42
  nil
@@ -50,19 +50,21 @@ module ShopifyCli
50
50
  #
51
51
  # * `identifier` - a string or symbol to identify the new process by.
52
52
  # * `args` - a command to run, either a string or array of strings
53
+ # * `force_spawn` - whether we want the child process to be a spawn and not a fork, so it is terminated along with
54
+ # the parent
53
55
  #
54
56
  # #### Returns
55
57
  #
56
58
  # * `process` - ProcessSupervision instance if the process is running, this
57
59
  # will be nil if the process did not start.
58
60
  #
59
- def start(identifier, args)
61
+ def start(identifier, args, force_spawn: false)
60
62
  return for_ident(identifier) if running?(identifier)
61
63
 
62
64
  # Some systems don't support forking process without extra gems, so we resort to spawning a new child process -
63
65
  # that means that it dies along with the original process if it is interrupted. If possible, we fork the process
64
66
  # so that it doesn't have to be restarted on every run.
65
- if Process.respond_to?(:fork)
67
+ if Process.respond_to?(:fork) && !force_spawn
66
68
  fork do
67
69
  pid_file = new(identifier, pid: Process.pid)
68
70
  pid_file.write
@@ -132,9 +134,9 @@ module ShopifyCli
132
134
  @identifier = identifier
133
135
  @pid = pid
134
136
  @time = time
135
- FileUtils.mkdir_p(ShopifyCli::ProcessSupervision.run_dir)
136
- @pid_path = File.join(ShopifyCli::ProcessSupervision.run_dir, "#{identifier}.pid")
137
- @log_path = File.join(ShopifyCli::ProcessSupervision.run_dir, "#{identifier}.log")
137
+ FileUtils.mkdir_p(ShopifyCLI::ProcessSupervision.run_dir)
138
+ @pid_path = File.join(ShopifyCLI::ProcessSupervision.run_dir, "#{identifier}.pid")
139
+ @log_path = File.join(ShopifyCLI::ProcessSupervision.run_dir, "#{identifier}.log")
138
140
  end
139
141
 
140
142
  ##