shopify-cli 1.0.2 → 1.1.1

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 (138) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/CHANGELOG.md +20 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +13 -13
  6. data/bin/load_shopify.rb +3 -1
  7. data/bin/shopify +2 -0
  8. data/docs/Gemfile.lock +23 -13
  9. data/docs/getting-started/index.md +3 -2
  10. data/docs/getting-started/install/index.md +55 -9
  11. data/docs/getting-started/uninstall/index.md +1 -1
  12. data/docs/getting-started/upgrade/index.md +8 -4
  13. data/ext/shopify-cli/extconf.rb +40 -20
  14. data/lib/project_types/extension/cli.rb +1 -1
  15. data/lib/project_types/extension/commands/build.rb +1 -1
  16. data/lib/project_types/extension/models/type.rb +1 -0
  17. data/lib/project_types/extension/tasks/create_extension.rb +1 -1
  18. data/lib/project_types/extension/tasks/get_app.rb +1 -1
  19. data/lib/project_types/extension/tasks/update_draft.rb +1 -1
  20. data/lib/project_types/node/commands/create.rb +4 -4
  21. data/lib/project_types/node/commands/deploy/heroku.rb +6 -1
  22. data/lib/project_types/node/commands/generate/billing.rb +7 -5
  23. data/lib/project_types/node/commands/generate/page.rb +9 -5
  24. data/lib/project_types/node/commands/generate/webhook.rb +5 -1
  25. data/lib/project_types/node/messages/messages.rb +1 -0
  26. data/lib/project_types/rails/cli.rb +0 -1
  27. data/lib/project_types/rails/commands/create.rb +52 -4
  28. data/lib/project_types/rails/commands/generate.rb +1 -0
  29. data/lib/project_types/rails/commands/generate/webhook.rb +3 -2
  30. data/lib/project_types/rails/commands/serve.rb +6 -2
  31. data/lib/project_types/rails/gem.rb +61 -6
  32. data/lib/project_types/rails/messages/messages.rb +27 -11
  33. data/lib/project_types/script/cli.rb +2 -3
  34. data/lib/project_types/script/commands/create.rb +5 -9
  35. data/lib/project_types/script/commands/disable.rb +4 -15
  36. data/lib/project_types/script/commands/enable.rb +37 -13
  37. data/lib/project_types/script/commands/push.rb +8 -13
  38. data/lib/project_types/script/config/extension_points.yml +9 -3
  39. data/lib/project_types/script/errors.rb +8 -0
  40. data/lib/project_types/script/forms/create.rb +1 -1
  41. data/lib/project_types/script/layers/application/create_script.rb +7 -6
  42. data/lib/project_types/script/layers/application/disable_script.rb +9 -7
  43. data/lib/project_types/script/layers/application/enable_script.rb +11 -9
  44. data/lib/project_types/script/layers/application/push_script.rb +6 -4
  45. data/lib/project_types/script/layers/domain/errors.rb +2 -0
  46. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +2 -2
  47. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +1 -1
  48. data/lib/project_types/script/layers/infrastructure/errors.rb +2 -0
  49. data/lib/project_types/script/layers/infrastructure/script_service.rb +8 -2
  50. data/lib/project_types/script/messages/messages.rb +25 -31
  51. data/lib/project_types/script/script_project.rb +6 -2
  52. data/lib/project_types/script/templates/ts/as-pect.config.js +6 -0
  53. data/lib/project_types/script/ui/error_handler.rb +8 -0
  54. data/lib/project_types/script/ui/printing_spinner.rb +75 -0
  55. data/lib/rubygems_plugin.rb +18 -10
  56. data/lib/shopify-cli/admin_api/populate_resource_command.rb +1 -1
  57. data/lib/shopify-cli/admin_api/schema.rb +20 -18
  58. data/lib/shopify-cli/command.rb +14 -11
  59. data/lib/shopify-cli/commands.rb +1 -0
  60. data/lib/shopify-cli/commands/config.rb +44 -0
  61. data/lib/shopify-cli/commands/connect.rb +8 -69
  62. data/lib/shopify-cli/commands/create.rb +2 -2
  63. data/lib/shopify-cli/commands/help.rb +1 -1
  64. data/lib/shopify-cli/commands/system.rb +22 -13
  65. data/lib/shopify-cli/context.rb +28 -0
  66. data/lib/shopify-cli/core.rb +0 -1
  67. data/lib/shopify-cli/core/entry_point.rb +1 -1
  68. data/lib/shopify-cli/core/executor.rb +3 -5
  69. data/lib/shopify-cli/core/monorail.rb +1 -1
  70. data/lib/shopify-cli/db.rb +1 -1
  71. data/lib/shopify-cli/feature.rb +97 -0
  72. data/lib/shopify-cli/heroku.rb +21 -5
  73. data/lib/shopify-cli/js_deps.rb +2 -2
  74. data/lib/shopify-cli/js_system.rb +2 -2
  75. data/lib/shopify-cli/messages/messages.rb +40 -12
  76. data/lib/shopify-cli/partners_api/organizations.rb +7 -7
  77. data/lib/shopify-cli/process_supervision.rb +60 -21
  78. data/lib/shopify-cli/project.rb +14 -6
  79. data/lib/shopify-cli/project_type.rb +5 -7
  80. data/lib/shopify-cli/sub_command.rb +1 -0
  81. data/lib/shopify-cli/task.rb +2 -2
  82. data/lib/shopify-cli/tasks.rb +11 -4
  83. data/lib/shopify-cli/tasks/ensure_env.rb +72 -16
  84. data/lib/shopify-cli/tasks/update_dashboard_urls.rb +4 -3
  85. data/lib/shopify-cli/tunnel.rb +53 -14
  86. data/lib/shopify-cli/version.rb +1 -1
  87. data/lib/shopify_cli.rb +36 -9
  88. data/shopify-cli.gemspec +4 -1
  89. data/vendor/deps/cli-kit/REVISION +1 -1
  90. data/vendor/deps/cli-kit/lib/cli/kit.rb +1 -1
  91. data/vendor/deps/cli-kit/lib/cli/kit/autocall.rb +2 -2
  92. data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +12 -6
  93. data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +9 -11
  94. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +8 -2
  95. data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +7 -7
  96. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +48 -17
  97. data/vendor/deps/cli-ui/REVISION +1 -1
  98. data/vendor/deps/cli-ui/lib/cli/ui.rb +5 -4
  99. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +9 -3
  100. data/vendor/deps/cli-ui/lib/cli/ui/color.rb +1 -0
  101. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -2
  102. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -0
  103. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +13 -5
  104. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +29 -2
  105. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +21 -10
  106. data/vendor/deps/cli-ui/lib/cli/ui/os.rb +63 -0
  107. data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +11 -2
  108. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +1 -0
  109. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -3
  110. data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +6 -8
  111. data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +2 -0
  112. data/vendor/gen/lib/gen.rb +39 -0
  113. data/vendor/gen/lib/gen/commands.rb +18 -0
  114. data/vendor/gen/lib/gen/commands/help.rb +20 -0
  115. data/vendor/gen/lib/gen/commands/new.rb +21 -0
  116. data/vendor/gen/lib/gen/entry_point.rb +10 -0
  117. data/vendor/gen/lib/gen/generator.rb +165 -0
  118. data/vendor/gen/template/.gitignore +2 -0
  119. data/vendor/gen/template/Gemfile +10 -0
  120. data/vendor/gen/template/README.md +1 -0
  121. data/vendor/gen/template/bin/testunit +23 -0
  122. data/vendor/gen/template/bin/update-deps +97 -0
  123. data/vendor/gen/template/dev-gems.yml +3 -0
  124. data/vendor/gen/template/dev-vendor.yml +4 -0
  125. data/vendor/gen/template/exe/__app__-gems +17 -0
  126. data/vendor/gen/template/exe/__app__-vendor +18 -0
  127. data/vendor/gen/template/lib/__app__.rb +33 -0
  128. data/vendor/gen/template/lib/__app__/commands.rb +18 -0
  129. data/vendor/gen/template/lib/__app__/commands/example.rb +19 -0
  130. data/vendor/gen/template/lib/__app__/commands/help.rb +21 -0
  131. data/vendor/gen/template/lib/__app__/entry_point.rb +10 -0
  132. data/vendor/gen/template/test/example_test.rb +17 -0
  133. data/vendor/gen/template/test/test_helper.rb +22 -0
  134. metadata +28 -6
  135. data/Vagrantfile +0 -17
  136. data/lib/project_types/script/forms/enable.rb +0 -24
  137. data/lib/project_types/script/forms/push.rb +0 -19
  138. data/lib/project_types/script/forms/script_form.rb +0 -66
@@ -6,27 +6,20 @@ module ShopifyCli
6
6
  def call(*)
7
7
  project_type = ask_project_type unless Project.has_current?
8
8
 
9
- if Project.has_current? && Project.current
9
+ if Project.has_current? && Project.current && Project.current.env
10
10
  @ctx.puts @ctx.message('core.connect.already_connected_warning')
11
11
  prod_warning = @ctx.message('core.connect.production_warning')
12
12
  @ctx.puts prod_warning if [:rails, :node].include?(Project.current_project_type)
13
13
  end
14
14
 
15
- env_data = begin
16
- Resources::EnvFile.parse_external_env
17
- rescue Errno::ENOENT
18
- {}
19
- end
20
-
21
- org = fetch_org
22
- id = org['id']
23
- app = get_app(org['apps'])
24
- shop = get_shop(org['stores'], id)
25
-
26
- write_env(app, shop, env_data[:scopes], env_data[:extra])
27
- write_cli_yml(project_type, id) unless Project.has_current?
15
+ org = ShopifyCli::Tasks::EnsureEnv.call(@ctx, regenerate: true)
16
+ write_cli_yml(project_type, org['id']) unless Project.has_current?
17
+ api_key = Project.current(force_reload: true).env['api_key']
18
+ @ctx.puts(@ctx.message('core.connect.connected', get_app(org['apps'], api_key).first["title"]))
19
+ end
28
20
 
29
- @ctx.puts(@ctx.message('core.connect.connected', app.first['title']))
21
+ def get_app(apps, api_key)
22
+ apps.select { |app| app["apiKey"] == api_key }
30
23
  end
31
24
 
32
25
  def ask_project_type
@@ -37,60 +30,6 @@ module ShopifyCli
37
30
  end
38
31
  end
39
32
 
40
- def fetch_org
41
- orgs = PartnersAPI::Organizations.fetch_with_app(@ctx)
42
- org_id = if orgs.count == 1
43
- orgs.first["id"]
44
- else
45
- CLI::UI::Prompt.ask(@ctx.message('core.connect.organization_select')) do |handler|
46
- orgs.each do |org|
47
- handler.option(
48
- ctx.message('core.partners_api.org_name_and_id', org['businessName'], org['id'])
49
- ) { org["id"] }
50
- end
51
- end
52
- end
53
- org = orgs.find { |o| o["id"] == org_id }
54
- org
55
- end
56
-
57
- def get_app(apps)
58
- app_id = if apps.count == 1
59
- apps.first["id"]
60
- else
61
- CLI::UI::Prompt.ask(@ctx.message('core.connect.app_select')) do |handler|
62
- apps.each { |app| handler.option(app["title"]) { app["id"] } }
63
- end
64
- end
65
- apps.select { |app| app["id"] == app_id }
66
- end
67
-
68
- def get_shop(shops, id)
69
- if shops.count == 1
70
- shop = shops.first["shopDomain"]
71
- elsif shops.count == 0
72
- @ctx.puts(@ctx.message('core.connect.no_development_stores', id))
73
- else
74
- shop = CLI::UI::Prompt.ask(@ctx.message('core.connect.development_store_select')) do |handler|
75
- shops.each { |s| handler.option(s["shopName"]) { s["shopDomain"] } }
76
- end
77
- end
78
- shop
79
- end
80
-
81
- def write_env(app, shop, scopes, extra)
82
- scopes = 'write_products,write_customers,write_draft_orders' if scopes.nil?
83
- extra = {} if extra.nil?
84
-
85
- Resources::EnvFile.new(
86
- api_key: app.first["apiKey"],
87
- secret: app.first["apiSecretKeys"].first["secret"],
88
- shop: shop,
89
- scopes: scopes,
90
- extra: extra,
91
- ).write(@ctx)
92
- end
93
-
94
33
  def write_cli_yml(project_type, org_id)
95
34
  ShopifyCli::Project.write(
96
35
  @ctx,
@@ -28,11 +28,11 @@ module ShopifyCli
28
28
  def self.all_visible_type
29
29
  ProjectType
30
30
  .load_all
31
- .select { |type| !type.hidden }
31
+ .select { |type| !type.hidden? }
32
32
  end
33
33
 
34
34
  def self.help
35
- project_types = all_visible_type.map(&:project_type).join(" | ")
35
+ project_types = all_visible_type.map(&:project_type).sort.join(" | ")
36
36
  ShopifyCli::Context.message('core.create.help', ShopifyCli::TOOL_NAME, project_types)
37
37
  end
38
38
 
@@ -47,7 +47,7 @@ module ShopifyCli
47
47
 
48
48
  def core_commands
49
49
  resolved_commands
50
- .select { |_name, c| !c.hidden }
50
+ .select { |_name, c| !c.hidden? }
51
51
  .select { |name, _c| Commands.core_command?(name) }
52
52
  end
53
53
 
@@ -4,7 +4,7 @@ require 'rbconfig'
4
4
  module ShopifyCli
5
5
  module Commands
6
6
  class System < ShopifyCli::Command
7
- hidden_command
7
+ hidden_feature(feature_set: :debug)
8
8
 
9
9
  def call(args, _name)
10
10
  show_all_details = false
@@ -36,11 +36,13 @@ module ShopifyCli
36
36
  cli_constants_extra = %w(
37
37
  PROJECT_TYPES_DIR
38
38
  TEMP_DIR
39
- CACHE_DIR
40
- TOOL_CONFIG_PATH
41
- LOG_FILE
42
- DEBUG_LOG_FILE
43
39
  )
40
+ cli_path_methods = [
41
+ :cache_dir,
42
+ :tool_config_path,
43
+ :log_file,
44
+ :debug_log_file,
45
+ ]
44
46
 
45
47
  cli_constants += cli_constants_extra if show_all_details
46
48
 
@@ -48,6 +50,12 @@ module ShopifyCli
48
50
  cli_constants.each do |s|
49
51
  @ctx.puts(" " + @ctx.message('core.system.const', s, ShopifyCli.const_get(s.to_sym)) + "\n")
50
52
  end
53
+
54
+ if show_all_details
55
+ cli_path_methods.each do |m|
56
+ @ctx.puts(" " + @ctx.message('core.system.const', m.upcase, ShopifyCli.send(m)) + "\n")
57
+ end
58
+ end
51
59
  end
52
60
 
53
61
  def display_cli_ruby(_show_all_details)
@@ -60,13 +68,14 @@ module ShopifyCli
60
68
  end
61
69
 
62
70
  def display_utility_commands(_show_all_details)
63
- commands = %w(git curl tar unzip)
71
+ commands = %w(git curl tar)
64
72
 
65
73
  @ctx.puts("\n" + @ctx.message('core.system.command_header'))
66
74
  commands.each do |s|
67
- output, status = @ctx.capture2e('which', s)
68
- if status.success?
69
- @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))
70
79
  else
71
80
  @ctx.puts(" " + @ctx.message('core.system.command_not_found', s))
72
81
  end
@@ -74,7 +83,7 @@ module ShopifyCli
74
83
  end
75
84
 
76
85
  def display_ngrok
77
- ngrok_location = File.join(ShopifyCli::CACHE_DIR, 'ngrok')
86
+ ngrok_location = File.join(ShopifyCli.cache_dir, @ctx.windows? ? 'ngrok.exe' : 'ngrok')
78
87
  if File.exist?(ngrok_location)
79
88
  @ctx.puts(" " + @ctx.message('core.system.ngrok_available', ngrok_location))
80
89
  else
@@ -94,11 +103,11 @@ module ShopifyCli
94
103
  def display_project(project_type, commands)
95
104
  @ctx.puts("\n" + @ctx.message('core.system.project.header', project_type))
96
105
  commands.each do |s|
97
- output, status = @ctx.capture2e('which', s)
98
- if status.success?
106
+ cmd_path = @ctx.which(s)
107
+ if !cmd_path.nil?
99
108
  version_output, _ = @ctx.capture2e(s, '--version')
100
109
  version = version_output.match(/(\d+\.[^\s]+)/)[0]
101
- @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))
102
111
  else
103
112
  @ctx.puts(" " + @ctx.message('core.system.project.command_not_found', s))
104
113
  end
@@ -56,6 +56,7 @@ module ShopifyCli
56
56
  host = uname
57
57
  return :mac if /darwin/.match(host)
58
58
  return :linux if /linux/.match(host)
59
+ return :windows if /mingw32/.match(host)
59
60
  end
60
61
 
61
62
  # will return true if the cli is running on an apple computer.
@@ -68,6 +69,11 @@ module ShopifyCli
68
69
  os == :linux
69
70
  end
70
71
 
72
+ # will return true if the cli is running on Windows
73
+ def windows?
74
+ os == :windows
75
+ end
76
+
71
77
  # will return true if the cli is being run from an installation, and not a
72
78
  # development instance. The gem installation will not have a 'test' directory.
73
79
  # See `#development?` for checking for development environment.
@@ -418,6 +424,28 @@ module ShopifyCli
418
424
  end
419
425
  end
420
426
 
427
+ # Checks if the given command exists in the system
428
+ #
429
+ # #### Parameters
430
+ # - `cmd`: The command to test
431
+ #
432
+ # #### Returns
433
+ # The path of the executable if it is found
434
+ #
435
+ # @todo This is currently a duplicate of CLI::Kit::System.which() - we should make that method public when we make
436
+ # Kit changes and make this a wrapper instead.
437
+ def which(cmd)
438
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
439
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
440
+ exts.each do |ext|
441
+ exe = File.join(File.expand_path(path), "#{cmd}#{ext}")
442
+ return exe if File.executable?(exe) && !File.directory?(exe)
443
+ end
444
+ end
445
+
446
+ nil
447
+ end
448
+
421
449
  private
422
450
 
423
451
  def ctx_path(fname)
@@ -4,6 +4,5 @@ module ShopifyCli
4
4
  autoload :Executor, 'shopify-cli/core/executor'
5
5
  autoload :HelpResolver, 'shopify-cli/core/help_resolver'
6
6
  autoload :Monorail, 'shopify-cli/core/monorail'
7
- autoload :Update, 'shopify-cli/core/update'
8
7
  end
9
8
  end
@@ -35,7 +35,7 @@ module ShopifyCli
35
35
  task_registry = ShopifyCli::Tasks::Registry
36
36
 
37
37
  command, command_name, args = ShopifyCli::Resolver.call(args)
38
- executor = ShopifyCli::Core::Executor.new(ctx, task_registry, log_file: ShopifyCli::LOG_FILE)
38
+ executor = ShopifyCli::Core::Executor.new(ctx, task_registry, log_file: ShopifyCli.log_file)
39
39
  ShopifyCli::Core::Monorail.log(command_name, args) do
40
40
  executor.call(command, command_name, args)
41
41
  end
@@ -3,16 +3,14 @@ require 'shopify_cli'
3
3
  module ShopifyCli
4
4
  module Core
5
5
  class Executor < CLI::Kit::Executor
6
- def initialize(ctx, task_registry, *args)
6
+ def initialize(ctx, task_registry, *args, **kwargs)
7
7
  @ctx = ctx || ShopifyCli::Context.new
8
8
  @task_registry = task_registry || ShopifyCli::Tasks::TaskRegistry.new
9
- super(*args)
9
+ super(*args, **kwargs)
10
10
  end
11
11
 
12
12
  def call(command, command_name, args)
13
- command.prerequisite_tasks.each do |task, _|
14
- @task_registry[task]&.call(@ctx)
15
- end
13
+ command.task_registry = @task_registry
16
14
  command.ctx = @ctx
17
15
  super
18
16
  end
@@ -99,7 +99,7 @@ module ShopifyCli
99
99
  success: err.nil?,
100
100
  error_message: err,
101
101
  uname: RbConfig::CONFIG["host"],
102
- cli_version: ShopifyCli::Git.sha(dir: ShopifyCli::ROOT),
102
+ cli_version: ShopifyCli::VERSION,
103
103
  ruby_version: RUBY_VERSION,
104
104
  }.tap do |payload|
105
105
  payload[:metadata] = JSON.dump(metadata) unless metadata.empty?
@@ -14,7 +14,7 @@ module ShopifyCli
14
14
 
15
15
  attr_reader :db # :nodoc:
16
16
 
17
- def initialize(path: File.join(ShopifyCli::CACHE_DIR, ".db.pstore")) # :nodoc:
17
+ def initialize(path: File.join(ShopifyCli.cache_dir, ".db.pstore")) # :nodoc:
18
18
  @db = PStore.new(path)
19
19
  end
20
20
 
@@ -0,0 +1,97 @@
1
+ module ShopifyCli
2
+ ##
3
+ # ShopifyCli::Feature contains the logic to hide and show features across the CLI
4
+ # These features can be either commands or project types currently.
5
+ #
6
+ # Feature flags will persist between runs so if the flag is enabled or disabled,
7
+ # it will still be in that same state on the next cli invocation.
8
+ class Feature
9
+ SECTION = 'features'
10
+
11
+ ##
12
+ # ShopifyCli::Feature::Set is included on commands and projects to allow you to hide
13
+ # and enable projects and commands based on feature flags.
14
+ module Set
15
+ ##
16
+ # will hide a feature, either a project_type or a command
17
+ #
18
+ # #### Parameters
19
+ #
20
+ # * `feature_set` - either a single, or array of symbols that represent feature sets
21
+ #
22
+ # #### Example
23
+ #
24
+ # module ShopifyCli
25
+ # module Commands
26
+ # class Config < ShopifyCli::Command
27
+ # hidden_feature(feature_set: :basic)
28
+ # ....
29
+ #
30
+ def hidden_feature(feature_set: [])
31
+ @feature_hidden = true
32
+ @hidden_feature_set = Array(feature_set).compact
33
+ end
34
+
35
+ ##
36
+ # will return if the feature has been hidden or not
37
+ #
38
+ # #### Returns
39
+ #
40
+ # * `is_hidden` - returns true if the feature has been hidden and false otherwise
41
+ #
42
+ # #### Example
43
+ #
44
+ # ShopifyCli::Commands::Config.hidden?
45
+ #
46
+ def hidden?
47
+ enabled = (@hidden_feature_set || []).any? do |feature|
48
+ Feature.enabled?(feature)
49
+ end
50
+ @feature_hidden && !enabled
51
+ end
52
+ end
53
+
54
+ class << self
55
+ ##
56
+ # will enable a feature in the CLI.
57
+ #
58
+ # #### Parameters
59
+ #
60
+ # * `feature` - a symbol representing the flag to be enabled
61
+ def enable(feature)
62
+ set(feature, true)
63
+ end
64
+
65
+ ##
66
+ # will disable a feature in the CLI.
67
+ #
68
+ # #### Parameters
69
+ #
70
+ # * `feature` - a symbol representing the flag to be disabled
71
+ def disable(feature)
72
+ set(feature, false)
73
+ end
74
+
75
+ ##
76
+ # will check if the feature has been enabled
77
+ #
78
+ # #### Parameters
79
+ #
80
+ # * `feature` - a symbol representing a flag that the status should be requested
81
+ #
82
+ # #### Returns
83
+ #
84
+ # * `is_enabled` - will be true if the feature has been enabled.
85
+ def enabled?(feature)
86
+ return false if feature.nil?
87
+ ShopifyCli::Config.get_bool(SECTION, feature.to_s)
88
+ end
89
+
90
+ private
91
+
92
+ def set(feature, value)
93
+ ShopifyCli::Config.set(SECTION, feature.to_s, value)
94
+ end
95
+ end
96
+ end
97
+ end
@@ -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)
@@ -36,7 +36,7 @@ module ShopifyCli
36
36
  def download
37
37
  return if installed?
38
38
 
39
- result = @ctx.system('curl', '-o', download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCli::CACHE_DIR)
39
+ result = @ctx.system('curl', '-o', download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCli.cache_dir)
40
40
  @ctx.abort(@ctx.message('core.heroku.error.download')) unless result.success?
41
41
  @ctx.abort(@ctx.message('core.heroku.error.download')) unless File.exist?(download_path)
42
42
  end
@@ -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)
@@ -70,7 +74,7 @@ module ShopifyCli
70
74
  end
71
75
 
72
76
  def download_path
73
- File.join(ShopifyCli::CACHE_DIR, download_filename)
77
+ File.join(ShopifyCli.cache_dir, download_filename)
74
78
  end
75
79
 
76
80
  def git_remote
@@ -79,9 +83,21 @@ module ShopifyCli
79
83
  end
80
84
 
81
85
  def heroku_command
82
- local_path = File.join(ShopifyCli::CACHE_DIR, 'heroku', 'bin', 'heroku').to_s
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