shopify-cli 2.4.0 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/shopify.yml +0 -2
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +14 -14
  5. data/.rubocop_todo.yml +3 -3
  6. data/CHANGELOG.md +25 -0
  7. data/Dockerfile +1 -3
  8. data/Gemfile.lock +22 -16
  9. data/README.md +1 -1
  10. data/RELEASING.md +1 -1
  11. data/Rakefile +25 -34
  12. data/bin/console +11 -0
  13. data/bin/shopify +17 -4
  14. data/dev.yml +3 -0
  15. data/ext/shopify-cli/extconf.rb +1 -0
  16. data/lib/project_types/extension/cli.rb +5 -3
  17. data/lib/project_types/extension/commands/build.rb +4 -3
  18. data/lib/project_types/extension/commands/check.rb +2 -2
  19. data/lib/project_types/extension/commands/connect.rb +1 -1
  20. data/lib/project_types/extension/commands/create.rb +41 -23
  21. data/lib/project_types/extension/commands/extension_command.rb +1 -1
  22. data/lib/project_types/extension/commands/info.rb +1 -1
  23. data/lib/project_types/extension/commands/push.rb +1 -1
  24. data/lib/project_types/extension/commands/register.rb +2 -2
  25. data/lib/project_types/extension/commands/serve.rb +5 -5
  26. data/lib/project_types/extension/commands/tunnel.rb +6 -6
  27. data/lib/project_types/extension/extension_project.rb +4 -4
  28. data/lib/project_types/extension/features/argo.rb +3 -3
  29. data/lib/project_types/extension/features/argo_config.rb +5 -5
  30. data/lib/project_types/extension/features/argo_serve.rb +21 -6
  31. data/lib/project_types/extension/features/argo_setup.rb +1 -1
  32. data/lib/project_types/extension/features/argo_setup_step.rb +1 -1
  33. data/lib/project_types/extension/features/argo_setup_steps.rb +2 -2
  34. data/lib/project_types/extension/forms/connect.rb +2 -2
  35. data/lib/project_types/extension/forms/create.rb +2 -2
  36. data/lib/project_types/extension/forms/questions/ask_app.rb +2 -2
  37. data/lib/project_types/extension/forms/questions/ask_name.rb +1 -1
  38. data/lib/project_types/extension/forms/questions/ask_registration.rb +2 -2
  39. data/lib/project_types/extension/forms/questions/ask_template.rb +2 -2
  40. data/lib/project_types/extension/forms/questions/ask_type.rb +2 -2
  41. data/lib/project_types/extension/messages/message_loading.rb +2 -2
  42. data/lib/project_types/extension/models/development_server.rb +49 -6
  43. data/lib/project_types/extension/models/development_server_requirements.rb +21 -3
  44. data/lib/project_types/extension/models/lazy_specification_handler.rb +1 -1
  45. data/lib/project_types/extension/models/specification.rb +1 -1
  46. data/lib/project_types/extension/models/specification_handlers/default.rb +14 -2
  47. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +1 -1
  48. data/lib/project_types/extension/models/specifications.rb +4 -4
  49. data/lib/project_types/extension/tasks/choose_next_available_port.rb +1 -1
  50. data/lib/project_types/extension/tasks/configure_features.rb +1 -1
  51. data/lib/project_types/extension/tasks/configure_options.rb +1 -1
  52. data/lib/project_types/extension/tasks/converters/product_converter.rb +1 -1
  53. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +31 -0
  54. data/lib/project_types/extension/tasks/create_extension.rb +2 -2
  55. data/lib/project_types/extension/tasks/fetch_specifications.rb +2 -2
  56. data/lib/project_types/extension/tasks/find_npm_packages.rb +5 -5
  57. data/lib/project_types/extension/tasks/get_app.rb +2 -2
  58. data/lib/project_types/extension/tasks/get_apps.rb +2 -2
  59. data/lib/project_types/extension/tasks/get_extensions.rb +2 -2
  60. data/lib/project_types/extension/tasks/get_product.rb +2 -2
  61. data/lib/project_types/extension/tasks/load_server_config.rb +23 -0
  62. data/lib/project_types/extension/tasks/run_extension_command.rb +34 -11
  63. data/lib/project_types/extension/tasks/update_draft.rb +2 -2
  64. data/lib/project_types/node/cli.rb +3 -3
  65. data/lib/project_types/node/commands/connect.rb +4 -4
  66. data/lib/project_types/node/commands/create.rb +10 -10
  67. data/lib/project_types/node/commands/deploy/heroku.rb +4 -4
  68. data/lib/project_types/node/commands/deploy.rb +3 -3
  69. data/lib/project_types/node/commands/generate.rb +2 -2
  70. data/lib/project_types/node/commands/open.rb +3 -3
  71. data/lib/project_types/node/commands/serve.rb +15 -7
  72. data/lib/project_types/node/commands/tunnel.rb +6 -6
  73. data/lib/project_types/node/forms/create.rb +3 -3
  74. data/lib/project_types/node/messages/messages.rb +3 -0
  75. data/lib/project_types/php/cli.rb +27 -0
  76. data/lib/project_types/php/commands/connect.rb +19 -0
  77. data/lib/project_types/php/commands/create.rb +143 -0
  78. data/lib/project_types/php/commands/deploy/heroku.rb +129 -0
  79. data/lib/project_types/php/commands/deploy.rb +32 -0
  80. data/lib/project_types/php/commands/open.rb +16 -0
  81. data/lib/project_types/php/commands/serve.rb +51 -0
  82. data/lib/project_types/php/commands/tunnel.rb +37 -0
  83. data/lib/project_types/php/forms/create.rb +45 -0
  84. data/lib/project_types/php/messages/messages.rb +191 -0
  85. data/lib/project_types/rails/cli.rb +3 -3
  86. data/lib/project_types/rails/commands/connect.rb +4 -4
  87. data/lib/project_types/rails/commands/create.rb +12 -12
  88. data/lib/project_types/rails/commands/deploy/heroku.rb +4 -4
  89. data/lib/project_types/rails/commands/deploy.rb +3 -3
  90. data/lib/project_types/rails/commands/generate/webhook.rb +3 -3
  91. data/lib/project_types/rails/commands/generate.rb +3 -3
  92. data/lib/project_types/rails/commands/open.rb +3 -3
  93. data/lib/project_types/rails/commands/serve.rb +8 -8
  94. data/lib/project_types/rails/commands/tunnel.rb +6 -6
  95. data/lib/project_types/rails/forms/create.rb +3 -3
  96. data/lib/project_types/rails/gem.rb +1 -1
  97. data/lib/project_types/rails/ruby.rb +1 -1
  98. data/lib/project_types/script/cli.rb +15 -7
  99. data/lib/project_types/script/commands/create.rb +4 -2
  100. data/lib/project_types/script/commands/push.rb +2 -2
  101. data/lib/project_types/script/config/extension_points.yml +30 -29
  102. data/lib/project_types/script/forms/create.rb +1 -1
  103. data/lib/project_types/script/layers/application/create_script.rb +32 -12
  104. data/lib/project_types/script/layers/application/extension_points.rb +4 -4
  105. data/lib/project_types/script/layers/application/push_script.rb +4 -1
  106. data/lib/project_types/script/layers/domain/extension_point.rb +13 -45
  107. data/lib/project_types/script/layers/domain/script_project.rb +2 -2
  108. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +57 -0
  109. data/lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb +35 -0
  110. data/lib/project_types/script/layers/infrastructure/command_runner.rb +1 -1
  111. data/lib/project_types/script/layers/infrastructure/errors.rb +5 -0
  112. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +10 -90
  113. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +76 -11
  114. data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +1 -1
  115. data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +33 -0
  116. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +105 -0
  117. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +1 -1
  118. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +6 -6
  119. data/lib/project_types/script/layers/infrastructure/script_service.rb +4 -8
  120. data/lib/project_types/script/layers/infrastructure/service_locator.rb +20 -0
  121. data/lib/project_types/script/messages/messages.rb +4 -0
  122. data/lib/project_types/script/tasks/ensure_env.rb +6 -6
  123. data/lib/project_types/script/ui/error_handler.rb +83 -75
  124. data/lib/project_types/script/ui/printing_spinner.rb +1 -1
  125. data/lib/project_types/theme/cli.rb +3 -3
  126. data/lib/project_types/theme/commands/check.rb +3 -3
  127. data/lib/project_types/theme/commands/delete.rb +7 -7
  128. data/lib/project_types/theme/commands/init.rb +3 -3
  129. data/lib/project_types/theme/commands/language_server.rb +2 -2
  130. data/lib/project_types/theme/commands/package.rb +2 -2
  131. data/lib/project_types/theme/commands/publish.rb +5 -5
  132. data/lib/project_types/theme/commands/pull.rb +9 -9
  133. data/lib/project_types/theme/commands/push.rb +12 -12
  134. data/lib/project_types/theme/commands/serve.rb +4 -4
  135. data/lib/project_types/theme/forms/confirm_store.rb +1 -1
  136. data/lib/project_types/theme/forms/select.rb +2 -2
  137. data/lib/{shopify-cli → shopify_cli}/admin_api/populate_resource_command.rb +3 -3
  138. data/lib/{shopify-cli → shopify_cli}/admin_api/schema.rb +4 -4
  139. data/lib/{shopify-cli → shopify_cli}/admin_api.rb +27 -27
  140. data/lib/{shopify-cli → shopify_cli}/api.rb +12 -8
  141. data/lib/shopify_cli/command/app_sub_command.rb +16 -0
  142. data/lib/{shopify-cli → shopify_cli}/command.rb +3 -3
  143. data/lib/{shopify-cli → shopify_cli}/commands/config.rb +14 -14
  144. data/lib/{shopify-cli → shopify_cli}/commands/help.rb +4 -4
  145. data/lib/{shopify-cli → shopify_cli}/commands/login.rb +7 -7
  146. data/lib/shopify_cli/commands/logout.rb +39 -0
  147. data/lib/{shopify-cli → shopify_cli}/commands/populate/customer.rb +4 -4
  148. data/lib/{shopify-cli → shopify_cli}/commands/populate/draft_order.rb +4 -4
  149. data/lib/{shopify-cli → shopify_cli}/commands/populate/product.rb +4 -4
  150. data/lib/shopify_cli/commands/populate.rb +23 -0
  151. data/lib/shopify_cli/commands/store.rb +15 -0
  152. data/lib/{shopify-cli → shopify_cli}/commands/switch.rb +5 -5
  153. data/lib/{shopify-cli → shopify_cli}/commands/system.rb +10 -10
  154. data/lib/shopify_cli/commands/version.rb +15 -0
  155. data/lib/{shopify-cli → shopify_cli}/commands/whoami.rb +7 -7
  156. data/lib/shopify_cli/commands.rb +34 -0
  157. data/lib/{shopify-cli → shopify_cli}/connect.rb +3 -3
  158. data/lib/shopify_cli/constants.rb +54 -0
  159. data/lib/{shopify-cli → shopify_cli}/context.rb +6 -6
  160. data/lib/{shopify-cli → shopify_cli}/core/entry_point.rb +7 -7
  161. data/lib/{shopify-cli → shopify_cli}/core/executor.rb +8 -4
  162. data/lib/{shopify-cli → shopify_cli}/core/finalize.rb +1 -1
  163. data/lib/{shopify-cli → shopify_cli}/core/help_resolver.rb +2 -2
  164. data/lib/{shopify-cli → shopify_cli}/core/monorail.rb +8 -8
  165. data/lib/shopify_cli/core.rb +8 -0
  166. data/lib/{shopify-cli → shopify_cli}/db.rb +8 -8
  167. data/lib/{shopify-cli → shopify_cli}/environment.rb +36 -5
  168. data/lib/shopify_cli/exception_reporter/permission_controller.rb +54 -0
  169. data/lib/shopify_cli/exception_reporter.rb +55 -0
  170. data/lib/{shopify-cli → shopify_cli}/feature.rb +8 -8
  171. data/lib/{shopify-cli → shopify_cli}/form.rb +2 -2
  172. data/lib/{shopify-cli → shopify_cli}/git.rb +36 -6
  173. data/lib/{shopify-cli → shopify_cli}/helpers/haikunator.rb +1 -1
  174. data/lib/shopify_cli/helpers.rb +5 -0
  175. data/lib/{shopify-cli → shopify_cli}/heroku.rb +38 -13
  176. data/lib/{shopify-cli → shopify_cli}/http_request.rb +1 -1
  177. data/lib/{shopify-cli → shopify_cli}/identity_auth/servlet.rb +1 -1
  178. data/lib/{shopify-cli → shopify_cli}/identity_auth.rb +8 -8
  179. data/lib/{shopify-cli → shopify_cli}/js_deps.rb +7 -7
  180. data/lib/{shopify-cli → shopify_cli}/js_system.rb +10 -10
  181. data/lib/{shopify-cli → shopify_cli}/lazy_delegator.rb +2 -2
  182. data/lib/{shopify-cli → shopify_cli}/messages/messages.rb +44 -2
  183. data/lib/{shopify-cli → shopify_cli}/method_object.rb +15 -8
  184. data/lib/shopify_cli/migrator/migration.rb +27 -0
  185. data/lib/shopify_cli/migrator/migrations/1631709766_noop.rb +13 -0
  186. data/lib/shopify_cli/migrator.rb +48 -0
  187. data/lib/{shopify-cli → shopify_cli}/options.rb +1 -1
  188. data/lib/{shopify-cli → shopify_cli}/packager.rb +8 -8
  189. data/lib/{shopify-cli → shopify_cli}/partners_api/organizations.rb +1 -1
  190. data/lib/{shopify-cli → shopify_cli}/partners_api.rb +13 -13
  191. data/lib/shopify_cli/php_deps.rb +102 -0
  192. data/lib/{shopify-cli → shopify_cli}/process_supervision.rb +10 -8
  193. data/lib/{shopify-cli → shopify_cli}/project.rb +15 -15
  194. data/lib/{shopify-cli → shopify_cli}/project_commands.rb +3 -3
  195. data/lib/{shopify-cli → shopify_cli}/project_type.rb +5 -5
  196. data/lib/{shopify-cli → shopify_cli}/resolve_constant.rb +5 -5
  197. data/lib/{shopify-cli → shopify_cli}/resources/env_file.rb +1 -1
  198. data/lib/shopify_cli/resources.rb +5 -0
  199. data/lib/{shopify-cli → shopify_cli}/result.rb +11 -11
  200. data/lib/{shopify-cli → shopify_cli}/shopifolk.rb +6 -6
  201. data/lib/{shopify-cli → shopify_cli}/sub_command.rb +1 -1
  202. data/lib/{shopify-cli → shopify_cli}/task.rb +1 -1
  203. data/lib/{shopify-cli → shopify_cli}/tasks/confirm_store.rb +3 -3
  204. data/lib/{shopify-cli → shopify_cli}/tasks/create_api_client.rb +4 -4
  205. data/lib/shopify_cli/tasks/ensure_authenticated.rb +13 -0
  206. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_dev_store.rb +5 -5
  207. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_env.rb +3 -3
  208. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_loopback_url.rb +4 -4
  209. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_project_type.rb +3 -3
  210. data/lib/{shopify-cli → shopify_cli}/tasks/select_org_and_shop.rb +8 -8
  211. data/lib/{shopify-cli → shopify_cli}/tasks/update_dashboard_urls.rb +6 -6
  212. data/lib/{shopify-cli → shopify_cli}/tasks.rb +10 -10
  213. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/certificate_manager.rb +5 -5
  214. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/header_hash.rb +1 -1
  215. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/hot-reload.js +0 -0
  216. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/hot_reload.rb +1 -1
  217. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/local_assets.rb +1 -1
  218. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/proxy.rb +2 -2
  219. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/sse.rb +1 -1
  220. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/watcher.rb +1 -1
  221. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/web_server.rb +1 -1
  222. data/lib/{shopify-cli → shopify_cli}/theme/dev_server.rb +3 -3
  223. data/lib/{shopify-cli → shopify_cli}/theme/development_theme.rb +9 -9
  224. data/lib/{shopify-cli → shopify_cli}/theme/file.rb +1 -1
  225. data/lib/{shopify-cli → shopify_cli}/theme/ignore_filter.rb +1 -1
  226. data/lib/{shopify-cli → shopify_cli}/theme/mime_type.rb +1 -1
  227. data/lib/{shopify-cli → shopify_cli}/theme/syncer.rb +6 -6
  228. data/lib/{shopify-cli → shopify_cli}/theme/theme.rb +4 -4
  229. data/lib/{shopify-cli → shopify_cli}/transform_data_structure.rb +4 -4
  230. data/lib/{shopify-cli → shopify_cli}/tunnel.rb +14 -14
  231. data/lib/shopify_cli/version.rb +3 -0
  232. data/lib/shopify_cli.rb +61 -52
  233. data/shopify-cli.gemspec +11 -3
  234. data/utilities/docker.rb +47 -0
  235. data/utilities/utilities.rb +5 -0
  236. metadata +133 -95
  237. data/lib/project_types/script/layers/infrastructure/api_clients.rb +0 -89
  238. data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +0 -73
  239. data/lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb +0 -60
  240. data/lib/shopify-cli/commands/logout.rb +0 -39
  241. data/lib/shopify-cli/commands/populate.rb +0 -23
  242. data/lib/shopify-cli/commands/store.rb +0 -15
  243. data/lib/shopify-cli/commands/version.rb +0 -15
  244. data/lib/shopify-cli/commands.rb +0 -34
  245. data/lib/shopify-cli/constants.rb +0 -26
  246. data/lib/shopify-cli/core.rb +0 -8
  247. data/lib/shopify-cli/helpers.rb +0 -5
  248. data/lib/shopify-cli/resources.rb +0 -5
  249. data/lib/shopify-cli/tasks/ensure_authenticated.rb +0 -13
  250. data/lib/shopify-cli/version.rb +0 -3
@@ -0,0 +1,55 @@
1
+ module ShopifyCLI
2
+ module ExceptionReporter
3
+ autoload :PermissionController, "shopify_cli/exception_reporter/permission_controller"
4
+
5
+ def self.report(error, _logs = nil, _api_key = nil, custom_metadata = {})
6
+ context = ShopifyCLI::Context.new
7
+ context.puts("\n")
8
+ context.puts(context.message("core.error_reporting.unhandled_error.message"))
9
+ context.puts(context.message("core.error_reporting.unhandled_error.issue_message"))
10
+ unless ShopifyCLI::Environment.print_stacktrace?
11
+ context.puts(context.message("core.error_reporting.unhandled_error.stacktrace_message",
12
+ "#{ShopifyCLI::Constants::EnvironmentVariables::STACKTRACE}=1"))
13
+ end
14
+ context.puts("\n")
15
+
16
+ return unless reportable_error?(error)
17
+ return unless report?
18
+
19
+ ENV["BUGSNAG_DISABLE_AUTOCONFIGURE"] = "1"
20
+ require "bugsnag"
21
+
22
+ Bugsnag.configure do |config|
23
+ config.logger.level = ::Logger::ERROR
24
+ config.api_key = ShopifyCLI::Constants::Bugsnag::API_KEY
25
+ config.app_type = "shopify"
26
+ config.project_root = File.expand_path("../../..", __FILE__)
27
+ config.app_version = ShopifyCLI::VERSION
28
+ config.auto_capture_sessions = false
29
+ end
30
+
31
+ metadata = {}
32
+ metadata.merge!(custom_metadata)
33
+ # Bugsnag.notify(error, metadata)
34
+ end
35
+
36
+ def self.report?
37
+ # return false if ShopifyCLI::Environment.development?
38
+ return true if ExceptionReporter::PermissionController.automatic_reporting_prompted? &&
39
+ ExceptionReporter::PermissionController.can_report_automatically?
40
+
41
+ report_error = ExceptionReporter::PermissionController.report_error?
42
+
43
+ unless ExceptionReporter::PermissionController.automatic_reporting_prompted?
44
+ ExceptionReporter::PermissionController.can_report_automatically?
45
+ end
46
+
47
+ report_error
48
+ end
49
+
50
+ def self.reportable_error?(error)
51
+ is_abort = error.is_a?(ShopifyCLI::Abort) || error.is_a?(ShopifyCLI::AbortSilent)
52
+ !is_abort
53
+ end
54
+ end
55
+ end
@@ -1,6 +1,6 @@
1
- module ShopifyCli
1
+ module ShopifyCLI
2
2
  ##
3
- # ShopifyCli::Feature contains the logic to hide and show features across the CLI
3
+ # ShopifyCLI::Feature contains the logic to hide and show features across the CLI
4
4
  # These features can be either commands or project types currently.
5
5
  #
6
6
  # Feature flags will persist between runs so if the flag is enabled or disabled,
@@ -9,7 +9,7 @@ module ShopifyCli
9
9
  SECTION = "features"
10
10
 
11
11
  ##
12
- # ShopifyCli::Feature::Set is included on commands and projects to allow you to hide
12
+ # ShopifyCLI::Feature::Set is included on commands and projects to allow you to hide
13
13
  # and enable projects and commands based on feature flags.
14
14
  module Set
15
15
  ##
@@ -21,9 +21,9 @@ module ShopifyCli
21
21
  #
22
22
  # #### Example
23
23
  #
24
- # module ShopifyCli
24
+ # module ShopifyCLI
25
25
  # module Commands
26
- # class Config < ShopifyCli::Command
26
+ # class Config < ShopifyCLI::Command
27
27
  # hidden_feature(feature_set: :basic)
28
28
  # ....
29
29
  #
@@ -41,7 +41,7 @@ module ShopifyCli
41
41
  #
42
42
  # #### Example
43
43
  #
44
- # ShopifyCli::Commands::Config.hidden?
44
+ # ShopifyCLI::Commands::Config.hidden?
45
45
  #
46
46
  def hidden?
47
47
  enabled = (@hidden_feature_set || []).any? do |feature|
@@ -84,11 +84,11 @@ module ShopifyCli
84
84
  # * `is_enabled` - will be true if the feature has been enabled.
85
85
  def enabled?(feature)
86
86
  return false if feature.nil?
87
- ShopifyCli::Config.get_bool(SECTION, feature.to_s)
87
+ ShopifyCLI::Config.get_bool(SECTION, feature.to_s)
88
88
  end
89
89
 
90
90
  def set(feature, value)
91
- ShopifyCli::Config.set(SECTION, feature.to_s, value)
91
+ ShopifyCLI::Config.set(SECTION, feature.to_s, value)
92
92
  end
93
93
  end
94
94
  end
@@ -1,6 +1,6 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  class Form
5
5
  class << self
6
6
  def ask(ctx, args, flags)
@@ -12,7 +12,7 @@ module ShopifyCli
12
12
  begin
13
13
  form.ask
14
14
  form
15
- rescue ShopifyCli::Abort => err
15
+ rescue ShopifyCLI::Abort => err
16
16
  ctx.puts(err.message)
17
17
  nil
18
18
  end
@@ -1,6 +1,6 @@
1
- module ShopifyCli
1
+ module ShopifyCLI
2
2
  ##
3
- # ShopifyCli::Git wraps git functionality to make it easier to integrate will
3
+ # ShopifyCLI::Git wraps git functionality to make it easier to integrate will
4
4
  # git.
5
5
  class Git
6
6
  class << self
@@ -18,7 +18,7 @@ module ShopifyCli
18
18
  #
19
19
  # #### Example
20
20
  #
21
- # ShopifyCli::Git.sha
21
+ # ShopifyCLI::Git.sha
22
22
  #
23
23
  def sha(dir: Dir.pwd, ctx: Context.new)
24
24
  rev_parse("HEAD", dir: dir, ctx: ctx)
@@ -40,7 +40,7 @@ module ShopifyCli
40
40
  #
41
41
  # #### Example
42
42
  #
43
- # ShopifyCli::Git.clone('git@github.com:shopify/test.git', 'test-app')
43
+ # ShopifyCLI::Git.clone('git@github.com:shopify/test.git', 'test-app')
44
44
  #
45
45
  def clone(repository, dest, ctx: Context.new)
46
46
  if Dir.exist?(dest)
@@ -66,7 +66,7 @@ module ShopifyCli
66
66
  #
67
67
  # #### Example
68
68
  #
69
- # branches = ShopifyCli::Git.branches(@ctx)
69
+ # branches = ShopifyCLI::Git.branches(@ctx)
70
70
  #
71
71
  def branches(ctx)
72
72
  output, status = ctx.capture2e("git", "branch", "--list", "--format=%(refname:short)")
@@ -91,7 +91,7 @@ module ShopifyCli
91
91
  #
92
92
  # #### Example
93
93
  #
94
- # ShopifyCli::Git.init(@ctx)
94
+ # ShopifyCLI::Git.init(@ctx)
95
95
  #
96
96
  def init(ctx)
97
97
  output, status = ctx.capture2e("git", "status")
@@ -105,6 +105,36 @@ module ShopifyCli
105
105
  end
106
106
  end
107
107
 
108
+ def sparse_checkout(repo, set, branch, ctx)
109
+ _, status = ctx.capture2e("git init")
110
+ unless status.success?
111
+ ctx.abort(ctx.message("core.git.error.repo_not_initiated"))
112
+ end
113
+
114
+ _, status = ctx.capture2e("git remote add -f origin #{repo}")
115
+ unless status.success?
116
+ ctx.abort(ctx.message("core.git.error.remote_not_added"))
117
+ end
118
+
119
+ _, status = ctx.capture2e("git config core.sparsecheckout true")
120
+ unless status.success?
121
+ ctx.abort(ctx.message("core.git.error.sparse_checkout_not_enabled"))
122
+ end
123
+
124
+ _, status = ctx.capture2e("git sparse-checkout set #{set}")
125
+ unless status.success?
126
+ ctx.abort(ctx.message("core.git.error.sparse_checkout_not_set"))
127
+ end
128
+
129
+ resp, status = ctx.capture2e("git pull origin #{branch}")
130
+ unless status.success?
131
+ if resp.include?("fatal: couldn't find remote ref")
132
+ ctx.abort(ctx.message("core.git.error.pull_failed_bad_branch", branch))
133
+ end
134
+ ctx.abort(ctx.message("core.git.error.pull_failed"))
135
+ end
136
+ end
137
+
108
138
  private
109
139
 
110
140
  def exec(*args, dir: Dir.pwd, default: nil, ctx: Context.new)
@@ -23,7 +23,7 @@
23
23
 
24
24
  require "securerandom"
25
25
 
26
- module ShopifyCli
26
+ module ShopifyCLI
27
27
  module Helpers
28
28
  module Haikunator
29
29
  class << self
@@ -0,0 +1,5 @@
1
+ module ShopifyCLI
2
+ module Helpers
3
+ autoload :Haikunator, "shopify_cli/helpers/haikunator"
4
+ end
5
+ end
@@ -1,4 +1,4 @@
1
- module ShopifyCli
1
+ module ShopifyCLI
2
2
  class Heroku
3
3
  DOWNLOAD_URLS = {
4
4
  linux: "https://cli-assets.heroku.com/heroku-linux-x64.tar.gz",
@@ -36,7 +36,7 @@ module ShopifyCli
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)
39
+ result = @ctx.system("curl", "-o", download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCLI.cache_dir)
40
40
  @ctx.abort(@ctx.message("core.heroku.error.download")) unless result.success?
41
41
  @ctx.abort(@ctx.message("core.heroku.error.download")) unless File.exist?(download_path)
42
42
  end
@@ -47,7 +47,7 @@ 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
52
  @ctx.abort(@ctx.message("core.heroku.error.install")) unless result.success?
53
53
 
@@ -67,23 +67,33 @@ module ShopifyCli
67
67
  nil
68
68
  end
69
69
 
70
- private
71
-
72
- def download_filename
73
- URI.parse(DOWNLOAD_URLS[@ctx.os]).path.split("/").last
70
+ def get_config(config)
71
+ output, status = @ctx.capture2e(heroku_command, "config:get", config.to_s)
72
+ return output.strip if status.success?
73
+ nil
74
74
  end
75
75
 
76
- def download_path
77
- File.join(ShopifyCli.cache_dir, download_filename)
76
+ def set_config(config, value)
77
+ result = @ctx.system(heroku_command, "config:set", "#{config}=#{value}")
78
+
79
+ msg = @ctx.message("core.heroku.error.set_config", config, value)
80
+ @ctx.abort(msg) unless result.success?
78
81
  end
79
82
 
80
- def git_remote
81
- output, status = @ctx.capture2e("git", "remote", "get-url", "heroku")
82
- status.success? ? output : nil
83
+ def add_buildpacks(buildpacks)
84
+ result = @ctx.system(heroku_command, "buildpacks:clear")
85
+ msg = @ctx.message("core.heroku.error.add_buildpacks")
86
+ @ctx.abort(msg) unless result.success?
87
+
88
+ buildpacks.each do |buildpack|
89
+ result = @ctx.system(heroku_command, "buildpacks:add", buildpack)
90
+ msg = @ctx.message("core.heroku.error.add_buildpacks")
91
+ @ctx.abort(msg) unless result.success?
92
+ end
83
93
  end
84
94
 
85
95
  def heroku_command
86
- local_path = File.join(ShopifyCli.cache_dir, "heroku", "bin", "heroku").to_s
96
+ local_path = File.join(ShopifyCLI.cache_dir, "heroku", "bin", "heroku").to_s
87
97
  if File.exist?(local_path)
88
98
  local_path
89
99
  elsif @ctx.windows?
@@ -103,6 +113,21 @@ module ShopifyCli
103
113
  end
104
114
  end
105
115
 
116
+ private
117
+
118
+ def download_filename
119
+ URI.parse(DOWNLOAD_URLS[@ctx.os]).path.split("/").last
120
+ end
121
+
122
+ def download_path
123
+ File.join(ShopifyCLI.cache_dir, download_filename)
124
+ end
125
+
126
+ def git_remote
127
+ output, status = @ctx.capture2e("git", "remote", "get-url", "heroku")
128
+ status.success? ? output : nil
129
+ end
130
+
106
131
  def installed?
107
132
  _output, status = @ctx.capture2e(heroku_command, "--version")
108
133
  status.success?
@@ -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: {
@@ -14,6 +14,25 @@ module ShopifyCli
14
14
  },
15
15
  },
16
16
  core: {
17
+ error_reporting: {
18
+ unhandled_error: {
19
+ message: "{{x}} {{red:An unexpected error occured.}}",
20
+ issue_message: "{{red:\tTo \e]8;;#{ShopifyCLI::Constants::Links::NEW_ISSUE}\e\\submit an issue\e]8;;\e\\"\
21
+ " include the stack trace.}}",
22
+ stacktrace_message: "{{red:\tTo print the stack trace, add the environment variable %s.}}",
23
+ },
24
+ enable_automatic_reporting_prompt: {
25
+ question: "Automatically send error reports moving forward?",
26
+ yes: "Automatically send error reports to the Shopify team",
27
+ no: "Don't send error reports",
28
+ enabled: "Anonymized error reports will be sent to Shopify.",
29
+ },
30
+ report_error: {
31
+ question: "Send an error report to Shopify?",
32
+ yes: "Send report",
33
+ no: "Don't send",
34
+ },
35
+ },
17
36
  connect: {
18
37
  already_connected_warning: "{{yellow:! This app appears to be already connected}}",
19
38
  project_type_select: "What type of project would you like to connect?",
@@ -67,10 +86,18 @@ module ShopifyCli
67
86
  repo_not_initiated:
68
87
  "Git repo is not initiated. Please run {{command:git init}} and make at least one commit.",
69
88
  no_commits_made: "No git commits have been made. Please make at least one commit.",
89
+ remote_not_added: "Remote could not be added.",
90
+ sparse_checkout_not_enabled: "Sparse checkout could not be enabled.",
91
+ sparse_checkout_not_set: "Sparse checkout set command failed.",
92
+ pull_failed: "Pull failed.",
93
+ pull_failed_bad_branch: "Pull failed. Branch %s cannot be found. Check the branch name and try again.",
70
94
  },
71
95
 
72
96
  cloning: "Cloning %s into %s…",
73
97
  cloned: "{{v}} Cloned into %s",
98
+ pulling_from_to: "Pulling %s into %s…",
99
+ pulling: "Pulling…",
100
+ pulled: "Pulled into %s",
74
101
  },
75
102
 
76
103
  help: {
@@ -92,6 +119,8 @@ module ShopifyCli
92
119
  download: "Heroku CLI could not be downloaded",
93
120
  install: "Could not install Heroku CLI",
94
121
  could_not_select_app: "Heroku app {{green:%s}} could not be selected",
122
+ set_config: "Failed to set config %s to %s in Heroku app",
123
+ add_buildpacks: "Failed to add buildpacks in Heroku app",
95
124
  },
96
125
  },
97
126
 
@@ -188,6 +217,20 @@ module ShopifyCli
188
217
  },
189
218
  },
190
219
 
220
+ php_deps: {
221
+ error: {
222
+ missing_package: "Expected to have a file at: %s",
223
+ invalid_package: "{{info:%s}} was not valid JSON. Fix this then try again",
224
+ install: "Failed to install %s packages",
225
+ install_spinner_error: "Unable to install all %d dependencies",
226
+ install_error: "An error occurred while installing dependencies",
227
+ },
228
+
229
+ installing: "Installing Composer dependencies…",
230
+ installed: "Dependencies installed",
231
+ installed_count: "%d dependencies installed",
232
+ },
233
+
191
234
  api: {
192
235
  error: {
193
236
  failed_auth: "Failed to authenticate with Shopify. Please try again later.",
@@ -413,7 +456,6 @@ module ShopifyCli
413
456
  ngrok: "Something went wrong with ngrok installation,"\
414
457
  "please make sure %s exists within %s before trying again",
415
458
  },
416
-
417
459
  installing: "Installing ngrok…",
418
460
  not_running: "{{green:x}} ngrok tunnel not running",
419
461
  prereq_command_location: "%s @ %s",
@@ -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,18 +42,20 @@ 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
50
50
  module AutoCreateResultObject
51
+ def self.ruby2_keywords(*); end unless respond_to?(:ruby2_keywords, true)
52
+
51
53
  ##
52
54
  # invokes the original `call` implementation and wraps its return value
53
55
  # into a result object.
54
56
  #
55
- def call(*args, **kwargs, &block)
56
- Result.wrap { kwargs.any? ? super(*args, **kwargs, &block) : super(*args, &block) }.call
57
+ ruby2_keywords def call(*args, &block)
58
+ Result.wrap { super(*args, &block) }.call
57
59
  end
58
60
  end
59
61
 
@@ -66,8 +68,13 @@ module ShopifyCli
66
68
  #
67
69
  def call(*args, **kwargs, &block)
68
70
  properties.keys.yield_self do |properties|
69
- new(**kwargs.slice(*properties))
70
- .call(*args, **kwargs.slice(*(kwargs.keys - properties)), &block)
71
+ instance = new(**kwargs.slice(*properties))
72
+ kwargs = kwargs.slice(*(kwargs.keys - properties))
73
+ if kwargs.any?
74
+ instance.call(*args, **kwargs, &block)
75
+ else
76
+ instance.call(*args, &block)
77
+ end
71
78
  end
72
79
  end
73
80