shopify-cli 1.0.5 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CONTRIBUTING.md +1 -1
  3. data/CHANGELOG.md +20 -0
  4. data/bin/load_shopify.rb +3 -1
  5. data/bin/shopify +2 -0
  6. data/docs/core/index.md +16 -0
  7. data/docs/getting-started/index.md +3 -2
  8. data/docs/getting-started/install/index.md +55 -9
  9. data/docs/getting-started/uninstall/index.md +1 -1
  10. data/docs/getting-started/upgrade/index.md +8 -4
  11. data/ext/shopify-cli/extconf.rb +40 -20
  12. data/lib/project_types/extension/cli.rb +6 -1
  13. data/lib/project_types/extension/commands/register.rb +1 -1
  14. data/lib/project_types/extension/features/argo/admin.rb +20 -0
  15. data/lib/project_types/extension/features/argo/base.rb +129 -0
  16. data/lib/project_types/extension/features/argo/checkout.rb +20 -0
  17. data/lib/project_types/extension/features/argo_config.rb +60 -0
  18. data/lib/project_types/extension/messages/messages.rb +11 -2
  19. data/lib/project_types/extension/models/type.rb +4 -0
  20. data/lib/project_types/extension/models/types/checkout_post_purchase.rb +6 -3
  21. data/lib/project_types/extension/models/types/product_subscription.rb +24 -0
  22. data/lib/project_types/node/commands/create.rb +4 -4
  23. data/lib/project_types/node/commands/deploy/heroku.rb +6 -1
  24. data/lib/project_types/node/commands/generate/billing.rb +7 -5
  25. data/lib/project_types/node/commands/generate/page.rb +9 -5
  26. data/lib/project_types/node/commands/generate/webhook.rb +5 -1
  27. data/lib/project_types/node/commands/serve.rb +5 -5
  28. data/lib/project_types/node/messages/messages.rb +5 -1
  29. data/lib/project_types/rails/commands/create.rb +56 -5
  30. data/lib/project_types/rails/commands/generate.rb +1 -0
  31. data/lib/project_types/rails/commands/generate/webhook.rb +3 -2
  32. data/lib/project_types/rails/commands/serve.rb +11 -7
  33. data/lib/project_types/rails/gem.rb +61 -6
  34. data/lib/project_types/rails/messages/messages.rb +32 -12
  35. data/lib/project_types/script/config/extension_points.yml +4 -4
  36. data/lib/project_types/script/forms/create.rb +1 -1
  37. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +36 -1
  38. data/lib/project_types/script/layers/infrastructure/errors.rb +7 -0
  39. data/lib/project_types/script/layers/infrastructure/script_service.rb +6 -2
  40. data/lib/project_types/script/messages/messages.rb +12 -37
  41. data/lib/project_types/script/ui/error_handler.rb +13 -5
  42. data/lib/rubygems_plugin.rb +18 -10
  43. data/lib/shopify-cli/admin_api/populate_resource_command.rb +1 -1
  44. data/lib/shopify-cli/commands/config.rb +33 -1
  45. data/lib/shopify-cli/commands/connect.rb +1 -1
  46. data/lib/shopify-cli/commands/system.rb +9 -8
  47. data/lib/shopify-cli/context.rb +68 -0
  48. data/lib/shopify-cli/core/entry_point.rb +3 -0
  49. data/lib/shopify-cli/git.rb +1 -1
  50. data/lib/shopify-cli/heroku.rb +18 -2
  51. data/lib/shopify-cli/js_deps.rb +2 -2
  52. data/lib/shopify-cli/js_system.rb +24 -7
  53. data/lib/shopify-cli/messages/messages.rb +39 -11
  54. data/lib/shopify-cli/process_supervision.rb +52 -15
  55. data/lib/shopify-cli/project.rb +17 -9
  56. data/lib/shopify-cli/tunnel.rb +19 -4
  57. data/lib/shopify-cli/version.rb +1 -1
  58. data/lib/shopify_cli.rb +6 -2
  59. data/shopify-cli.gemspec +4 -1
  60. data/vendor/deps/cli-kit/REVISION +1 -1
  61. data/vendor/deps/cli-kit/lib/cli/kit.rb +1 -1
  62. data/vendor/deps/cli-kit/lib/cli/kit/autocall.rb +2 -2
  63. data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +12 -6
  64. data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +9 -11
  65. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +8 -2
  66. data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +7 -7
  67. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +48 -17
  68. data/vendor/deps/cli-ui/REVISION +1 -1
  69. data/vendor/deps/cli-ui/lib/cli/ui.rb +5 -4
  70. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +9 -3
  71. data/vendor/deps/cli-ui/lib/cli/ui/color.rb +1 -0
  72. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -2
  73. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -0
  74. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +13 -5
  75. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +29 -2
  76. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +21 -10
  77. data/vendor/deps/cli-ui/lib/cli/ui/os.rb +63 -0
  78. data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +11 -2
  79. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +1 -0
  80. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -3
  81. data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +6 -8
  82. data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +2 -0
  83. data/vendor/gen/lib/gen.rb +39 -0
  84. data/vendor/gen/lib/gen/commands.rb +18 -0
  85. data/vendor/gen/lib/gen/commands/help.rb +20 -0
  86. data/vendor/gen/lib/gen/commands/new.rb +21 -0
  87. data/vendor/gen/lib/gen/entry_point.rb +10 -0
  88. data/vendor/gen/lib/gen/generator.rb +165 -0
  89. data/vendor/gen/template/.gitignore +2 -0
  90. data/vendor/gen/template/Gemfile +10 -0
  91. data/vendor/gen/template/README.md +1 -0
  92. data/vendor/gen/template/bin/testunit +23 -0
  93. data/vendor/gen/template/bin/update-deps +97 -0
  94. data/vendor/gen/template/dev-gems.yml +3 -0
  95. data/vendor/gen/template/dev-vendor.yml +4 -0
  96. data/vendor/gen/template/exe/__app__-gems +17 -0
  97. data/vendor/gen/template/exe/__app__-vendor +18 -0
  98. data/vendor/gen/template/lib/__app__.rb +33 -0
  99. data/vendor/gen/template/lib/__app__/commands.rb +18 -0
  100. data/vendor/gen/template/lib/__app__/commands/example.rb +19 -0
  101. data/vendor/gen/template/lib/__app__/commands/help.rb +21 -0
  102. data/vendor/gen/template/lib/__app__/entry_point.rb +10 -0
  103. data/vendor/gen/template/test/example_test.rb +17 -0
  104. data/vendor/gen/template/test/test_helper.rb +22 -0
  105. metadata +30 -6
  106. data/Vagrantfile +0 -17
  107. data/lib/project_types/extension/features/argo.rb +0 -48
  108. data/lib/project_types/extension/models/types/subscription_management.rb +0 -20
  109. data/lib/project_types/script/forms/script_form.rb +0 -69
@@ -96,14 +96,11 @@ module Script
96
96
  {
97
97
  cause_of_error: ShopifyCli::Context.message('script.error.app_not_installed_cause'),
98
98
  }
99
- when Layers::Infrastructure::Errors::AppScriptNotPushedError
99
+ when Layers::Infrastructure::Errors::AppScriptNotPushedError,
100
+ Layers::Infrastructure::Errors::AppScriptUndefinedError
100
101
  {
101
102
  cause_of_error: ShopifyCli::Context.message('script.error.app_script_not_pushed_help'),
102
103
  }
103
- when Layers::Infrastructure::Errors::AppScriptUndefinedError
104
- {
105
- help_suggestion: ShopifyCli::Context.message('script.error.app_script_undefined_help'),
106
- }
107
104
  when Layers::Infrastructure::Errors::BuildError
108
105
  {
109
106
  cause_of_error: ShopifyCli::Context.message('script.error.build_error_cause'),
@@ -142,6 +139,17 @@ module Script
142
139
  {
143
140
  cause_of_error: ShopifyCli::Context.message('script.error.shop_script_undefined_cause'),
144
141
  }
142
+ when Layers::Infrastructure::Errors::PackagesOutdatedError
143
+ {
144
+ cause_of_error: ShopifyCli::Context.message(
145
+ 'script.error.packages_outdated_cause',
146
+ e.outdated_packages.join(', ')
147
+ ),
148
+ help_suggestion: ShopifyCli::Context.message(
149
+ 'script.error.packages_outdated_help',
150
+ e.outdated_packages.collect { |package| "#{package}@latest" }.join(' ')
151
+ ),
152
+ }
145
153
  end
146
154
  end
147
155
  end
@@ -1,17 +1,25 @@
1
1
  Gem.post_uninstall do |uninstaller|
2
2
  if uninstaller.spec.name == 'shopify-cli'
3
- require 'fileutils'
3
+ if RUBY_PLATFORM.match(/mingw32/)
4
+ bat_path = File.dirname(RbConfig.ruby)
5
+ bat = "#{bat_path}\\shopify.bat"
4
6
 
5
- symlink = '/usr/local/bin/shopify'
7
+ # delete the auto-generated batch script
8
+ File.unlink(bat)
9
+ else
10
+ require 'fileutils'
6
11
 
7
- # delete the symbolic link IFF it exists AND it does not point to a file
8
- # (i.e., it's been left hanging as a result of the uninstall, as expected)
9
- #
10
- # if the file still exists, either the uninstall failed (possible but
11
- # unlikely) OR
12
- # there's another installation of the gem in another ruby folder that has
13
- # overwritten it, so leave the symbolic link alone
14
- system("sudo rm -f #{symlink}") if File.symlink?(symlink) && !File.exist?(symlink)
12
+ symlink = '/usr/local/bin/shopify'
13
+
14
+ # delete the symbolic link IFF it exists AND it does not point to a file
15
+ # (i.e., it's been left hanging as a result of the uninstall, as expected)
16
+ #
17
+ # if the file still exists, either the uninstall failed (possible but
18
+ # unlikely) OR
19
+ # there's another installation of the gem in another ruby folder that has
20
+ # overwritten it, so leave the symbolic link alone
21
+ system("sudo rm -f #{symlink}") if File.symlink?(symlink) && !File.exist?(symlink)
22
+ end
15
23
  end
16
24
 
17
25
  true
@@ -118,7 +118,7 @@ module ShopifyCli
118
118
  kwargs = { input: data }
119
119
  kwargs[:shop] = @shop
120
120
  resp = AdminAPI.query(
121
- @ctx, "create_#{snake_case_resource_type}", kwargs
121
+ @ctx, "create_#{snake_case_resource_type}", **kwargs
122
122
  )
123
123
  @ctx.abort(resp['errors']) if resp['errors']
124
124
  @ctx.done(message(resp['data'])) unless @silent
@@ -6,6 +6,7 @@ module ShopifyCli
6
6
  hidden_feature(feature_set: :debug)
7
7
 
8
8
  subcommand :Feature, 'feature'
9
+ subcommand :Analytics, 'analytics'
9
10
 
10
11
  def call(*)
11
12
  @ctx.puts(self.class.help)
@@ -16,6 +17,10 @@ module ShopifyCli
16
17
  end
17
18
 
18
19
  class Feature < ShopifyCli::SubCommand
20
+ def self.help
21
+ ShopifyCli::Context.message('core.config.feature.help', ShopifyCli::TOOL_NAME)
22
+ end
23
+
19
24
  options do |parser, flags|
20
25
  parser.on('--enable') { flags[:action] = 'enable' }
21
26
  parser.on('--disable') { flags[:action] = 'disable' }
@@ -28,7 +33,7 @@ module ShopifyCli
28
33
  is_enabled = ShopifyCli::Feature.enabled?(feature_name)
29
34
  if options.flags[:action] == 'disable' && is_enabled
30
35
  ShopifyCli::Feature.disable(feature_name)
31
- @ctx.puts(@ctx.message('core.config.feature.disabled', is_enabled))
36
+ @ctx.puts(@ctx.message('core.config.feature.disabled', feature_name))
32
37
  elsif options.flags[:action] == 'enable' && !is_enabled
33
38
  ShopifyCli::Feature.enable(feature_name)
34
39
  @ctx.puts(@ctx.message('core.config.feature.enabled', feature_name))
@@ -39,6 +44,33 @@ module ShopifyCli
39
44
  end
40
45
  end
41
46
  end
47
+
48
+ class Analytics < ShopifyCli::SubCommand
49
+ def self.help
50
+ ShopifyCli::Context.message('core.config.analytics.help', ShopifyCli::TOOL_NAME)
51
+ end
52
+
53
+ options do |parser, flags|
54
+ parser.on('--enable') { flags[:action] = 'enable' }
55
+ parser.on('--disable') { flags[:action] = 'disable' }
56
+ parser.on('--status') { flags[:action] = 'status' }
57
+ end
58
+
59
+ def call(_args, _name)
60
+ is_enabled = ShopifyCli::Config.get_bool('analytics', 'enabled')
61
+ if options.flags[:action] == 'disable' && is_enabled
62
+ ShopifyCli::Config.set('analytics', 'enabled', false)
63
+ @ctx.puts(@ctx.message('core.config.analytics.disabled'))
64
+ elsif options.flags[:action] == 'enable' && !is_enabled
65
+ ShopifyCli::Config.set('analytics', 'enabled', true)
66
+ @ctx.puts(@ctx.message('core.config.analytics.enabled'))
67
+ elsif is_enabled
68
+ @ctx.puts(@ctx.message('core.config.analytics.is_enabled'))
69
+ else
70
+ @ctx.puts(@ctx.message('core.config.analytics.is_disabled'))
71
+ end
72
+ end
73
+ end
42
74
  end
43
75
  end
44
76
  end
@@ -13,8 +13,8 @@ module ShopifyCli
13
13
  end
14
14
 
15
15
  org = ShopifyCli::Tasks::EnsureEnv.call(@ctx, regenerate: true)
16
- api_key = Project.current.env['api_key']
17
16
  write_cli_yml(project_type, org['id']) unless Project.has_current?
17
+ api_key = Project.current(force_reload: true).env['api_key']
18
18
  @ctx.puts(@ctx.message('core.connect.connected', get_app(org['apps'], api_key).first["title"]))
19
19
  end
20
20
 
@@ -68,13 +68,14 @@ module ShopifyCli
68
68
  end
69
69
 
70
70
  def display_utility_commands(_show_all_details)
71
- commands = %w(git curl tar unzip)
71
+ commands = %w(git curl tar)
72
72
 
73
73
  @ctx.puts("\n" + @ctx.message('core.system.command_header'))
74
74
  commands.each do |s|
75
- output, status = @ctx.capture2e('which', s)
76
- if status.success?
77
- @ctx.puts(" " + @ctx.message('core.system.command_with_path', s, output))
75
+ cmd_path = @ctx.which(s)
76
+
77
+ if !cmd_path.nil?
78
+ @ctx.puts(" " + @ctx.message('core.system.command_with_path', s, cmd_path))
78
79
  else
79
80
  @ctx.puts(" " + @ctx.message('core.system.command_not_found', s))
80
81
  end
@@ -82,7 +83,7 @@ module ShopifyCli
82
83
  end
83
84
 
84
85
  def display_ngrok
85
- ngrok_location = File.join(ShopifyCli.cache_dir, 'ngrok')
86
+ ngrok_location = File.join(ShopifyCli.cache_dir, @ctx.windows? ? 'ngrok.exe' : 'ngrok')
86
87
  if File.exist?(ngrok_location)
87
88
  @ctx.puts(" " + @ctx.message('core.system.ngrok_available', ngrok_location))
88
89
  else
@@ -102,11 +103,11 @@ module ShopifyCli
102
103
  def display_project(project_type, commands)
103
104
  @ctx.puts("\n" + @ctx.message('core.system.project.header', project_type))
104
105
  commands.each do |s|
105
- output, status = @ctx.capture2e('which', s)
106
- if status.success?
106
+ cmd_path = @ctx.which(s)
107
+ if !cmd_path.nil?
107
108
  version_output, _ = @ctx.capture2e(s, '--version')
108
109
  version = version_output.match(/(\d+\.[^\s]+)/)[0]
109
- @ctx.puts(" " + @ctx.message('core.system.project.command_with_path', s, output.strip, version.strip))
110
+ @ctx.puts(" " + @ctx.message('core.system.project.command_with_path', s, cmd_path.strip, version.strip))
110
111
  else
111
112
  @ctx.puts(" " + @ctx.message('core.system.project.command_not_found', s))
112
113
  end
@@ -2,6 +2,8 @@
2
2
  require 'shopify_cli'
3
3
  require 'fileutils'
4
4
  require 'rbconfig'
5
+ require 'net/http'
6
+ require 'json'
5
7
 
6
8
  module ShopifyCli
7
9
  ##
@@ -11,6 +13,11 @@ module ShopifyCli
11
13
  # resoures.
12
14
  #
13
15
  class Context
16
+ GEM_LATEST_URI = URI.parse('https://rubygems.org/api/v1/versions/shopify-cli/latest.json')
17
+ VERSION_CHECK_SECTION = 'versioncheck'
18
+ LAST_CHECKED_AT_FIELD = 'last_checked_at'
19
+ VERSION_CHECK_INTERVAL = 86400
20
+
14
21
  class << self
15
22
  attr_reader :messages
16
23
 
@@ -56,6 +63,7 @@ module ShopifyCli
56
63
  host = uname
57
64
  return :mac if /darwin/.match(host)
58
65
  return :linux if /linux/.match(host)
66
+ return :windows if /mingw32/.match(host)
59
67
  end
60
68
 
61
69
  # will return true if the cli is running on an apple computer.
@@ -68,6 +76,11 @@ module ShopifyCli
68
76
  os == :linux
69
77
  end
70
78
 
79
+ # will return true if the cli is running on Windows
80
+ def windows?
81
+ os == :windows
82
+ end
83
+
71
84
  # will return true if the cli is being run from an installation, and not a
72
85
  # development instance. The gem installation will not have a 'test' directory.
73
86
  # See `#development?` for checking for development environment.
@@ -418,6 +431,45 @@ module ShopifyCli
418
431
  end
419
432
  end
420
433
 
434
+ # Checks if the given command exists in the system
435
+ #
436
+ # #### Parameters
437
+ # - `cmd`: The command to test
438
+ #
439
+ # #### Returns
440
+ # The path of the executable if it is found
441
+ #
442
+ # @todo This is currently a duplicate of CLI::Kit::System.which() - we should make that method public when we make
443
+ # Kit changes and make this a wrapper instead.
444
+ def which(cmd)
445
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
446
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
447
+ exts.each do |ext|
448
+ exe = File.join(File.expand_path(path), "#{cmd}#{ext}")
449
+ return exe if File.executable?(exe) && !File.directory?(exe)
450
+ end
451
+ end
452
+
453
+ nil
454
+ end
455
+
456
+ # Checks if there's a newer version of the CLI available and returns version string if
457
+ # this should be conveyed to the user (i.e., if it's been over 24 hours since last check)
458
+ #
459
+ # #### Parameters
460
+ #
461
+ # #### Returns
462
+ # - `version`: string of newer version available, IFF new version is available AND it's time to inform user,
463
+ # : nil otherwise
464
+ #
465
+ def new_version
466
+ if (time_of_last_check + VERSION_CHECK_INTERVAL) < (now = Time.now.to_i)
467
+ update_time_of_last_check(now)
468
+ latest_version = retrieve_latest_gem_version
469
+ latest_version unless latest_version == ShopifyCli::VERSION
470
+ end
471
+ end
472
+
421
473
  private
422
474
 
423
475
  def ctx_path(fname)
@@ -428,5 +480,21 @@ module ShopifyCli
428
480
  File.join(root, fname)
429
481
  end
430
482
  end
483
+
484
+ def retrieve_latest_gem_version
485
+ response = Net::HTTP.get_response(GEM_LATEST_URI)
486
+ latest = JSON.parse(response.body)
487
+ latest["version"]
488
+ rescue
489
+ nil
490
+ end
491
+
492
+ def time_of_last_check
493
+ (val = ShopifyCli::Config.get(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD)) ? val.to_i : 0
494
+ end
495
+
496
+ def update_time_of_last_check(time)
497
+ ShopifyCli::Config.set(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD, time)
498
+ end
431
499
  end
432
500
  end
@@ -28,6 +28,9 @@ module ShopifyCli
28
28
  ctx.puts(
29
29
  ctx.message('core.warning.development_version', File.join(ShopifyCli::ROOT, 'bin', ShopifyCli::TOOL_NAME))
30
30
  )
31
+ else
32
+ new_version = ctx.new_version
33
+ ctx.puts(ctx.message('core.warning.new_version', ShopifyCli::VERSION, new_version)) unless new_version.nil?
31
34
  end
32
35
 
33
36
  ProjectType.load_type(Project.current_project_type)
@@ -125,13 +125,13 @@ module ShopifyCli
125
125
 
126
126
  success = Open3.popen3('git', *git_command, '--progress') do |_stdin, _stdout, stderr, thread|
127
127
  while (line = stderr.gets)
128
+ msg << line.chomp
128
129
  next unless line.strip.start_with?('Receiving objects:')
129
130
  percent = (line.match(/Receiving objects:\s+(\d+)/)[1].to_f / 100).round(2)
130
131
  bar.tick(set_percent: percent)
131
132
  next
132
133
  end
133
134
 
134
- msg << stderr
135
135
  thread.value
136
136
  end.success?
137
137
 
@@ -3,7 +3,7 @@ module ShopifyCli
3
3
  DOWNLOAD_URLS = {
4
4
  linux: 'https://cli-assets.heroku.com/heroku-linux-x64.tar.gz',
5
5
  mac: 'https://cli-assets.heroku.com/heroku-darwin-x64.tar.gz',
6
- windows: 'https://cli-assets.heroku.com/heroku-win32-x64.tar.gz',
6
+ windows: 'https://cli-assets.heroku.com/heroku-x64.exe',
7
7
  }
8
8
 
9
9
  def initialize(ctx)
@@ -44,7 +44,11 @@ module ShopifyCli
44
44
  def install
45
45
  return if installed?
46
46
 
47
- result = @ctx.system('tar', '-xf', download_path, chdir: ShopifyCli.cache_dir)
47
+ result = if @ctx.windows?
48
+ @ctx.system("\"#{download_path}\"")
49
+ else
50
+ @ctx.system('tar', '-xf', download_path, chdir: ShopifyCli.cache_dir)
51
+ end
48
52
  @ctx.abort(@ctx.message('core.heroku.error.install')) unless result.success?
49
53
 
50
54
  @ctx.rm(download_path)
@@ -82,6 +86,18 @@ module ShopifyCli
82
86
  local_path = File.join(ShopifyCli.cache_dir, 'heroku', 'bin', 'heroku').to_s
83
87
  if File.exist?(local_path)
84
88
  local_path
89
+ elsif @ctx.windows?
90
+ # Check if Heroku exists in the Windows registry and run it from there
91
+ require 'win32/registry'
92
+ begin
93
+ windows_path = Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\heroku') do |reg|
94
+ reg[''] # This reads the 'Default' registry key
95
+ end
96
+
97
+ File.join(windows_path, 'bin', 'heroku').to_s
98
+ rescue
99
+ 'heroku'
100
+ end
85
101
  else
86
102
  'heroku'
87
103
  end
@@ -69,7 +69,7 @@ module ShopifyCli
69
69
  deps = parse_dependencies
70
70
  errors = nil
71
71
 
72
- spinner_title = ctx.message('core.js_deps.installing_deps', deps.size)
72
+ spinner_title = ctx.message('core.js_deps.installing', @system.package_manager)
73
73
  success = CLI::UI::Spinner.spin(spinner_title, auto_debrief: false) do |spinner|
74
74
  _, errors, status = CLI::Kit::System.capture3(*cmd, env: @ctx.env, chdir: ctx.root)
75
75
  update_spinner_title_and_status(spinner, status, deps)
@@ -81,7 +81,7 @@ module ShopifyCli
81
81
 
82
82
  def update_spinner_title_and_status(spinner, status, deps)
83
83
  if status.success?
84
- spinner.update_title(ctx.message('core.js_deps.installed_deps', deps.size))
84
+ spinner.update_title(ctx.message('core.js_deps.installed', deps.size))
85
85
  else
86
86
  spinner.update_title(ctx.message('core.js_deps.error.install_spinner_error', deps.size))
87
87
  CLI::UI::Spinner::TASK_FAILED
@@ -64,8 +64,8 @@ module ShopifyCli
64
64
  #
65
65
  def yarn?
66
66
  @has_yarn ||= begin
67
- _, status = CLI::Kit::System.capture2('which', 'yarn')
68
- File.exist?(File.join(ctx.root, 'yarn.lock')) && status.success?
67
+ cmd_path = @ctx.which('yarn')
68
+ File.exist?(File.join(ctx.root, 'yarn.lock')) && !cmd_path.nil?
69
69
  end
70
70
  end
71
71
 
@@ -76,23 +76,40 @@ module ShopifyCli
76
76
  # - `ctx`: running context from your command
77
77
  # - `yarn`: The proc, array, or string command to run if yarn is available
78
78
  # - `npm`: The proc, array, or string command to run if npm is available
79
+ # - `capture_response`: The boolean flag to capture the output of the running command if it is set to true
79
80
  #
80
81
  # #### Example
81
82
  #
82
- # ShopifyCli::JsSystem.new(ctx: ctx).call(yarn: ['install', '--silent'], npm: ['install', '--no-audit'])
83
+ # ShopifyCli::JsSystem.new(ctx: ctx).call(
84
+ # yarn: ['install', '--silent'],
85
+ # npm: ['install', '--no-audit'],
86
+ # capture_response: false
87
+ # )
83
88
  #
84
- def call(yarn:, npm:)
85
- yarn? ? call_command(yarn, YARN_CORE_COMMAND) : call_command(npm, NPM_CORE_COMMAND)
89
+ def call(yarn:, npm:, capture_response: false)
90
+ if yarn?
91
+ call_command(yarn, YARN_CORE_COMMAND, capture_response)
92
+ else
93
+ call_command(npm, NPM_CORE_COMMAND, capture_response)
94
+ end
86
95
  end
87
96
 
88
97
  private
89
98
 
90
- def call_command(command, core_command)
99
+ def call_command(command, core_command, capture_response)
91
100
  if command.is_a?(String) || command.is_a?(Array)
92
- CLI::Kit::System.system(core_command, *command, chdir: ctx.root).success?
101
+ capture_response ? call_with_capture(command, core_command) : call_without_capture(command, core_command)
93
102
  else
94
103
  command.call
95
104
  end
96
105
  end
106
+
107
+ def call_with_capture(command, core_command)
108
+ CLI::Kit::System.capture3(core_command, *command, chdir: ctx.root)
109
+ end
110
+
111
+ def call_without_capture(command, core_command)
112
+ CLI::Kit::System.system(core_command, *command, chdir: ctx.root).success?
113
+ end
97
114
  end
98
115
  end
@@ -48,13 +48,27 @@ module ShopifyCli
48
48
  config: {
49
49
  help: <<~HELP,
50
50
  Change configuration of how the CLI operates
51
- Usage: {{command:%s config [ feature ] [ feature_name ] }}
51
+ Usage: {{command:%s config [ feature | analytics ] }}
52
52
  HELP
53
53
  feature: {
54
- enabled: "{{v}} feature {{green:%s}} was enabled",
55
- disabled: "{{v}} feature {{green:%s}} was disabled",
56
- is_enabled: "{{v}} feature {{green:%s}} is enabled",
57
- is_disabled: "{{v}} feature {{green:%s}} is disabled",
54
+ help: <<~HELP,
55
+ Change configuration of various features
56
+ Usage: {{command:%s config [ feature ] [ feature_name ] }}
57
+ HELP
58
+ enabled: "{{v}} feature {{green:%s}} has been enabled",
59
+ disabled: "{{v}} feature {{green:%s}} has been disabled",
60
+ is_enabled: "{{v}} feature {{green:%s}} is currently enabled",
61
+ is_disabled: "{{v}} feature {{green:%s}} is currently disabled",
62
+ },
63
+ analytics: {
64
+ help: <<~HELP,
65
+ Opt in/out of anonymous usage reporting
66
+ Usage: {{command:%s config [ analytics ] }}
67
+ HELP
68
+ enabled: "{{v}} analytics have been enabled",
69
+ disabled: "{{v}} analytics have been disabled",
70
+ is_enabled: "{{v}} analytics are currently enabled",
71
+ is_disabled: "{{v}} analytics are currently disabled",
58
72
  },
59
73
  },
60
74
 
@@ -184,11 +198,14 @@ module ShopifyCli
184
198
  {{x}} You are not in a Shopify app project
185
199
  {{yellow:{{*}}}}{{reset: Run}}{{cyan: shopify create}}{{reset: to create your app}}
186
200
  MESSAGE
187
- cli_yaml: {
188
- not_hash: "{{x}} .shopify-cli.yml was not a proper YAML file. Expecting a hash.",
189
- invalid: "{{x}} %s contains invalid YAML: %s",
190
- not_found: "{{x}} %s not found",
191
- },
201
+ },
202
+ },
203
+
204
+ yaml: {
205
+ error: {
206
+ not_hash: "{{x}} %s was not a proper YAML file. Expecting a hash.",
207
+ invalid: "{{x}} %s contains invalid YAML: %s",
208
+ not_found: "{{x}} %s not found",
192
209
  },
193
210
  },
194
211
 
@@ -289,6 +306,8 @@ module ShopifyCli
289
306
  error: {
290
307
  stop: "ngrok tunnel could not be stopped. Try running {{command:killall -9 ngrok}}",
291
308
  url_fetch_failure: "Unable to fetch external url",
309
+ prereq_command_required: "%1$s is required for installing ngrok. Please install %1$s using the appropriate"\
310
+ " package manager for your system.",
292
311
  },
293
312
 
294
313
  not_running: "{{green:x}} ngrok tunnel not running",
@@ -302,6 +321,7 @@ module ShopifyCli
302
321
  stopped: "{{green:x}} ngrok tunnel stopped",
303
322
  timed_out: "{{x}} ngrok tunnel has timed out, restarting ...",
304
323
  will_timeout: "{{*}} This tunnel will timeout in {{red:%s}}",
324
+ prereq_command_location: "%s @ %s",
305
325
  },
306
326
 
307
327
  version: {
@@ -314,7 +334,7 @@ module ShopifyCli
314
334
  warning: {
315
335
  development_version: <<~DEVELOPMENT,
316
336
  {{*}} {{yellow:You are running a development version of the CLI at:}}
317
- {{yellow:%s}}
337
+ {{yellow:%s}}
318
338
 
319
339
  DEVELOPMENT
320
340
 
@@ -325,6 +345,14 @@ module ShopifyCli
325
345
  {{underline:https://shopify.github.io/shopify-app-cli/migrate/}}
326
346
 
327
347
  MESSAGE
348
+
349
+ new_version: <<~MESSAGE,
350
+ {{*}} {{yellow:A new version of the Shopify App CLI is available! You have version %s and the latest version is %s.
351
+
352
+ To upgrade, follow the instructions for the package manager you’re using:
353
+ {{underline:https://shopify.github.io/shopify-app-cli/getting-started/upgrade/}}}}
354
+
355
+ MESSAGE
328
356
  },
329
357
  },
330
358
  }.freeze