fanforce-app-factory 2.0.0.rc5 → 2.0.0.rc7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Rakefile +54 -3
- data/apps.json +8 -8
- data/lib/fanforce/app_factory.rb +19 -16
- data/lib/fanforce/app_factory/Rakefile +6 -14
- data/lib/fanforce/app_factory/Routes.rb +2 -2
- data/lib/fanforce/app_factory/app.rb +19 -8
- data/lib/fanforce/app_factory/cli.rb +5 -0
- data/lib/fanforce/app_factory/cli/bitbucket.rb +70 -0
- data/lib/fanforce/app_factory/cli/bundler.rb +21 -0
- data/lib/fanforce/app_factory/cli/env.rb +99 -0
- data/lib/fanforce/app_factory/cli/git.rb +58 -0
- data/lib/fanforce/app_factory/cli/iron.rb +61 -0
- data/lib/fanforce/app_factory/cli/pow.rb +46 -0
- data/lib/fanforce/app_factory/cli/scaffolding.rb +74 -0
- data/lib/fanforce/app_factory/cli/scaffolding_file.rb +510 -0
- data/lib/fanforce/app_factory/cli/scripts/config.rb +9 -0
- data/lib/fanforce/app_factory/cli/scripts/create.rb +64 -0
- data/lib/fanforce/app_factory/cli/scripts/destroy.rb +61 -0
- data/lib/fanforce/app_factory/cli/scripts/push.rb +70 -0
- data/lib/fanforce/app_factory/cli/scripts/restart.rb +40 -0
- data/lib/fanforce/app_factory/cli/scripts/setup.rb +70 -0
- data/lib/fanforce/app_factory/cli/scripts/status.rb +120 -0
- data/lib/fanforce/app_factory/cli/scripts/update.rb +41 -0
- data/lib/fanforce/app_factory/cli/uranium.rb +77 -0
- data/lib/fanforce/app_factory/cli/utils.rb +39 -0
- data/lib/fanforce/app_factory/cli_directory_of_apps.rb +50 -0
- data/lib/fanforce/app_factory/cli_single_app.rb +49 -0
- data/lib/fanforce/app_factory/controllers/base_controller.rb +0 -4
- data/lib/fanforce/app_factory/core_config.rb +25 -26
- data/lib/fanforce/app_factory/load.rb +8 -0
- data/lib/fanforce/app_factory/load_iron_worker.rb +2 -0
- data/lib/fanforce/app_factory/load_sprockets.rb +2 -0
- data/lib/fanforce/app_factory/scaffolding/._.gitignore.registry +1 -0
- data/lib/fanforce/app_factory/scaffolding/._Gemfile.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/._Rakefile.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/._config.json.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/._config.ru.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/._favicon.ico.registry +1 -0
- data/lib/fanforce/app_factory/scaffolding/._robots.txt.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/.gitignore +27 -0
- data/lib/fanforce/app_factory/scaffolding/Gemfile +9 -0
- data/lib/fanforce/app_factory/scaffolding/Rakefile +7 -0
- data/lib/fanforce/app_factory/{scafolding → scaffolding}/Routes.rb +5 -1
- data/lib/fanforce/app_factory/scaffolding/assets/css/._engagement.scss.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/assets/css/._fembedded.scss.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/assets/css/._promotional.scss.registry +3 -0
- data/lib/fanforce/app_factory/{scafolding/scafolding_assets → scaffolding/assets}/css/engagement.scss +8 -5
- data/lib/fanforce/app_factory/scaffolding/assets/css/fembedded.scss +22 -0
- data/lib/fanforce/app_factory/{scafolding/scafolding_assets → scaffolding/assets}/css/promotional.scss +9 -4
- data/lib/fanforce/app_factory/scaffolding/assets/img/._icon-16.png.registry +1 -0
- data/lib/fanforce/app_factory/scaffolding/assets/img/._icon-32.png.registry +1 -0
- data/lib/fanforce/app_factory/scaffolding/assets/img/._icon-42.png.registry +1 -0
- data/lib/fanforce/app_factory/scaffolding/assets/img/._marketplace.png.registry +1 -0
- data/lib/fanforce/app_factory/{scafolding/scafolding_assets → scaffolding/assets}/img/icon-16.png +0 -0
- data/lib/fanforce/app_factory/{scafolding/scafolding_assets → scaffolding/assets}/img/icon-32.png +0 -0
- data/lib/fanforce/app_factory/{scafolding/scafolding_assets → scaffolding/assets}/img/icon-42.png +0 -0
- data/lib/fanforce/app_factory/{scafolding/scafolding_assets → scaffolding/assets}/img/marketplace.png +0 -0
- data/lib/fanforce/app_factory/scaffolding/assets/img/promotional/._fanforce_bg.png.registry +1 -0
- data/lib/fanforce/app_factory/scaffolding/assets/img/promotional/._icon-42.png.registry +1 -0
- data/lib/fanforce/app_factory/scaffolding/assets/img/promotional/._icon-plus.png.registry +1 -0
- data/lib/fanforce/app_factory/{scafolding/scafolding_assets → scaffolding/assets}/img/promotional/fanforce_bg.png +0 -0
- data/lib/fanforce/app_factory/{scafolding/scafolding_assets → scaffolding/assets}/img/promotional/icon-42.png +0 -0
- data/lib/fanforce/app_factory/{scafolding/scafolding_assets → scaffolding/assets}/img/promotional/icon-plus.png +0 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/._fembedded-app.coffee.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/._fembedded.js.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/._promotional.js.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/fembedded-app.coffee +11 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/fembedded.js +12 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/lib/._cookie.coffee.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/lib/._filters.coffee.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/lib/._utils.coffee.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/lib/cookie.coffee +24 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/lib/filters.coffee +9 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/lib/utils.coffee +40 -0
- data/lib/fanforce/app_factory/scaffolding/assets/js/promotional.js +4 -0
- data/lib/fanforce/app_factory/scaffolding/config.json +24 -0
- data/lib/fanforce/app_factory/scaffolding/config.ru +8 -0
- data/lib/fanforce/app_factory/{scafolding/public → scaffolding}/favicon.ico +0 -0
- data/lib/fanforce/app_factory/scaffolding/layouts/._engagement.haml.registry +1 -0
- data/lib/fanforce/app_factory/scaffolding/layouts/._fembedded.haml.registry +2 -0
- data/lib/fanforce/app_factory/scaffolding/layouts/._promotional.haml.registry +1 -0
- data/lib/fanforce/app_factory/{scafolding → scaffolding}/layouts/engagement.haml +5 -4
- data/lib/fanforce/app_factory/scaffolding/layouts/fembedded.haml +26 -0
- data/lib/fanforce/app_factory/scaffolding/layouts/promotional.haml +19 -0
- data/lib/fanforce/app_factory/scaffolding/robots.txt +7 -0
- data/lib/fanforce/app_factory/scaffolding/views/._index.haml.registry +1 -0
- data/lib/fanforce/app_factory/{scafolding → scaffolding}/views/index.haml +13 -7
- data/lib/fanforce/app_factory/sinatra/_load.rb +7 -7
- data/lib/fanforce/app_factory/sinatra/helper_routes/app.rb +2 -2
- data/lib/fanforce/app_factory/sinatra/helper_routes/com_behavior.rb +2 -2
- data/lib/fanforce/app_factory/sinatra/helper_routes/com_broadcaster.rb +1 -1
- data/lib/fanforce/app_factory/sinatra/helper_routes/com_connector.rb +2 -2
- data/lib/fanforce/app_factory/sprockets/compiler.rb +0 -1
- data/lib/fanforce/app_factory/version.rb +1 -1
- data/workers.json +8 -8
- metadata +80 -38
- data/lib/fanforce/app_factory/asset_framework/app_factory/directives/internal-iframe/internal-iframe.scss +0 -1
- data/lib/fanforce/app_factory/asset_framework/app_factory/lib/cookie.coffee +0 -16
- data/lib/fanforce/app_factory/asset_framework/app_factory/lib/url.coffee +0 -20
- data/lib/fanforce/app_factory/asset_framework/app_factory/lib/utils.coffee +0 -11
- data/lib/fanforce/app_factory/asset_framework/app_factory/scafolding/_engagement.scss +0 -1
- data/lib/fanforce/app_factory/asset_framework/app_factory/scafolding/_promotional.scss +0 -1
- data/lib/fanforce/app_factory/asset_framework/app_factory/scafolding/_standard.scss +0 -1
- data/lib/fanforce/app_factory/asset_framework/app_factory/scafolding/promotional.coffee +0 -0
- data/lib/fanforce/app_factory/cli/_cleanorgs.rb +0 -54
- data/lib/fanforce/app_factory/scafolding/public/robots.txt +0 -2
- data/lib/fanforce/app_factory/scafolding/scafolding_assets/css/standard.scss +0 -10
- data/lib/fanforce/app_factory/scafolding/scafolding_assets/img/marketplace.psd +0 -0
- data/lib/fanforce/app_factory/scafolding/views/add_initiative.haml +0 -1
- data/lib/fanforce/app_factory/scafolding/views/add_source.haml +0 -1
- data/lib/fanforce/app_factory/scafolding/views/close_popup.haml +0 -8
- data/lib/fanforce/app_factory/scafolding/views/config.haml +0 -1
- data/lib/fanforce/app_factory/scafolding/views/convert_initiative.haml +0 -1
- data/lib/fanforce/app_factory/scafolding/views/dashboard.haml +0 -38
- data/lib/fanforce/app_factory/scafolding/views/edit_initiative.haml +0 -1
- data/lib/fanforce/app_factory/scafolding/views/engage.haml +0 -1
- data/lib/fanforce/app_factory/scafolding/views/new_message.haml +0 -1
- data/lib/fanforce/app_factory/scafolding/views/source_details.haml +0 -1
- data/lib/fanforce/app_factory/scafolding/views/widget_templates.haml +0 -1
- data/lib/fanforce/app_factory/sprockets/_all.rb +0 -2
@@ -0,0 +1,64 @@
|
|
1
|
+
class Fanforce::AppFactory::CLI::Scripts
|
2
|
+
include Fanforce::AppFactory::CLI::Utils
|
3
|
+
|
4
|
+
require_relative '../scaffolding'
|
5
|
+
require_relative '../bundler'
|
6
|
+
require_relative '../pow'
|
7
|
+
require_relative '../git'
|
8
|
+
require_relative '../bitbucket'
|
9
|
+
require_relative '../env'
|
10
|
+
require_relative '../uranium'
|
11
|
+
|
12
|
+
######################################################################################################################
|
13
|
+
|
14
|
+
def create(app_id)
|
15
|
+
app_id || error('You must supply a valid APP_ID', :create)
|
16
|
+
app_dir = "#{Fanforce::CLI::DIR}/#{app_id}"
|
17
|
+
|
18
|
+
if File.exists?("#{app_dir}/config.ru")
|
19
|
+
error "#{app_id} already exists. You should run: " + "fanforce update #{app_id}".format(:green)
|
20
|
+
end
|
21
|
+
|
22
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
23
|
+
log 'CREATING FILES...'
|
24
|
+
Dir.mkdir(app_dir) if !File.directory?(app_dir)
|
25
|
+
Dir.chdir(app_dir)
|
26
|
+
log "#{'Created'.format(:bold, :green)} #{app_dir}/"
|
27
|
+
app = Fanforce::CLI::App.new(app_dir)
|
28
|
+
Fanforce::AppFactory::CLI::Scaffolding.new(app).setup
|
29
|
+
|
30
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
31
|
+
log 'INSTALLING BUNDLER...'
|
32
|
+
Fanforce::AppFactory::CLI::Bundler.new(app).setup
|
33
|
+
|
34
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
35
|
+
log 'CREATING POW DOMAINS...'
|
36
|
+
Fanforce::AppFactory::CLI::Pow.new(app).setup
|
37
|
+
|
38
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
39
|
+
log 'CREATING LOCAL GIT REPOSITORY...'
|
40
|
+
Fanforce::AppFactory::CLI::Git.new(app).setup
|
41
|
+
|
42
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
43
|
+
log 'CREATING BITBUCKET REPOSITORY...'
|
44
|
+
Fanforce::AppFactory::CLI::Bitbucket.new(app).create
|
45
|
+
|
46
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
47
|
+
log 'CREATING ENV VARIABLES...'
|
48
|
+
Fanforce::AppFactory::CLI::Env.new(app).setup(:development)
|
49
|
+
|
50
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
51
|
+
log 'RUNNING TOUCH TMP/RESTART.TXT...'
|
52
|
+
`touch tmp/restart.txt`
|
53
|
+
log 'Finished'.format(:green,:bold) + ' restarting'
|
54
|
+
|
55
|
+
log divider '+---------------------------------------------------------------------------------------------------'
|
56
|
+
log 'SETTING UP URANIUM...'
|
57
|
+
Fanforce::AppFactory::CLI::Uranium.new(app).create
|
58
|
+
|
59
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
60
|
+
log 'SUCCESS!'.format(:bold,:green)
|
61
|
+
log divider '----------------------------------------------------------------------------------------------------++'
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Fanforce::AppFactory::CLI::Scripts
|
2
|
+
include Fanforce::AppFactory::CLI::Utils
|
3
|
+
|
4
|
+
require_relative '../bitbucket'
|
5
|
+
require_relative '../uranium'
|
6
|
+
require_relative '../pow'
|
7
|
+
|
8
|
+
######################################################################################################################
|
9
|
+
|
10
|
+
def destroy(app_id)
|
11
|
+
app_id || error('You must supply a valid APP_ID', :delete)
|
12
|
+
app_dir = "#{Fanforce::CLI::DIR}/#{app_id}"
|
13
|
+
|
14
|
+
error "Directory was not found for app: #{app_dir}" if !File.directory?("#{app_dir}")
|
15
|
+
error 'Bitbucket credentials were not found in config file' if !config[:bitbucket]
|
16
|
+
app = Fanforce::CLI::App.new(app_dir)
|
17
|
+
|
18
|
+
log divider '+-----'
|
19
|
+
confirm("You are about to delete both local and remote files for #{app_id}.\nARE YOU SURE?", true)
|
20
|
+
|
21
|
+
# puts "\n---------------------------------------------------------------------------------------------------------------"
|
22
|
+
# puts 'DELETING HEROKU APPS...'
|
23
|
+
# [:staging,:production].each do |environment|
|
24
|
+
# next if $Config[:heroku].blank? or $Config[:heroku][environment].blank?
|
25
|
+
# heroku = auth_heroku(environment)
|
26
|
+
# heroku_app_name = get_heroku_app_name(app, environment)
|
27
|
+
# begin
|
28
|
+
# heroku.delete_app(heroku_app_name)
|
29
|
+
# puts "#{'Removed '.format(:green,:bold)}" + " #{heroku_app_name}"
|
30
|
+
# rescue Exception => e
|
31
|
+
# puts "#{'Already Removed'.format(:green,:bold)}" + " #{heroku_app_name}"
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
|
35
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
36
|
+
log 'REMOVING BITBUCKET REPOSITORY...'
|
37
|
+
Fanforce::AppFactory::CLI::Bitbucket.new(app).destroy
|
38
|
+
|
39
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
40
|
+
log 'REMOVING URANIUM RECORD...'
|
41
|
+
Fanforce::AppFactory::CLI::Uranium.new(app).destroy
|
42
|
+
|
43
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
44
|
+
log 'REMOVING POW DOMAINS...'
|
45
|
+
Fanforce::AppFactory::CLI::Pow.new(app).destroy
|
46
|
+
|
47
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
48
|
+
log 'REMOVING FILES...'
|
49
|
+
if File.directory?(app_dir)
|
50
|
+
FileUtils.rm_rf(app_dir)
|
51
|
+
log "#{'Removed'.format(:bold, :green)} #{app_dir}/"
|
52
|
+
else
|
53
|
+
log "#{'Already Removed'.format(:bold, :green)} #{app_dir}/"
|
54
|
+
end
|
55
|
+
|
56
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
57
|
+
log 'DONE! (note: iron workers were not deleted)'
|
58
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class Fanforce::AppFactory::CLI::Scripts
|
2
|
+
include Fanforce::AppFactory::CLI::Utils
|
3
|
+
|
4
|
+
require_relative '../env'
|
5
|
+
require_relative '../iron'
|
6
|
+
|
7
|
+
######################################################################################################################
|
8
|
+
|
9
|
+
def push(environment, command)
|
10
|
+
command = command.to_sym
|
11
|
+
app = Fanforce::CLI::App.load(Fanforce::CLI::DIR)
|
12
|
+
|
13
|
+
if [:all,:iron].include?(command)
|
14
|
+
if Fanforce::CLI::TYPE == :directory_of_apps
|
15
|
+
confirm("\nYou are about to push iron works for #{Fanforce::CLI::Apps.total_count} apps in this directory.\n"+
|
16
|
+
'ARE YOU SURE?', true)
|
17
|
+
Fanforce::CLI::Apps.each do |app, processed_count, total_count|
|
18
|
+
log divider '+-------------------------------------------------------------------------------------------------'
|
19
|
+
log "#{'APP'.format(:bold)} - #{app._id.upcase.gsub('-',' ').format(:bold)} (#{processed_count} of #{total_count})... "
|
20
|
+
push_app_workers(app, environment)
|
21
|
+
end
|
22
|
+
elsif Fanforce::CLI::TYPE == :single_app
|
23
|
+
log divider '+-------------------------------------------------------------------------------------------------'
|
24
|
+
app = Fanforce::CLI::App.load(Fanforce::CLI::DIR)
|
25
|
+
push_app_workers(app, environment)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
log divider '----------------------------------------------------------------------------------------------------++'
|
30
|
+
end
|
31
|
+
|
32
|
+
def push_app_workers(app, environment)
|
33
|
+
Dir.chdir(app.dir) do
|
34
|
+
Fanforce::AppFactory::CLI::Iron.new(app).upload(environment)
|
35
|
+
|
36
|
+
# if [:all,:bitbucket].include?(command) and config[:bitbucket].present?
|
37
|
+
# if !(`git remote`).split(/\r?\n/).include?('bitbucket')
|
38
|
+
# setup_bitbucket(app)
|
39
|
+
# else
|
40
|
+
# puts "\n#{'Pushing '.format(:green,:bold)}" + "latest commit to Bitbucket (#{$Config[:bitbucket][:user]})..."
|
41
|
+
# Run.command('git push bitbucket --all')
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
|
45
|
+
# environments = (environment==:all) ? [:staging,:production] : [environment]
|
46
|
+
# environments.each do |environment|
|
47
|
+
# if [:all,:heroku].include?(command)
|
48
|
+
# remote_name = "#{env(environment)}-heroku"
|
49
|
+
# setup_heroku(app, environment) if !(`git remote`).split(/\r?\n/).include?(remote_name)
|
50
|
+
#
|
51
|
+
# vars = Env.vars_by_app(environment)[app.dir_name] || {}
|
52
|
+
# puts "\n#{"Updating Env Vars".format(:green,:bold)} on Heroku #{environment.to_s.titleize} (#{vars.size} variables)..."
|
53
|
+
# push_env_to(environment, app, vars)
|
54
|
+
#
|
55
|
+
# puts "\n#{'Pushing '.format(:green,:bold)}" + "latest commit to Heroku #{environment.to_s.titleize} (#{remote_name})..."
|
56
|
+
# Run.command("git push #{remote_name} master")
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# if [:all,:iron].include?(command)
|
60
|
+
# puts ''
|
61
|
+
# upload_iron(app, command, [environment])
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Fanforce::AppFactory::CLI::Scripts
|
2
|
+
include Fanforce::AppFactory::CLI::Utils
|
3
|
+
|
4
|
+
######################################################################################################################
|
5
|
+
|
6
|
+
def restart(environment=:development)
|
7
|
+
environment = environment.to_sym
|
8
|
+
app = Fanforce::CLI::App.load(Fanforce::CLI::DIR)
|
9
|
+
puts "---------------------------------------------------------------------------------------------------------------"
|
10
|
+
Dir.chdir(app.dir) do
|
11
|
+
if [:all, :development].include?(environment)
|
12
|
+
puts "#{'Restarted'.format(:bold,:green)} #{app.dir_name} (development)" if restart_app(app, :development)
|
13
|
+
end
|
14
|
+
if [:all, :staging].include?(environment)
|
15
|
+
puts "#{'Restarted'.format(:bold,:green)} #{app.dir_name} (staging)" if restart_app(app, :staging)
|
16
|
+
end
|
17
|
+
if [:all, :production].include?(environment)
|
18
|
+
puts "#{'Restarted'.format(:bold,:green)} #{app.dir_name} (production)" if restart_app(app, :production)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
puts ''
|
22
|
+
end
|
23
|
+
|
24
|
+
def restart_app(app, environment)
|
25
|
+
if environment == :development
|
26
|
+
File.mkdir("#{app.dir}/tmp") if !File.directory?("#{app.dir}/tmp")
|
27
|
+
FileUtils.touch("#{app.dir}/tmp/restart.txt")
|
28
|
+
elsif [:production, :staging].include?(environment)
|
29
|
+
error 'Production and Staging are not working'
|
30
|
+
if config[:heroku].blank? or config[:heroku][environment].blank?
|
31
|
+
puts "#{'OOPS...'.format(:red,:bold)} #{environment} has not been setup on heroku"
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
heroku = auth_heroku(environment)
|
35
|
+
heroku.post_ps_restart get_heroku_app_name(app, environment)
|
36
|
+
end
|
37
|
+
return true
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class Fanforce::AppFactory::CLI::Scripts
|
2
|
+
include Fanforce::AppFactory::CLI::Utils
|
3
|
+
|
4
|
+
require_relative '../bundler'
|
5
|
+
require_relative '../pow'
|
6
|
+
require_relative '../git'
|
7
|
+
require_relative '../bitbucket'
|
8
|
+
require_relative '../env'
|
9
|
+
require_relative '../uranium'
|
10
|
+
|
11
|
+
######################################################################################################################
|
12
|
+
|
13
|
+
def setup(type)
|
14
|
+
app = Fanforce::CLI::App.new(Fanforce::CLI::DIR)
|
15
|
+
type = type.to_s.downcase.to_sym
|
16
|
+
error 'Unknown setup type', :setup if ![:all,:bundler,:pow,:git,:env,:uranium].include?(type)
|
17
|
+
|
18
|
+
if !File.exists?("#{app.dir}/config.ru")
|
19
|
+
error "This does not seem to be a valid app directory since it's missing config.ru"
|
20
|
+
end
|
21
|
+
|
22
|
+
if [:all,:bundler].include?(type)
|
23
|
+
log divider '+---------------------------------------------------------------------------------------------------'
|
24
|
+
log 'SETTING UP BUNDLER...'
|
25
|
+
Fanforce::AppFactory::CLI::Bundler.new(app).setup
|
26
|
+
end
|
27
|
+
|
28
|
+
if [:all,:pow].include?(type)
|
29
|
+
log divider '+---------------------------------------------------------------------------------------------------'
|
30
|
+
log 'SETTING UP POW DOMAINS...'
|
31
|
+
Fanforce::AppFactory::CLI::Pow.new(app).setup
|
32
|
+
end
|
33
|
+
|
34
|
+
if [:all,:git].include?(type)
|
35
|
+
log divider '+---------------------------------------------------------------------------------------------------'
|
36
|
+
log 'SETTING UP GIT...'
|
37
|
+
Fanforce::AppFactory::CLI::Git.new(app).setup
|
38
|
+
end
|
39
|
+
|
40
|
+
if [:all,:bitbucket].include?(type)
|
41
|
+
log divider '+---------------------------------------------------------------------------------------------------'
|
42
|
+
log 'SETTING UP BITBUCKET...'
|
43
|
+
Fanforce::AppFactory::CLI::Bitbucket.new(app).setup
|
44
|
+
end
|
45
|
+
|
46
|
+
if [:all,:env].include?(type)
|
47
|
+
log divider '+---------------------------------------------------------------------------------------------------'
|
48
|
+
log 'SETTING UP ENV...'
|
49
|
+
Fanforce::AppFactory::CLI::Env.new(app).setup(:development)
|
50
|
+
end
|
51
|
+
|
52
|
+
if [:all,:uranium].include?(type)
|
53
|
+
log divider '+---------------------------------------------------------------------------------------------------'
|
54
|
+
log 'RUNNING TOUCH TMP/RESTART.TXT...'
|
55
|
+
`touch tmp/restart.txt`
|
56
|
+
log 'Finished'.format(:green,:bold) + ' restarting'
|
57
|
+
end
|
58
|
+
|
59
|
+
if [:all,:uranium].include?(type)
|
60
|
+
log divider '+---------------------------------------------------------------------------------------------------'
|
61
|
+
log 'SETTING UP URANIUM...'
|
62
|
+
Fanforce::AppFactory::CLI::Uranium.new(app).setup
|
63
|
+
end
|
64
|
+
|
65
|
+
log divider '+-----------------------------------------------------------------------------------------------------'
|
66
|
+
log 'SUCCESS!'.format(:bold,:green)
|
67
|
+
log divider '----------------------------------------------------------------------------------------------------++'
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
class Fanforce::AppFactory::CLI::Scripts
|
2
|
+
include Fanforce::AppFactory::CLI::Utils
|
3
|
+
|
4
|
+
require_relative '../git'
|
5
|
+
require_relative '../scaffolding'
|
6
|
+
|
7
|
+
######################################################################################################################
|
8
|
+
|
9
|
+
def status(type, detail_level=nil)
|
10
|
+
type = type.to_sym
|
11
|
+
detail_level = (detail_level||'overview').to_sym if type == :files
|
12
|
+
|
13
|
+
if [:all,:files].include?(type)
|
14
|
+
if Fanforce::CLI::TYPE == :directory_of_apps
|
15
|
+
files_overview
|
16
|
+
elsif Fanforce::CLI::TYPE == :single_app
|
17
|
+
app = Fanforce::CLI::App.load(Fanforce::CLI::DIR)
|
18
|
+
files_details(app, detail_level)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if [:all,:git].include?(type)
|
23
|
+
if Fanforce::CLI::TYPE == :directory_of_apps
|
24
|
+
status_git_overview
|
25
|
+
elsif Fanforce::CLI::TYPE == :single_app
|
26
|
+
status_git
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def status_git_overview
|
33
|
+
app_column_width = Fanforce::CLI::Apps.dir_names.inject(0){|l,d| d.length>l ? d.length : l}
|
34
|
+
log Fanforce::AppFactory::CLI::Git.status_table_header(app_column_width)
|
35
|
+
log divider '======================================================================================================'
|
36
|
+
Fanforce::CLI::Apps.each do |app, current_count, total|
|
37
|
+
log Fanforce::AppFactory::CLI::Git.new(app).status_row(app_column_width)
|
38
|
+
log divider '---------------------------------------------------------------------------------------------------+'
|
39
|
+
end
|
40
|
+
log ''
|
41
|
+
end
|
42
|
+
|
43
|
+
def status_git
|
44
|
+
exec 'git status'
|
45
|
+
log ''
|
46
|
+
end
|
47
|
+
|
48
|
+
def files_overview
|
49
|
+
log ''
|
50
|
+
log sprintf('%-12s %-50s %85s', 'FILE STATUS', 'APP NAME', 'STATS OVERVIEW').format(:bold)
|
51
|
+
log divider '======================================================================================================'
|
52
|
+
Fanforce::CLI::Apps.each do |app, current_count, total|
|
53
|
+
missing = 0
|
54
|
+
diverged = 0
|
55
|
+
previous = 0
|
56
|
+
corrupted = 0
|
57
|
+
is_synced = true
|
58
|
+
Fanforce::AppFactory::CLI::Scaffolding.new(app).metadata.each do |filepath, change|
|
59
|
+
if change[:status] == :missing
|
60
|
+
is_synced = false
|
61
|
+
next missing += 1
|
62
|
+
elsif change[:status] == :diverged
|
63
|
+
is_synced = false
|
64
|
+
next diverged += 1
|
65
|
+
elsif change[:status] == :previous
|
66
|
+
is_synced = false
|
67
|
+
next previous += 1
|
68
|
+
elsif change[:status] == :corrupted
|
69
|
+
is_synced = false
|
70
|
+
next corrupted += 1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
changed_stats = [
|
74
|
+
"#{missing} files missing",
|
75
|
+
"#{previous} files previous",
|
76
|
+
"#{diverged} files diverged",
|
77
|
+
"#{corrupted} files corrupted"
|
78
|
+
]
|
79
|
+
puts sprintf("%s%-12s#{fmt_end} %-41s %23s %23s %23s %23s",
|
80
|
+
fmt_start(is_synced ? :green : :red),
|
81
|
+
(is_synced ? 'Synced' : 'Changed'),
|
82
|
+
app.name,
|
83
|
+
*changed_stats
|
84
|
+
)
|
85
|
+
log divider '---------------------------------------------------------------------------------------------------+'
|
86
|
+
end
|
87
|
+
puts ''
|
88
|
+
end
|
89
|
+
|
90
|
+
def files_details(app, detail_level)
|
91
|
+
log ''
|
92
|
+
log sprintf "%-30s %119s\n", "FILES (#{app.dir_name})", 'changes needed during update'
|
93
|
+
log divider '======================================================================================================'
|
94
|
+
Fanforce::AppFactory::CLI::Scaffolding.new(app).metadata.each do |filepath, change|
|
95
|
+
filepath = filepath.gsub(Fanforce::CLI::DIR, '')
|
96
|
+
log sprintf "%s%-8s#{fmt_end} %-95s %22s %22s\n",
|
97
|
+
fmt_start([:previous,:diverged,:missing,:corrupted].include?(change[:status]) ? :red : :green),
|
98
|
+
change[:status].to_s.titleize,
|
99
|
+
filepath,
|
100
|
+
("#{change[:insertions]} insertions(+)" if change[:insertions].to_i > 0),
|
101
|
+
("#{change[:deletions]} deletions(-)" if change[:insertions].to_i > 0)
|
102
|
+
if detail_level == :diff and change[:diff]
|
103
|
+
lines = ''
|
104
|
+
change[:diff].lines do |line|
|
105
|
+
line = line.format(:red) if line[0] == '-'
|
106
|
+
line = line.format(:green) if line[0] == '+'
|
107
|
+
line = (' '*3) + line
|
108
|
+
lines += line
|
109
|
+
end
|
110
|
+
log divider ' -----------------------------------------------------------------------------------------------'
|
111
|
+
log ' THE FOLLOWING CHANGES WILL OCCUR DURING UPDATE:'
|
112
|
+
log ' -----------------------------------------------'
|
113
|
+
log "\n" + lines + "\n"
|
114
|
+
end
|
115
|
+
log divider '---------------------------------------------------------------------------------------------------+'
|
116
|
+
end
|
117
|
+
puts ''
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Fanforce::AppFactory::CLI::Scripts
|
2
|
+
include Fanforce::AppFactory::CLI::Utils
|
3
|
+
|
4
|
+
require_relative '../env'
|
5
|
+
require_relative '../scaffolding'
|
6
|
+
|
7
|
+
######################################################################################################################
|
8
|
+
|
9
|
+
def update(type)
|
10
|
+
type = type.to_sym
|
11
|
+
|
12
|
+
if Fanforce::CLI::TYPE == :directory_of_apps
|
13
|
+
confirm("\nYou are about to update #{Fanforce::CLI::Apps.total_count} apps in this directory. This cannot be undone.\n"+
|
14
|
+
'ARE YOU SURE?', true)
|
15
|
+
|
16
|
+
Fanforce::CLI::Apps.each do |app, processed_count, total_count|
|
17
|
+
log divider '+-------------------------------------------------------------------------------------------------'
|
18
|
+
log "#{'APP'.format(:bold)} - #{app._id.upcase.gsub('-',' ').format(:bold)} (#{processed_count} of #{total_count})... "
|
19
|
+
update_app(app, type)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
app = Fanforce::CLI::App.load(Fanforce::CLI::DIR)
|
23
|
+
confirm("\nYou are about to update #{app.name}. This cannot be undone.\n" +
|
24
|
+
'ARE YOU SURE?', true)
|
25
|
+
update_app(app, type)
|
26
|
+
end
|
27
|
+
puts ''
|
28
|
+
end
|
29
|
+
|
30
|
+
def update_app(app, type)
|
31
|
+
if [:all,:files].include?(type)
|
32
|
+
if !Fanforce::AppFactory::CLI::Scaffolding.new(app).update
|
33
|
+
log "\nNO FILES NEED UPDATING"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
if [:all,:env].include?(type)
|
37
|
+
Fanforce::AppFactory::CLI::Env.new(app).setup(:development)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|