fanforce-cli 1.6.0 → 1.7.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dd322f56edd83f205daebadc27a6f6c95823258
4
- data.tar.gz: 66d95972b4e054b04b716e31d2f12b797e46ea6d
3
+ metadata.gz: 7755e4c53dc744b5379f207ae89a153d4abb5ffe
4
+ data.tar.gz: 7774a0e270164adb3eb792a9c7cddc2e01ee6f10
5
5
  SHA512:
6
- metadata.gz: b40bf4088fcbbf88097aea2af2ffadce7923d4663db3b6884a9b5a08fccf24880e8c478fd9fc08a79f97671f8a41f66c1234a37a7b34b5f91d189f7a5d170d2f
7
- data.tar.gz: d441466e9e6fcf3200f9ecaa8f4cea9779c51482e453250aea469138b498e3e2494343d84b67f6841263a16ba839941562d95e1673c516cb855f05f4e8960ef8
6
+ metadata.gz: c482e88c8ea7c19da2cde0aa84479dae70d057400714b2a35caaa7e2305569e19841ddc0c528984cf3f9a63ffa7c58719b6f5cf9c57addf65233f52e0d941636
7
+ data.tar.gz: e622283205243815b7561083be35d92b0442ea8ab0a7ec2d052c410152c7d340fc075db956af513e0fcf150613a2e007581a2be83c2b65f95ff6620a806f91c7
@@ -63,23 +63,14 @@ class Fanforce::CLI
63
63
  #################################################################
64
64
 
65
65
  elsif ARGV[0] == 'update'
66
- if (!ARGV[1] or ARGV[1] == 'all') and !ARGV[2]
67
- app_id = 'all' if !$Filter
68
- elsif ARGV[1] =~ /^(all|app-([a-z0-9-]+))$/
69
- app_id = ($1 == 'all') ? $1 : $2
70
- raw_command = ARGV[2]
71
- elsif ARGV[1]
72
- raw_command = ARGV[1]
73
- else
74
- error('You supplied an invalid update command.', :update)
66
+ if !$Filter
67
+ ARGV[1] =~ /^(all|app-([a-z0-9-]+))$/i || error('You supplied an invalid update command.', :update)
68
+ app_id = $1
69
+ ARGV.delete_at(1)
75
70
  end
76
71
 
77
- if raw_command
78
- error('You supplied an invalid update command.', :update) if raw_command !~ /^(all|files|bundle|pow|get|env)$/
79
- command = $1.to_sym
80
- else
81
- command = :all
82
- end
72
+ ARGV[1] !~ /^(all|files|bundle|pow|get|env)$/i || error('You supplied an invalid update command.', :update)
73
+ command = $1.to_sym
83
74
 
84
75
  (!app_id or app_id == 'all') ? run(:update, command) : update_app(app_id, command)
85
76
 
@@ -93,9 +84,11 @@ class Fanforce::CLI
93
84
  #################################################################
94
85
 
95
86
  elsif ARGV[0] == 'push'
96
- ARGV[1] =~ /^(all|development|staging|production)$/ || error('You supplied an invalid push command.', :push)
87
+ ARGV[1] =~ /^(all|development|staging|production)$/i || error('You supplied an invalid push command.', :push)
97
88
  environment = $1.to_sym
98
- command = (ARGV[2] =~ /(:all|:heroku|:iron|bitbucket)$/) ? $1.to_sym : :all
89
+
90
+ ARGV[2] =~ /^(all|heroku|iron|bitbucket)$/i || error('You supplied an invalid push command.', :push)
91
+ command = $1.to_sym
99
92
 
100
93
  confirm('Are you sure you want to push to all environments, including production?') if environment == :all
101
94
  confirm('Are you sure you want to push to production?') if environment == :production
@@ -139,15 +132,12 @@ class Fanforce::CLI
139
132
  #################################################################
140
133
 
141
134
  elsif ARGV[0] == 'iron'
142
- ARGV[1] =~ /^(upload|reset|delete)$/ || error('You supplied an invalid iron command.', :iron)
135
+ ARGV[1] =~ /^(upload|reset|delete)$/i || error('You supplied an invalid iron command.', :iron)
143
136
  command = $1.to_sym
144
137
 
145
- if ARGV[2].blank? or ARGV[2] =~ /^(all|development|staging|production)$/
146
- environment = ($1.present?) ? $1.to_sym : :all
147
- confirm("Are you sure you want to #{command} workers in all environments?") if environment == :all
148
- else
149
- error('You supplied an invalid iron environment.', :iron)
150
- end
138
+ ARGV[2] =~ /^(all|development|staging|production)$/i || error('You supplied an invalid iron environment.', :iron)
139
+ environment = $1.to_sym
140
+ confirm("Are you sure you want to #{command} workers in all environments?") if environment == :all
151
141
 
152
142
  if command == :delete
153
143
  delete_all_iron_workers(environment)
@@ -203,7 +203,7 @@ class Fanforce::CLI
203
203
  environments = (environment==:all) ? [:staging,:production] : [environment]
204
204
  environments.each do |environment|
205
205
  if [:all,:heroku].include?(command)
206
- remote_name = "#{environment==:staging ? 'stg' : 'prd'}-heroku"
206
+ remote_name = "#{env(environment)}-heroku"
207
207
  setup_heroku(app, environment) if !(`git remote`).split(/\r?\n/).include?(remote_name)
208
208
 
209
209
  vars = Env.vars_by_app(environment)[app.dir_name] || {}
@@ -469,10 +469,6 @@ class Fanforce::CLI
469
469
  end
470
470
 
471
471
  ######################################################################################################################
472
- def get_heroku_app_qa_name(app, environment)
473
- heroku_app_name = "#{environment==:production ? 'prd' : 'qa'}-#{app.dir_name}"
474
- heroku_app_name.length > 30 ? heroku_app_name.gsub!(/(a|e|i|o|u)/, '') : heroku_app_name
475
- end
476
472
 
477
473
  def run_upgrade(app_dir, processed_count, total_count)
478
474
  environment = :qa
@@ -1,11 +1,6 @@
1
1
  class Fanforce::CLI
2
2
  require 'fileutils'
3
3
 
4
- def get_heroku_app_name(app, environment)
5
- heroku_app_name = "#{environment==:production ? 'prd' : 'stg'}-#{app.dir_name}"
6
- heroku_app_name.length > 30 ? heroku_app_name.gsub!(/(a|e|i|o|u)/, '') : heroku_app_name
7
- end
8
-
9
4
  def setup_files(app)
10
5
  if File.directory?("#{app.dir}/tmp")
11
6
  puts "#{'Found '.format(:green,:bold)} #{app.dir_name}/tmp/"
@@ -145,7 +140,7 @@ class Fanforce::CLI
145
140
  heroku.put_config_vars(heroku_app_name, vars) if vars
146
141
 
147
142
  # Setup standard app domain
148
- domain = "#{app._id}.#{Fanforce.apps_base_domain}"
143
+ domain = "#{app._id}.#{Fanforce::DomainEnvironments.method(environment).call[:apps_base]}"
149
144
  domain_found = heroku.get_domains(heroku_app_name).body.inject(false) {|result, d| d['domain'] == domain ? (break true) : false }
150
145
  if domain_found
151
146
  puts "#{'Found '.format(:green,:bold)}" + "#{domain} domain on #{environment}"
@@ -155,7 +150,7 @@ class Fanforce::CLI
155
150
  end
156
151
 
157
152
  # Setup default short domain
158
- domain = "#{app._id}.#{Fanforce.default_short_domain}"
153
+ domain = "#{app._id}.#{Fanforce::DomainEnvironments.method(environment).call[:default_short_domain]}"
159
154
  domain_found = heroku.get_domains(heroku_app_name).body.inject(false) {|result, d| d['domain'] == domain ? (break true) : false }
160
155
  if domain_found
161
156
  puts "#{'Found '.format(:green,:bold)}" + "#{domain} domain on #{environment}"
@@ -164,7 +159,7 @@ class Fanforce::CLI
164
159
  puts "#{'Added '.format(:green,:bold)}" + "#{domain} domain to #{environment}"
165
160
  end
166
161
 
167
- remote_name = "#{environment==:staging ? 'stg' : 'prd'}-heroku"
162
+ remote_name = "#{env(environment)}-heroku"
168
163
  if (`git remote`).split(/\r?\n/).include?(remote_name)
169
164
  puts "#{'Updated '.format(:green,:bold)}" + "git remote for #{remote_name}"
170
165
  `git remote rm #{remote_name}`
@@ -17,6 +17,7 @@ module Fanforce::CLI::Help
17
17
 
18
18
  def for(command, allowed_commands)
19
19
  response = "\n#{command.to_s.upcase} COMMAND...\n-----------------------------------------------------------------------------------------------------------------------\n"
20
+ response += self.method("#{command}_command").call
20
21
  response += "-----------------------------------------------------------------------------------------------------------------------\n\n"
21
22
  end
22
23
 
@@ -31,12 +32,12 @@ create app-ID Creates a new app folder and
31
32
  end
32
33
 
33
34
  def update_command; <<-eos
34
- update *all|app-ID [*all|OR...] Similar to the create command, except it updates existing files
35
- |files Ensure all needed files exists and contain correct config
36
- |bundle Run bundle install
37
- |pow Ensure correct pow domains are configured
38
- |git Ensure git is initialized
39
- |env Update ENV variables
35
+ update app-ID|all all|OR... Similar to the create command, except it updates existing files
36
+ |files Ensure all files exist and contain correct config
37
+ |bundle Run bundle install
38
+ |pow Ensure correct pow domains are configured
39
+ |git Ensure git is initialized
40
+ |env Update ENV variables
40
41
  eos
41
42
  end
42
43
 
@@ -46,11 +47,11 @@ delete app-ID Delete the app folder and al
46
47
  end
47
48
 
48
49
  def push_command; <<-eos
49
- push development|RACK_ENV [*all|OR...] Push all changes to the environment specified
50
- |env Update environment vars in remote environments
51
- |bitbucket Push the latest commit to bitbucket
52
- |heroku Push the latest commit to heroku and restart
53
- |iron Push changes to workers
50
+ push RACK_ENV all|OR... Push all changes to the environment specified
51
+ |env Update environment vars in remote environments
52
+ |bitbucket Push the latest commit to bitbucket
53
+ |heroku Push the latest commit to heroku and restart
54
+ |iron Push changes to workers
54
55
  eos
55
56
  end
56
57
 
@@ -65,7 +66,7 @@ count Display the number of fanfor
65
66
  end
66
67
 
67
68
  def bundle_command; <<-eos
68
- bundle (install|update) Run bundle on all apps in current fanforce
69
+ bundle install|update Run bundle on all apps in current fanforce
69
70
  eos
70
71
  end
71
72
 
@@ -76,7 +77,7 @@ git status:overview A custom git command that di
76
77
  end
77
78
 
78
79
  def iron_command; <<-eos
79
- iron (upload|reset|delete) [*all|RACK_ENV] Updates env variables and upload one or more workers to iron.io
80
+ iron upload|reset|delete RACK_ENV|all Updates env variables and upload one or more workers to iron.io
80
81
  eos
81
82
  end
82
83
 
@@ -91,7 +92,7 @@ config Display your Fanforce CLI co
91
92
  end
92
93
 
93
94
  def cleanorgs_command; <<-eos
94
- cleanorgs environment supercore_api_key Remove installs that are no longer valid in the db
95
+ cleanorgs environment supercore_api_key Remove installs that are no longer valid in the db
95
96
  eos
96
97
  end
97
98
 
@@ -42,6 +42,25 @@ module Fanforce::CLI::Utils
42
42
  exit 0 if input.downcase == 'n'
43
43
  end
44
44
 
45
+ def env(environment)
46
+ return if environment.blank?
47
+ is_symbol = environment.is_a?(Symbol)
48
+ env = case environment.to_sym
49
+ when :development then :dev
50
+ when :staging then :stg
51
+ when :production then :prd
52
+ else raise 'unknown environment'
53
+ end
54
+ is_symbol ? env : env.to_s
55
+ end
56
+
57
+ def get_heroku_app_name(app, environment)
58
+ raise 'unknown environment' if ![:production, :staging].include?(environment)
59
+
60
+ heroku_app_name = "#{env(environment)}-#{app.dir_name}"
61
+ heroku_app_name.length > 30 ? heroku_app_name.gsub!(/(a|e|i|o|u)/, '') : heroku_app_name
62
+ end
63
+
45
64
  end
46
65
 
47
66
  class String
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  class CLI
3
- VERSION = '1.6.0'
3
+ VERSION = '1.7.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-15 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis