magentify 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/magentify +84 -0
- data/lib/mage.rb +112 -0
- data/lib/magentify.rb +5 -0
- data/lib/magentify/version.rb +3 -0
- data/magentify.gemspec +20 -0
- metadata +68 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Alistair Stead
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Magentify
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'magentify'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install magentify
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/magentify
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: #{File.basename($0)} [path]"
|
8
|
+
|
9
|
+
opts.on("-h", "--help", "Displays this help info") do
|
10
|
+
puts opts
|
11
|
+
exit 0
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
opts.parse!(ARGV)
|
16
|
+
rescue OptionParser::ParseError => e
|
17
|
+
warn e.message
|
18
|
+
puts opts
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
if ARGV.empty?
|
24
|
+
abort "Please specify the directory to capifony, e.g. `#{File.basename($0)} .'"
|
25
|
+
elsif !File.exists?(ARGV.first)
|
26
|
+
abort "`#{ARGV.first}' does not exist."
|
27
|
+
elsif !File.directory?(ARGV.first)
|
28
|
+
abort "`#{ARGV.first}' is not a directory."
|
29
|
+
elsif ARGV.length > 1
|
30
|
+
abort "Too many arguments; please specify only the directory to magentify."
|
31
|
+
end
|
32
|
+
|
33
|
+
def unindent(string)
|
34
|
+
indentation = string[/\A\s*/]
|
35
|
+
string.strip.gsub(/^#{indentation}/, "")
|
36
|
+
end
|
37
|
+
|
38
|
+
base = ARGV.shift
|
39
|
+
|
40
|
+
files = {
|
41
|
+
"Capfile" => unindent(<<-FILE),
|
42
|
+
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
|
43
|
+
Dir['plugins/*/lib/recipes/*.rb'].each { |plugin| load(plugin) }
|
44
|
+
load Gem.find_files('mage.rb').last.to_s
|
45
|
+
load 'config/deploy'
|
46
|
+
FILE
|
47
|
+
|
48
|
+
"config/deploy.rb" => 'set :application, "set your application name here"
|
49
|
+
set :domain, "#{application}.com"
|
50
|
+
set :deploy_to, "/var/www/#{domain}"
|
51
|
+
|
52
|
+
set :repository, "#{domain}:/var/repos/#{application}.git"
|
53
|
+
set :scm, :git
|
54
|
+
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, `subversion` or `none`
|
55
|
+
|
56
|
+
role :web, domain # Your HTTP server, Apache/etc
|
57
|
+
role :app, domain # This may be the same as your `Web` server
|
58
|
+
role :db, domain, :primary => true # This is where Rails migrations will run
|
59
|
+
|
60
|
+
set :keep_releases, 3
|
61
|
+
|
62
|
+
set :app_symlinks, ["/media", "/var", "/sitemaps", "/staging"]
|
63
|
+
set :app_shared_dirs, ["/app/etc", "/sitemaps", "/media", "/var", "/staging"]
|
64
|
+
set :app_shared_files, ["/app/etc/local.xml"]'
|
65
|
+
|
66
|
+
}
|
67
|
+
|
68
|
+
files.each do |file, content|
|
69
|
+
file = File.join(base, file)
|
70
|
+
if File.exists?(file)
|
71
|
+
warn "[skip] '#{file}' already exists"
|
72
|
+
elsif File.exists?(file.downcase)
|
73
|
+
warn "[skip] '#{file.downcase}' exists, which could conflict with `#{file}'"
|
74
|
+
else
|
75
|
+
unless File.exists?(File.dirname(file))
|
76
|
+
puts "[add] making directory '#{File.dirname(file)}'"
|
77
|
+
FileUtils.mkdir(File.dirname(file))
|
78
|
+
end
|
79
|
+
puts "[add] writing '#{file}'"
|
80
|
+
File.open(file, "w") { |f| f.write(content) }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
puts "[done] Magento project capified with magentify!"
|
data/lib/mage.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
set :app_symlinks, ["/media", "/var", "/sitemaps", "/staging"]
|
2
|
+
set :app_shared_dirs, ["/app/etc", "/sitemaps", "/media", "/var", "/staging"]
|
3
|
+
set :app_shared_files, ["/app/etc/local.xml"]
|
4
|
+
|
5
|
+
namespace :mage do
|
6
|
+
desc <<-DESC
|
7
|
+
Prepares one or more servers for deployment of Magento. Before you can use any \
|
8
|
+
of the Capistrano deployment tasks with your project, you will need to \
|
9
|
+
make sure all of your servers have been prepared with `cap deploy:setup'. When \
|
10
|
+
you add a new server to your cluster, you can easily run the setup task \
|
11
|
+
on just that server by specifying the HOSTS environment variable:
|
12
|
+
|
13
|
+
$ cap HOSTS=new.server.com mage:setup
|
14
|
+
|
15
|
+
It is safe to run this task on servers that have already been set up; it \
|
16
|
+
will not destroy any deployed revisions or data.
|
17
|
+
DESC
|
18
|
+
task :setup, :roles => :web, :except => { :no_release => true } do
|
19
|
+
if app_shared_dirs
|
20
|
+
app_shared_dirs.each { |link| run "#{try_sudo} mkdir -p #{shared_path}#{link} && chmod 777 #{shared_path}#{link}"}
|
21
|
+
end
|
22
|
+
if app_shared_files
|
23
|
+
app_shared_files.each { |link| run "#{try_sudo} touch #{shared_path}#{link} && chmod 777 #{shared_path}#{link}" }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc <<-DESC
|
28
|
+
Touches up the released code. This is called by update_code \
|
29
|
+
after the basic deploy finishes.
|
30
|
+
|
31
|
+
Any directories deployed from the SCM are first removed and then replaced with \
|
32
|
+
symlinks to the same directories within the shared location.
|
33
|
+
DESC
|
34
|
+
task :finalize_update, :roles => :web, :except => { :no_release => true } do
|
35
|
+
run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
|
36
|
+
|
37
|
+
if app_symlinks
|
38
|
+
# Remove the contents of the shared directories if they were deployed from SCM
|
39
|
+
app_symlinks.each { |link| run "#{try_sudo} rm -rf #{latest_release}#{link}" }
|
40
|
+
# Add symlinks the directoris in the shared location
|
41
|
+
app_symlinks.each { |link| run "ln -nfs #{shared_path}#{link} #{latest_release}#{link}" }
|
42
|
+
end
|
43
|
+
|
44
|
+
if app_shared_files
|
45
|
+
# Remove the contents of the shared directories if they were deployed from SCM
|
46
|
+
app_shared_files.each { |link| run "#{try_sudo} rm -rf #{latest_release}/#{link}" }
|
47
|
+
# Add symlinks the directoris in the shared location
|
48
|
+
app_shared_files.each { |link| run "ln -s #{shared_path}#{link} #{latest_release}#{link}" }
|
49
|
+
end
|
50
|
+
# TODO should add configoration for this happening post deployment.
|
51
|
+
compiler
|
52
|
+
end
|
53
|
+
|
54
|
+
desc <<-DESC
|
55
|
+
Clear the Magento Cache
|
56
|
+
DESC
|
57
|
+
task :cc, :roles => :web do
|
58
|
+
run "cd #{current_path} && rm -rf var/cache/*"
|
59
|
+
end
|
60
|
+
|
61
|
+
desc <<-DESC
|
62
|
+
Disable the Magento install by creating the maintenance.flag in the web root.
|
63
|
+
DESC
|
64
|
+
task :disable, :roles => :web do
|
65
|
+
run "cd #{current_path} && touch maintenance.flag"
|
66
|
+
end
|
67
|
+
|
68
|
+
desc <<-DESC
|
69
|
+
Enable the Magento stores by removing the maintenance.flag in the web root.
|
70
|
+
DESC
|
71
|
+
task :enable, :roles => :web do
|
72
|
+
run "cd #{current_path} && rm -f maintenance.flag"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc <<-DESC
|
76
|
+
Run the Magento compiler
|
77
|
+
DESC
|
78
|
+
task :compiler, :roles => :web do
|
79
|
+
run "cd #{current_path}/shell && php -f compiler.php -- compile"
|
80
|
+
end
|
81
|
+
|
82
|
+
desc <<-DESC
|
83
|
+
Enable the Magento compiler
|
84
|
+
DESC
|
85
|
+
task :enable_compiler, :roles => :web do
|
86
|
+
run "cd #{current_path}/shell && php -f compiler.php -- enable"
|
87
|
+
end
|
88
|
+
|
89
|
+
desc <<-DESC
|
90
|
+
Disable the Magento compiler
|
91
|
+
DESC
|
92
|
+
task :disable_compiler, :roles => :web do
|
93
|
+
run "cd #{current_path}/shell && php -f compiler.php -- disable"
|
94
|
+
end
|
95
|
+
|
96
|
+
desc <<-DESC
|
97
|
+
Run the Magento indexer
|
98
|
+
DESC
|
99
|
+
task :indexer, :roles => :app do
|
100
|
+
run "cd #{current_path}/shell && php -f indexer.php -- reindexall"
|
101
|
+
end
|
102
|
+
|
103
|
+
desc <<-DESC
|
104
|
+
Clean the Magento logs
|
105
|
+
DESC
|
106
|
+
task :clean_logs, :roles => :web do
|
107
|
+
run "cd #{current_path}/shell && php -f log.php -- clean"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
after 'deploy:setup', 'mage:setup'
|
112
|
+
after 'deploy:finalize_update', 'mage:finalize_update'
|
data/lib/magentify.rb
ADDED
data/magentify.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/magentify/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Alistair Stead"]
|
6
|
+
gem.email = ["alistair.stead@designdisclosure.com"]
|
7
|
+
gem.description = %q{An extension to Capistrano to deploy Magento. Adding the specific requirements and additional tasks.}
|
8
|
+
gem.summary = %q{Deploying Magento PHP applications with Capistrano.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "magentify"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Magentify::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'capistrano', ">= 2.5.10"
|
19
|
+
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magentify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alistair Stead
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: &70328495790360 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.5.10
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70328495790360
|
25
|
+
description: An extension to Capistrano to deploy Magento. Adding the specific requirements
|
26
|
+
and additional tasks.
|
27
|
+
email:
|
28
|
+
- alistair.stead@designdisclosure.com
|
29
|
+
executables:
|
30
|
+
- magentify
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- bin/magentify
|
40
|
+
- lib/mage.rb
|
41
|
+
- lib/magentify.rb
|
42
|
+
- lib/magentify/version.rb
|
43
|
+
- magentify.gemspec
|
44
|
+
homepage: ''
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.15
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Deploying Magento PHP applications with Capistrano.
|
68
|
+
test_files: []
|