fanforce-app-factory 2.0.0.rc17 → 2.0.0.rc18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9f8669748e3705968a85c6e23b827eb3a682a84
4
- data.tar.gz: 181106208de0cf2e82651e751ef742c42d47bffc
3
+ metadata.gz: e73df51eb850160211a41f20ba46a6ab9f4c038d
4
+ data.tar.gz: dbc25ad3926d94314063dd9c25b45c59a393717a
5
5
  SHA512:
6
- metadata.gz: 432472d0836d18ead8089be68a93886d41034678c2a40833396d540495f9d27f03b20c11f0d702a85f0cf0d8183f6c15727573ea90ecde2037c8b8f074bc519e
7
- data.tar.gz: 094f41dee08edc6989235b6fa194b255c4265ae35b87c3c5244fdd643fc0e8f5430bc4cc0d703900a61107ce7d01bf1c7c442a84ee278876f81de2f97132b044
6
+ metadata.gz: 0120807082f05388a4dd2dc324979d194e3fb48908042ab49c9f5088a101cf4188bcf25c97faaa63ef8d816cd7e7b8d48d7c944c9032356e605940ad31c1a9cd
7
+ data.tar.gz: e8590e0ae0ffd9d5161c4ee66135a65c1d467d493ecfe135ec5f3acb6abec42560e9ec518500d6197f74b5ccd142db5fb54e339e06fa675b0595af2098ee3caa
@@ -17,18 +17,36 @@ module Fanforce::AppFactory::CLI::Utils
17
17
  output.join("\n")
18
18
  end
19
19
 
20
- def config
21
- return @@config if @@config
22
- require 'yaml'
20
+ def silence_warnings
21
+ require 'stringio'
22
+ old_stderr = $stderr
23
+ $stderr = StringIO.new
24
+ yield
25
+ ensure
26
+ $stderr = old_stderr
27
+ end
28
+
29
+ def config_filepath
23
30
  if Fanforce::CLI::TYPE == :directory_of_apps
24
- config_path = "#{Fanforce::CLI::DIR}/.fanforce-app-factory"
25
- config_filename = '.fanforce-app-factory'
31
+ "#{Fanforce::CLI::DIR}/.fanforce-app-factory"
26
32
  elsif Fanforce::CLI::TYPE == :single_app
27
- config_path = "#{Fanforce::CLI::DIR}/../.fanforce-app-factory"
28
- config_filename = '../.fanforce-app-factory'
33
+ "#{Fanforce::CLI::DIR}/../.fanforce-app-factory"
29
34
  end
30
- error "The required config file was not found: #{config_filename}" if !File.exists?(config_path)
31
- @@config = format_config(YAML.load_file(config_path))
35
+ end
36
+
37
+ def config_relativepath
38
+ if Fanforce::CLI::TYPE == :directory_of_apps
39
+ '.fanforce-app-factory'
40
+ elsif Fanforce::CLI::TYPE == :single_app
41
+ '../.fanforce-app-factory'
42
+ end
43
+ end
44
+
45
+ def config
46
+ return @@config if @@config
47
+ require 'yaml'
48
+ error "The required config file was not found: #{config_relativepath}" if !File.exists?(config_filepath)
49
+ @@config = format_config(YAML.load_file(config_filepath))
32
50
  end
33
51
 
34
52
  def format_config(hash)
@@ -3,12 +3,15 @@ class Fanforce::AppFactory::CLI::Scripts
3
3
 
4
4
  require_relative '../lib/env'
5
5
  require_relative '../lib/scaffolding'
6
+ require_relative '../lib/bundler'
6
7
 
7
8
  ######################################################################################################################
8
9
 
9
10
  def update(type)
10
11
  type = type.to_sym
11
12
 
13
+ return update_factory if type == :factory
14
+
12
15
  if Fanforce::CLI::TYPE == :directory_of_apps
13
16
  confirm("\nYou are about to update #{Fanforce::CLI::Apps.total_count} apps in this directory. This cannot be undone.\n"+
14
17
  'ARE YOU SURE?', true)
@@ -18,7 +21,7 @@ class Fanforce::AppFactory::CLI::Scripts
18
21
  log "#{'APP'.format(:bold)} - #{app._id.upcase.gsub('-',' ').format(:bold)} (#{processed_count} of #{total_count})... "
19
22
  update_app(app, type)
20
23
  end
21
- else
24
+ elsif Fanforce::CLI::TYPE == :single_app
22
25
  app = Fanforce::CLI::App.load(Fanforce::CLI::DIR)
23
26
  confirm("\nYou are about to update #{app.name}. This cannot be undone.\n" +
24
27
  'ARE YOU SURE?', true)
@@ -30,7 +33,7 @@ class Fanforce::AppFactory::CLI::Scripts
30
33
  def update_app(app, type)
31
34
  if [:all,:files].include?(type)
32
35
  if !Fanforce::AppFactory::CLI::Scaffolding.new(app).update
33
- log "\nNO FILES NEED UPDATING"
36
+ log 'NO FILES NEED UPDATING'
34
37
  end
35
38
  end
36
39
  if [:all,:env].include?(type)
@@ -38,4 +41,108 @@ class Fanforce::AppFactory::CLI::Scripts
38
41
  end
39
42
  end
40
43
 
44
+ def update_factory
45
+ require_gem 'rest-client', 'rest_client'
46
+ require_gem 'multi_json', 'multi_json'
47
+
48
+ log divider '+--------------------------------------------------------------------------------------------------+'
49
+ print 'CHECKING RUBYGEMS... '
50
+ response = RestClient::Request.execute(:method => :get, :url => 'https://rubygems.org/api/v1/versions/fanforce-app-factory.json', :ssl_version => 'SSLv23').body
51
+ rubygems_version = MultiJson.load(response, symbolize_keys: true).first[:number]
52
+ current_version = config[:app_factory_gem][:version].match(/(\S+)\s*$/)[1] if config[:app_factory_gem][:version]
53
+
54
+ local_path = '/Fanforce/gems/fanforce-app-factory'
55
+ if File.directory?(local_path)
56
+ silence_warnings do require "#{local_path}/lib/fanforce/app_factory/version" end
57
+ local_version = Fanforce::AppFactory::VERSION
58
+ end
59
+
60
+ if current_version and (rubygems_version != current_version or local_version)
61
+ i = 0
62
+ options = {}
63
+ log "\n\nWe found multiple gem versions. Select the one you want used:"
64
+
65
+ if local_version or config[:app_factory_gem][:path]
66
+ if config[:app_factory_gem][:path]
67
+ log " #{i+=1}. #{local_version} (found in .fanforce-app-factory / locally)"
68
+ else
69
+ log " #{i+=1}. #{local_version} (found locally)"
70
+ end
71
+ options[i] = :local
72
+ end
73
+
74
+ log " #{i+=1}. #{rubygems_version} (found in rubygems)"
75
+ options[i] = :rubygems
76
+
77
+ if !local_version
78
+ log " #{i+=1}. #{current_version} (found in .fanforce-app-factory)"
79
+ options[i] = :current
80
+ end
81
+
82
+ num_selected = prompt('> ').to_i
83
+ if options[num_selected] == :local
84
+ version = local_version
85
+ config[:app_factory_gem][:path] = local_path
86
+ elsif options[num_selected] == :rubygems
87
+ version = rubygems_version
88
+ config[:app_factory_gem].delete(:path)
89
+ local_path = nil
90
+ elsif options[num_selected] == :current
91
+ version = current_version
92
+ local_path = nil
93
+ else
94
+ error "Error: must enter a valid number [1-#{i}]"
95
+ end
96
+
97
+ File.open(config_filepath,'w') do |f|
98
+ config[:app_factory_gem][:version] = version
99
+ f.write config.to_yaml
100
+ end
101
+ else
102
+ log 'DONE'
103
+ version = rubygems_version
104
+ end
105
+ log divider '---------------------------------------------------------------------------------------------------+'
106
+
107
+ if Fanforce::CLI::TYPE == :directory_of_apps
108
+ confirm("\nYou are about to update #{Fanforce::CLI::Apps.total_count} apps in this directory. This cannot be undone.\n"+
109
+ 'ARE YOU SURE?', true)
110
+
111
+ Fanforce::CLI::Apps.each do |app, processed_count, total_count|
112
+ log divider '+-------------------------------------------------------------------------------------------------'
113
+ log "#{'APP'.format(:bold)} - #{app._id.upcase.gsub('-',' ').format(:bold)} (#{processed_count} of #{total_count})... "
114
+ update_factory_for_app(app)
115
+ end
116
+ elsif Fanforce::CLI::TYPE == :single_app
117
+ app = Fanforce::CLI::App.load(Fanforce::CLI::DIR)
118
+ update_factory_for_app(app)
119
+ end
120
+
121
+ install_factory_gem_locally(version, local_path) if local_path
122
+ puts ''
123
+ end
124
+
125
+ def update_factory_for_app(app)
126
+ gemfile_filepath = Fanforce::AppFactory::CLI::Scaffolding.dir + '/Gemfile'
127
+ file = Fanforce::AppFactory::CLI::ScaffoldingFile.new(gemfile_filepath, app)
128
+ if file.update
129
+ Fanforce::AppFactory::CLI::Bundler.new(app).setup
130
+ else
131
+ log('Gemfile up to date')
132
+ end
133
+ end
134
+
135
+ def install_factory_gem_locally(version, local_path)
136
+ return if !local_path
137
+ gem_filepath = nil
138
+ Dir.chdir(local_path) do
139
+ system 'git add -A'
140
+ system 'rake build'
141
+ Dir.glob("#{local_path}/pkg/*.gem").each do |file|
142
+ break gem_filepath = file if file.include?(version)
143
+ end
144
+ end
145
+ system "gem install #{gem_filepath}"
146
+ end
147
+
41
148
  end
@@ -28,7 +28,8 @@ class Fanforce::AppFactory::CLI::Scripts
28
28
  Fanforce::CLI.register(self, :update,
29
29
  ['all/TYPE', 'Update all app files and env variables'],
30
30
  ['files', 'Copy the latest scaffolding files from fanforce-app-factory'],
31
- ['env', 'Create ENV variables from your local .env folder']
31
+ ['env', 'Create ENV variables from your local .env folder'],
32
+ ['factory', 'Update fanforce-app-factory gem in Gemfile and run bundle']
32
33
  ) { require_relative 'cli/scripts/update' }
33
34
 
34
35
  ########################################################################################################################
@@ -27,7 +27,8 @@ class Fanforce::AppFactory::CLI::Scripts
27
27
  Fanforce::CLI.register(self, :update,
28
28
  ['all/TYPE', 'Update all app files and env variables'],
29
29
  ['files', 'Copy the latest scaffolding files from fanforce-app-factory'],
30
- ['env', 'Create ENV variables from your local .env folder']
30
+ ['env', 'Create ENV variables from your local .env folder'],
31
+ ['factory', 'Update fanforce-app-factory gem in Gemfile and run bundle']
31
32
  ) { require_relative 'cli/scripts/update' }
32
33
 
33
34
  ########################################################################################################################
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  class AppFactory
3
- VERSION = '2.0.0.rc17'
3
+ VERSION = '2.0.0.rc18'
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.rc17
4
+ version: 2.0.0.rc18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Clark