shopify-cli 2.6.3 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) 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/.github/PULL_REQUEST_TEMPLATE.md +15 -4
  6. data/.github/workflows/shopify.yml +3 -6
  7. data/.vscode/extensions.json +5 -0
  8. data/.vscode/settings.json +9 -0
  9. data/CHANGELOG.md +98 -104
  10. data/CONTRIBUTING.md +1 -21
  11. data/Codespace.dockerfile +35 -0
  12. data/Gemfile +2 -0
  13. data/Gemfile.lock +9 -5
  14. data/README.md +20 -99
  15. data/RELEASING.md +17 -30
  16. data/Rakefile +0 -5
  17. data/Tests.dockerfile +35 -0
  18. data/assets/logo.png +0 -0
  19. data/dev.yml +0 -3
  20. data/docs/README.md +13 -0
  21. data/docs/contributors/testing.md +27 -0
  22. data/docs/users/installation.md +46 -0
  23. data/{THEMEKIT_MIGRATION.md → docs/users/migrate-from-themekit.md} +1 -1
  24. data/lib/project_types/extension/cli.rb +7 -3
  25. data/lib/project_types/extension/commands/create.rb +6 -6
  26. data/lib/project_types/extension/commands/extension_command.rb +1 -1
  27. data/lib/project_types/extension/features/argo.rb +9 -10
  28. data/lib/project_types/extension/features/argo_serve.rb +9 -23
  29. data/lib/project_types/extension/forms/create.rb +1 -1
  30. data/lib/project_types/extension/forms/questions/ask_template.rb +3 -6
  31. data/lib/project_types/extension/messages/messages.rb +1 -0
  32. data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
  33. data/lib/project_types/extension/models/server_config/app.rb +13 -0
  34. data/lib/project_types/extension/models/server_config/development.rb +5 -4
  35. data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
  36. data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
  37. data/lib/project_types/extension/models/server_config/extension.rb +4 -0
  38. data/lib/project_types/extension/models/server_config/root.rb +4 -1
  39. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
  40. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +1 -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 +10 -9
  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 -149
  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 -164
  52. data/lib/project_types/rails/cli.rb +0 -16
  53. data/lib/project_types/rails/commands/create.rb +46 -17
  54. data/lib/project_types/rails/forms/create.rb +5 -7
  55. data/lib/project_types/rails/messages/messages.rb +6 -154
  56. data/lib/project_types/script/cli.rb +1 -1
  57. data/lib/project_types/script/commands/create.rb +5 -6
  58. data/lib/project_types/script/commands/push.rb +1 -1
  59. data/lib/project_types/script/config/extension_points.yml +10 -0
  60. data/lib/project_types/script/errors.rb +0 -18
  61. data/lib/project_types/script/graphql/app_script_set.graphql +2 -0
  62. data/lib/project_types/script/layers/application/build_script.rb +2 -1
  63. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  64. data/lib/project_types/script/layers/application/push_script.rb +15 -1
  65. data/lib/project_types/script/layers/domain/push_package.rb +5 -2
  66. data/lib/project_types/script/layers/domain/script_json.rb +1 -1
  67. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -4
  68. data/lib/project_types/script/layers/infrastructure/errors.rb +17 -2
  69. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +29 -13
  70. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +29 -13
  71. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +4 -2
  72. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +3 -4
  73. data/lib/project_types/script/layers/infrastructure/script_service.rb +7 -2
  74. data/lib/project_types/script/messages/messages.rb +9 -22
  75. data/lib/project_types/script/ui/error_handler.rb +16 -26
  76. data/lib/project_types/theme/cli.rb +1 -1
  77. data/lib/project_types/theme/commands/check.rb +1 -1
  78. data/lib/project_types/theme/commands/delete.rb +1 -1
  79. data/lib/project_types/theme/commands/init.rb +1 -1
  80. data/lib/project_types/theme/commands/language_server.rb +1 -1
  81. data/lib/project_types/theme/commands/package.rb +1 -1
  82. data/lib/project_types/theme/commands/publish.rb +1 -1
  83. data/lib/project_types/theme/commands/pull.rb +1 -1
  84. data/lib/project_types/theme/commands/push.rb +1 -1
  85. data/lib/project_types/theme/commands/serve.rb +10 -2
  86. data/lib/project_types/theme/messages/messages.rb +10 -0
  87. data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
  88. data/lib/shopify_cli/api.rb +7 -2
  89. data/lib/shopify_cli/app_type_detector.rb +36 -0
  90. data/lib/shopify_cli/command/app_sub_command.rb +10 -0
  91. data/lib/shopify_cli/command/project_command.rb +18 -0
  92. data/lib/shopify_cli/command/sub_command.rb +19 -0
  93. data/lib/shopify_cli/command.rb +13 -3
  94. data/lib/shopify_cli/command_options/command_serve_options.rb +43 -0
  95. data/lib/shopify_cli/command_options.rb +7 -0
  96. data/lib/shopify_cli/commands/app/connect.rb +22 -0
  97. data/lib/shopify_cli/commands/app/create/node.rb +38 -0
  98. data/lib/shopify_cli/commands/app/create/php.rb +36 -0
  99. data/lib/shopify_cli/commands/app/create/rails.rb +40 -0
  100. data/lib/shopify_cli/commands/app/create.rb +28 -0
  101. data/lib/shopify_cli/commands/app/deploy.rb +49 -0
  102. data/lib/shopify_cli/commands/app/open.rb +19 -0
  103. data/lib/shopify_cli/commands/app/serve.rb +49 -0
  104. data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
  105. data/lib/shopify_cli/commands/app.rb +29 -0
  106. data/lib/shopify_cli/commands/config.rb +2 -2
  107. data/lib/shopify_cli/commands/login.rb +3 -3
  108. data/lib/shopify_cli/commands/reporting.rb +38 -0
  109. data/lib/shopify_cli/commands/switch.rb +1 -1
  110. data/lib/shopify_cli/commands.rb +2 -0
  111. data/lib/shopify_cli/constants.rb +11 -3
  112. data/lib/shopify_cli/core/monorail.rb +9 -20
  113. data/lib/shopify_cli/environment.rb +15 -1
  114. data/lib/shopify_cli/exception_reporter.rb +29 -16
  115. data/lib/shopify_cli/git.rb +12 -1
  116. data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
  117. data/lib/shopify_cli/github.rb +5 -0
  118. data/lib/shopify_cli/messages/messages.rb +295 -22
  119. data/lib/shopify_cli/migrator/migration.rb +1 -1
  120. data/lib/shopify_cli/migrator/migrations/1631709766_noop.rb +1 -1
  121. data/lib/shopify_cli/migrator/migrations/1633691650_merge_reporting_configuration.rb +41 -0
  122. data/lib/shopify_cli/migrator.rb +9 -11
  123. data/lib/shopify_cli/project.rb +5 -1
  124. data/lib/shopify_cli/project_commands.rb +1 -1
  125. data/lib/shopify_cli/reporting_configuration_controller.rb +64 -0
  126. data/lib/shopify_cli/services/app/connect_service.rb +25 -0
  127. data/lib/shopify_cli/services/app/create/node_service.rb +153 -0
  128. data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
  129. data/lib/shopify_cli/services/app/create/rails_service.rb +213 -0
  130. data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
  131. data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
  132. data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
  133. data/lib/shopify_cli/services/app/open_service.rb +19 -0
  134. data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
  135. data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
  136. data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
  137. data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
  138. data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
  139. data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
  140. data/lib/shopify_cli/services/base_service.rb +13 -0
  141. data/lib/shopify_cli/services/reporting_service.rb +16 -0
  142. data/lib/shopify_cli/services.rb +37 -0
  143. data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
  144. data/lib/shopify_cli/theme/dev_server/watcher.rb +2 -2
  145. data/lib/shopify_cli/theme/dev_server.rb +9 -2
  146. data/lib/shopify_cli/version.rb +1 -1
  147. data/lib/shopify_cli.rb +5 -2
  148. data/shopify-cli.gemspec +2 -13
  149. data/shopify-dev +18 -0
  150. data/utilities/constants.rb +7 -0
  151. data/utilities/docker/container.rb +104 -0
  152. data/utilities/docker.rb +45 -3
  153. data/utilities/utilities.rb +1 -0
  154. metadata +63 -54
  155. data/Dockerfile +0 -17
  156. data/docs/_config.yml +0 -2
  157. data/docs/app/node/commands/index.md +0 -4
  158. data/docs/app/node/index.md +0 -4
  159. data/docs/app/rails/commands/index.md +0 -4
  160. data/docs/app/rails/index.md +0 -4
  161. data/docs/core/index.md +0 -4
  162. data/docs/getting-started/index.md +0 -4
  163. data/docs/getting-started/install/index.md +0 -4
  164. data/docs/getting-started/migrate/index.md +0 -4
  165. data/docs/getting-started/uninstall/index.md +0 -4
  166. data/docs/getting-started/upgrade/index.md +0 -4
  167. data/docs/help/start-app/index.md +0 -4
  168. data/docs/index.md +0 -4
  169. data/ext/shopify-cli/extconf.rb +0 -60
  170. data/install.sh +0 -7
  171. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -31
  172. data/lib/project_types/extension/tasks/load_server_config.rb +0 -23
  173. data/lib/project_types/node/commands/connect.rb +0 -21
  174. data/lib/project_types/node/commands/create.rb +0 -125
  175. data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
  176. data/lib/project_types/node/commands/deploy.rb +0 -32
  177. data/lib/project_types/node/commands/generate.rb +0 -22
  178. data/lib/project_types/node/commands/open.rb +0 -18
  179. data/lib/project_types/node/commands/serve.rb +0 -54
  180. data/lib/project_types/node/commands/tunnel.rb +0 -41
  181. data/lib/project_types/php/commands/connect.rb +0 -19
  182. data/lib/project_types/php/commands/create.rb +0 -143
  183. data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
  184. data/lib/project_types/php/commands/deploy.rb +0 -32
  185. data/lib/project_types/php/commands/open.rb +0 -16
  186. data/lib/project_types/php/commands/serve.rb +0 -51
  187. data/lib/project_types/php/commands/tunnel.rb +0 -37
  188. data/lib/project_types/rails/commands/connect.rb +0 -21
  189. data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
  190. data/lib/project_types/rails/commands/deploy.rb +0 -32
  191. data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
  192. data/lib/project_types/rails/commands/generate.rb +0 -60
  193. data/lib/project_types/rails/commands/open.rb +0 -18
  194. data/lib/project_types/rails/commands/serve.rb +0 -52
  195. data/lib/project_types/rails/commands/tunnel.rb +0 -41
  196. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -0
  197. data/lib/shopify_cli/exception_reporter/permission_controller.rb +0 -54
  198. data/lib/shopify_cli/sub_command.rb +0 -17
  199. data/shopify.fish +0 -12
  200. data/shopify.sh +0 -11
@@ -16,7 +16,7 @@ module ShopifyCLI
16
16
  end
17
17
 
18
18
  shop = if options.flags[:shop]
19
- Login.validate_shop(options.flags[:shop])
19
+ Login.validate_shop(options.flags[:shop], context: @ctx)
20
20
  elsif (org_id = DB.get(:organization_id))
21
21
  res = ShopifyCLI::Tasks::SelectOrgAndShop.call(@ctx, organization_id: org_id)
22
22
  res[:shop_domain]
@@ -23,11 +23,13 @@ module ShopifyCLI
23
23
  register :Login, "login", "shopify_cli/commands/login", true
24
24
  register :Logout, "logout", "shopify_cli/commands/logout", true
25
25
  register :Populate, "populate", "shopify_cli/commands/populate", true
26
+ register :Reporting, "reporting", "shopify_cli/commands/reporting", true
26
27
  register :Store, "store", "shopify_cli/commands/store", true
27
28
  register :Switch, "switch", "shopify_cli/commands/switch", true
28
29
  register :System, "system", "shopify_cli/commands/system", true
29
30
  register :Version, "version", "shopify_cli/commands/version", true
30
31
  register :Whoami, "whoami", "shopify_cli/commands/whoami", true
32
+ register :App, "app", "shopify_cli/commands/app", true
31
33
 
32
34
  autoload :Connect, "shopify_cli/commands/connect"
33
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
@@ -15,10 +19,10 @@ module ShopifyCLI
15
19
 
16
20
  module Config
17
21
  module Sections
18
- module ErrorTracking
19
- NAME = "error-tracking"
22
+ module Analytics
23
+ NAME = "analytics"
20
24
  module Fields
21
- AUTOMATIC_REPORTING = "automatic-reporting"
25
+ ENABLED = "enabled"
22
26
  end
23
27
  end
24
28
  end
@@ -39,7 +43,11 @@ module ShopifyCLI
39
43
 
40
44
  # Environments
41
45
  TEST = "SHOPIFY_CLI_TEST"
46
+ ACCEPTANCE_TEST = "SHOPIFY_CLI_ACCEPTANCE_TEST"
42
47
  DEVELOPMENT = "SHOPIFY_CLI_DEVELOPMENT"
48
+
49
+ # Monorail
50
+ MONORAIL_REAL_EVENTS = "MONORAIL_REAL_EVENTS"
43
51
  end
44
52
 
45
53
  module Identity
@@ -16,9 +16,6 @@ module ShopifyCLI
16
16
  attr_accessor :metadata
17
17
 
18
18
  def log(name, args, &block) # rubocop:disable Lint/UnusedMethodArgument
19
- prompt_for_consent
20
- return yield unless enabled? && consented?
21
-
22
19
  command, command_name = Commands::Registry.lookup_command(name)
23
20
  final_command = [command_name]
24
21
  if command
@@ -28,13 +25,18 @@ module ShopifyCLI
28
25
 
29
26
  start_time = now_in_milliseconds
30
27
  err = nil
28
+
31
29
  begin
32
30
  yield
33
31
  rescue Exception => e # rubocop:disable Lint/RescueException
34
32
  err = e
35
33
  raise
36
34
  ensure
37
- send_event(start_time, final_command, args - final_command, err&.message)
35
+ # If there's an error, we don't prompt from here and we let the exception
36
+ # reporter do that.
37
+ if report?(prompt: err.nil?)
38
+ send_event(start_time, final_command, args - final_command, err&.message)
39
+ end
38
40
  end
39
41
  end
40
42
 
@@ -44,22 +46,9 @@ module ShopifyCLI
44
46
  (Time.now.utc.to_f * 1000).to_i
45
47
  end
46
48
 
47
- # we only want to send Monorail events in production or when explicitly developing
48
- def enabled?
49
- (Context.new.system? || ENV["MONORAIL_REAL_EVENTS"] == "1") && !Context.new.ci?
50
- end
51
-
52
- def consented?
53
- ShopifyCLI::Config.get_bool("analytics", "enabled")
54
- end
55
-
56
- def prompt_for_consent
57
- return if Context.new.ci?
58
- return unless enabled?
59
- return if ShopifyCLI::Config.get_section("analytics").key?("enabled")
60
- msg = Context.message("core.monorail.consent_prompt")
61
- opt = CLI::UI::Prompt.confirm(msg)
62
- ShopifyCLI::Config.set("analytics", "enabled", opt)
49
+ def report?(prompt:)
50
+ return true if Environment.send_monorail_events?
51
+ ReportingConfigurationController.check_or_prompt_report_automatically(source: :usage, prompt: prompt)
63
52
  end
64
53
 
65
54
  def send_event(start_time, commands, args, err = nil)
@@ -26,7 +26,7 @@ module ShopifyCLI
26
26
  env_variable_truthy?(
27
27
  Constants::EnvironmentVariables::STACKTRACE,
28
28
  env_variables: env_variables
29
- )
29
+ ) || development?(env_variables: env_variables)
30
30
  end
31
31
 
32
32
  def self.test?(env_variables: ENV)
@@ -36,6 +36,13 @@ module ShopifyCLI
36
36
  )
37
37
  end
38
38
 
39
+ def self.acceptance_test?(env_variables: ENV)
40
+ env_variable_truthy?(
41
+ Constants::EnvironmentVariables::ACCEPTANCE_TEST,
42
+ env_variables: env_variables
43
+ )
44
+ end
45
+
39
46
  def self.print_backtrace?(env_variables: ENV)
40
47
  env_variable_truthy?(
41
48
  Constants::EnvironmentVariables::BACKTRACE,
@@ -72,6 +79,13 @@ module ShopifyCLI
72
79
  "#{spin_workspace}.#{spin_namespace}.#{spin_host}"
73
80
  end
74
81
 
82
+ def self.send_monorail_events?(env_variables: ENV)
83
+ env_variable_truthy?(
84
+ Constants::EnvironmentVariables::MONORAIL_REAL_EVENTS,
85
+ env_variables: env_variables
86
+ )
87
+ end
88
+
75
89
  def self.env_variable_truthy?(variable_name, env_variables: ENV)
76
90
  TRUTHY_ENV_VARIABLE_VALUES.include?(env_variables[variable_name.to_s])
77
91
  end
@@ -1,21 +1,24 @@
1
1
  module ShopifyCLI
2
2
  module ExceptionReporter
3
- autoload :PermissionController, "shopify_cli/exception_reporter/permission_controller"
4
-
5
3
  def self.report(error, _logs = nil, _api_key = nil, custom_metadata = {})
6
4
  context = ShopifyCLI::Context.new
7
- context.puts("\n")
8
- context.puts(context.message("core.error_reporting.unhandled_error.message"))
9
- context.puts(context.message("core.error_reporting.unhandled_error.issue_message"))
5
+ unless ShopifyCLI::Environment.development?
6
+ context.puts(context.message("core.error_reporting.unhandled_error.message"))
7
+ context.puts(context.message("core.error_reporting.unhandled_error.issue_message",
8
+ ShopifyCLI::GitHub::IssueURLGenerator.error_url(error)))
9
+ end
10
+
11
+ # Stack trace hint
10
12
  unless ShopifyCLI::Environment.print_stacktrace?
11
13
  context.puts(context.message("core.error_reporting.unhandled_error.stacktrace_message",
12
14
  "#{ShopifyCLI::Constants::EnvironmentVariables::STACKTRACE}=1"))
13
15
  end
16
+
14
17
  context.puts("\n")
15
18
 
16
19
  return unless reportable_error?(error)
17
- return unless report?
18
20
 
21
+ return unless report?(context: context)
19
22
  ENV["BUGSNAG_DISABLE_AUTOCONFIGURE"] = "1"
20
23
  require "bugsnag"
21
24
 
@@ -28,25 +31,35 @@ module ShopifyCLI
28
31
  config.auto_capture_sessions = false
29
32
  end
30
33
 
31
- metadata = {}
34
+ metadata = { rubyPlatform: RUBY_PLATFORM }
32
35
  metadata.merge!(custom_metadata)
33
- Bugsnag.notify(error, metadata)
36
+
37
+ Bugsnag.notify(error) do |event|
38
+ event.add_metadata(:device, metadata)
39
+ end
34
40
  end
35
41
 
36
- def self.report?
37
- return false if ShopifyCLI::Environment.development?
38
- return true if ExceptionReporter::PermissionController.automatic_reporting_prompted? &&
39
- ExceptionReporter::PermissionController.can_report_automatically?
42
+ def self.report?(context:)
43
+ return true if ReportingConfigurationController.reporting_prompted? &&
44
+ ReportingConfigurationController.check_or_prompt_report_automatically(source: :uncaught_error)
40
45
 
41
- report_error = ExceptionReporter::PermissionController.report_error?
46
+ report_error = report_error?(context: context)
42
47
 
43
- unless ExceptionReporter::PermissionController.automatic_reporting_prompted?
44
- ExceptionReporter::PermissionController.can_report_automatically?
48
+ unless ReportingConfigurationController.reporting_prompted?
49
+ ReportingConfigurationController.check_or_prompt_report_automatically(source: :uncaught_error)
45
50
  end
46
-
47
51
  report_error
48
52
  end
49
53
 
54
+ def self.report_error?(context:)
55
+ return false if Environment.development?
56
+
57
+ CLI::UI::Prompt.ask(context.message("core.error_reporting.report_error.question")) do |handler|
58
+ handler.option(context.message("core.error_reporting.report_error.yes")) { |_| true }
59
+ handler.option(context.message("core.error_reporting.report_error.no")) { |_| false }
60
+ end
61
+ end
62
+
50
63
  def self.reportable_error?(error)
51
64
  is_abort = error.is_a?(ShopifyCLI::Abort) || error.is_a?(ShopifyCLI::AbortSilent)
52
65
  !is_abort
@@ -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
@@ -8,29 +8,294 @@ module ShopifyCLI
8
8
  info: {
9
9
  created: "{{v}} {{green:%s}} was created in the organization's Partner Dashboard {{underline:%s}}",
10
10
  serve: "{{*}} Change directories to your new project folder {{green:%s}} and run "\
11
- "{{command:%s %s serve}} to start a local server",
11
+ "{{command:%s app serve}} to start a local server",
12
12
  install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
13
13
  },
14
14
  },
15
15
  },
16
16
  core: {
17
+ app: {
18
+ help: <<~HELP,
19
+ Suite of commands for developing apps. See {{command:%1$s app <command> --help}} for usage of each command.
20
+ Usage: {{command:%1$s app [ %2$s ]}}
21
+ HELP
22
+ error: {
23
+ type_not_found: <<~MESSAGE,
24
+ Couldn't detect the app type in directory %s. We currently support Rails, PHP, and NodeJS apps.
25
+ MESSAGE
26
+ missing_shopify_cli_yml: <<~MESSAGE,
27
+ Couldn't find a #{Constants::Files::SHOPIFY_CLI_YML} file in the directory %s to determine the app type.
28
+ MESSAGE
29
+ invalid_project_type: <<~MESSAGE,
30
+ The project type %s doesn't represent an app.
31
+ MESSAGE
32
+ },
33
+ create: {
34
+ type_required_error: "",
35
+ invalid_type: "The type %s is not supported. The only supported types are"\
36
+ " {{command:[ rails | node | php ]}}",
37
+ help: <<~HELP,
38
+ {{command:%s app create}}: Creates a ruby on rails app.
39
+ Usage: {{command:%s app create [ rails | node | php ]}}
40
+ HELP
41
+ rails: {
42
+ help: <<~HELP,
43
+ {{command:%s app create rails}}: Creates a ruby on rails app.
44
+ Usage: {{command:%s app create rails}}
45
+ Options:
46
+ {{command:--name=NAME}} App name. Any string.
47
+ {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
48
+ {{command:--store-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
49
+ {{command:--db=DB}} Database type. Must be one of: mysql, postgresql, sqlite3, oracle, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc.
50
+ {{command:--rails-opts=RAILSOPTS}} Additional options. Must be string containing one or more valid Rails options, separated by spaces.
51
+ HELP
52
+
53
+ error: {
54
+ invalid_ruby_version: "This project requires a Ruby version ~> 2.5 or Ruby 3.0.",
55
+ dir_exists: "Project directory %s already exists. Please use a different name.",
56
+ install_failure: "Error installing %s gem",
57
+ node_required: "node is required to create a rails project. Download at https://nodejs.org/en/download.",
58
+ node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
59
+ "per the instructions at https://nodejs.org/en.",
60
+ yarn_required: "yarn is required to create a rails project. Download at " \
61
+ "https://classic.yarnpkg.com/en/docs/install.",
62
+ yarn_version_failure: "Failed to get the current yarn version. Please make sure it is " \
63
+ "installed as per the instructions at https://classic.yarnpkg.com/en/docs/install.",
64
+ },
65
+
66
+ info: {
67
+ open_new_shell: "{{*}} {{yellow:After installing %s, please open a new Command Prompt or PowerShell " \
68
+ "window to continue.}}",
69
+ },
70
+ installing_bundler: "Installing bundler…",
71
+ generating_app: "Generating new rails app project in %s…",
72
+ adding_shopify_gem: "{{v}} Adding shopify_app gem…",
73
+ node_version: "node %s",
74
+ yarn_version: "yarn %s",
75
+ running_bundle_install: "Running bundle install…",
76
+ running_generator: "Running shopify_app generator…",
77
+ running_migrations: "Running migrations…",
78
+ running_webpacker_install: "Running webpacker:install…",
79
+ },
80
+ node: {
81
+ help: <<~HELP,
82
+ {{command:%s app create node}}: Creates an embedded nodejs app.
83
+ Usage: {{command:%s app create node}}
84
+ Options:
85
+ {{command:--name=NAME}} App name. Any string.
86
+ {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
87
+ {{command:--store-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
88
+ HELP
89
+ error: {
90
+ node_required: "node is required to create an app project. Download at https://nodejs.org/en/download.",
91
+ node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
92
+ "per the instructions at https://nodejs.org/en.",
93
+ npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.",
94
+ npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
95
+ "the instructions at https://www.npmjs.com/get-npm.",
96
+ },
97
+ node_version: "node %s",
98
+ npm_version: "npm %s",
99
+ },
100
+ php: {
101
+ help: <<~HELP,
102
+ {{command:%s app create php}}: Creates an embedded PHP app.
103
+ Usage: {{command:%s app create php}}
104
+ Options:
105
+ {{command:--name=NAME}} App name. Any string.
106
+ {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
107
+ {{command:--store-domain=MYSHOPIFYDOMAIN}} Development store URL. Must be an existing development store.
108
+ {{command:--type=APPTYPE}} Whether this app is public or custom.
109
+ {{command:--verbose}} Output verbose information when installing dependencies.
110
+ HELP
111
+
112
+ error: {
113
+ php_required: <<~VERSION,
114
+ PHP is required to create an app project. For installation instructions, visit:
115
+ {{underline:https://www.php.net/manual/en/install.php}}
116
+ VERSION
117
+ php_version_failure: <<~VERSION,
118
+ Failed to get the current PHP version. Please make sure it is installed as per the instructions at:
119
+ {{underline:https://www.php.net/manual/en/install.php.}}
120
+ VERSION
121
+ php_version_too_low: "Your PHP version is too low. Please use version %s or higher.",
122
+ composer_required: <<~COMPOSER,
123
+ Composer is required to create an app project. Download at:
124
+ {{underline:https://getcomposer.org/download/}}
125
+ COMPOSER
126
+ npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.",
127
+ npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
128
+ "the instructions at https://www.npmjs.com/get-npm.",
129
+ app_setup: "Failed to set up the app",
130
+ },
131
+
132
+ php_version: "PHP %s",
133
+ npm_version: "npm %s",
134
+ app_setting_up: "Setting up app…",
135
+ app_set_up: "App is now set up",
136
+ },
137
+ },
138
+ deploy: {
139
+ help: <<~HELP,
140
+ Deploy the current app to a hosting service. Heroku ({{underline:https://www.heroku.com}}) is currently the only option, but more will be added in the future.
141
+ Usage: {{command:%s app deploy [ heroku ]}}
142
+ HELP
143
+ extended_help: <<~HELP,
144
+ {{bold:Subcommands:}}
145
+ {{cyan:heroku}}: Deploys the current app to Heroku.
146
+ Usage: {{command:%s app deploy heroku}}
147
+ HELP
148
+ error: {
149
+ missing_platform: <<~MESSAGE,
150
+ The platform argument is missing.
151
+ Usage: {{command:%s app deploy [ heroku ]}}
152
+ MESSAGE
153
+ invalid_platform: <<~MESSAGE,
154
+ The platform argument passed {{command:%s}} is not supported.
155
+ Usage: {{command:%s app deploy [ heroku ]}}
156
+ MESSAGE
157
+ },
158
+ heroku: {
159
+ downloading: "Downloading Heroku CLI…",
160
+ downloaded: "Downloaded Heroku CLI",
161
+ installing: "Installing Heroku CLI…",
162
+ installing_windows: "Running Heroku CLI install wizard…",
163
+ installed: "Installed Heroku CLI",
164
+ authenticated_with_account: "{{v}} Authenticated with Heroku as {{green:%s}}",
165
+ authenticating: "Authenticating with Heroku…",
166
+ authenticated: "{{v}} Authenticated with Heroku",
167
+ deploying: "Deploying to Heroku…",
168
+ deployed: "{{v}} Deployed to Heroku",
169
+ php: {
170
+ post_deploy: <<~DEPLOYED,
171
+ {{v}} Deployed to Heroku, you can access your app at {{green:%s}}
172
+
173
+ If you're deploying this app for the first time, make sure to set up your database and your app's environment at {{bold:App dashboard -> Settings -> Config Vars}}.
174
+
175
+ When setting your config vars, don't forget to set up your database and the appropriate Laravel values for it, particularly {{bold:DB_CONNECTION and DB_DATABASE}}.
176
+ DEPLOYED
177
+ error: {
178
+ generate_app_key: "Failed to generate Laravel APP_KEY",
179
+ },
180
+ },
181
+ rails: {
182
+ db_check: {
183
+ validating: "Validating application…",
184
+ checking: "Checking database type…",
185
+ validated: "Database type \"%s\" validated for platform \"Heroku\"",
186
+ problem: "A problem was encountered while checking your database type.",
187
+ sqlite: <<~SQLITE,
188
+ Heroku does not support deployment using the SQLite database system.
189
+ Change the database type using {{command:rails db:system:change --to=[new_db_type]}}. For more info:
190
+ {{underline:https://gorails.com/episodes/rails-6-db-system-change-command}}
191
+ SQLITE
192
+ },
193
+ },
194
+ git: {
195
+ checking: "Checking git repo…",
196
+ initialized: "Git repo initialized",
197
+ what_branch: "What branch would you like to deploy?",
198
+ branch_selected: "{{v}} Git branch {{green:%s}} selected for deploy",
199
+ },
200
+ app: {
201
+ no_apps_found: "No existing Heroku app found. What would you like to do?",
202
+ name: "What is your Heroku app’s name?",
203
+ select: "Specify an existing Heroku app",
204
+ selecting: "Selecting Heroku app %s…",
205
+ selected: "{{v}} Heroku app {{green:%s}} selected",
206
+ create: "Create a new Heroku app",
207
+ creating: "Creating new Heroku app…",
208
+ created: "{{v}} New Heroku app created",
209
+ setting_configs: "Setting Shopify app configs…",
210
+ configs_set: "{{v}} Shopify app configs set",
211
+ },
212
+ },
213
+ },
214
+ connect: {
215
+ help: <<~HELP,
216
+ {{command:%s app connect}}: Connects an existing app to Shopify CLI. Creates a config file.
217
+ Usage: {{command:%s app connect}}
218
+ HELP
219
+ connected: "Project now connected to {{green:%s}}",
220
+ production_warning: <<~MESSAGE,
221
+ {{yellow:! Warning: if you have connected to an {{bold:app in production}}, running {{command:serve}} may update the app URL and cause an outage.
222
+ MESSAGE
223
+ },
224
+ tunnel: {
225
+ help: <<~HELP,
226
+ Start or stop an http tunnel to your local development app using ngrok.
227
+ Usage: {{command:%s app tunnel [ auth | start | stop ]}}
228
+ HELP
229
+ extended_help: <<~HELP,
230
+ {{bold:Subcommands:}}
231
+
232
+ {{cyan:auth}}: Writes an ngrok auth token to ~/.ngrok2/ngrok.yml to connect with an ngrok account. Visit https://dashboard.ngrok.com/signup to sign up.
233
+ Usage: {{command:%1$s app tunnel auth <token>}}
234
+
235
+ {{cyan:start}}: Starts an ngrok tunnel, will print the URL for an existing tunnel if already running.
236
+ Usage: {{command:%1$s app tunnel start}}
237
+
238
+ {{cyan:stop}}: Stops the ngrok tunnel.
239
+ Usage: {{command:%1$s app tunnel stop}}
240
+
241
+ HELP
242
+ error: {
243
+ token_argument_missing: "{{x}} {{red:auth requires a token argument}}\n\n",
244
+ },
245
+ },
246
+ serve: {
247
+ help: <<~HELP,
248
+ Start a local development server for your project, as well as a public ngrok tunnel to your localhost.
249
+ Usage: {{command:%s app serve}}
250
+ HELP
251
+ extended_help: <<~HELP,
252
+ {{bold:Options:}}
253
+ {{cyan:--host=HOST}}: Bypass running tunnel and use custom host. HOST must be HTTPS url.
254
+ {{cyan:--port=PORT}}: Use custom port.
255
+ HELP
256
+ open_info: <<~MESSAGE,
257
+ {{*}} To install and start using your app, open this URL in your browser:
258
+ {{green:%s}}
259
+ MESSAGE
260
+ running_server: "Running server…",
261
+ error: {
262
+ host_must_be_https: "HOST must be a HTTPS url.",
263
+ invalid_port: "%s is not a valid port.",
264
+ },
265
+ },
266
+ open: {
267
+ help: <<~HELP,
268
+ Open your local development app in the default browser.
269
+ Usage: {{command:%s app open}}
270
+ HELP
271
+ },
272
+ },
17
273
  error_reporting: {
18
274
  unhandled_error: {
19
275
  message: "{{x}} {{red:An unexpected error occured.}}",
20
- issue_message: "{{red:\tTo \e]8;;#{ShopifyCLI::Constants::Links::NEW_ISSUE}\e\\submit an issue\e]8;;\e\\"\
276
+ issue_message: "{{red:\tTo \e]8;;%s\e\\submit an issue\e]8;;\e\\"\
21
277
  " include the stack trace.}}",
22
278
  stacktrace_message: "{{red:\tTo print the stack trace, add the environment variable %s.}}",
23
279
  },
24
- enable_automatic_reporting_prompt: {
25
- question: "Automatically send error reports moving forward?",
26
- yes: "Automatically send error reports to the Shopify team",
27
- no: "Don't send error reports",
28
- enabled: "Anonymized error reports will be sent to Shopify.",
29
- },
30
280
  report_error: {
31
- question: "Send an error report to Shopify?",
32
- yes: "Send report",
33
- no: "Don't send",
281
+ question: "Send an anonymized error report to Shopify?",
282
+ yes: "Yes, send",
283
+ no: "No, don't send",
284
+ },
285
+ },
286
+ analytics: {
287
+ enable_prompt: {
288
+ uncaught_error: {
289
+ question: "Automatically send reports from now on?",
290
+ yes: "Yes, automatically send anonymized reports to Shopify",
291
+ no: "No, don't send",
292
+ },
293
+ usage: {
294
+ question: "Automatically send anonymized usage and error reports to Shopify? We use these"\
295
+ " to make development on Shopify better.",
296
+ yes: "Yes, automatically send anonymized reports to Shopify",
297
+ no: "No, don't send",
298
+ },
34
299
  },
35
300
  },
36
301
  connect: {
@@ -168,15 +433,6 @@ module ShopifyCLI
168
433
  disabled_as_shopify_org: "Can't switch development stores logged in as {{green:Shopify partners org}}",
169
434
  success: "Switched development store to {{green:%s}}",
170
435
  },
171
-
172
- monorail: {
173
- consent_prompt: <<~MSG,
174
- Would you like to enable anonymous usage reporting?
175
- If you select “Yes”, we’ll collect data about which commands you use and which errors you encounter.
176
- Sharing this anonymous data helps Shopify improve this tool.
177
- MSG
178
- },
179
-
180
436
  identity_auth: {
181
437
  error: {
182
438
  timeout: "Timed out while waiting for response from Shopify",
@@ -316,7 +572,7 @@ module ShopifyCLI
316
572
  error: {
317
573
  not_in_project: <<~MESSAGE,
318
574
  {{x}} You are not in a Shopify app project
319
- {{yellow:{{*}}}}{{reset: Run}}{{cyan: shopify rails create}}{{reset: or}}{{cyan: shopify node create}}{{reset: to create your app}}
575
+ {{yellow:{{*}}}}{{reset: Run}}{{cyan: shopify app create}}{{reset: to create your app}}
320
576
  MESSAGE
321
577
  },
322
578
  },
@@ -493,7 +749,24 @@ module ShopifyCLI
493
749
 
494
750
  MESSAGE
495
751
  },
496
-
752
+ reporting: {
753
+ help: <<~HELP,
754
+ Turns anonymous reporting on or off.
755
+ Usage: {{command:%s reporting on}}
756
+ HELP
757
+ invalid_argument: <<~MESSAGE,
758
+ {{command:%s reporting %s}} is not supported. The valid values are {{command:on}} or {{command:off}}
759
+ MESSAGE
760
+ missing_argument: <<~MESSAGE,
761
+ {{command:%s reporting}} expects an argument {{command:on}} or {{command:off}}
762
+ MESSAGE
763
+ turned_on_message: <<~MESSAGE,
764
+ Anonymized reports will be sent to Shopify.
765
+ MESSAGE
766
+ turned_off_message: <<~MESSAGE,
767
+ Turn on automatic reporting later wtih {{command:%s reporting on}}.
768
+ MESSAGE
769
+ },
497
770
  whoami: {
498
771
  help: <<~HELP,
499
772
  Identifies which partner organization or store you are currently logged into.
@@ -14,7 +14,7 @@ module ShopifyCLI
14
14
 
15
15
  def run
16
16
  require(path)
17
- ShopifyCli::Migrator::Migrations.const_get(class_name).run
17
+ ShopifyCLI::Migrator::Migrations.const_get(class_name).run
18
18
  rescue StandardError
19
19
  # Continue
20
20
  end
@@ -3,7 +3,7 @@
3
3
  module ShopifyCLI
4
4
  module Migrator
5
5
  module Migrations
6
- class Base
6
+ class Noop
7
7
  def self.run
8
8
  # This is a noop migration to be used as a reference
9
9
  end