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
@@ -43,10 +43,12 @@ module Extension
43
43
  end
44
44
 
45
45
  def choose_port?(context)
46
+ return true if supports_development_server?
46
47
  argo_runtime(context).supports?(:port)
47
48
  end
48
49
 
49
50
  def establish_tunnel?(context)
51
+ return true if supports_development_server?
50
52
  argo_runtime(context).supports?(:public_url)
51
53
  end
52
54
 
@@ -66,6 +68,8 @@ module Extension
66
68
  end
67
69
 
68
70
  def argo_runtime(context)
71
+ return if supports_development_server?
72
+
69
73
  @argo_runtime ||= Features::ArgoRuntime.find(
70
74
  cli_package: cli_package(context),
71
75
  identifier: identifier
@@ -76,7 +80,7 @@ module Extension
76
80
  cli_package_name = specification.features.argo&.cli_package_name
77
81
  return unless cli_package_name
78
82
 
79
- js_system = ShopifyCli::JsSystem.new(ctx: context)
83
+ js_system = ShopifyCLI::JsSystem.new(ctx: context)
80
84
  Tasks::FindNpmPackages.exactly_one_of(cli_package_name, js_system: js_system)
81
85
  .unwrap { |_e| context.abort(context.message("errors.package_not_found", cli_package_name)) }
82
86
  end
@@ -87,7 +91,7 @@ module Extension
87
91
  if (str = messages.dig(*key_parts))
88
92
  str % params
89
93
  else
90
- ShopifyCli::Context.message(key, *params)
94
+ ShopifyCLI::Context.message(key, *params)
91
95
  end
92
96
  end
93
97
 
@@ -99,6 +103,10 @@ module Extension
99
103
  raise NotImplementedError
100
104
  end
101
105
 
106
+ def server_config_file
107
+ "shopifile.yml"
108
+ end
109
+
102
110
  protected
103
111
 
104
112
  def argo
@@ -118,6 +126,10 @@ module Extension
118
126
  def messages
119
127
  @messages ||= Messages::TYPES[identifier.downcase.to_sym] || {}
120
128
  end
129
+
130
+ def supports_development_server?
131
+ Models::DevelopmentServerRequirements.supported?(identifier)
132
+ end
121
133
  end
122
134
  end
123
135
  end
@@ -15,7 +15,7 @@ module Extension
15
15
  context.root = File.join(context.root, directory_name)
16
16
 
17
17
  if getting_started
18
- ShopifyCli::Git.clone("https://github.com/Shopify/theme-extension-getting-started", context.root)
18
+ ShopifyCLI::Git.clone("https://github.com/Shopify/theme-extension-getting-started", context.root)
19
19
  context.rm_r(".git")
20
20
  else
21
21
  FileUtils.makedirs(SUPPORTED_BUCKETS.map { |b| File.join(context.root, b) })
@@ -5,7 +5,7 @@ module Extension
5
5
 
6
6
  property! :custom_handler_root,
7
7
  accepts: ->(d) { File.directory?(d) },
8
- default: -> { File.expand_path("lib/project_types/extension/models/specification_handlers", ShopifyCli::ROOT) }
8
+ default: -> { File.expand_path("lib/project_types/extension/models/specification_handlers", ShopifyCLI::ROOT) }
9
9
 
10
10
  property! :custom_handler_namespace,
11
11
  accepts: ->(m) { m.respond_to?(:const_get) },
@@ -39,9 +39,9 @@ module Extension
39
39
  private
40
40
 
41
41
  def fetch_specifications_and_build_handlers
42
- ShopifyCli::Result
42
+ ShopifyCLI::Result
43
43
  .call(&fetch_specifications)
44
- .map(&ShopifyCli::TransformDataStructure.new(symbolize_keys: true, underscore_keys: true))
44
+ .map(&ShopifyCLI::TransformDataStructure.new(symbolize_keys: true, underscore_keys: true))
45
45
  .then(&method(:select_cli_extensions))
46
46
  .then(&Tasks::ConfigureFeatures)
47
47
  .then(&Tasks::ConfigureOptions)
@@ -61,7 +61,7 @@ module Extension
61
61
 
62
62
  def instantiate_specification_handlers(specifications)
63
63
  specifications.each_with_object({}) do |specification, handlers|
64
- ShopifyCli::ResolveConstant.call(specification.identifier, namespace: custom_handler_namespace)
64
+ ShopifyCLI::ResolveConstant.call(specification.identifier, namespace: custom_handler_namespace)
65
65
  .rescue { |error| error.is_a?(NameError) ? SpecificationHandlers::Default : raise(error) }
66
66
  .then { |handler_class| handler_class.new(specification) }
67
67
  .unwrap { |error| raise error }
@@ -5,11 +5,11 @@ require "socket"
5
5
  module Extension
6
6
  module Tasks
7
7
  class ChooseNextAvailablePort
8
- include ShopifyCli::MethodObject
8
+ include ShopifyCLI::MethodObject
9
9
 
10
10
  property! :from
11
11
  property! :to, default: -> { from + 10 }
12
- property! :host, default: "localhost"
12
+ property! :host, default: "127.0.0.1"
13
13
 
14
14
  def call
15
15
  available_port = port_range(from: from, to: to).find { |p| available?(host, p) }
@@ -1,7 +1,7 @@
1
1
  module Extension
2
2
  module Tasks
3
3
  class ConfigureFeatures
4
- include ShopifyCli::MethodObject
4
+ include ShopifyCLI::MethodObject
5
5
 
6
6
  class Error < RuntimeError; end
7
7
  class UnknownSurfaceArea < Error; end
@@ -1,7 +1,7 @@
1
1
  module Extension
2
2
  module Tasks
3
3
  class ConfigureOptions
4
- include ShopifyCli::MethodObject
4
+ include ShopifyCLI::MethodObject
5
5
 
6
6
  def call(specification_attribute_sets)
7
7
  specification_attribute_sets.each do |attributes|
@@ -12,7 +12,7 @@ module Extension
12
12
  variant = hash.dig(*VARIANT_PATH)
13
13
  return unless variant
14
14
  Models::Product.new(
15
- variant_id: ShopifyCli::API.gid_to_id(variant)
15
+ variant_id: ShopifyCLI::API.gid_to_id(variant)
16
16
  )
17
17
  end
18
18
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ require "shopify_cli"
3
+
4
+ module Extension
5
+ module Tasks
6
+ module Converters
7
+ module ServerConfigConverter
8
+ def self.from_hash(hash, type)
9
+ context.abort(context.message("tasks.errors.parse_error")) if hash.nil?
10
+
11
+ project = ExtensionProject.current
12
+
13
+ extension = Models::ServerConfig::Extension.new(
14
+ uuid: project.registration_uuid,
15
+ type: type.upcase,
16
+ user: Models::ServerConfig::User.new,
17
+ development: Models::ServerConfig::Development.new(
18
+ build_dir: hash.dig("development", "build_dir"),
19
+ renderer: Models::ServerConfig::DevelopmentRenderer.find(type),
20
+ entries: Models::ServerConfig::DevelopmentEntries.new(
21
+ main: hash.dig("development", "entries", "main")
22
+ )
23
+ )
24
+ )
25
+
26
+ Models::ServerConfig::Root.new(extensions: [extension])
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -3,7 +3,7 @@ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
- class CreateExtension < ShopifyCli::Task
6
+ class CreateExtension < ShopifyCLI::Task
7
7
  include UserErrors
8
8
 
9
9
  GRAPHQL_FILE = "extension_create"
@@ -20,7 +20,7 @@ module Extension
20
20
  extension_context: extension_context,
21
21
  }
22
22
 
23
- response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
23
+ response = ShopifyCLI::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
24
24
  context.abort(context.message("tasks.errors.parse_error")) if response.nil?
25
25
 
26
26
  abort_if_user_errors(context, response)
@@ -1,13 +1,13 @@
1
1
  module Extension
2
2
  module Tasks
3
3
  class FetchSpecifications
4
- include ShopifyCli::MethodObject
4
+ include ShopifyCLI::MethodObject
5
5
 
6
6
  property :context
7
7
  property :api_key
8
8
 
9
9
  def call
10
- response = ShopifyCli::PartnersAPI
10
+ response = ShopifyCLI::PartnersAPI
11
11
  .query(context, "fetch_specifications", api_key: api_key)
12
12
  .dig("data", "extensionSpecifications")
13
13
  context.abort(context.message("tasks.errors.parse_error")) if response.nil?
@@ -1,9 +1,9 @@
1
1
  module Extension
2
2
  module Tasks
3
3
  class FindNpmPackages
4
- include ShopifyCli::MethodObject
4
+ include ShopifyCLI::MethodObject
5
5
 
6
- property! :js_system, accepts: ShopifyCli::JsSystem
6
+ property! :js_system, accepts: ShopifyCLI::JsSystem
7
7
  property! :production_only, accepts: [true, false], default: false, reader: :production_only?
8
8
 
9
9
  def self.at_least_one_of(*package_names, **config)
@@ -69,7 +69,7 @@ module Extension
69
69
  raise ArgumentError, "Expected a list of package names"
70
70
  end
71
71
 
72
- ShopifyCli::Result
72
+ ShopifyCLI::Result
73
73
  .call(&method(:list_packages))
74
74
  .then(&method(:search_packages).curry[package_names])
75
75
  .then(&method(:filter_duplicates))
@@ -84,11 +84,11 @@ module Extension
84
84
  end
85
85
 
86
86
  def yarn_list
87
- production_only? ? %w[list --production] : %w[list]
87
+ production_only? ? %w[list --production --depth=0] : %w[list]
88
88
  end
89
89
 
90
90
  def npm_list
91
- production_only? ? %w[list --prod --depth=1] : %w[list --depth=1]
91
+ production_only? ? %w[list --prod --depth=0] : %w[list]
92
92
  end
93
93
 
94
94
  def search_packages(packages, package_list)
@@ -3,7 +3,7 @@ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
- class GetApp < ShopifyCli::Task
6
+ class GetApp < ShopifyCLI::Task
7
7
  GRAPHQL_FILE = "get_app_by_api_key"
8
8
 
9
9
  RESPONSE_FIELD = %w(data)
@@ -12,7 +12,7 @@ module Extension
12
12
  def call(context:, api_key:)
13
13
  input = { api_key: api_key }
14
14
 
15
- response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
15
+ response = ShopifyCLI::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
16
16
  context.abort(context.message("tasks.errors.parse_error")) if response.nil?
17
17
 
18
18
  Converters::AppConverter.from_hash(response.dig(APP_FIELD))
@@ -3,9 +3,9 @@ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
- class GetApps < ShopifyCli::Task
6
+ class GetApps < ShopifyCLI::Task
7
7
  def call(context:)
8
- organizations = ShopifyCli::PartnersAPI::Organizations.fetch_with_app(context)
8
+ organizations = ShopifyCLI::PartnersAPI::Organizations.fetch_with_app(context)
9
9
  apps_from_organizations(organizations)
10
10
  end
11
11
 
@@ -3,9 +3,9 @@ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
- class GetExtensions < ShopifyCli::Task
6
+ class GetExtensions < ShopifyCLI::Task
7
7
  def call(context:, type:)
8
- organizations = ShopifyCli::PartnersAPI::Organizations.fetch_with_extensions(context, type)
8
+ organizations = ShopifyCLI::PartnersAPI::Organizations.fetch_with_extensions(context, type)
9
9
  extensions_from_organizations(organizations, context: context)
10
10
  end
11
11
 
@@ -3,12 +3,12 @@ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
- class GetProduct < ShopifyCli::Task
6
+ class GetProduct < ShopifyCLI::Task
7
7
  API_VERSION = "2021-07"
8
8
  GRAPHQL_FILE = "get_variant_id"
9
9
 
10
10
  def call(context, shop)
11
- response = ShopifyCli::AdminAPI.query(
11
+ response = ShopifyCLI::AdminAPI.query(
12
12
  context,
13
13
  GRAPHQL_FILE,
14
14
  shop: shop,
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ require "shopify_cli"
3
+ require "yaml"
4
+
5
+ module Extension
6
+ module Tasks
7
+ class LoadServerConfig < ShopifyCLI::Task
8
+ include SmartProperties
9
+
10
+ class << self
11
+ def call(file_name:, type:)
12
+ config = YAML.load_file(file_name)
13
+ Tasks::Converters::ServerConfigConverter.from_hash(config, type)
14
+ rescue Psych::SyntaxError => e
15
+ raise(
16
+ ShopifyCLI::Abort,
17
+ ShopifyCLI::Context.message("core.yaml.error.invalid", file_name, e.message)
18
+ )
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,81 @@
1
+
2
+ # frozen_string_literal: true
3
+ require "shopify_cli"
4
+
5
+ module Extension
6
+ module Tasks
7
+ class RunExtensionCommand < ShopifyCLI::Task
8
+ include SmartProperties
9
+
10
+ SUPPORTED_EXTENSION_TYPES = [
11
+ "checkout_ui_extension",
12
+ ]
13
+
14
+ SUPPORTED_COMMANDS = [
15
+ "create",
16
+ "build",
17
+ "serve",
18
+ ]
19
+
20
+ property! :command, accepts: SUPPORTED_COMMANDS
21
+ property! :type, accepts: SUPPORTED_EXTENSION_TYPES
22
+ property :context, accepts: ShopifyCLI::Context
23
+ property :config_file_name, accepts: String
24
+ property :port, accepts: Integer, default: 39351
25
+ property :root_dir, accepts: String
26
+ property :template, accepts: Models::ServerConfig::Development::VALID_TEMPLATES
27
+
28
+ def call
29
+ ShopifyCLI::Result.success(config_file_exists?)
30
+ .then(&method(:load_or_build_server_config))
31
+ .then(&method(:run_command))
32
+ .unwrap do |error|
33
+ raise error unless error.nil?
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def config_file_exists?
40
+ return false if config_file_name.nil?
41
+ project = ExtensionProject.current
42
+ File.exist?(File.join(project.directory, config_file_name))
43
+ end
44
+
45
+ def load_or_build_server_config(config_file_exists)
46
+ return load_server_config if config_file_exists
47
+ build_server_config
48
+ end
49
+
50
+ def load_server_config
51
+ Tasks::LoadServerConfig.call(
52
+ file_name: config_file_name,
53
+ type: type,
54
+ )
55
+ end
56
+
57
+ def build_server_config
58
+ extension = Models::ServerConfig::Extension.build(
59
+ template: template,
60
+ type: type,
61
+ root_dir: root_dir,
62
+ )
63
+
64
+ Models::ServerConfig::Root.new(port: port, extensions: [extension])
65
+ end
66
+
67
+ def run_command(server_config)
68
+ case command
69
+ when "create"
70
+ Models::DevelopmentServer.new.create(server_config)
71
+ when "build"
72
+ Models::DevelopmentServer.new.build(server_config)
73
+ when "serve"
74
+ Models::DevelopmentServer.new.serve(context, server_config)
75
+ else
76
+ raise NotImplementedError
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -3,7 +3,7 @@ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
- class UpdateDraft < ShopifyCli::Task
6
+ class UpdateDraft < ShopifyCLI::Task
7
7
  include UserErrors
8
8
 
9
9
  GRAPHQL_FILE = "extension_update_draft"
@@ -18,7 +18,7 @@ module Extension
18
18
  config: JSON.generate(config),
19
19
  extension_context: extension_context,
20
20
  }
21
- response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
21
+ response = ShopifyCLI::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
22
22
  context.abort(context.message("tasks.errors.parse_error")) if response.nil?
23
23
 
24
24
  abort_if_user_errors(context, response)
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
  module Node
3
- class Project < ShopifyCli::ProjectType
3
+ class Project < ShopifyCLI::ProjectType
4
4
  require Project.project_filepath("messages/messages")
5
5
  register_messages(Node::Messages::MESSAGES)
6
6
  end
7
7
 
8
8
  # define/autoload project specific Commands
9
- class Command < ShopifyCli::ProjectCommands
9
+ class Command < ShopifyCLI::ProjectCommands
10
10
  subcommand :Connect, "connect", Project.project_filepath("commands/connect")
11
11
  subcommand :Create, "create", Project.project_filepath("commands/create")
12
12
  subcommand :Deploy, "deploy", Project.project_filepath("commands/deploy")
@@ -15,7 +15,7 @@ module Node
15
15
  subcommand :Serve, "serve", Project.project_filepath("commands/serve")
16
16
  subcommand :Tunnel, "tunnel", Project.project_filepath("commands/tunnel")
17
17
  end
18
- ShopifyCli::Commands.register("Node::Command", "node")
18
+ ShopifyCLI::Commands.register("Node::Command", "node")
19
19
 
20
20
  # define/autoload project specific Tasks
21
21
  module Tasks
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
  module Node
3
3
  class Command
4
- class Connect < ShopifyCli::SubCommand
4
+ class Connect < ShopifyCLI::SubCommand
5
5
  prerequisite_task ensure_project_type: :node
6
6
 
7
7
  def call(*)
8
- if ShopifyCli::Project.has_current? && ShopifyCli::Project.current.env
8
+ if ShopifyCLI::Project.has_current? && ShopifyCLI::Project.current.env
9
9
  @ctx.puts(@ctx.message("node.connect.production_warning"))
10
10
  end
11
11
 
12
- app = ShopifyCli::Connect.new(@ctx).default_connect("node")
12
+ app = ShopifyCLI::Connect.new(@ctx).default_connect("node")
13
13
  @ctx.done(@ctx.message("node.connect.connected", app))
14
14
  end
15
15
 
16
16
  def self.help
17
- ShopifyCli::Context.message("node.connect.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
17
+ ShopifyCLI::Context.message("node.connect.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
18
18
  end
19
19
  end
20
20
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Node
3
3
  class Command
4
- class Create < ShopifyCli::SubCommand
4
+ class Create < ShopifyCLI::SubCommand
5
5
  prerequisite_task :ensure_authenticated
6
6
 
7
7
  options do |parser, flags|
@@ -26,37 +26,37 @@ module Node
26
26
  check_npm
27
27
  build(form.name)
28
28
 
29
- ShopifyCli::Project.write(
29
+ ShopifyCLI::Project.write(
30
30
  @ctx,
31
31
  project_type: "node",
32
32
  organization_id: form.organization_id,
33
33
  )
34
34
 
35
- api_client = ShopifyCli::Tasks::CreateApiClient.call(
35
+ api_client = ShopifyCLI::Tasks::CreateApiClient.call(
36
36
  @ctx,
37
37
  org_id: form.organization_id,
38
38
  title: form.title,
39
39
  type: form.type,
40
40
  )
41
41
 
42
- ShopifyCli::Resources::EnvFile.new(
42
+ ShopifyCLI::Resources::EnvFile.new(
43
43
  api_key: api_client["apiKey"],
44
44
  secret: api_client["apiSecretKeys"].first["secret"],
45
45
  shop: form.shop_domain,
46
46
  scopes: "write_products,write_customers,write_draft_orders",
47
47
  ).write(@ctx)
48
48
 
49
- partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client["id"], local_debug?)
49
+ partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form.organization_id, api_client["id"])
50
50
 
51
51
  @ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
52
- @ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCli::TOOL_NAME, "node"))
53
- unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
52
+ @ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCLI::TOOL_NAME, "node"))
53
+ unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
54
54
  @ctx.puts(@ctx.message("apps.create.info.install", partners_url, form.title))
55
55
  end
56
56
  end
57
57
 
58
58
  def self.help
59
- ShopifyCli::Context.message("node.create.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
59
+ ShopifyCLI::Context.message("node.create.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
60
60
  end
61
61
 
62
62
  private
@@ -101,12 +101,12 @@ module Node
101
101
  end
102
102
 
103
103
  def build(name)
104
- ShopifyCli::Git.clone("https://github.com/Shopify/shopify-app-node.git", name)
104
+ ShopifyCLI::Git.clone("https://github.com/Shopify/shopify-app-node.git", name)
105
105
 
106
106
  @ctx.root = File.join(@ctx.root, name)
107
107
 
108
108
  set_npm_config
109
- ShopifyCli::JsDeps.install(@ctx, !options.flags[:verbose].nil?)
109
+ ShopifyCLI::JsDeps.install(@ctx, !options.flags[:verbose].nil?)
110
110
 
111
111
  begin
112
112
  @ctx.rm_r(".git")
@@ -120,10 +120,6 @@ module Node
120
120
  @ctx.debug(e)
121
121
  end
122
122
  end
123
-
124
- def local_debug?
125
- @ctx.getenv(ShopifyCli::PartnersAPI::LOCAL_DEBUG)
126
- end
127
123
  end
128
124
  end
129
125
  end
@@ -6,12 +6,12 @@ module Node
6
6
  class Deploy
7
7
  class Heroku
8
8
  def self.help
9
- ShopifyCli::Context.message("node.deploy.heroku.help", ShopifyCli::TOOL_NAME)
9
+ ShopifyCLI::Context.message("node.deploy.heroku.help", ShopifyCLI::TOOL_NAME)
10
10
  end
11
11
 
12
12
  def self.start(ctx)
13
13
  spin_group = CLI::UI::SpinGroup.new
14
- heroku_service = ShopifyCli::Heroku.new(ctx)
14
+ heroku_service = ShopifyCLI::Heroku.new(ctx)
15
15
 
16
16
  spin_group.add(ctx.message("node.deploy.heroku.downloading")) do |spinner|
17
17
  heroku_service.download
@@ -29,7 +29,7 @@ module Node
29
29
  spin_group.wait
30
30
 
31
31
  spin_group.add(ctx.message("node.deploy.heroku.git.checking")) do |spinner|
32
- ShopifyCli::Git.init(ctx)
32
+ ShopifyCLI::Git.init(ctx)
33
33
  spinner.update_title(ctx.message("node.deploy.heroku.git.initialized"))
34
34
  end
35
35
  spin_group.wait
@@ -71,7 +71,7 @@ module Node
71
71
  end
72
72
  end
73
73
 
74
- branches = ShopifyCli::Git.branches(ctx)
74
+ branches = ShopifyCLI::Git.branches(ctx)
75
75
  if branches.length == 1
76
76
  branch_to_deploy = branches[0]
77
77
  ctx.puts(ctx.message("node.deploy.heroku.git.branch_selected", branch_to_deploy))
@@ -3,7 +3,7 @@ require "shopify_cli"
3
3
 
4
4
  module Node
5
5
  class Command
6
- class Deploy < ShopifyCli::SubCommand
6
+ class Deploy < ShopifyCLI::SubCommand
7
7
  prerequisite_task ensure_project_type: :node
8
8
 
9
9
  autoload :Heroku, Project.project_filepath("commands/deploy/heroku")
@@ -21,11 +21,11 @@ module Node
21
21
  end
22
22
 
23
23
  def self.help
24
- ShopifyCli::Context.message("node.deploy.help", ShopifyCli::TOOL_NAME)
24
+ ShopifyCLI::Context.message("node.deploy.help", ShopifyCLI::TOOL_NAME)
25
25
  end
26
26
 
27
27
  def self.extended_help
28
- ShopifyCli::Context.message("node.deploy.extended_help", ShopifyCli::TOOL_NAME)
28
+ ShopifyCLI::Context.message("node.deploy.extended_help", ShopifyCLI::TOOL_NAME)
29
29
  end
30
30
  end
31
31
  end
@@ -3,7 +3,7 @@ require "shopify_cli"
3
3
 
4
4
  module Node
5
5
  class Command
6
- class Generate < ShopifyCli::SubCommand
6
+ class Generate < ShopifyCLI::SubCommand
7
7
  prerequisite_task ensure_project_type: :node
8
8
 
9
9
  def call(*)
@@ -11,7 +11,7 @@ module Node
11
11
  end
12
12
 
13
13
  def self.help
14
- ShopifyCli::Context.message("node.generate.help")
14
+ ShopifyCLI::Context.message("node.generate.help")
15
15
  end
16
16
 
17
17
  def self.extended_help
@@ -2,16 +2,16 @@ require "shopify_cli"
2
2
 
3
3
  module Node
4
4
  class Command
5
- class Open < ShopifyCli::SubCommand
5
+ class Open < ShopifyCLI::SubCommand
6
6
  prerequisite_task ensure_project_type: :node
7
7
 
8
8
  def call(*)
9
- project = ShopifyCli::Project.current
9
+ project = ShopifyCLI::Project.current
10
10
  @ctx.open_url!("#{project.env.host}/auth?shop=#{project.env.shop}")
11
11
  end
12
12
 
13
13
  def self.help
14
- ShopifyCli::Context.message("node.open.help", ShopifyCli::TOOL_NAME)
14
+ ShopifyCLI::Context.message("node.open.help", ShopifyCLI::TOOL_NAME)
15
15
  end
16
16
  end
17
17
  end