fanforce-factory 0.4.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 +15 -0
- data/.gitignore +19 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +177 -0
- data/Rakefile +1 -0
- data/bin/factory +18 -0
- data/bin/factory-supercharge +7 -0
- data/fanforce-factory.gemspec +28 -0
- data/lib/fanforce/factory.rb +12 -0
- data/lib/fanforce/factory/_base.rb +290 -0
- data/lib/fanforce/factory/addons.rb +128 -0
- data/lib/fanforce/factory/commands.rb +449 -0
- data/lib/fanforce/factory/commands_support.rb +180 -0
- data/lib/fanforce/factory/developer_config.rb +112 -0
- data/lib/fanforce/factory/env.rb +37 -0
- data/lib/fanforce/factory/files.rb +269 -0
- data/lib/fanforce/factory/help.rb +104 -0
- data/lib/fanforce/factory/initializers/ff_globals.rb +72 -0
- data/lib/fanforce/factory/run.rb +51 -0
- data/lib/fanforce/factory/utils.rb +51 -0
- data/lib/fanforce/factory/version.rb +5 -0
- data/lib/fanforce_factory.rb +3 -0
- metadata +151 -0
@@ -0,0 +1,104 @@
|
|
1
|
+
module Fanforce::Factory::Help
|
2
|
+
extend Fanforce::Factory::Help
|
3
|
+
|
4
|
+
def intro(executable, runtype)
|
5
|
+
response = "-----------------------------------------------------------------------------------------------------------------------\n"
|
6
|
+
response += "USAGE: #{executable} #{runtype == :single ? '' : '[:filter] '}<command>\n"
|
7
|
+
end
|
8
|
+
|
9
|
+
def commands(allowed_commands)
|
10
|
+
response = "\n\nAVAILABLE COMMANDS...\n-----------------------------------------------------------------------------------------------------------------------\n"
|
11
|
+
commands = allowed_commands.map do |c|
|
12
|
+
c = "standalone_#{c}" if c == :update and !allowed_commands.include?(:setup)
|
13
|
+
self.send(:"#{c}_command")
|
14
|
+
end
|
15
|
+
response += commands.join("-----------------------------------------------------------------------------------------------------------------------\n")
|
16
|
+
response += "-----------------------------------------------------------------------------------------------------------------------\n\n"
|
17
|
+
end
|
18
|
+
|
19
|
+
def for(command, allowed_commands)
|
20
|
+
response = "\n#{command.to_s.upcase} COMMAND...\n-----------------------------------------------------------------------------------------------------------------------\n"
|
21
|
+
response += self.send(:"#{'standalone_' if command == :update}#{command}_command")
|
22
|
+
response += "-----------------------------------------------------------------------------------------------------------------------\n\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_command; <<-eos
|
26
|
+
create (plugin|widget|app)-ID [PLUGIN_TYPE] Create new addon folder and setup the file structure
|
27
|
+
eos
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete_command; <<-eos
|
31
|
+
delete (plugin|widget|app)-ID Delete the addon folder and all related services
|
32
|
+
eos
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup_command; <<-eos
|
36
|
+
setup (all|OR...) Setup all items needed for the addon
|
37
|
+
|files Create or update needed files
|
38
|
+
|env:[*all|RACK_ENV] Update environment vars for a specific environment
|
39
|
+
|pow Ensure pow domains are setup for development environment
|
40
|
+
|bitbucket Create new repositories in bitbucket and push latest commit
|
41
|
+
|heroku:[*all|RACK_ENV] Create new app in heroku account and push latest commit
|
42
|
+
eos
|
43
|
+
end
|
44
|
+
|
45
|
+
def update_command; <<-eos
|
46
|
+
update ANY_SETUP_COMMAND Update anything that is a setup command
|
47
|
+
eos
|
48
|
+
end
|
49
|
+
|
50
|
+
def standalone_update_command; <<-eos
|
51
|
+
update (all|OR...) Update all items
|
52
|
+
|files Create or update needed files
|
53
|
+
|env:[*all|RACK_ENV] Update environment vars for a specific environment
|
54
|
+
|pow Ensure pow domains are setup for development environment
|
55
|
+
|bitbucket Ensure bitbucket repositories exist and push latest commit if new
|
56
|
+
|heroku:[*all|RACK_ENV] Ensure app exists in heroku account and push latest commit if new
|
57
|
+
eos
|
58
|
+
end
|
59
|
+
|
60
|
+
def restart_command; <<-eos
|
61
|
+
restart [*development|RACK_ENV|all] Runs `touch tmp/restart` if development or else `heroku restart`
|
62
|
+
eos
|
63
|
+
end
|
64
|
+
|
65
|
+
def push_command; <<-eos
|
66
|
+
push RACK_ENV:[*all|OR...] Push all changes to the environment specified
|
67
|
+
|bitbucket Push the latest commit to bitbucket
|
68
|
+
|heroku Push the latest commit to heroku and restart
|
69
|
+
|iron:[*upload:nuclear] Push changes to workers
|
70
|
+
eos
|
71
|
+
end
|
72
|
+
|
73
|
+
def count_command; <<-eos
|
74
|
+
count Display the number of addons in the current factory
|
75
|
+
eos
|
76
|
+
end
|
77
|
+
|
78
|
+
def bundle_command; <<-eos
|
79
|
+
bundle (install|update) Run bundle on all addons in current factory
|
80
|
+
eos
|
81
|
+
end
|
82
|
+
|
83
|
+
def git_command; <<-eos
|
84
|
+
git [ANY GIT COMMAND] Run the same git command across all addons in current factory
|
85
|
+
git status:overview A custom git command that displays a simple status for each addon
|
86
|
+
eos
|
87
|
+
end
|
88
|
+
|
89
|
+
def iron_command; <<-eos
|
90
|
+
iron (upload|reset|delete):[*all|RACK_ENV] Updates env variables and upload one or more workers to iron.io
|
91
|
+
eos
|
92
|
+
end
|
93
|
+
|
94
|
+
def version_command; <<-eos
|
95
|
+
version Display your current Fanforce Factory version number
|
96
|
+
eos
|
97
|
+
end
|
98
|
+
|
99
|
+
def config_command; <<-eos
|
100
|
+
config Display your Fanforce Factory config in the current directory
|
101
|
+
eos
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
if !ENV['RACK_ENV'] or ENV['RACK_ENV'] == 'development'
|
2
|
+
$BASE_DOMAIN = 'fanforce.gg'
|
3
|
+
$APP_DOMAIN = 'app.' + $BASE_DOMAIN
|
4
|
+
$API_DOMAIN = 'api.' + $BASE_DOMAIN
|
5
|
+
$I_DOMAIN = 'i.' + $BASE_DOMAIN
|
6
|
+
$WEBSITE_DOMAIN = $BASE_DOMAIN
|
7
|
+
|
8
|
+
$SMARTURL_DOMAIN = 'fanforc.gg'
|
9
|
+
$FF_PLUGIN_DOMAIN = 'ffplugin.gg'
|
10
|
+
$FF_APP_DOMAIN = 'ffapp.gg'
|
11
|
+
$FF_WIDGET_DOMAIN = 'ffwidget.gg'
|
12
|
+
|
13
|
+
$DEVS_DOMAIN = 'technical%40mobilizationlabs.com:zE27fdevelopers@developers-fanforce.dotcloud.com' # or localhost:3000'
|
14
|
+
|
15
|
+
$PUSHER_APP_ID = '23240'
|
16
|
+
$PUSHER_KEY = '029caf227a64c8e82e99'
|
17
|
+
$PUSHER_SECRET = '3169163d2e27de9a2291'
|
18
|
+
|
19
|
+
elsif ENV['RACK_ENV'] == 'test'
|
20
|
+
$BASE_DOMAIN = 'fanforce.gg'
|
21
|
+
$APP_DOMAIN = 'app.' + $BASE_DOMAIN
|
22
|
+
$API_DOMAIN = 'api.' + $BASE_DOMAIN
|
23
|
+
$I_DOMAIN = 'i.' + $BASE_DOMAIN
|
24
|
+
$WEBSITE_DOMAIN = $BASE_DOMAIN
|
25
|
+
|
26
|
+
$SMARTURL_DOMAIN = 'fanforc.gg'
|
27
|
+
$FF_PLUGIN_DOMAIN = 'ffplugin.gg'
|
28
|
+
$FF_WIDGET_DOMAIN = 'ffwidget.gg'
|
29
|
+
$FF_APP_DOMAIN = 'ffapp.gg'
|
30
|
+
|
31
|
+
$DEVS_DOMAIN = 'technical%40mobilizationlabs.com:zE27fdevelopers@developers-fanforce.dotcloud.com'
|
32
|
+
|
33
|
+
$PUSHER_APP_ID = '23243'
|
34
|
+
$PUSHER_KEY = '7bcc87b3c55301f687b9'
|
35
|
+
$PUSHER_SECRET = '61c760c05430e68d7e8d'
|
36
|
+
|
37
|
+
elsif ENV['RACK_ENV'] == 'qa'
|
38
|
+
$BASE_DOMAIN = 'fanforce-qa.com'
|
39
|
+
$APP_DOMAIN = 'app.' + $BASE_DOMAIN
|
40
|
+
$API_DOMAIN = 'api.' + $BASE_DOMAIN
|
41
|
+
$I_DOMAIN = 'i.' + $BASE_DOMAIN
|
42
|
+
$WEBSITE_DOMAIN = $BASE_DOMAIN
|
43
|
+
|
44
|
+
$SMARTURL_DOMAIN = 'fanforc.us'
|
45
|
+
$FF_PLUGIN_DOMAIN = 'ffplugin.us'
|
46
|
+
$FF_APP_DOMAIN = 'ffapp.us'
|
47
|
+
$FF_WIDGET_DOMAIN = 'ffwidget.us'
|
48
|
+
|
49
|
+
$DEVS_DOMAIN = 'technical%40mobilizationlabs.com:zE27fdevelopers@developers-fanforce.dotcloud.com'
|
50
|
+
|
51
|
+
$PUSHER_APP_ID = '14778'
|
52
|
+
$PUSHER_KEY = 'b5e2e23fb9542798ef38'
|
53
|
+
$PUSHER_SECRET = '7bfba2003df078ca64e9'
|
54
|
+
|
55
|
+
elsif ENV['RACK_ENV'] == 'production'
|
56
|
+
$BASE_DOMAIN = 'fanforce.com'
|
57
|
+
$APP_DOMAIN = 'app.' + $BASE_DOMAIN
|
58
|
+
$API_DOMAIN = 'api.' + $BASE_DOMAIN
|
59
|
+
$I_DOMAIN = 'i.' + $BASE_DOMAIN
|
60
|
+
$WEBSITE_DOMAIN = $BASE_DOMAIN
|
61
|
+
|
62
|
+
$SMARTURL_DOMAIN = 'fanforce.io'
|
63
|
+
$FF_PLUGIN_DOMAIN = 'ffplugin.io'
|
64
|
+
$FF_APP_DOMAIN = 'ffapp.io'
|
65
|
+
$FF_WIDGET_DOMAIN = 'ffwidget.io'
|
66
|
+
|
67
|
+
$DEVS_DOMAIN = 'technical%40mobilizationlabs.com:zE27fdevelopers@developers-fanforce.dotcloud.com'
|
68
|
+
|
69
|
+
$PUSHER_APP_ID = '14778'
|
70
|
+
$PUSHER_KEY = 'b5e2e23fb9542798ef38'
|
71
|
+
$PUSHER_SECRET = '7bfba2003df078ca64e9'
|
72
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fanforce::Factory::Run
|
2
|
+
require 'pty'
|
3
|
+
|
4
|
+
def self.bundle_install(dir)
|
5
|
+
Dir.chdir(dir) do
|
6
|
+
command('gem install bundler') if Gem::Specification::find_all_by_name('bundler').empty?
|
7
|
+
command('bundle install')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.pow_create(addon, root_domain)
|
12
|
+
domain = "#{addon._id}.#{root_domain}"
|
13
|
+
|
14
|
+
symbolic_link = "#{ENV['HOME']}/.pow/#{domain.gsub('.gg','')}"
|
15
|
+
File.delete(symbolic_link) if File.exists?(symbolic_link)
|
16
|
+
`ln -s #{addon.dir} #{symbolic_link}`
|
17
|
+
puts "#{'Connected'.format(:bold,:green)} #{domain} to #{addon.dir}/"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.pow_destroy(addon, root_domain)
|
21
|
+
domain = "#{addon._id}.#{root_domain}"
|
22
|
+
symbolic_link = "#{ENV['HOME']}/.pow/#{domain.gsub('.gg','')}"
|
23
|
+
if File.exists?(symbolic_link)
|
24
|
+
File.delete(symbolic_link)
|
25
|
+
puts "#{'Removed'.format(:bold,:green)} #{domain}"
|
26
|
+
else
|
27
|
+
puts "#{'Already Removed'.format(:bold,:green)} #{domain} to #{addon.dir}/"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.git_init
|
32
|
+
`git init`
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.git_add
|
36
|
+
`git add .`
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.git_first_commit
|
40
|
+
`git commit -m "initial factory commit"`
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.command(command, print_now=true)
|
44
|
+
output = []
|
45
|
+
PTY.spawn(command) do |stdin, stdout, pid|
|
46
|
+
stdin.each { |line| output << line; print line if print_now }
|
47
|
+
end
|
48
|
+
output.join("\n")
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fanforce::Factory::Utils
|
2
|
+
extend Fanforce::Factory::Utils
|
3
|
+
|
4
|
+
def format(text, *args)
|
5
|
+
effect = args.include?(:bold) ? 1 : 0
|
6
|
+
color = if args.include?(:red) then 31
|
7
|
+
elsif args.include?(:green) then 32
|
8
|
+
elsif args.include?(:magenta) then 35
|
9
|
+
else 39 end
|
10
|
+
"\033[#{effect};#{color}m#{text}\033[0m"
|
11
|
+
end
|
12
|
+
|
13
|
+
def format_config(hash)
|
14
|
+
hash.values.select{|v| v.is_a? Hash}.each{|h| format_config(h)}
|
15
|
+
hash.symbolize_keys!
|
16
|
+
end
|
17
|
+
|
18
|
+
def unknown
|
19
|
+
puts '---------------------------------------------------------------------------------------------------------------'
|
20
|
+
puts 'OOPS'.format(:bold,:red) + '... unknown command'.format(:red)
|
21
|
+
puts Fanforce::Factory::Help.commands(@allowed_commands)
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
|
25
|
+
def error(msg, command=nil)
|
26
|
+
puts '---------------------------------------------------------------------------------------------------------------'
|
27
|
+
puts 'ERROR... '.format(:bold,:red) + msg
|
28
|
+
puts '---------------------------------------------------------------------------------------------------------------'
|
29
|
+
puts ''
|
30
|
+
if command.present?
|
31
|
+
puts Fanforce::Factory::Help.for(command, @allowed_commands)
|
32
|
+
else
|
33
|
+
puts Fanforce::Factory::Help.commands(@allowed_commands)
|
34
|
+
end
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def confirm(msg)
|
39
|
+
puts '---------------------------------------------------------------------------------------------------------------'
|
40
|
+
print "#{msg} [y/n]: "
|
41
|
+
input = $stdin.gets.strip
|
42
|
+
exit 0 if input.downcase == 'n'
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class String
|
48
|
+
def format(*args)
|
49
|
+
Fanforce::Factory::Utils.format(self, *args)
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fanforce-factory
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Caleb Clark
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: iron_worker_ng
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: heroku-api
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.8
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.3.8
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: multi_json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bitbucket_rest_api
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: CLI for managing a folder of Fanforce addons
|
98
|
+
email:
|
99
|
+
- cclark@mobilizationlabs.com
|
100
|
+
executables:
|
101
|
+
- factory
|
102
|
+
- factory-supercharge
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- .gitignore
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/factory
|
112
|
+
- bin/factory-supercharge
|
113
|
+
- fanforce-factory.gemspec
|
114
|
+
- lib/fanforce/factory.rb
|
115
|
+
- lib/fanforce/factory/_base.rb
|
116
|
+
- lib/fanforce/factory/addons.rb
|
117
|
+
- lib/fanforce/factory/commands.rb
|
118
|
+
- lib/fanforce/factory/commands_support.rb
|
119
|
+
- lib/fanforce/factory/developer_config.rb
|
120
|
+
- lib/fanforce/factory/env.rb
|
121
|
+
- lib/fanforce/factory/files.rb
|
122
|
+
- lib/fanforce/factory/help.rb
|
123
|
+
- lib/fanforce/factory/initializers/ff_globals.rb
|
124
|
+
- lib/fanforce/factory/run.rb
|
125
|
+
- lib/fanforce/factory/utils.rb
|
126
|
+
- lib/fanforce/factory/version.rb
|
127
|
+
- lib/fanforce_factory.rb
|
128
|
+
homepage: ''
|
129
|
+
licenses: []
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.0.3
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Manage a folder of Fanforce addons
|
151
|
+
test_files: []
|