fanforce-app-factory 2.0.0.rc29 → 2.0.0.rc30

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,23 +13,15 @@ class Fanforce::AppFactory::CLI::Heroku
13
13
  @heroku ||= {}
14
14
  @heroku[environment] ||= Heroku::API.new(:username => config[:heroku][environment][:user], :password => config[:heroku][environment][:password])
15
15
  rescue Exception => e
16
+ error "OOPS... #{environment.to_s.upcase}".format(:red,:bold) + ' has not been setup for Heroku' if config[:heroku].blank? or config[:heroku][environment].blank?
16
17
  #raise "Heroku user #{config[:heroku][environment][:user]} does not seem to exist: #{e.message}" if e.response.status == 404
17
18
  raise
18
19
  end
19
20
 
20
21
  def setup(environment)
21
22
  environment = environment.to_sym
22
- return puts "OOPS... #{environment.to_s.upcase}".format(:red,:bold) + ' has not been setup for Heroku' if config[:heroku].blank? or config[:heroku][environment].blank?
23
-
24
23
  heroku = heroku(environment)
25
24
  heroku_app_name = app_name(environment)
26
- begin
27
- heroku.get_app(heroku_app_name)
28
- puts "#{'Found '.format(:green,:bold)}" + "#{environment} app on heroku (#{heroku_app_name})"
29
- rescue
30
- heroku.post_app(name: heroku_app_name)
31
- puts "#{'Created '.format(:green,:bold)}" + "#{environment} on heroku (#{heroku_app_name})"
32
- end
33
25
 
34
26
  # Setup standard app domain
35
27
  domain = "#{app._id}.#{Fanforce::Base::DomainEnvironments.method(environment).call[:apps_base]}"
@@ -51,6 +43,7 @@ class Fanforce::AppFactory::CLI::Heroku
51
43
  puts "#{'Added '.format(:green,:bold)}" + "#{domain} domain to #{environment}"
52
44
  end
53
45
 
46
+ # Setup git remote
54
47
  remote_name = "#{env(environment)}-heroku"
55
48
  if (`git remote`).split(/\r?\n/).include?(remote_name)
56
49
  puts "#{'Updated '.format(:green,:bold)}" + "git remote for #{remote_name}"
@@ -61,6 +54,24 @@ class Fanforce::AppFactory::CLI::Heroku
61
54
  `git remote add #{remote_name} git@#{config[:heroku][environment][:git_ssh_domain] || 'heroku.com'}:#{heroku_app_name}.git`
62
55
  end
63
56
 
57
+ def app_exists?(heroku, app_name)
58
+ heroku.get_app(app_name)
59
+ return true
60
+ rescue
61
+ return false
62
+ end
63
+
64
+ def ensure_app_exists(environment)
65
+ heroku = heroku(environment)
66
+ heroku_app_name = app_name(environment)
67
+ if app_exists?(heroku, heroku_app_name)
68
+ puts "#{'Found '.format(:green,:bold)}" + "#{environment} app on heroku (#{heroku_app_name})"
69
+ else
70
+ heroku.post_app(name: heroku_app_name)
71
+ puts "#{'Created '.format(:green,:bold)}" + "#{environment} on heroku (#{heroku_app_name})"
72
+ end
73
+ end
74
+
64
75
  def update_config(environment, vars)
65
76
  heroku(environment).put_config_vars(app_name(environment), vars) if vars
66
77
  end
@@ -16,6 +16,7 @@ class Fanforce::AppFactory::CLI::Iron
16
16
 
17
17
  env = Fanforce::AppFactory::CLI::Env.new(app)
18
18
  vars = env.vars(environment) || {}
19
+ factory_version = current_factory_version
19
20
 
20
21
  return puts "#{'Skipped '.format(:bold)} #{environment.to_s.titleize} is missing IRON_TOKEN and/or IRON_PROJECT_ID env variables" if vars['IRON_TOKEN'].blank? or vars['IRON_PROJECT_ID'].blank?
21
22
 
@@ -35,7 +36,7 @@ class Fanforce::AppFactory::CLI::Iron
35
36
 
36
37
  puts "#{'Uploading'.format(:green,:bold)} #{filename.gsub('.worker', '')} to #{environment.to_s.titleize}..."
37
38
  code = IronWorkerNG::Code::Base.new(:workerfile => "#{app.dir}/workers/#{filename}")
38
- code.gem('fanforce-app-factory', config[:app_factory_gem][:version])
39
+ code.gem('fanforce-app-factory', factory_version)
39
40
  code.remote
40
41
  code.name = code_name
41
42
  code.file("#{app.dir}/workers/.env/.#{environment}env.rb")
@@ -47,6 +48,13 @@ class Fanforce::AppFactory::CLI::Iron
47
48
  end
48
49
  end
49
50
 
51
+ def current_factory_version
52
+ `bundle list`.lines.each do |line|
53
+ return $1 if line =~ /fanforce-app-factory \(([A-Za-z0-9.-]+)\)/
54
+ end
55
+ error 'fanforce-app-factory version was not found in `bundle list`'
56
+ end
57
+
50
58
  def upload_iron_worker(iron_worker, code, filename, environment)
51
59
  fork do
52
60
  begin
@@ -6,13 +6,13 @@ class Fanforce::AppFactory::CLI::Scripts
6
6
 
7
7
  ######################################################################################################################
8
8
 
9
- def status(type, detail_level=nil)
9
+ def diff(type, detail_level=nil)
10
10
  type = type.to_sym
11
- detail_level = (detail_level||'overview').to_sym if type == :files
11
+ detail_level = (detail_level||'detailed').to_sym if type == :files
12
12
 
13
13
  if [:all,:files].include?(type)
14
14
  if Fanforce::CLI::TYPE == :directory_of_apps
15
- if detail_level == :diff
15
+ if detail_level == :detailed
16
16
  directory_file_details(detail_level)
17
17
  else
18
18
  directory_file_overview
@@ -88,7 +88,7 @@ class Fanforce::AppFactory::CLI::Scripts
88
88
  filepath,
89
89
  ("#{metadata[:insertions]} insertions(+)" if metadata[:insertions].to_i > 0),
90
90
  ("#{metadata[:deletions]} deletions(-)" if metadata[:insertions].to_i > 0)
91
- if detail_level == :diff and metadata[:diff]
91
+ if detail_level == :detailed and metadata[:diff]
92
92
  lines = ''
93
93
  metadata[:diff].lines do |line|
94
94
  line = line.format(:red) if line[0] == '-'
@@ -119,7 +119,7 @@ class Fanforce::AppFactory::CLI::Scripts
119
119
  filepath,
120
120
  ("#{metadata[:insertions]} insertions(+)" if metadata[:insertions].to_i > 0),
121
121
  ("#{metadata[:deletions]} deletions(-)" if metadata[:insertions].to_i > 0)
122
- if detail_level == :diff and metadata[:diff]
122
+ if detail_level == :detailed and metadata[:diff]
123
123
  lines = ''
124
124
  metadata[:diff].lines do |line|
125
125
  line = line.format(:red) if line[0] == '-'
@@ -34,6 +34,11 @@ class Fanforce::AppFactory::CLI::Scripts
34
34
  return push_app_worker(app, environment, command.to_s)
35
35
  end
36
36
 
37
+ if [:all,:heroku].include?(command) and environment != :development
38
+ heroku = Fanforce::AppFactory::CLI::Heroku.new(app)
39
+ heroku.ensure_app_exists(environment)
40
+ end
41
+
37
42
  if [:all,:iron].include?(command)
38
43
  push_app_workers(app, environment)
39
44
  end
@@ -42,9 +47,8 @@ class Fanforce::AppFactory::CLI::Scripts
42
47
  push_env(app, environment)
43
48
  end
44
49
 
45
- if [:all,:heroku].include?(command)
46
- error 'Heroku is not setup for development' if environment == :development
47
- push_heroku(app, environment)
50
+ if [:all,:heroku].include?(command) and environment != :development
51
+ push_heroku(heroku, app, environment)
48
52
  end
49
53
  end
50
54
 
@@ -64,14 +68,13 @@ class Fanforce::AppFactory::CLI::Scripts
64
68
  Fanforce::AppFactory::CLI::Env.new(app).setup(environment)
65
69
  end
66
70
 
67
- def push_heroku(app, environment)
71
+ def push_heroku(heroku, app, environment)
68
72
  case environment
69
73
  when :staging then env = :stg
70
74
  when :production then env = :prd
71
75
  end
72
76
  remote_name = "#{env}-heroku"
73
77
 
74
- heroku = Fanforce::AppFactory::CLI::Heroku.new(app)
75
78
  heroku.setup(environment) if !(`git remote`).split(/\r?\n/).include?(remote_name)
76
79
 
77
80
  vars = Fanforce::AppFactory::CLI::Env.new(app).vars(environment)
@@ -16,12 +16,12 @@ class Fanforce::AppFactory::CLI::Scripts
16
16
 
17
17
  ########################################################################################################################
18
18
 
19
- Fanforce::CLI.register(self, :status,
19
+ Fanforce::CLI.register(self, :diff,
20
20
  ['all/TYPE', 'Check the status of files, git, and gems'],
21
- ['files *overview/diff','Check for file diffs between app_factory scaffolding'],
21
+ ['files *detailed/overview','Check for file diffs between app_factory scaffolding'],
22
22
  ['git', 'Check the status of git commit'],
23
23
  ['gems', 'Check the gem versions being used across apps']
24
- ) { require_relative 'cli/scripts/status' }
24
+ ) { require_relative 'cli/scripts/diff' }
25
25
 
26
26
  ########################################################################################################################
27
27
 
@@ -4,12 +4,12 @@ class Fanforce::AppFactory::CLI::Scripts
4
4
 
5
5
  ########################################################################################################################
6
6
 
7
- Fanforce::CLI.register(self, :status,
7
+ Fanforce::CLI.register(self, :diff,
8
8
  ['all/TYPE', 'Check the status of files, git, and gems'],
9
- ['files *overview/diff', 'Check for file diffs between app_factory scaffolding'],
9
+ ['files *detailed/overview', 'Check for file diffs between app_factory scaffolding'],
10
10
  ['git', 'Check the status of git commit'],
11
11
  # ['gems', 'Check if the gem versions are behind other apps']
12
- ) { require_relative 'cli/scripts/status' }
12
+ ) { require_relative 'cli/scripts/diff' }
13
13
 
14
14
  ########################################################################################################################
15
15
 
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  class AppFactory
3
- VERSION = '2.0.0.rc29'
3
+ VERSION = '2.0.0.rc30'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-app-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc29
4
+ version: 2.0.0.rc30
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -416,10 +416,10 @@ files:
416
416
  - lib/fanforce/app_factory/cli/scripts/config.rb
417
417
  - lib/fanforce/app_factory/cli/scripts/create.rb
418
418
  - lib/fanforce/app_factory/cli/scripts/destroy.rb
419
+ - lib/fanforce/app_factory/cli/scripts/diff.rb
419
420
  - lib/fanforce/app_factory/cli/scripts/push.rb
420
421
  - lib/fanforce/app_factory/cli/scripts/restart.rb
421
422
  - lib/fanforce/app_factory/cli/scripts/setup.rb
422
- - lib/fanforce/app_factory/cli/scripts/status.rb
423
423
  - lib/fanforce/app_factory/cli/scripts/update.rb
424
424
  - lib/fanforce/app_factory/cli_directory_of_apps.rb
425
425
  - lib/fanforce/app_factory/cli_single_app.rb