@govuk-pay/cli 0.0.23 → 0.0.25

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@govuk-pay/cli",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "GOV.UK Pay Command Line Interface",
5
5
  "bin": {
6
6
  "pay": "bin/cli.js",
@@ -3,8 +3,8 @@ require 'yaml'
3
3
 
4
4
  class PayCLI::Commands::Doctor
5
5
  def start!
6
+ check_workspace!
6
7
  check_ruby_version!
7
- check_path!
8
8
  check_old_pay_config_dir!
9
9
  check_secrets_file!
10
10
  check_pay_low_pass!
@@ -93,18 +93,23 @@ class PayCLI::Commands::Doctor
93
93
  end
94
94
  end
95
95
 
96
- def check_path!
97
- if ENV['PATH'] =~ %r{pay-infra/cli}
98
- STDERR.puts "✅ PATH looks okay"
99
- else
100
- STDERR.puts "🔥 PATH does not contain pay-infra/cli"
96
+ def check_workspace!
97
+ # Normally in doctor we continue to more tests, but if WORKSPACE isn't set lots of the tests will result in a crash
98
+ if ! ENV.has_key?('WORKSPACE')
99
+ STDERR.puts "🔥 WORKSPACE env var not set, it needs to be set to the directory where you check out alphagov repos"
100
+ exit 1
101
+ end
102
+
103
+ if !File.directory?(ENV['WORKSPACE'])
104
+ STDERR.puts "🔥 WORKSPACE env var not set, it needs to be set to the directory where you check out alphagov repos"
105
+ exit 1
101
106
  end
107
+
108
+ STDERR.puts "✅ WORKSPACE looks okay"
102
109
  end
103
110
 
104
111
  def check_pay_low_pass!
105
- pay_low_pass_path = File.expand_path(File.join(
106
- PayCLI::Config::PROJECT_PATH, '..', 'pay-low-pass'
107
- ))
112
+ pay_low_pass_path = File.expand_path(ENV['WORKSPACE'], 'pay-low-pass')
108
113
  if File.exist? pay_low_pass_path
109
114
  STDERR.puts "✅ pay-low-pass is in the right place"
110
115
  else
@@ -47,7 +47,19 @@ module PayCLI::Commands::Tf
47
47
 
48
48
  def self.item!(command, environment, deployment_type, args)
49
49
  account = environment.split('-').first
50
- deployment_path = [PayCLI::Config::PROJECT_PATH, 'provisioning', 'terraform', 'deployments']
50
+ if ! ENV.has_key?('WORKSPACE')
51
+ STDERR.puts 'Error: You must set your WORKSPACE env var to the directory where you checkout alphagov github projects'
52
+ exit 1
53
+ end
54
+
55
+ pay_infra_path = File.join(ENV['WORKSPACE'], 'pay-infra')
56
+
57
+ if ! File.directory?(pay_infra_path)
58
+ STDERR.puts "Error: #{pay_infra_path} is not a directory. Do you need to check out pay-infra?"
59
+ exit 1
60
+ end
61
+
62
+ deployment_path = [pay_infra_path, 'provisioning', 'terraform', 'deployments']
51
63
  if account == environment
52
64
  deployment_path += [account, deployment_type]
53
65
  else
@@ -17,9 +17,7 @@ module PayCLI::Config
17
17
  performance
18
18
  ).freeze
19
19
 
20
- PROJECT_PATH = File.expand_path("../../..", __dir__)
21
-
22
- CLI_PATH = File.join PROJECT_PATH, 'cli'
20
+ CLI_PATH = File.expand_path(File.join(__dir__, '..', '..'))
23
21
  CONFIG_PATH = File.join CLI_PATH, 'config'
24
22
  LOCAL_SECRETS_PATH = File.expand_path(
25
23
  File.join('~', '.govuk-pay', 'secrets.yml')
@@ -129,11 +129,16 @@ module PayCLI::Secrets
129
129
  end
130
130
 
131
131
  def self.fetch_pay_pass!(env, service, key, provider, pass_path)
132
+ if ! ENV.has_key?('WORKSPACE')
133
+ STDERR.puts 'Error: You must set your WORKSPACE env var to the directory where you checkout alphagov github projects'
134
+ exit 1
135
+ end
136
+
132
137
  path = File.expand_path(File.join(
133
- PayCLI::Config::PROJECT_PATH, '..', provider
138
+ ENV['WORKSPACE'], provider
134
139
  ))
135
140
 
136
- abort "Path #{path} doesn't exist" unless File.exist? path
141
+ abort "Path #{path} doesn't exist or isn't a directory" unless File.directory? path
137
142
 
138
143
  STDERR.puts "Pulling secret #{key} from #{path} for #{service}"
139
144
  fetch_pass! path, pass_path