shopify-cli 2.6.5 → 2.7.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 (201) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer.json +5 -0
  3. data/.github/DESIGN.md +1 -1
  4. data/.github/ISSUE_TEMPLATE.md +7 -0
  5. data/.gitignore +1 -0
  6. data/.vscode/extensions.json +5 -0
  7. data/.vscode/settings.json +9 -0
  8. data/CHANGELOG.md +42 -4
  9. data/CONTRIBUTING.md +1 -21
  10. data/{Dockerfile → Codespace.dockerfile} +11 -3
  11. data/Gemfile +1 -0
  12. data/Gemfile.lock +6 -4
  13. data/README.md +20 -99
  14. data/Rakefile +27 -0
  15. data/Tests.dockerfile +35 -0
  16. data/assets/logo.png +0 -0
  17. data/dev.yml +0 -3
  18. data/docs/README.md +13 -0
  19. data/docs/contributors/testing.md +27 -0
  20. data/docs/users/installation.md +46 -0
  21. data/{THEMEKIT_MIGRATION.md → docs/users/migrate-from-themekit.md} +1 -1
  22. data/ext/javy/javy.rb +186 -0
  23. data/ext/javy/version +1 -0
  24. data/lib/project_types/extension/cli.rb +7 -3
  25. data/lib/project_types/extension/commands/build.rb +4 -8
  26. data/lib/project_types/extension/commands/create.rb +3 -5
  27. data/lib/project_types/extension/commands/extension_command.rb +1 -1
  28. data/lib/project_types/extension/features/argo.rb +1 -8
  29. data/lib/project_types/extension/features/argo_serve.rb +9 -23
  30. data/lib/project_types/extension/forms/create.rb +1 -1
  31. data/lib/project_types/extension/forms/questions/ask_template.rb +3 -6
  32. data/lib/project_types/extension/messages/messages.rb +1 -2
  33. data/lib/project_types/extension/models/development_server.rb +2 -2
  34. data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
  35. data/lib/project_types/extension/models/server_config/app.rb +13 -0
  36. data/lib/project_types/extension/models/server_config/development.rb +5 -4
  37. data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
  38. data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
  39. data/lib/project_types/extension/models/server_config/extension.rb +4 -0
  40. data/lib/project_types/extension/models/server_config/root.rb +4 -1
  41. data/lib/project_types/extension/tasks/convert_server_config.rb +65 -0
  42. data/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
  43. data/lib/project_types/extension/tasks/find_package_from_json.rb +37 -0
  44. data/lib/project_types/extension/tasks/merge_server_config.rb +32 -0
  45. data/lib/project_types/extension/tasks/run_extension_command.rb +11 -10
  46. data/lib/project_types/node/cli.rb +0 -16
  47. data/lib/project_types/node/forms/create.rb +5 -5
  48. data/lib/project_types/node/messages/messages.rb +2 -144
  49. data/lib/project_types/php/cli.rb +0 -11
  50. data/lib/project_types/php/forms/create.rb +5 -6
  51. data/lib/project_types/php/messages/messages.rb +2 -161
  52. data/lib/project_types/rails/cli.rb +0 -16
  53. data/lib/project_types/rails/commands/create.rb +43 -16
  54. data/lib/project_types/rails/forms/create.rb +5 -7
  55. data/lib/project_types/rails/messages/messages.rb +6 -151
  56. data/lib/project_types/script/cli.rb +7 -1
  57. data/lib/project_types/script/commands/create.rb +3 -8
  58. data/lib/project_types/script/commands/javy.rb +29 -0
  59. data/lib/project_types/script/commands/push.rb +3 -2
  60. data/lib/project_types/script/config/extension_points.yml +3 -26
  61. data/lib/project_types/script/errors.rb +0 -18
  62. data/lib/project_types/script/forms/ask_app.rb +32 -0
  63. data/lib/project_types/script/forms/ask_org.rb +30 -0
  64. data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
  65. data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
  66. data/lib/project_types/script/layers/application/build_script.rb +0 -1
  67. data/lib/project_types/script/layers/application/connect_app.rb +73 -0
  68. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  69. data/lib/project_types/script/layers/domain/script_json.rb +1 -1
  70. data/lib/project_types/script/layers/domain/script_project.rb +4 -0
  71. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -4
  72. data/lib/project_types/script/layers/infrastructure/errors.rb +8 -4
  73. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +1 -5
  74. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +25 -4
  75. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +3 -4
  76. data/lib/project_types/script/layers/infrastructure/script_service.rb +1 -1
  77. data/lib/project_types/script/messages/messages.rb +16 -20
  78. data/lib/project_types/script/ui/error_handler.rb +1 -32
  79. data/lib/project_types/theme/cli.rb +1 -1
  80. data/lib/project_types/theme/commands/check.rb +1 -1
  81. data/lib/project_types/theme/commands/delete.rb +1 -1
  82. data/lib/project_types/theme/commands/init.rb +1 -1
  83. data/lib/project_types/theme/commands/language_server.rb +1 -1
  84. data/lib/project_types/theme/commands/package.rb +1 -1
  85. data/lib/project_types/theme/commands/publish.rb +1 -1
  86. data/lib/project_types/theme/commands/pull.rb +4 -1
  87. data/lib/project_types/theme/commands/push.rb +7 -2
  88. data/lib/project_types/theme/commands/serve.rb +9 -2
  89. data/lib/project_types/theme/messages/messages.rb +39 -1
  90. data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
  91. data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
  92. data/lib/shopify_cli/api.rb +7 -2
  93. data/lib/shopify_cli/app_type_detector.rb +24 -20
  94. data/lib/shopify_cli/command/app_sub_command.rb +10 -0
  95. data/lib/shopify_cli/command/project_command.rb +31 -0
  96. data/lib/shopify_cli/command/sub_command.rb +19 -0
  97. data/lib/shopify_cli/command.rb +7 -2
  98. data/lib/shopify_cli/commands/app/connect.rb +22 -0
  99. data/lib/shopify_cli/commands/app/create/node.rb +36 -0
  100. data/lib/shopify_cli/commands/app/create/php.rb +36 -0
  101. data/lib/shopify_cli/commands/app/create/rails.rb +38 -0
  102. data/lib/shopify_cli/commands/app/create.rb +28 -0
  103. data/lib/shopify_cli/commands/app/deploy.rb +49 -0
  104. data/lib/shopify_cli/commands/app/open.rb +19 -0
  105. data/lib/shopify_cli/commands/app/serve.rb +49 -0
  106. data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
  107. data/lib/shopify_cli/commands/app.rb +29 -0
  108. data/lib/shopify_cli/commands/config.rb +2 -2
  109. data/lib/shopify_cli/commands.rb +1 -0
  110. data/lib/shopify_cli/constants.rb +7 -0
  111. data/lib/shopify_cli/context.rb +9 -0
  112. data/lib/shopify_cli/environment.rb +4 -0
  113. data/lib/shopify_cli/exception_reporter.rb +8 -6
  114. data/lib/shopify_cli/git.rb +12 -1
  115. data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
  116. data/lib/shopify_cli/github.rb +5 -0
  117. data/lib/shopify_cli/identity_auth.rb +18 -0
  118. data/lib/shopify_cli/messages/messages.rb +254 -9
  119. data/lib/shopify_cli/migrator.rb +9 -11
  120. data/lib/shopify_cli/partners_api.rb +1 -8
  121. data/lib/shopify_cli/project.rb +5 -1
  122. data/lib/shopify_cli/project_commands.rb +1 -1
  123. data/lib/shopify_cli/services/app/connect_service.rb +25 -0
  124. data/lib/shopify_cli/services/app/create/node_service.rb +155 -0
  125. data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
  126. data/lib/shopify_cli/services/app/create/rails_service.rb +215 -0
  127. data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
  128. data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
  129. data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
  130. data/lib/shopify_cli/services/app/open_service.rb +19 -0
  131. data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
  132. data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
  133. data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
  134. data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
  135. data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
  136. data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
  137. data/lib/shopify_cli/services.rb +31 -0
  138. data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
  139. data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
  140. data/lib/shopify_cli/theme/dev_server.rb +35 -17
  141. data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
  142. data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
  143. data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
  144. data/lib/shopify_cli/theme/syncer.rb +40 -39
  145. data/lib/shopify_cli/theme/theme.rb +31 -19
  146. data/lib/shopify_cli/tunnel.rb +25 -22
  147. data/lib/shopify_cli/version.rb +1 -1
  148. data/lib/shopify_cli.rb +1 -2
  149. data/shopify-cli.gemspec +2 -6
  150. data/shopify-dev +18 -0
  151. data/utilities/constants.rb +7 -0
  152. data/utilities/docker/container.rb +30 -2
  153. data/utilities/docker.rb +3 -2
  154. data/utilities/utilities.rb +1 -0
  155. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
  156. metadata +64 -54
  157. data/docs/_config.yml +0 -2
  158. data/docs/app/node/commands/index.md +0 -4
  159. data/docs/app/node/index.md +0 -4
  160. data/docs/app/rails/commands/index.md +0 -4
  161. data/docs/app/rails/index.md +0 -4
  162. data/docs/core/index.md +0 -4
  163. data/docs/getting-started/index.md +0 -4
  164. data/docs/getting-started/install/index.md +0 -4
  165. data/docs/getting-started/migrate/index.md +0 -4
  166. data/docs/getting-started/uninstall/index.md +0 -4
  167. data/docs/getting-started/upgrade/index.md +0 -4
  168. data/docs/help/start-app/index.md +0 -4
  169. data/docs/index.md +0 -4
  170. data/ext/shopify-cli/extconf.rb +0 -60
  171. data/install.sh +0 -7
  172. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -31
  173. data/lib/project_types/extension/tasks/load_server_config.rb +0 -23
  174. data/lib/project_types/node/commands/connect.rb +0 -21
  175. data/lib/project_types/node/commands/create.rb +0 -125
  176. data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
  177. data/lib/project_types/node/commands/deploy.rb +0 -32
  178. data/lib/project_types/node/commands/generate.rb +0 -22
  179. data/lib/project_types/node/commands/open.rb +0 -18
  180. data/lib/project_types/node/commands/serve.rb +0 -45
  181. data/lib/project_types/node/commands/tunnel.rb +0 -41
  182. data/lib/project_types/php/commands/connect.rb +0 -19
  183. data/lib/project_types/php/commands/create.rb +0 -143
  184. data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
  185. data/lib/project_types/php/commands/deploy.rb +0 -32
  186. data/lib/project_types/php/commands/open.rb +0 -16
  187. data/lib/project_types/php/commands/serve.rb +0 -48
  188. data/lib/project_types/php/commands/tunnel.rb +0 -37
  189. data/lib/project_types/rails/commands/connect.rb +0 -21
  190. data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
  191. data/lib/project_types/rails/commands/deploy.rb +0 -32
  192. data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
  193. data/lib/project_types/rails/commands/generate.rb +0 -60
  194. data/lib/project_types/rails/commands/open.rb +0 -18
  195. data/lib/project_types/rails/commands/serve.rb +0 -51
  196. data/lib/project_types/rails/commands/tunnel.rb +0 -41
  197. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -0
  198. data/lib/project_types/script/tasks/ensure_env.rb +0 -106
  199. data/lib/shopify_cli/sub_command.rb +0 -17
  200. data/shopify.fish +0 -12
  201. data/shopify.sh +0 -11
@@ -0,0 +1,31 @@
1
+ module ShopifyCLI
2
+ class Command
3
+ class ProjectCommand < Command
4
+ def call(*)
5
+ @ctx.puts(self.class.help)
6
+ end
7
+
8
+ class << self
9
+ def help
10
+ project_type = name.split("::")[0].downcase
11
+ ShopifyCLI::Context.message(
12
+ "#{project_type}.help",
13
+ ShopifyCLI::TOOL_NAME,
14
+ available_subcommands
15
+ )
16
+ end
17
+
18
+ private
19
+
20
+ def available_subcommands
21
+ subcommand_registry
22
+ .resolved_commands
23
+ .reject { |_name, command| command.hidden? }
24
+ .keys
25
+ .sort
26
+ .join(" | ")
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ require "shopify_cli"
3
+
4
+ module ShopifyCLI
5
+ class Command
6
+ class SubCommand < Command
7
+ class << self
8
+ def call(args, command_name, parent_command)
9
+ cmd = new(@ctx)
10
+ args = cmd.options.parse(@_options, args || [])
11
+ return call_help(parent_command, command_name) if cmd.options.help
12
+ run_prerequisites
13
+
14
+ cmd.call(args, command_name)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,6 +3,10 @@ require "shopify_cli"
3
3
 
4
4
  module ShopifyCLI
5
5
  class Command < CLI::Kit::BaseCommand
6
+ autoload :SubCommand, "shopify_cli/command/sub_command"
7
+ autoload :AppSubCommand, "shopify_cli/command/app_sub_command"
8
+ autoload :ProjectCommand, "shopify_cli/command/project_command"
9
+
6
10
  extend Feature::Set
7
11
 
8
12
  attr_writer :ctx
@@ -11,12 +15,13 @@ module ShopifyCLI
11
15
  class << self
12
16
  attr_writer :ctx, :task_registry
13
17
 
14
- def call(args, command_name)
18
+ def call(args, command_name, *)
15
19
  subcommand, resolved_name = subcommand_registry.lookup_command(args.first)
16
20
  if subcommand
17
21
  subcommand.ctx = @ctx
18
22
  subcommand.task_registry = @task_registry
19
- subcommand.call(args, resolved_name, command_name)
23
+
24
+ subcommand.call(args.drop(1), resolved_name, command_name)
20
25
  else
21
26
  cmd = new(@ctx)
22
27
  cmd.options.parse(@_options, args)
@@ -0,0 +1,22 @@
1
+ module ShopifyCLI
2
+ module Commands
3
+ class App
4
+ class Connect < ShopifyCLI::Command::AppSubCommand
5
+ def call(_args, _command_name, *)
6
+ app_type = detect_app(directory: Dir.pwd)
7
+ project = ShopifyCLI::Project.current
8
+
9
+ Services::App::ConnectService.call(
10
+ app_type: app_type,
11
+ project: project,
12
+ context: @ctx
13
+ )
14
+ end
15
+
16
+ def self.help
17
+ ShopifyCLI::Context.message("core.app.connect.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,36 @@
1
+ module ShopifyCLI
2
+ module Commands
3
+ class App
4
+ class Create
5
+ class Node < ShopifyCLI::Command::AppSubCommand
6
+ prerequisite_task :ensure_authenticated
7
+
8
+ options do |parser, flags|
9
+ parser.on("--name=NAME") { |t| flags[:name] = t }
10
+ parser.on("--organization-id=ID") { |id| flags[:organization_id] = id }
11
+ parser.on("--store-domain=MYSHOPIFYDOMAIN") { |url| flags[:store_domain] = url }
12
+ parser.on("--type=APPTYPE") { |type| flags[:type] = type }
13
+ parser.on("--verbose") { flags[:verbose] = true }
14
+ end
15
+
16
+ def call(*)
17
+ Services::App::Create::NodeService.call(
18
+ name: options.flags[:name],
19
+ organization_id: options.flags[:organization_id],
20
+ store_domain: options.flags[:store_domain],
21
+ type: options.flags[:type],
22
+ verbose: !options.flags[:verbose].nil?,
23
+ context: @ctx
24
+ )
25
+ end
26
+
27
+ class << self
28
+ def help
29
+ ShopifyCLI::Context.message("core.app.create.node.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ module ShopifyCLI
2
+ module Commands
3
+ class App
4
+ class Create
5
+ class PHP < ShopifyCLI::Command::AppSubCommand
6
+ prerequisite_task :ensure_authenticated
7
+
8
+ options do |parser, flags|
9
+ parser.on("--name=NAME") { |name| flags[:name] = name }
10
+ parser.on("--organization-id=ID") { |organization_id| flags[:organization_id] = organization_id }
11
+ parser.on("--store-domain=MYSHOPIFYDOMAIN") { |url| flags[:store_domain] = url }
12
+ parser.on("--type=APPTYPE") { |type| flags[:type] = type }
13
+ parser.on("--verbose") { flags[:verbose] = true }
14
+ end
15
+
16
+ def call(*)
17
+ Services::App::Create::PHPService.call(
18
+ name: options.flags[:name],
19
+ organization_id: options.flags[:organization_id],
20
+ store_domain: options.flags[:store_domain],
21
+ type: options.flags[:type],
22
+ verbose: !options.flags[:verbose].nil?,
23
+ context: @ctx
24
+ )
25
+ end
26
+
27
+ class << self
28
+ def help
29
+ ShopifyCLI::Context.message("core.app.create.php.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,38 @@
1
+ module ShopifyCLI
2
+ module Commands
3
+ class App
4
+ class Create
5
+ class Rails < ShopifyCLI::Command::AppSubCommand
6
+ prerequisite_task :ensure_authenticated
7
+
8
+ options do |parser, flags|
9
+ parser.on("--name=NAME") { |t| flags[:name] = t }
10
+ parser.on("--organization-id=ID") { |id| flags[:organization_id] = id }
11
+ parser.on("--store-domain=MYSHOPIFYDOMAIN") { |url| flags[:store_domain] = url }
12
+ parser.on("--type=APPTYPE") { |type| flags[:type] = type }
13
+ parser.on("--db=DB") { |db| flags[:db] = db }
14
+ parser.on("--rails-opts=RAILSOPTS") { |opts| flags[:rails_opts] = opts }
15
+ end
16
+
17
+ def call(*)
18
+ Services::App::Create::RailsService.call(
19
+ name: options.flags[:name],
20
+ organization_id: options.flags[:organization_id],
21
+ store_domain: options.flags[:store_domain],
22
+ type: options.flags[:type],
23
+ db: options.flags[:db],
24
+ rails_opts: options.flags[:rails_opts],
25
+ context: @ctx
26
+ )
27
+ end
28
+
29
+ class << self
30
+ def help
31
+ ShopifyCLI::Context.message("core.app.create.rails.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,28 @@
1
+ module ShopifyCLI
2
+ module Commands
3
+ class App
4
+ class Create < ShopifyCLI::Command
5
+ subcommand :Rails, "rails", "shopify_cli/commands/app/create/rails"
6
+ subcommand :PHP, "php", "shopify_cli/commands/app/create/php"
7
+ subcommand :Node, "node", "shopify_cli/commands/app/create/node"
8
+
9
+ def call(_args, _command_name)
10
+ @ctx.puts(self.class.help)
11
+ end
12
+
13
+ def self.help
14
+ ShopifyCLI::Context.message("core.app.create.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
15
+ end
16
+
17
+ def self.call_help(*)
18
+ output = help
19
+ if respond_to?(:extended_help)
20
+ output += "\n"
21
+ output += extended_help
22
+ end
23
+ @ctx.puts(output)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,49 @@
1
+ module ShopifyCLI
2
+ module Commands
3
+ class App
4
+ class Deploy < ShopifyCLI::Command::AppSubCommand
5
+ subcommand :Heroku, "heroku", "shopify_cli/commands/app/deploy/heroku"
6
+
7
+ def call(args, _name)
8
+ platform = args.shift
9
+ case platform
10
+ when "heroku"
11
+ case detect_app
12
+ when :rails
13
+ Services::App::Deploy::Heroku::RailsService.call(
14
+ context: @ctx
15
+ )
16
+ when :php
17
+ Services::App::Deploy::Heroku::PHPService.call(
18
+ context: @ctx
19
+ )
20
+ when :node
21
+ Services::App::Deploy::Heroku::NodeService.call(
22
+ context: @ctx
23
+ )
24
+ end
25
+ when nil
26
+ raise ShopifyCLI::Abort, @ctx.message(
27
+ "core.app.deploy.error.missing_platform",
28
+ ShopifyCLI::TOOL_NAME
29
+ )
30
+ else
31
+ raise ShopifyCLI::Abort, @ctx.message(
32
+ "core.app.deploy.error.invalid_platform",
33
+ platform,
34
+ ShopifyCLI::TOOL_NAME
35
+ )
36
+ end
37
+ end
38
+
39
+ def self.help
40
+ ShopifyCLI::Context.message("core.app.deploy.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
41
+ end
42
+
43
+ def self.extended_help
44
+ ShopifyCLI::Context.message("core.app.deploy.extended_help", ShopifyCLI::TOOL_NAME)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ module ShopifyCLI
2
+ module Commands
3
+ class App
4
+ class Open < ShopifyCLI::Command::AppSubCommand
5
+ def call(*)
6
+ project = ShopifyCLI::Project.current
7
+ Services::App::OpenService.call(
8
+ project: project,
9
+ context: @ctx
10
+ )
11
+ end
12
+
13
+ def self.help
14
+ ShopifyCLI::Context.message("core.app.open.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,49 @@
1
+ module ShopifyCLI
2
+ module Commands
3
+ class App
4
+ class Serve < ShopifyCLI::Command::AppSubCommand
5
+ include ShopifyCLI::CommandOptions::CommandServeOptions
6
+
7
+ prerequisite_task :ensure_env, :ensure_dev_store
8
+
9
+ options do |parser, flags|
10
+ parser.on("--host=HOST") do |h|
11
+ flags[:host] = h.gsub('"', "")
12
+ end
13
+ parser.on("--port=PORT") { |port| flags[:port] = port }
14
+ end
15
+
16
+ def call(*)
17
+ case detect_app
18
+ when :rails
19
+ Services::App::Serve::RailsService.call(
20
+ host: host,
21
+ port: port,
22
+ context: @ctx
23
+ )
24
+ when :node
25
+ Services::App::Serve::NodeService.call(
26
+ host: host,
27
+ port: port,
28
+ context: @ctx
29
+ )
30
+ when :php
31
+ Services::App::Serve::PHPService.call(
32
+ host: host,
33
+ port: port,
34
+ context: @ctx
35
+ )
36
+ end
37
+ end
38
+
39
+ def self.help
40
+ ShopifyCLI::Context.message("core.app.serve.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
41
+ end
42
+
43
+ def self.extended_help
44
+ ShopifyCLI::Context.message("app.core.serve.extended_help")
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,43 @@
1
+ require "project_types/node/cli"
2
+
3
+ module ShopifyCLI
4
+ module Commands
5
+ class App
6
+ class Tunnel < ShopifyCLI::Command::AppSubCommand
7
+ def call(args, _name)
8
+ subcommand = args.shift
9
+ case subcommand
10
+ when "auth"
11
+ token = args.shift
12
+ if token.nil?
13
+ raise ShopifyCLI::Abort, @ctx.message("core.app.tunnel.error.token_argument_missing")
14
+ else
15
+ Services::App::Tunnel::AuthService.call(
16
+ token: token,
17
+ context: @ctx
18
+ )
19
+ end
20
+ when "start"
21
+ Services::App::Tunnel::StartService.call(
22
+ context: @ctx
23
+ )
24
+ when "stop"
25
+ Services::App::Tunnel::StopService.call(
26
+ context: @ctx
27
+ )
28
+ else
29
+ @ctx.puts(self.class.help)
30
+ end
31
+ end
32
+
33
+ def self.help
34
+ ShopifyCLI::Context.message("core.app.tunnel.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
35
+ end
36
+
37
+ def self.extended_help
38
+ ShopifyCLI::Context.message("core.app.tunnel.extended_help", ShopifyCLI::TOOL_NAME)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,29 @@
1
+ require "shopify_cli"
2
+
3
+ module ShopifyCLI
4
+ module Commands
5
+ class App < ShopifyCLI::Command
6
+ subcommand :Connect, "connect", "shopify_cli/commands/app/connect"
7
+ subcommand :Create, "create", "shopify_cli/commands/app/create"
8
+ subcommand :Deploy, "deploy", "shopify_cli/commands/app/deploy"
9
+ subcommand :Open, "open", "shopify_cli/commands/app/open"
10
+ subcommand :Serve, "serve", "shopify_cli/commands/app/serve"
11
+ subcommand :Tunnel, "tunnel", "shopify_cli/commands/app/tunnel"
12
+
13
+ def call(*)
14
+ @ctx.puts(self.class.help)
15
+ end
16
+
17
+ class << self
18
+ def help
19
+ subcommands = subcommand_registry.command_names.join(" | ")
20
+ ShopifyCLI::Context.message("core.app.help", ShopifyCLI::TOOL_NAME, subcommands)
21
+ end
22
+
23
+ def call_help(*)
24
+ @ctx.puts(help)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -16,7 +16,7 @@ module ShopifyCLI
16
16
  ShopifyCLI::Context.message("core.config.help", ShopifyCLI::TOOL_NAME)
17
17
  end
18
18
 
19
- class Feature < ShopifyCLI::SubCommand
19
+ class Feature < ShopifyCLI::Command::SubCommand
20
20
  def self.help
21
21
  ShopifyCLI::Context.message("core.config.feature.help", ShopifyCLI::TOOL_NAME)
22
22
  end
@@ -45,7 +45,7 @@ module ShopifyCLI
45
45
  end
46
46
  end
47
47
 
48
- class Analytics < ShopifyCLI::SubCommand
48
+ class Analytics < ShopifyCLI::Command::SubCommand
49
49
  def self.help
50
50
  ShopifyCLI::Context.message("core.config.analytics.help", ShopifyCLI::TOOL_NAME)
51
51
  end
@@ -29,6 +29,7 @@ module ShopifyCLI
29
29
  register :System, "system", "shopify_cli/commands/system", true
30
30
  register :Version, "version", "shopify_cli/commands/version", true
31
31
  register :Whoami, "whoami", "shopify_cli/commands/whoami", true
32
+ register :App, "app", "shopify_cli/commands/app", true
32
33
 
33
34
  autoload :Connect, "shopify_cli/commands/connect"
34
35
  end
@@ -4,6 +4,10 @@ module ShopifyCLI
4
4
  ROOT = File.expand_path("../..", __dir__)
5
5
  end
6
6
 
7
+ module Files
8
+ SHOPIFY_CLI_YML = ".shopify-cli.yml"
9
+ end
10
+
7
11
  module StoreKeys
8
12
  LAST_MIGRATION_DATE = :last_migration_date
9
13
  ANALYTICS_ENABLED = :analytics_enabled
@@ -42,6 +46,9 @@ module ShopifyCLI
42
46
  ACCEPTANCE_TEST = "SHOPIFY_CLI_ACCEPTANCE_TEST"
43
47
  DEVELOPMENT = "SHOPIFY_CLI_DEVELOPMENT"
44
48
 
49
+ # Authentication
50
+ AUTH_TOKEN = "SHOPIFY_CLI_AUTH_TOKEN"
51
+
45
52
  # Monorail
46
53
  MONORAIL_REAL_EVENTS = "MONORAIL_REAL_EVENTS"
47
54
  end
@@ -357,6 +357,15 @@ module ShopifyCLI
357
357
  Kernel.puts(CLI::UI.fmt(*args))
358
358
  end
359
359
 
360
+ # a wrapper around $stderr.puts to allow for easy formatting
361
+ #
362
+ # #### Parameters
363
+ # * `text` - a string message to output
364
+ #
365
+ def error(text)
366
+ $stderr.puts(CLI::UI.fmt(text))
367
+ end
368
+
360
369
  # a wrapper around Kernel.warn to allow for easy formatting
361
370
  #
362
371
  # #### Parameters
@@ -86,6 +86,10 @@ module ShopifyCLI
86
86
  )
87
87
  end
88
88
 
89
+ def self.auth_token(env_variables: ENV)
90
+ env_variables[Constants::EnvironmentVariables::AUTH_TOKEN]
91
+ end
92
+
89
93
  def self.env_variable_truthy?(variable_name, env_variables: ENV)
90
94
  TRUTHY_ENV_VARIABLE_VALUES.include?(env_variables[variable_name.to_s])
91
95
  end
@@ -2,10 +2,10 @@ module ShopifyCLI
2
2
  module ExceptionReporter
3
3
  def self.report(error, _logs = nil, _api_key = nil, custom_metadata = {})
4
4
  context = ShopifyCLI::Context.new
5
-
6
5
  unless ShopifyCLI::Environment.development?
7
6
  context.puts(context.message("core.error_reporting.unhandled_error.message"))
8
- context.puts(context.message("core.error_reporting.unhandled_error.issue_message"))
7
+ context.puts(context.message("core.error_reporting.unhandled_error.issue_message",
8
+ ShopifyCLI::GitHub::IssueURLGenerator.error_url(error)))
9
9
  end
10
10
 
11
11
  # Stack trace hint
@@ -17,8 +17,8 @@ module ShopifyCLI
17
17
  context.puts("\n")
18
18
 
19
19
  return unless reportable_error?(error)
20
- return unless report?(context: context)
21
20
 
21
+ return unless report?(context: context)
22
22
  ENV["BUGSNAG_DISABLE_AUTOCONFIGURE"] = "1"
23
23
  require "bugsnag"
24
24
 
@@ -31,9 +31,12 @@ module ShopifyCLI
31
31
  config.auto_capture_sessions = false
32
32
  end
33
33
 
34
- metadata = {}
34
+ metadata = { rubyPlatform: RUBY_PLATFORM }
35
35
  metadata.merge!(custom_metadata)
36
- Bugsnag.notify(error, metadata)
36
+
37
+ Bugsnag.notify(error) do |event|
38
+ event.add_metadata(:device, metadata)
39
+ end
37
40
  end
38
41
 
39
42
  def self.report?(context:)
@@ -45,7 +48,6 @@ module ShopifyCLI
45
48
  unless ReportingConfigurationController.reporting_prompted?
46
49
  ReportingConfigurationController.check_or_prompt_report_automatically(source: :uncaught_error)
47
50
  end
48
-
49
51
  report_error
50
52
  end
51
53
 
@@ -4,6 +4,12 @@ module ShopifyCLI
4
4
  # git.
5
5
  class Git
6
6
  class << self
7
+ # Check if Git is available in the environment
8
+ def available?(ctx)
9
+ _output, status = ctx.capture2e("git", "status")
10
+ status.success?
11
+ end
12
+
7
13
  ##
8
14
  # will return the current sha of the cli repo
9
15
  #
@@ -20,8 +26,13 @@ module ShopifyCLI
20
26
  #
21
27
  # ShopifyCLI::Git.sha
22
28
  #
29
+ # Some environments don't have git in PATH and this prevents
30
+ # the execution from raising an error
31
+ # https://app.bugsnag.com/shopify/shopify-cli/errors/615dd36365ce57000889d4c5
23
32
  def sha(dir: Dir.pwd, ctx: Context.new)
24
- rev_parse("HEAD", dir: dir, ctx: ctx)
33
+ if available?(ctx)
34
+ rev_parse("HEAD", dir: dir, ctx: ctx)
35
+ end
25
36
  end
26
37
 
27
38
  ##
@@ -0,0 +1,19 @@
1
+ module ShopifyCLI
2
+ module GitHub
3
+ module IssueURLGenerator
4
+ def self.error_url(error)
5
+ title = "#{error.class}: #{error.message}"
6
+ labels = "type:bug"
7
+ content = File.read(File.join(ShopifyCLI::ROOT, ".github/ISSUE_TEMPLATE.md"))
8
+
9
+ # take at most 5 lines from backtrace
10
+ stacktrace = error.backtrace.length < 5 ? error.backtrace : error.backtrace[0..4]
11
+ body = stacktrace.join("\n").to_s
12
+ output = content.gsub(/<!--Stacktrace(.|\n)*-->/, body)
13
+ query = URI.encode_www_form({ title: title, body: output, labels: labels })
14
+ url = "#{ShopifyCLI::Constants::Links::NEW_ISSUE}?#{query}"
15
+ url
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module ShopifyCLI
2
+ module GitHub
3
+ autoload :IssueURLGenerator, "shopify_cli/github/issue_url_generator"
4
+ end
5
+ end
@@ -68,6 +68,24 @@ module ShopifyCLI
68
68
  request_exchange_tokens
69
69
  end
70
70
 
71
+ def self.fetch_or_auth_partners_token(ctx:)
72
+ env_var_auth_token = Environment.auth_token
73
+ return env_var_auth_token if env_var_auth_token
74
+
75
+ ShopifyCLI::DB.get(:partners_exchange_token) do
76
+ IdentityAuth.new(ctx: ctx).authenticate
77
+ ShopifyCLI::DB.get(:partners_exchange_token)
78
+ end
79
+ end
80
+
81
+ def self.environment_auth_token?
82
+ !!Environment.auth_token
83
+ end
84
+
85
+ def self.authenticated?
86
+ environment_auth_token? || IDENTITY_ACCESS_TOKENS.all? { |key| ShopifyCLI::DB.exists?(key) }
87
+ end
88
+
71
89
  def reauthenticate
72
90
  return if refresh_exchange_tokens || refresh_access_tokens
73
91
  ctx.abort(ctx.message("core.identity_auth.error.reauthenticate", ShopifyCLI::TOOL_NAME))