shopify-cli 2.2.2 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/ISSUE_TEMPLATE.md +0 -4
  4. data/.github/workflows/shopify.yml +104 -0
  5. data/.gitignore +3 -0
  6. data/.rubocop.yml +14 -14
  7. data/.rubocop_todo.yml +3 -3
  8. data/CHANGELOG.md +30 -0
  9. data/CONTRIBUTING.md +23 -0
  10. data/Dockerfile +17 -0
  11. data/Gemfile +1 -0
  12. data/Gemfile.lock +67 -24
  13. data/RELEASING.md +1 -1
  14. data/Rakefile +75 -18
  15. data/bin/console +11 -0
  16. data/bin/shopify +16 -4
  17. data/dev.yml +14 -1
  18. data/ext/shopify-cli/extconf.rb +2 -0
  19. data/ext/shopify-extensions/extconf.rb +21 -0
  20. data/ext/shopify-extensions/shopify_extensions.rb +152 -0
  21. data/ext/shopify-extensions/version +1 -0
  22. data/lib/project_types/extension/cli.rb +19 -3
  23. data/lib/project_types/extension/commands/build.rb +32 -3
  24. data/lib/project_types/extension/commands/check.rb +2 -2
  25. data/lib/project_types/extension/commands/connect.rb +1 -1
  26. data/lib/project_types/extension/commands/create.rb +59 -16
  27. data/lib/project_types/extension/commands/extension_command.rb +1 -1
  28. data/lib/project_types/extension/commands/info.rb +1 -1
  29. data/lib/project_types/extension/commands/push.rb +1 -1
  30. data/lib/project_types/extension/commands/register.rb +2 -2
  31. data/lib/project_types/extension/commands/serve.rb +5 -5
  32. data/lib/project_types/extension/commands/tunnel.rb +6 -6
  33. data/lib/project_types/extension/extension_project.rb +4 -4
  34. data/lib/project_types/extension/features/argo.rb +3 -3
  35. data/lib/project_types/extension/features/argo_config.rb +5 -5
  36. data/lib/project_types/extension/features/argo_serve.rb +21 -6
  37. data/lib/project_types/extension/features/argo_setup.rb +1 -1
  38. data/lib/project_types/extension/features/argo_setup_step.rb +1 -1
  39. data/lib/project_types/extension/features/argo_setup_steps.rb +2 -2
  40. data/lib/project_types/extension/forms/connect.rb +2 -2
  41. data/lib/project_types/extension/forms/create.rb +6 -3
  42. data/lib/project_types/extension/forms/questions/ask_app.rb +2 -2
  43. data/lib/project_types/extension/forms/questions/ask_name.rb +1 -1
  44. data/lib/project_types/extension/forms/questions/ask_registration.rb +2 -2
  45. data/lib/project_types/extension/forms/questions/ask_template.rb +44 -0
  46. data/lib/project_types/extension/forms/questions/ask_type.rb +2 -2
  47. data/lib/project_types/extension/messages/message_loading.rb +2 -2
  48. data/lib/project_types/extension/messages/messages.rb +3 -0
  49. data/lib/project_types/extension/models/development_server.rb +78 -0
  50. data/lib/project_types/extension/models/development_server_requirements.rb +35 -0
  51. data/lib/project_types/extension/models/lazy_specification_handler.rb +1 -1
  52. data/lib/project_types/extension/models/server_config/base.rb +31 -0
  53. data/lib/project_types/extension/models/server_config/development.rb +23 -0
  54. data/lib/project_types/extension/models/server_config/development_entries.rb +38 -0
  55. data/lib/project_types/extension/models/server_config/development_renderer.rb +30 -0
  56. data/lib/project_types/extension/models/server_config/extension.rb +35 -0
  57. data/lib/project_types/extension/models/server_config/root.rb +18 -0
  58. data/lib/project_types/extension/models/server_config/user.rb +10 -0
  59. data/lib/project_types/extension/models/specification.rb +1 -1
  60. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +1 -1
  61. data/lib/project_types/extension/models/specification_handlers/default.rb +14 -2
  62. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +1 -1
  63. data/lib/project_types/extension/models/specifications.rb +4 -4
  64. data/lib/project_types/extension/tasks/choose_next_available_port.rb +2 -2
  65. data/lib/project_types/extension/tasks/configure_features.rb +1 -1
  66. data/lib/project_types/extension/tasks/configure_options.rb +1 -1
  67. data/lib/project_types/extension/tasks/converters/product_converter.rb +1 -1
  68. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +31 -0
  69. data/lib/project_types/extension/tasks/create_extension.rb +2 -2
  70. data/lib/project_types/extension/tasks/fetch_specifications.rb +2 -2
  71. data/lib/project_types/extension/tasks/find_npm_packages.rb +5 -5
  72. data/lib/project_types/extension/tasks/get_app.rb +2 -2
  73. data/lib/project_types/extension/tasks/get_apps.rb +2 -2
  74. data/lib/project_types/extension/tasks/get_extensions.rb +2 -2
  75. data/lib/project_types/extension/tasks/get_product.rb +2 -2
  76. data/lib/project_types/extension/tasks/load_server_config.rb +23 -0
  77. data/lib/project_types/extension/tasks/run_extension_command.rb +81 -0
  78. data/lib/project_types/extension/tasks/update_draft.rb +2 -2
  79. data/lib/project_types/node/cli.rb +3 -3
  80. data/lib/project_types/node/commands/connect.rb +4 -4
  81. data/lib/project_types/node/commands/create.rb +10 -14
  82. data/lib/project_types/node/commands/deploy/heroku.rb +4 -4
  83. data/lib/project_types/node/commands/deploy.rb +3 -3
  84. data/lib/project_types/node/commands/generate.rb +2 -2
  85. data/lib/project_types/node/commands/open.rb +3 -3
  86. data/lib/project_types/node/commands/serve.rb +15 -7
  87. data/lib/project_types/node/commands/tunnel.rb +6 -6
  88. data/lib/project_types/node/forms/create.rb +3 -3
  89. data/lib/project_types/node/messages/messages.rb +3 -0
  90. data/lib/project_types/php/cli.rb +27 -0
  91. data/lib/project_types/php/commands/connect.rb +19 -0
  92. data/lib/project_types/php/commands/create.rb +143 -0
  93. data/lib/project_types/php/commands/deploy/heroku.rb +129 -0
  94. data/lib/project_types/php/commands/deploy.rb +32 -0
  95. data/lib/project_types/php/commands/open.rb +16 -0
  96. data/lib/project_types/php/commands/serve.rb +51 -0
  97. data/lib/project_types/php/commands/tunnel.rb +37 -0
  98. data/lib/project_types/php/forms/create.rb +45 -0
  99. data/lib/project_types/php/messages/messages.rb +191 -0
  100. data/lib/project_types/rails/cli.rb +3 -3
  101. data/lib/project_types/rails/commands/connect.rb +4 -4
  102. data/lib/project_types/rails/commands/create.rb +12 -16
  103. data/lib/project_types/rails/commands/deploy/heroku.rb +4 -4
  104. data/lib/project_types/rails/commands/deploy.rb +3 -3
  105. data/lib/project_types/rails/commands/generate/webhook.rb +3 -3
  106. data/lib/project_types/rails/commands/generate.rb +3 -3
  107. data/lib/project_types/rails/commands/open.rb +3 -3
  108. data/lib/project_types/rails/commands/serve.rb +8 -8
  109. data/lib/project_types/rails/commands/tunnel.rb +6 -6
  110. data/lib/project_types/rails/forms/create.rb +3 -3
  111. data/lib/project_types/rails/gem.rb +1 -1
  112. data/lib/project_types/rails/ruby.rb +1 -1
  113. data/lib/project_types/script/cli.rb +16 -6
  114. data/lib/project_types/script/commands/create.rb +4 -2
  115. data/lib/project_types/script/commands/push.rb +2 -2
  116. data/lib/project_types/script/config/extension_points.yml +30 -29
  117. data/lib/project_types/script/forms/create.rb +1 -1
  118. data/lib/project_types/script/layers/application/create_script.rb +32 -12
  119. data/lib/project_types/script/layers/application/extension_points.rb +4 -4
  120. data/lib/project_types/script/layers/application/push_script.rb +13 -1
  121. data/lib/project_types/script/layers/domain/extension_point.rb +13 -45
  122. data/lib/project_types/script/layers/domain/push_package.rb +0 -12
  123. data/lib/project_types/script/layers/domain/script_project.rb +2 -2
  124. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +57 -0
  125. data/lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb +35 -0
  126. data/lib/project_types/script/layers/infrastructure/command_runner.rb +1 -1
  127. data/lib/project_types/script/layers/infrastructure/errors.rb +5 -0
  128. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +10 -90
  129. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +76 -11
  130. data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +1 -1
  131. data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +33 -0
  132. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +105 -0
  133. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +1 -1
  134. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +6 -6
  135. data/lib/project_types/script/layers/infrastructure/script_service.rb +25 -144
  136. data/lib/project_types/script/layers/infrastructure/script_uploader.rb +27 -0
  137. data/lib/project_types/script/layers/infrastructure/service_locator.rb +20 -0
  138. data/lib/project_types/script/messages/messages.rb +4 -0
  139. data/lib/project_types/script/tasks/ensure_env.rb +7 -7
  140. data/lib/project_types/script/ui/error_handler.rb +84 -76
  141. data/lib/project_types/script/ui/printing_spinner.rb +1 -1
  142. data/lib/project_types/theme/cli.rb +3 -3
  143. data/lib/project_types/theme/commands/check.rb +3 -3
  144. data/lib/project_types/theme/commands/delete.rb +7 -7
  145. data/lib/project_types/theme/commands/init.rb +3 -3
  146. data/lib/project_types/theme/commands/language_server.rb +2 -2
  147. data/lib/project_types/theme/commands/package.rb +2 -2
  148. data/lib/project_types/theme/commands/publish.rb +5 -5
  149. data/lib/project_types/theme/commands/pull.rb +15 -9
  150. data/lib/project_types/theme/commands/push.rb +18 -12
  151. data/lib/project_types/theme/commands/serve.rb +4 -4
  152. data/lib/project_types/theme/forms/confirm_store.rb +1 -1
  153. data/lib/project_types/theme/forms/select.rb +2 -2
  154. data/lib/{shopify-cli → shopify_cli}/admin_api/populate_resource_command.rb +3 -3
  155. data/lib/{shopify-cli → shopify_cli}/admin_api/schema.rb +4 -4
  156. data/lib/{shopify-cli → shopify_cli}/admin_api.rb +27 -27
  157. data/lib/{shopify-cli → shopify_cli}/api.rb +8 -8
  158. data/lib/shopify_cli/command/app_sub_command.rb +16 -0
  159. data/lib/{shopify-cli → shopify_cli}/command.rb +3 -3
  160. data/lib/{shopify-cli → shopify_cli}/commands/config.rb +14 -14
  161. data/lib/{shopify-cli → shopify_cli}/commands/help.rb +4 -4
  162. data/lib/{shopify-cli → shopify_cli}/commands/login.rb +7 -7
  163. data/lib/shopify_cli/commands/logout.rb +39 -0
  164. data/lib/{shopify-cli → shopify_cli}/commands/populate/customer.rb +4 -4
  165. data/lib/{shopify-cli → shopify_cli}/commands/populate/draft_order.rb +4 -4
  166. data/lib/{shopify-cli → shopify_cli}/commands/populate/product.rb +4 -4
  167. data/lib/shopify_cli/commands/populate.rb +23 -0
  168. data/lib/shopify_cli/commands/store.rb +15 -0
  169. data/lib/{shopify-cli → shopify_cli}/commands/switch.rb +5 -5
  170. data/lib/{shopify-cli → shopify_cli}/commands/system.rb +10 -10
  171. data/lib/shopify_cli/commands/version.rb +15 -0
  172. data/lib/{shopify-cli → shopify_cli}/commands/whoami.rb +7 -7
  173. data/lib/shopify_cli/commands.rb +34 -0
  174. data/lib/{shopify-cli → shopify_cli}/connect.rb +3 -3
  175. data/lib/shopify_cli/constants.rb +54 -0
  176. data/lib/{shopify-cli → shopify_cli}/context.rb +6 -6
  177. data/lib/{shopify-cli → shopify_cli}/core/entry_point.rb +7 -7
  178. data/lib/{shopify-cli → shopify_cli}/core/executor.rb +8 -4
  179. data/lib/{shopify-cli → shopify_cli}/core/finalize.rb +1 -1
  180. data/lib/{shopify-cli → shopify_cli}/core/help_resolver.rb +2 -2
  181. data/lib/{shopify-cli → shopify_cli}/core/monorail.rb +8 -8
  182. data/lib/shopify_cli/core.rb +8 -0
  183. data/lib/{shopify-cli → shopify_cli}/db.rb +8 -8
  184. data/lib/shopify_cli/environment.rb +91 -0
  185. data/lib/shopify_cli/exception_reporter/permission_controller.rb +54 -0
  186. data/lib/shopify_cli/exception_reporter.rb +55 -0
  187. data/lib/{shopify-cli → shopify_cli}/feature.rb +8 -8
  188. data/lib/{shopify-cli → shopify_cli}/form.rb +2 -2
  189. data/lib/{shopify-cli → shopify_cli}/git.rb +38 -8
  190. data/lib/{shopify-cli → shopify_cli}/helpers/haikunator.rb +1 -1
  191. data/lib/shopify_cli/helpers.rb +5 -0
  192. data/lib/{shopify-cli → shopify_cli}/heroku.rb +38 -13
  193. data/lib/{shopify-cli → shopify_cli}/http_request.rb +1 -1
  194. data/lib/{shopify-cli → shopify_cli}/identity_auth/servlet.rb +1 -1
  195. data/lib/{shopify-cli → shopify_cli}/identity_auth.rb +24 -31
  196. data/lib/{shopify-cli → shopify_cli}/js_deps.rb +7 -7
  197. data/lib/{shopify-cli → shopify_cli}/js_system.rb +10 -10
  198. data/lib/{shopify-cli → shopify_cli}/lazy_delegator.rb +2 -2
  199. data/lib/{shopify-cli → shopify_cli}/messages/messages.rb +44 -2
  200. data/lib/{shopify-cli → shopify_cli}/method_object.rb +15 -8
  201. data/lib/shopify_cli/migrator/migration.rb +27 -0
  202. data/lib/shopify_cli/migrator/migrations/1631709766_noop.rb +13 -0
  203. data/lib/shopify_cli/migrator.rb +48 -0
  204. data/lib/{shopify-cli → shopify_cli}/options.rb +1 -1
  205. data/lib/{shopify-cli → shopify_cli}/packager.rb +8 -8
  206. data/lib/{shopify-cli → shopify_cli}/partners_api/organizations.rb +1 -1
  207. data/lib/{shopify-cli → shopify_cli}/partners_api.rb +16 -40
  208. data/lib/shopify_cli/php_deps.rb +102 -0
  209. data/lib/{shopify-cli → shopify_cli}/process_supervision.rb +23 -21
  210. data/lib/{shopify-cli → shopify_cli}/project.rb +15 -15
  211. data/lib/{shopify-cli → shopify_cli}/project_commands.rb +3 -3
  212. data/lib/{shopify-cli → shopify_cli}/project_type.rb +5 -5
  213. data/lib/{shopify-cli → shopify_cli}/resolve_constant.rb +5 -5
  214. data/lib/{shopify-cli → shopify_cli}/resources/env_file.rb +1 -1
  215. data/lib/shopify_cli/resources.rb +5 -0
  216. data/lib/{shopify-cli → shopify_cli}/result.rb +11 -11
  217. data/lib/{shopify-cli → shopify_cli}/shopifolk.rb +6 -6
  218. data/lib/{shopify-cli → shopify_cli}/sub_command.rb +1 -1
  219. data/lib/{shopify-cli → shopify_cli}/task.rb +1 -1
  220. data/lib/{shopify-cli → shopify_cli}/tasks/confirm_store.rb +3 -3
  221. data/lib/{shopify-cli → shopify_cli}/tasks/create_api_client.rb +4 -4
  222. data/lib/shopify_cli/tasks/ensure_authenticated.rb +13 -0
  223. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_dev_store.rb +5 -5
  224. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_env.rb +3 -3
  225. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_loopback_url.rb +4 -4
  226. data/lib/{shopify-cli → shopify_cli}/tasks/ensure_project_type.rb +3 -3
  227. data/lib/{shopify-cli → shopify_cli}/tasks/select_org_and_shop.rb +8 -8
  228. data/lib/{shopify-cli → shopify_cli}/tasks/update_dashboard_urls.rb +6 -6
  229. data/lib/{shopify-cli → shopify_cli}/tasks.rb +10 -10
  230. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/certificate_manager.rb +5 -5
  231. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/header_hash.rb +5 -1
  232. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/hot-reload.js +0 -0
  233. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/hot_reload.rb +5 -6
  234. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/local_assets.rb +1 -1
  235. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/proxy.rb +15 -3
  236. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/sse.rb +1 -1
  237. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/watcher.rb +1 -1
  238. data/lib/{shopify-cli → shopify_cli}/theme/dev_server/web_server.rb +1 -1
  239. data/lib/{shopify-cli → shopify_cli}/theme/dev_server.rb +3 -3
  240. data/lib/shopify_cli/theme/development_theme.rb +83 -0
  241. data/lib/{shopify-cli → shopify_cli}/theme/file.rb +12 -4
  242. data/lib/{shopify-cli → shopify_cli}/theme/ignore_filter.rb +8 -1
  243. data/lib/{shopify-cli → shopify_cli}/theme/mime_type.rb +1 -1
  244. data/lib/{shopify-cli → shopify_cli}/theme/syncer.rb +7 -7
  245. data/lib/{shopify-cli → shopify_cli}/theme/theme.rb +4 -4
  246. data/lib/{shopify-cli → shopify_cli}/transform_data_structure.rb +4 -4
  247. data/lib/{shopify-cli → shopify_cli}/tunnel.rb +14 -14
  248. data/lib/shopify_cli/version.rb +3 -0
  249. data/lib/shopify_cli.rb +61 -50
  250. data/shopify-cli.gemspec +13 -5
  251. data/utilities/docker.rb +47 -0
  252. data/utilities/utilities.rb +5 -0
  253. metadata +155 -97
  254. data/.github/workflows/build.yml +0 -28
  255. data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +0 -73
  256. data/lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb +0 -60
  257. data/lib/shopify-cli/commands/logout.rb +0 -39
  258. data/lib/shopify-cli/commands/populate.rb +0 -23
  259. data/lib/shopify-cli/commands/store.rb +0 -15
  260. data/lib/shopify-cli/commands/version.rb +0 -15
  261. data/lib/shopify-cli/commands.rb +0 -34
  262. data/lib/shopify-cli/core.rb +0 -8
  263. data/lib/shopify-cli/helpers.rb +0 -5
  264. data/lib/shopify-cli/resources.rb +0 -5
  265. data/lib/shopify-cli/tasks/ensure_authenticated.rb +0 -13
  266. data/lib/shopify-cli/theme/development_theme.rb +0 -69
  267. data/lib/shopify-cli/version.rb +0 -3
@@ -1,21 +1,21 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  module Commands
5
5
  class Populate
6
- class Product < ShopifyCli::AdminAPI::PopulateResourceCommand
6
+ class Product < ShopifyCLI::AdminAPI::PopulateResourceCommand
7
7
  @input_type = :ProductInput
8
8
 
9
9
  def defaults
10
10
  {
11
- title: ShopifyCli::Helpers::Haikunator.title,
11
+ title: ShopifyCLI::Helpers::Haikunator.title,
12
12
  variants: [{ price: price }],
13
13
  }
14
14
  end
15
15
 
16
16
  def message(data)
17
17
  ret = data["productCreate"]["product"]
18
- id = ShopifyCli::API.gid_to_id(ret["id"])
18
+ id = ShopifyCLI::API.gid_to_id(ret["id"])
19
19
  @ctx.message("core.populate.product.added", ret["title"], @shop, admin_url, id)
20
20
  end
21
21
  end
@@ -0,0 +1,23 @@
1
+ require "shopify_cli"
2
+
3
+ module ShopifyCLI
4
+ module Commands
5
+ class Populate < ShopifyCLI::Command
6
+ subcommand :Customer, "customers", "shopify_cli/commands/populate/customer"
7
+ subcommand :DraftOrder, "draftorders", "shopify_cli/commands/populate/draft_order"
8
+ subcommand :Product, "products", "shopify_cli/commands/populate/product"
9
+
10
+ def call(_args, _name)
11
+ @ctx.puts(self.class.help)
12
+ end
13
+
14
+ def self.help
15
+ ShopifyCLI::Context.message("core.populate.help", ShopifyCLI::TOOL_NAME)
16
+ end
17
+
18
+ def self.extended_help
19
+ ShopifyCLI::Context.message("core.populate.extended_help", ShopifyCLI::TOOL_NAME)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ require "shopify_cli"
2
+
3
+ module ShopifyCLI
4
+ module Commands
5
+ class Store < ShopifyCLI::Command
6
+ def call(_args, _name)
7
+ @ctx.puts(@ctx.message("core.store.shop", ShopifyCLI::AdminAPI.get_shop_or_abort(@ctx)))
8
+ end
9
+
10
+ def self.help
11
+ ShopifyCLI::Context.message("core.store.help", ShopifyCLI::TOOL_NAME)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,8 +1,8 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  module Commands
5
- class Switch < ShopifyCli::Command
5
+ class Switch < ShopifyCLI::Command
6
6
  options do |parser, flags|
7
7
  parser.on("--store=STORE") { |url| flags[:shop] = url }
8
8
  # backwards compatibility allow 'shop' for now
@@ -18,11 +18,11 @@ module ShopifyCli
18
18
  shop = if options.flags[:shop]
19
19
  Login.validate_shop(options.flags[:shop])
20
20
  elsif (org_id = DB.get(:organization_id))
21
- res = ShopifyCli::Tasks::SelectOrgAndShop.call(@ctx, organization_id: org_id)
21
+ res = ShopifyCLI::Tasks::SelectOrgAndShop.call(@ctx, organization_id: org_id)
22
22
  res[:shop_domain]
23
23
  else
24
24
  AdminAPI.get_shop_or_abort(@ctx)
25
- res = ShopifyCli::Tasks::SelectOrgAndShop.call(@ctx)
25
+ res = ShopifyCLI::Tasks::SelectOrgAndShop.call(@ctx)
26
26
  res[:shop_domain]
27
27
  end
28
28
  DB.set(shop: shop)
@@ -32,7 +32,7 @@ module ShopifyCli
32
32
  end
33
33
 
34
34
  def self.help
35
- ShopifyCli::Context.message("core.switch.help", ShopifyCli::TOOL_NAME)
35
+ ShopifyCLI::Context.message("core.switch.help", ShopifyCLI::TOOL_NAME)
36
36
  end
37
37
  end
38
38
  end
@@ -1,9 +1,9 @@
1
1
  require "shopify_cli"
2
2
  require "rbconfig"
3
3
 
4
- module ShopifyCli
4
+ module ShopifyCLI
5
5
  module Commands
6
- class System < ShopifyCli::Command
6
+ class System < ShopifyCLI::Command
7
7
  hidden_feature(feature_set: :debug)
8
8
 
9
9
  def call(args, _name)
@@ -28,7 +28,7 @@ module ShopifyCli
28
28
  end
29
29
 
30
30
  def self.help
31
- ShopifyCli::Context.message("core.system.help", ShopifyCli::TOOL_NAME)
31
+ ShopifyCLI::Context.message("core.system.help", ShopifyCLI::TOOL_NAME)
32
32
  end
33
33
 
34
34
  private
@@ -50,21 +50,21 @@ module ShopifyCli
50
50
 
51
51
  @ctx.puts(@ctx.message("core.system.header"))
52
52
  cli_constants.each do |s|
53
- @ctx.puts(" " + @ctx.message("core.system.const", s, ShopifyCli.const_get(s.to_sym)) + "\n")
53
+ @ctx.puts(" " + @ctx.message("core.system.const", s, ShopifyCLI.const_get(s.to_sym)) + "\n")
54
54
  end
55
55
 
56
56
  if show_all_details
57
57
  cli_path_methods.each do |m|
58
- @ctx.puts(" " + @ctx.message("core.system.const", m.upcase, ShopifyCli.send(m)) + "\n")
58
+ @ctx.puts(" " + @ctx.message("core.system.const", m.upcase, ShopifyCLI.send(m)) + "\n")
59
59
  end
60
60
  end
61
61
  end
62
62
 
63
63
  def display_shopify_store(_show_all_details)
64
- shop = if ShopifyCli::DB.exists?(:shop)
65
- ShopifyCli::AdminAPI.get_shop_or_abort(@ctx)
64
+ shop = if ShopifyCLI::DB.exists?(:shop)
65
+ ShopifyCLI::AdminAPI.get_shop_or_abort(@ctx)
66
66
  else
67
- @ctx.message("core.populate.error.no_shop", ShopifyCli::TOOL_NAME)
67
+ @ctx.message("core.populate.error.no_shop", ShopifyCLI::TOOL_NAME)
68
68
  end
69
69
 
70
70
  @ctx.puts("\n" + @ctx.message("core.system.shop_header"))
@@ -96,7 +96,7 @@ module ShopifyCli
96
96
  end
97
97
 
98
98
  def display_ngrok
99
- ngrok_location = File.join(ShopifyCli.cache_dir, "ngrok#{@ctx.executable_file_extension}")
99
+ ngrok_location = File.join(ShopifyCLI.cache_dir, "ngrok#{@ctx.executable_file_extension}")
100
100
  if File.exist?(ngrok_location)
101
101
  @ctx.puts(" " + @ctx.message("core.system.ngrok_available", ngrok_location))
102
102
  else
@@ -154,7 +154,7 @@ module ShopifyCli
154
154
  end
155
155
 
156
156
  def display_shopify_staff_identity
157
- is_shopifolk = ShopifyCli::Shopifolk.check
157
+ is_shopifolk = ShopifyCLI::Shopifolk.check
158
158
  if is_shopifolk
159
159
  @ctx.puts("\n" + @ctx.message("core.system.identity_header"))
160
160
  @ctx.puts(" " + @ctx.message("core.system.identity_is_shopifolk"))
@@ -0,0 +1,15 @@
1
+ require "shopify_cli"
2
+
3
+ module ShopifyCLI
4
+ module Commands
5
+ class Version < ShopifyCLI::Command
6
+ def self.help
7
+ ShopifyCLI::Context.message("core.version.help", ShopifyCLI::TOOL_NAME)
8
+ end
9
+
10
+ def call(_args, _name)
11
+ @ctx.puts(ShopifyCLI::VERSION.to_s)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,15 +1,15 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  module Commands
5
- class Whoami < ShopifyCli::Command
5
+ class Whoami < ShopifyCLI::Command
6
6
  def call(_args, _name)
7
- shop = ShopifyCli::DB.get(:shop)
8
- org_id = ShopifyCli::DB.get(:organization_id)
9
- org = ShopifyCli::PartnersAPI::Organizations.fetch(@ctx, id: org_id) unless org_id.nil?
7
+ shop = ShopifyCLI::DB.get(:shop)
8
+ org_id = ShopifyCLI::DB.get(:organization_id)
9
+ org = ShopifyCLI::PartnersAPI::Organizations.fetch(@ctx, id: org_id) unless org_id.nil?
10
10
 
11
11
  output = if shop.nil? && org.nil?
12
- @ctx.message("core.whoami.not_logged_in", ShopifyCli::TOOL_NAME)
12
+ @ctx.message("core.whoami.not_logged_in", ShopifyCLI::TOOL_NAME)
13
13
  elsif !shop.nil? && org.nil?
14
14
  @ctx.message("core.whoami.logged_in_shop_only", shop)
15
15
  elsif shop.nil? && !org.nil?
@@ -21,7 +21,7 @@ module ShopifyCli
21
21
  end
22
22
 
23
23
  def self.help
24
- ShopifyCli::Context.message("core.whoami.help", ShopifyCli::TOOL_NAME)
24
+ ShopifyCLI::Context.message("core.whoami.help", ShopifyCLI::TOOL_NAME)
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,34 @@
1
+ require "shopify_cli"
2
+
3
+ module ShopifyCLI
4
+ module Commands
5
+ Registry = CLI::Kit::CommandRegistry.new(
6
+ default: "help",
7
+ contextual_resolver: nil,
8
+ )
9
+ @core_commands = []
10
+
11
+ def self.register(const, cmd, path = nil, is_core = false)
12
+ autoload(const, path) if path
13
+ Registry.add(->() { const_get(const) }, cmd)
14
+ @core_commands.push(cmd) if is_core
15
+ end
16
+
17
+ def self.core_command?(cmd)
18
+ @core_commands.include?(cmd)
19
+ end
20
+
21
+ register :Config, "config", "shopify_cli/commands/config", true
22
+ register :Help, "help", "shopify_cli/commands/help", true
23
+ register :Login, "login", "shopify_cli/commands/login", true
24
+ register :Logout, "logout", "shopify_cli/commands/logout", true
25
+ register :Populate, "populate", "shopify_cli/commands/populate", true
26
+ register :Store, "store", "shopify_cli/commands/store", true
27
+ register :Switch, "switch", "shopify_cli/commands/switch", true
28
+ register :System, "system", "shopify_cli/commands/system", true
29
+ register :Version, "version", "shopify_cli/commands/version", true
30
+ register :Whoami, "whoami", "shopify_cli/commands/whoami", true
31
+
32
+ autoload :Connect, "shopify_cli/commands/connect"
33
+ end
34
+ end
@@ -1,6 +1,6 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  class Connect
5
5
  def initialize(ctx)
6
6
  @ctx = ctx
@@ -10,14 +10,14 @@ module ShopifyCli
10
10
  if Project.current&.env
11
11
  @ctx.puts(@ctx.message("core.connect.already_connected_warning"))
12
12
  end
13
- org = ShopifyCli::Tasks::EnsureEnv.call(@ctx, regenerate: true)
13
+ org = ShopifyCLI::Tasks::EnsureEnv.call(@ctx, regenerate: true)
14
14
  write_cli_yml(project_type, org["id"]) unless Project.has_current?
15
15
  api_key = Project.current(force_reload: true).env["api_key"]
16
16
  get_app(org["apps"], api_key).first["title"]
17
17
  end
18
18
 
19
19
  def write_cli_yml(project_type, org_id)
20
- ShopifyCli::Project.write(
20
+ ShopifyCLI::Project.write(
21
21
  @ctx,
22
22
  project_type: project_type,
23
23
  organization_id: org_id,
@@ -0,0 +1,54 @@
1
+ module ShopifyCLI
2
+ module Constants
3
+ module Paths
4
+ ROOT = File.expand_path("../..", __dir__)
5
+ end
6
+
7
+ module StoreKeys
8
+ LAST_MIGRATION_DATE = :last_migration_date
9
+ ANALYTICS_ENABLED = :analytics_enabled
10
+ end
11
+
12
+ module Bugsnag
13
+ API_KEY = "773b0c801eb40c20d8928be5b7c739bd"
14
+ end
15
+
16
+ module Config
17
+ module Sections
18
+ module ErrorTracking
19
+ NAME = "error-tracking"
20
+ module Fields
21
+ AUTOMATIC_REPORTING = "automatic-reporting"
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ module EnvironmentVariables
28
+ STACKTRACE = "SHOPIFY_CLI_STACKTRACE"
29
+
30
+ # When true the CLI points to a local instance of
31
+ # the partners dashboard and identity.
32
+ LOCAL_PARTNERS = "SHOPIFY_APP_CLI_LOCAL_PARTNERS"
33
+
34
+ # When true the CLI points to a spin instance of spin
35
+ SPIN_PARTNERS = "SHOPIFY_APP_CLI_SPIN_PARTNERS"
36
+ SPIN_WORKSPACE = "SPIN_WORKSPACE"
37
+ SPIN_NAMESPACE = "SPIN_NAMESPACE"
38
+ SPIN_HOST = "SPIN_HOST"
39
+
40
+ # Environments
41
+ TEST = "SHOPIFY_CLI_TEST"
42
+ DEVELOPMENT = "SHOPIFY_CLI_DEVELOPMENT"
43
+ end
44
+
45
+ module Identity
46
+ CLIENT_ID_DEV = "e5380e02-312a-7408-5718-e07017e9cf52"
47
+ CLIENT_ID = "fbdb2649-e327-4907-8f67-908d24cfd7e3"
48
+ end
49
+
50
+ module Links
51
+ NEW_ISSUE = "https://github.com/Shopify/shopify-cli/issues/new"
52
+ end
53
+ end
54
+ end
@@ -5,7 +5,7 @@ require "rbconfig"
5
5
  require "net/http"
6
6
  require "json"
7
7
 
8
- module ShopifyCli
8
+ module ShopifyCLI
9
9
  ##
10
10
  # Context captures a lot about the current running command. It captures the
11
11
  # environment, output, system and file operations. It is useful to have the
@@ -97,7 +97,7 @@ module ShopifyCli
97
97
  # See `#development?` for checking for development environment.
98
98
  #
99
99
  def system?
100
- !Dir.exist?(File.join(ShopifyCli::ROOT, "test"))
100
+ !Dir.exist?(File.join(ShopifyCLI::ROOT, "test"))
101
101
  end
102
102
 
103
103
  # will return true if the cli is running on your development instance.
@@ -382,7 +382,7 @@ module ShopifyCli
382
382
  # * `text` - a string message to output
383
383
  #
384
384
  def abort(text)
385
- raise ShopifyCli::Abort, "{{x}} #{text}"
385
+ raise ShopifyCLI::Abort, "{{x}} #{text}"
386
386
  end
387
387
 
388
388
  # outputs a message, prefixed by a red `DEBUG` tag. This will only output to
@@ -559,7 +559,7 @@ module ShopifyCli
559
559
  if (time_of_last_check + VERSION_CHECK_INTERVAL) < (now = Time.now.to_i)
560
560
  update_time_of_last_check(now)
561
561
  latest_version = retrieve_latest_gem_version
562
- latest_version unless latest_version == ShopifyCli::VERSION
562
+ latest_version unless latest_version == ShopifyCLI::VERSION
563
563
  end
564
564
  end
565
565
 
@@ -600,11 +600,11 @@ module ShopifyCli
600
600
  end
601
601
 
602
602
  def time_of_last_check
603
- (val = ShopifyCli::Config.get(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD)) ? val.to_i : 0
603
+ (val = ShopifyCLI::Config.get(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD)) ? val.to_i : 0
604
604
  end
605
605
 
606
606
  def update_time_of_last_check(time)
607
- ShopifyCli::Config.set(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD, time)
607
+ ShopifyCLI::Config.set(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD, time)
608
608
  end
609
609
  end
610
610
  end
@@ -1,26 +1,26 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  module Core
5
5
  module EntryPoint
6
6
  class << self
7
7
  def call(args, ctx = Context.new)
8
8
  if ctx.development?
9
9
  ctx.warn(
10
- ctx.message("core.warning.development_version", File.join(ShopifyCli::ROOT, "bin", ShopifyCli::TOOL_NAME))
10
+ ctx.message("core.warning.development_version", File.join(ShopifyCLI::ROOT, "bin", ShopifyCLI::TOOL_NAME))
11
11
  )
12
12
  elsif !ctx.testing?
13
13
  new_version = ctx.new_version
14
- ctx.warn(ctx.message("core.warning.new_version", ShopifyCli::VERSION, new_version)) unless new_version.nil?
14
+ ctx.warn(ctx.message("core.warning.new_version", ShopifyCLI::VERSION, new_version)) unless new_version.nil?
15
15
  end
16
16
 
17
17
  ProjectType.load_all
18
18
 
19
- task_registry = ShopifyCli::Tasks::Registry
19
+ task_registry = ShopifyCLI::Tasks::Registry
20
20
 
21
- command, command_name, args = ShopifyCli::Resolver.call(args)
22
- executor = ShopifyCli::Core::Executor.new(ctx, task_registry, log_file: ShopifyCli.log_file)
23
- ShopifyCli::Core::Monorail.log(command_name, args) do
21
+ command, command_name, args = ShopifyCLI::Resolver.call(args)
22
+ executor = ShopifyCLI::Core::Executor.new(ctx, task_registry, log_file: ShopifyCLI.log_file)
23
+ ShopifyCLI::Core::Monorail.log(command_name, args) do
24
24
  executor.call(command, command_name, args)
25
25
  end
26
26
  end
@@ -1,18 +1,22 @@
1
1
  require "shopify_cli"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  module Core
5
5
  class Executor < CLI::Kit::Executor
6
6
  def initialize(ctx, task_registry, *args, **kwargs)
7
- @ctx = ctx || ShopifyCli::Context.new
8
- @task_registry = task_registry || ShopifyCli::Tasks::TaskRegistry.new
7
+ @ctx = ctx || ShopifyCLI::Context.new
8
+ @task_registry = task_registry || ShopifyCLI::Tasks::TaskRegistry.new
9
9
  super(*args, **kwargs)
10
10
  end
11
11
 
12
12
  def call(command, command_name, args)
13
13
  command.task_registry = @task_registry
14
14
  command.ctx = @ctx
15
- super
15
+ with_traps do
16
+ with_logging do |_id|
17
+ command.call(args, command_name)
18
+ end
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -1,4 +1,4 @@
1
- module ShopifyCli
1
+ module ShopifyCLI
2
2
  module Core
3
3
  # This class is just a dummy to make sure that we don't trigger warnings on the first time the updated code runs.
4
4
  # The old code would try to call the Finalizer after it is done updating, which would then trigger an autoload of
@@ -1,6 +1,6 @@
1
1
  require "cli/kit"
2
2
 
3
- module ShopifyCli
3
+ module ShopifyCLI
4
4
  module Core
5
5
  class HelpResolver < CLI::Kit::Resolver
6
6
  def call(args)
@@ -10,7 +10,7 @@ module ShopifyCli
10
10
  help = Commands::Help
11
11
  help.ctx = Context.new
12
12
  help.call([], nil)
13
- raise ShopifyCli::AbortSilent
13
+ raise ShopifyCLI::AbortSilent
14
14
  else
15
15
  super(args)
16
16
  end
@@ -3,7 +3,7 @@ require "net/http"
3
3
  require "time"
4
4
  require "rbconfig"
5
5
 
6
- module ShopifyCli
6
+ module ShopifyCLI
7
7
  module Core
8
8
  module Monorail
9
9
  ENDPOINT_URI = URI.parse("https://monorail-edge.shopifycloud.com/v1/produce")
@@ -50,16 +50,16 @@ module ShopifyCli
50
50
  end
51
51
 
52
52
  def consented?
53
- ShopifyCli::Config.get_bool("analytics", "enabled")
53
+ ShopifyCLI::Config.get_bool("analytics", "enabled")
54
54
  end
55
55
 
56
56
  def prompt_for_consent
57
57
  return if Context.new.ci?
58
58
  return unless enabled?
59
- return if ShopifyCli::Config.get_section("analytics").key?("enabled")
59
+ return if ShopifyCLI::Config.get_section("analytics").key?("enabled")
60
60
  msg = Context.message("core.monorail.consent_prompt")
61
61
  opt = CLI::UI::Prompt.confirm(msg)
62
- ShopifyCli::Config.set("analytics", "enabled", opt)
62
+ ShopifyCLI::Config.set("analytics", "enabled", opt)
63
63
  end
64
64
 
65
65
  def send_event(start_time, commands, args, err = nil)
@@ -100,12 +100,12 @@ module ShopifyCli
100
100
  success: err.nil?,
101
101
  error_message: err,
102
102
  uname: RbConfig::CONFIG["host"],
103
- cli_version: ShopifyCli::VERSION,
103
+ cli_version: ShopifyCLI::VERSION,
104
104
  ruby_version: RUBY_VERSION,
105
- is_employee: ShopifyCli::Shopifolk.acting_as_shopify_organization?,
105
+ is_employee: ShopifyCLI::Shopifolk.acting_as_shopify_organization?,
106
106
  }.tap do |payload|
107
107
  payload[:api_key] = metadata.delete(:api_key)
108
- payload[:partner_id] = metadata.delete(:organization_id) || ShopifyCli::DB.get(:organization_id)
108
+ payload[:partner_id] = metadata.delete(:organization_id) || ShopifyCLI::DB.get(:organization_id)
109
109
  if Project.has_current?
110
110
  project = Project.current(force_reload: true)
111
111
  payload[:api_key] = project.env&.api_key
@@ -117,7 +117,7 @@ module ShopifyCli
117
117
  end
118
118
 
119
119
  def project_type_from_dir_or_cmd(command)
120
- Project.current_project_type || (command unless ShopifyCli::Commands.core_command?(command)) || nil
120
+ Project.current_project_type || (command unless ShopifyCLI::Commands.core_command?(command)) || nil
121
121
  end
122
122
  end
123
123
  end
@@ -0,0 +1,8 @@
1
+ module ShopifyCLI
2
+ module Core
3
+ autoload :EntryPoint, "shopify_cli/core/entry_point"
4
+ autoload :Executor, "shopify_cli/core/executor"
5
+ autoload :HelpResolver, "shopify_cli/core/help_resolver"
6
+ autoload :Monorail, "shopify_cli/core/monorail"
7
+ end
8
+ end
@@ -1,7 +1,7 @@
1
1
  require "pstore"
2
2
  require "forwardable"
3
3
 
4
- module ShopifyCli
4
+ module ShopifyCLI
5
5
  # Persists transient data like access tokens that may be cleared
6
6
  # when user clears their session
7
7
  #
@@ -14,7 +14,7 @@ module ShopifyCli
14
14
 
15
15
  attr_reader :db # :nodoc:
16
16
 
17
- def initialize(path: File.join(ShopifyCli.cache_dir, ".db.pstore")) # :nodoc:
17
+ def initialize(path: File.join(ShopifyCLI.cache_dir, ".db.pstore")) # :nodoc:
18
18
  @db = PStore.new(path)
19
19
  end
20
20
 
@@ -25,7 +25,7 @@ module ShopifyCli
25
25
  #
26
26
  # #### Usage
27
27
  #
28
- # ShopifyCli::DB.keys
28
+ # ShopifyCLI::DB.keys
29
29
  #
30
30
  def keys
31
31
  db.transaction(true) { db.roots }
@@ -42,7 +42,7 @@ module ShopifyCli
42
42
  #
43
43
  # #### Usage
44
44
  #
45
- # exists = ShopifyCli::DB.exists?('shopify_exchange_token')
45
+ # exists = ShopifyCLI::DB.exists?('shopify_exchange_token')
46
46
  #
47
47
  def exists?(key)
48
48
  db.transaction(true) { db.root?(key) }
@@ -55,7 +55,7 @@ module ShopifyCli
55
55
  #
56
56
  # #### Usage
57
57
  #
58
- # ShopifyCli::DB.set(shopify_exchange_token: 'token', metric_consent: true)
58
+ # ShopifyCLI::DB.set(shopify_exchange_token: 'token', metric_consent: true)
59
59
  #
60
60
  def set(**args)
61
61
  db.transaction do
@@ -80,7 +80,7 @@ module ShopifyCli
80
80
  #
81
81
  # #### Usage
82
82
  #
83
- # ShopifyCli::DB.get(:shopify_exchange_token)
83
+ # ShopifyCLI::DB.get(:shopify_exchange_token)
84
84
  #
85
85
  def get(key)
86
86
  val = db.transaction(true) { db[key] }
@@ -95,7 +95,7 @@ module ShopifyCli
95
95
  #
96
96
  # #### Usage
97
97
  #
98
- # ShopifyCli::DB.del(:shopify_exchange_token)
98
+ # ShopifyCLI::DB.del(:shopify_exchange_token)
99
99
  #
100
100
  def del(*args)
101
101
  db.transaction { args.each { |key| db.delete(key) } }
@@ -105,7 +105,7 @@ module ShopifyCli
105
105
  #
106
106
  # #### Usage
107
107
  #
108
- # ShopifyCli::DB.clear
108
+ # ShopifyCLI::DB.clear
109
109
  #
110
110
  def clear
111
111
  del(*keys)