capimeria 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/bin/capimeria ADDED
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'fileutils'
5
+
6
+ multistage = true
7
+ stages = ["dev", "prod"]
8
+
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: #{File.basename($0)} [path]"
11
+
12
+ opts.on("-h", "--help", "Displays this help info") do
13
+ puts opts
14
+ exit 0
15
+ end
16
+
17
+ opts.on("-n", "--no-multistage", "Disabling multistages") do
18
+ multistage = false
19
+ stages = []
20
+ end
21
+
22
+ opts.on("-s", "--stages RAW_STAGES", "Specify stages you would like to create --stages dev,prod (first stage is default one)") do |raw_stages|
23
+ stages = raw_stages.to_s.split(/,/)
24
+ end
25
+
26
+ begin
27
+ opts.parse!(ARGV)
28
+ rescue OptionParser::ParseError => e
29
+ warn e.message
30
+ puts opts
31
+ exit 1
32
+ end
33
+ end
34
+
35
+ if ARGV.empty?
36
+ abort "Please specify the directory, e.g. `#{File.basename($0)} .'"
37
+ elsif !File.exists?(ARGV.first)
38
+ abort "`#{ARGV.first}' does not exist."
39
+ elsif !File.directory?(ARGV.first)
40
+ abort "`#{ARGV.first}' is not a directory."
41
+ elsif ARGV.length > 1
42
+ abort "Too many arguments; please specify only one directory."
43
+ end
44
+
45
+ def unindent(string)
46
+ indentation = string[/\A\s*/]
47
+ string.strip.gsub(/^#{indentation}/, "")
48
+ end
49
+
50
+ base = ARGV.shift
51
+ is_magento = File.exists? File.join(base,'app/Mage.php')
52
+
53
+ files = {}
54
+
55
+ head = unindent(<<-FILE)
56
+ set :application, "application"
57
+ set :domain, "hatimeria.com"
58
+ set :deploy_to, "/home/www/\#{application}"
59
+ set :user, "deployment"
60
+ set :use_sudo, false
61
+
62
+ ssh_options[:forward_agent] = true
63
+
64
+ set :repository, "git@github.com:hatimeria/\#{application}.git"
65
+ set :scm, :git
66
+ # Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, `subversion` or `none`
67
+ set :deploy_via, :remote_cache
68
+ set :copy_exclude, [".git"]
69
+
70
+ role :web, domain # Your HTTP server, Apache/etc
71
+ role :app, domain # This may be the same as your `Web` server
72
+ role :db, domain, :primary => true # This is where Rails migrations will run
73
+
74
+ set :keep_releases, 3
75
+ FILE
76
+
77
+ if is_magento
78
+ config_path = 'app/etc'
79
+
80
+ files["Capfile"] = unindent(<<-FILE)
81
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
82
+ load Gem.find_files('magento.rb').last.to_s
83
+ load Gem.find_files('capimeria_magento.rb').last.to_s
84
+ load '#{config_path}/deploy'
85
+ FILE
86
+
87
+ files["#{config_path}/deploy.rb"] = ''
88
+ else
89
+ symfony_version = nil
90
+ symfony_version = symfony_version || ((File.directory? File.join(base, 'config')) ? 1 : 2)
91
+ symfony_app_path = 'app'
92
+
93
+ if symfony_version == 2
94
+ config_path = "#{symfony_app_path}/config"
95
+
96
+ files["Capfile"] = unindent(<<-FILE)
97
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
98
+ Dir['vendor/bundles/*/*/recipes/*.rb'].each { |bundle| load(bundle) }
99
+ load Gem.find_files('symfony2.rb').last.to_s
100
+ load Gem.find_files('capimeria_symfony2.rb').last.to_s
101
+ load '#{symfony_app_path}/config/deploy'
102
+ FILE
103
+
104
+ files["#{config_path}/deploy.rb"] = unindent(<<-FILE)
105
+ set :app_path, "#{symfony_app_path}"
106
+ set :model_manager, "doctrine"
107
+ FILE
108
+ else
109
+ config_path = "config"
110
+
111
+ files["Capfile"] = unindent(<<-FILE)
112
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
113
+ Dir['plugins/*/lib/recipes/*.rb'].each { |plugin| load(plugin) }
114
+ load Gem.find_files('symfony1.rb').last.to_s
115
+ load Gem.find_files('capimeria_symfony1.rb').last.to_s
116
+ load 'config/deploy'
117
+ FILE
118
+
119
+ files["#{config_path}/deploy.rb"] = ''
120
+ end
121
+ end
122
+ if multistage
123
+ stages.each do |stage|
124
+ files["#{config_path}/deploy/#{stage}.rb"] = unindent(<<-FILE)
125
+ set :deploy_to, "/home/www/\#{application}/#{stage}"
126
+ FILE
127
+ end
128
+ multi = unindent(<<-FILE)
129
+ set :stages, %w(#{stages.join(' ')})
130
+ set :default_stage, "#{stages.first}"
131
+ set :stage_dir, "#{config_path}/deploy"
132
+
133
+ require 'capistrano/ext/multistage'
134
+
135
+ FILE
136
+ else
137
+ multi = ''
138
+ end
139
+ files["#{config_path}/deploy.rb"] = multi + "\n\n" + head + "\n\n" + files["#{config_path}/deploy.rb"]
140
+
141
+ files.each do |file, content|
142
+ file = File.join(base, file)
143
+ if File.exists?(file)
144
+ warn "[skip] '#{file}' already exists"
145
+ elsif File.exists?(file.downcase)
146
+ warn "[skip] '#{file.downcase}' exists, which could conflict with `#{file}'"
147
+ else
148
+ unless File.exists?(File.dirname(file))
149
+ puts "[add] making directory '#{File.dirname(file)}'"
150
+ FileUtils.mkdir(File.dirname(file))
151
+ end
152
+ puts "[add] writing '#{file}'"
153
+ File.open(file, "w") { |f| f.write(content) }
154
+ end
155
+ end
156
+
157
+ puts "[done] Project was capimariand!"
data/lib/capimeria.rb ADDED
File without changes
@@ -0,0 +1,24 @@
1
+ load Gem.find_files('capimeria.rb').last.to_s
2
+
3
+ set :shared_files, ["app/etc/local.xml", "index.php", ".htaccess"]
4
+
5
+ namespace :loc do
6
+ desc "Local clear cache"
7
+ task :cc do
8
+ clear_cache
9
+ clear_media_cache
10
+ end
11
+ desc "Local main cache clear"
12
+ task :clear_cache do
13
+ run_locally "if [ -d ./var/cache ] ; then rm -rf ./var/cache/*; fi"
14
+ end
15
+ desc "Local media cache clear"
16
+ task :clear_media_cache do
17
+ run_locally "if [ -d ./media/css ] ; then rm -rf ./media/css/*; fi"
18
+ run_locally "if [ -d ./media/js ] ; then rm -rf ./media/js/*; fi"
19
+ end
20
+ desc "Local session clear"
21
+ task :clear_session do
22
+ run_locally "if [ -d ./var/session ] ; then rm -rf ./var/session/*; fi"
23
+ end
24
+ end
@@ -0,0 +1 @@
1
+ load Gem.find_files('capimeria.rb').last.to_s
@@ -0,0 +1,40 @@
1
+ load Gem.find_files('capimeria.rb').last.to_s
2
+
3
+ # overwritting capistratno and capifony deployment procedures
4
+ namespace :deploy do
5
+ namespace :web do
6
+ desc "Disabling web directory"
7
+ task :disable, :roles => :web do
8
+ on_rollback { rm "#{shared_path}/web/system/maintenance.html" }
9
+
10
+ maintenance_file = "./app/Resources/maintenance.html"
11
+ if File.exists?(maintenance_file)
12
+ maintenance = File.read("./app/Resources/maintenance.html")
13
+ else
14
+ maintenance = 'Przerwa techniczna'
15
+ end
16
+
17
+ put maintenance, "#{shared_path}/web/system/maintenance.html", :mode => 0644
18
+ end
19
+ desc "Enabling web directory"
20
+ task :enable, :roles => :web, :except => { :no_release => true } do
21
+ run "rm #{shared_path}/web/system/#{maintenance_basename}.html"
22
+ end
23
+ end
24
+ end
25
+
26
+ namespace :symfony do
27
+ # remove after nice user will deploy application not f-in root!!
28
+ namespace :cache do
29
+ desc "Clears project cache."
30
+ task :clear do
31
+ run "cd #{latest_release} && #{php_bin} #{symfony_console} cache:clear --env=#{symfony_env_prod}"
32
+ run "chmod -R 777 #{latest_release}/#{cache_path}"
33
+ end
34
+ desc "Warms up an empty cache."
35
+ task :warmup do
36
+ run "cd #{latest_release} && #{php_bin} #{symfony_console} cache:warmup --env=#{symfony_env_prod}"
37
+ run "chmod -R 777 #{latest_release}/#{cache_path}"
38
+ end
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capimeria
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 7
9
+ version: 0.1.7
10
+ platform: ruby
11
+ authors:
12
+ - Witold Janusik
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-11-03 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: capistrano
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 9
31
+ - 0
32
+ version: 2.9.0
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: capistrano-ext
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 2
46
+ - 1
47
+ version: 1.2.1
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: capifony
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 2
60
+ - 1
61
+ - 3
62
+ version: 2.1.3
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: capigento
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ - 1
76
+ - 3
77
+ version: 0.1.3
78
+ type: :runtime
79
+ version_requirements: *id004
80
+ description: " Hatimeria capistrano deployment.\n"
81
+ email: me@freakphp.com
82
+ executables:
83
+ - capimeria
84
+ extensions: []
85
+
86
+ extra_rdoc_files: []
87
+
88
+ files:
89
+ - bin/capimeria
90
+ - lib/capimeria.rb
91
+ - lib/capimeria_magento.rb
92
+ - lib/capimeria_symfony1.rb
93
+ - lib/capimeria_symfony2.rb
94
+ has_rdoc: true
95
+ homepage: http://hatimeria.com
96
+ licenses: []
97
+
98
+ post_install_message:
99
+ rdoc_options: []
100
+
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ requirements: []
120
+
121
+ rubyforge_project:
122
+ rubygems_version: 1.3.7
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: Hatimeria capistrano deployment.
126
+ test_files: []
127
+