magentify 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,29 +1,58 @@
1
1
  # Magentify
2
2
 
3
- TODO: Write a gem description
3
+ [Capistrano](http://capify.org) is an open source tool for executing commands on multiple servers in parallel. It is intended to be used to easily deploying applications. While it was built specifically for deploying Rails apps, it is designed to be easily extended to deploy any type of application or run any number of commands. This project is a deployment recipes collection that works specifically with [Magento](http://www.magentocommerce.com/).
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ $ gem install magentify
8
+
9
+ ## Project setup
8
10
 
9
- gem 'magentify'
11
+ $ magentify .
10
12
 
11
- And then execute:
13
+ ## Usage
12
14
 
13
- $ bundle
15
+ Once you have run `magentify` on your project it will add a Capfile and deploy.rb configuration file
14
16
 
15
- Or install it yourself as:
17
+ ``` ruby config/deploy.rb
18
+ set :application, "magento"
19
+ set :domain, "#{application}.com"
20
+ set :deploy_to, "/var/www/#{domain}"
16
21
 
17
- $ gem install magentify
22
+ set :user, "deploy"
23
+ set :repository, "git@github.com:user/project.git"
24
+ set :scm, :git
18
25
 
19
- ## Usage
26
+ role :web, "000.000.000.000" # Your HTTP server, Apache/etc
27
+ role :app, "000.000.000.000" # This may be the same as your `Web` server or a separate administration server
28
+
29
+ set :keep_releases, 3
30
+
31
+ set :app_symlinks, ["/media", "/var", "/sitemaps", "/staging"]
32
+ set :app_shared_dirs, ["/app/etc", "/sitemaps", "/media", "/var", "/staging"]
33
+ set :app_shared_files, ["/app/etc/local.xml"]
34
+ ```
35
+
36
+ Once you have magentified your project you can run:
37
+
38
+ $ cap -T
39
+
40
+ This will list all the available tasks that can be run with a shot description. For more detailed information about each of the tests run:
41
+
42
+ $ cap -e [task_name]
43
+
44
+ For detailed information about how to configure and use Capistrano for deployment you should read the Capistrano wiki pages:
20
45
 
21
- TODO: Write usage instructions here
46
+ * [Getting Started](https://github.com/capistrano/capistrano/wiki/2.x-Getting-Started)
47
+ * [From the beginning](https://github.com/capistrano/capistrano/wiki/2.x-From-The-Beginning)
22
48
 
23
49
  ## Contributing
24
50
 
25
51
  1. Fork it
26
52
  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
53
+ 3. Create a cucumber scenario to describe your feature
54
+ 4. Add the steps to test the functionality
55
+ 5. Add your Feature or Fix to satisfy the tests.
56
+ 6. Commit your changes (`git commit -am 'Added some feature'`)
57
+ 7. Push to the branch (`git push origin my-new-feature`)
58
+ 8. Create new Pull Request
data/bin/magentify CHANGED
@@ -53,9 +53,8 @@ set :repository, "#{domain}:/var/repos/#{application}.git"
53
53
  set :scm, :git
54
54
  # Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, `subversion` or `none`
55
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
56
+ role :web, domain # Your HTTP server, Apache/etc
57
+ role :app, domain # This may be the same as your `Web` server or a separate administration server
59
58
 
60
59
  set :keep_releases, 3
61
60
 
data/cucumber.yml ADDED
@@ -0,0 +1,3 @@
1
+ default: features
2
+ autotest: --color
3
+ autotest-all: --color
@@ -0,0 +1,24 @@
1
+ Feature: Compiler
2
+ In order to make Magento fast
3
+ As a developer
4
+ I want the compiler to be run during finalize_deploy
5
+
6
+ Scenario: User runs $ cap deploy with compile true
7
+ Given an app
8
+ When I execute deploy with --set compile=true
9
+ Then the Magento compiler should be executed
10
+
11
+ Scenario: User runs $ cap deploy with compile false
12
+ Given an app
13
+ When I execute deploy with --set compile=false
14
+ Then the Magento compiler should not be executed
15
+
16
+ Scenario: User enables compiler
17
+ Given an app
18
+ When I execute mage:enable_compiler
19
+ Then the Magento compiler should be executed with enable option
20
+
21
+ Scenario: User disables compiler
22
+ Given an app
23
+ When I execute mage:disable_compiler
24
+ Then the Magento compiler should be executed with disable option
@@ -11,4 +11,16 @@ Feature: Deployment
11
11
  Scenario: User runs $ cap deploy with missing config
12
12
  Given an app
13
13
  When I have deploy.rb with missing config
14
- Then [error] should be returned
14
+ Then [error] should be returned
15
+
16
+ Scenario: User runs $ cap mage:disable
17
+ Given an app
18
+ When I execute deploy
19
+ And I execute mage:disable
20
+ Then the maintenance.flag file should be written to current
21
+
22
+ Scenario: User runs $ cap mage:enable
23
+ Given an app
24
+ When I execute deploy
25
+ And I execute mage:enable
26
+ Then the maintenance.flag file should be removed from current
@@ -0,0 +1,9 @@
1
+ Feature: Indexer
2
+ In order to make Magento fast
3
+ As a developer
4
+ I want the indexer to run to fill flat tables
5
+
6
+ Scenario: User runs $ mage:indexer
7
+ Given an app
8
+ When I execute mage:indexer
9
+ Then the Magento indexer should be executed
@@ -0,0 +1,9 @@
1
+ Feature: Log
2
+ In order to free disk space
3
+ As a developer
4
+ I want the log script to clear logs
5
+
6
+ Scenario: User runs $ mage:clean_log
7
+ Given an app
8
+ When I execute mage:clean_log
9
+ Then the Magento log should be executed
@@ -6,11 +6,15 @@ Given /^an app$/ do
6
6
  end
7
7
 
8
8
  # Create and capify the dummy app, and push it to the local repo
9
- FileUtils.mkdir_p @app_dir
10
- Dir.chdir(@app_dir) do
9
+ FileUtils.mkdir_p @src_dir
10
+ Dir.chdir(@src_dir) do
11
11
  [
12
12
  %Q{git init > /dev/null 2>&1} ,
13
- %Q{mkdir config > /dev/null 2>&1},
13
+ %Q{mkdir -p app/etc media var shell staging sitemaps > /dev/null 2>&1},
14
+ %Q{touch shell/compiler.php > /dev/null 2>&1},
15
+ %Q{touch shell/index.php > /dev/null 2>&1},
16
+ %Q{touch shell/log.php > /dev/null 2>&1},
17
+ %Q{touch app/etc/local.xml > /dev/null 2>&1},
14
18
  %Q{magentify . > /dev/null 2>&1},
15
19
  %Q{git add . > /dev/null 2>&1},
16
20
  %Q{git commit -m "first commit" > /dev/null 2>&1},
@@ -32,7 +36,7 @@ Given /^an app$/ do
32
36
  template_path = File.expand_path(File.join(__FILE__, "..", "..", "templates", "deploy.erb"))
33
37
  compiled_template = ERB.new(File.read(template_path)).result(binding)
34
38
 
35
- File.open(File.join(@app_dir, "config", "deploy.rb"), 'w') {|f|
39
+ File.open(File.join(@src_dir, "config", "deploy.rb"), 'w') {|f|
36
40
  f.write compiled_template
37
41
  }
38
42
  end
@@ -0,0 +1,39 @@
1
+ When /^I execute deploy with \-\-set compile=true$/ do
2
+ Dir.chdir(@src_dir) do
3
+ @out = %x[cap deploy --set compile=true 2>&1]
4
+ end
5
+ end
6
+
7
+ Then /^the Magento compiler should be executed$/ do
8
+ @out.match('php -f compiler.php -- compile').should be_true
9
+ end
10
+
11
+ When /^I execute deploy with \-\-set compile=false$/ do
12
+ Dir.chdir(@src_dir) do
13
+ @out = %x[cap deploy --set compile=false 2>&1]
14
+ end
15
+ end
16
+
17
+ Then /^the Magento compiler should not be executed$/ do
18
+ @out.match('php -f compiler.php -- compile').should be_false
19
+ end
20
+
21
+ When /^I execute mage:enable_compiler$/ do
22
+ Dir.chdir(@src_dir) do
23
+ @out = %x[cap mage:enable_compiler 2>&1]
24
+ end
25
+ end
26
+
27
+ Then /^the Magento compiler should be executed with enable option$/ do
28
+ @out.match('php -f compiler.php -- enable').should be_true
29
+ end
30
+
31
+ When /^I execute mage:disable_compiler$/ do
32
+ Dir.chdir(@src_dir) do
33
+ @out = %x[cap mage:disable_compiler 2>&1]
34
+ end
35
+ end
36
+
37
+ Then /^the Magento compiler should be executed with disable option$/ do
38
+ @out.match('php -f compiler.php -- disable').should be_true
39
+ end
@@ -1,5 +1,5 @@
1
1
  When /^I execute deploy$/ do
2
- Dir.chdir(@app_dir) do
2
+ Dir.chdir(@src_dir) do
3
3
  system "cap deploy:setup > /dev/null 2>&1"
4
4
  system "cap deploy > /dev/null 2>&1"
5
5
  end
@@ -21,14 +21,34 @@ When /^I have deploy\.rb with missing config$/ do
21
21
  template_path = File.expand_path(File.join(__FILE__, "..", "..", "templates", "deploy-fail.erb"))
22
22
  compiled_template = ERB.new(File.read(template_path)).result(binding)
23
23
 
24
- File.open(File.join(@app_dir, "config", "deploy.rb"), 'w') {|f|
24
+ File.open(File.join(@src_dir, "config", "deploy.rb"), 'w') {|f|
25
25
  f.write compiled_template
26
26
  }
27
+ Dir.chdir(@src_dir) do
28
+ @out = %x[cap deploy 2>&1]
29
+ end
27
30
  end
28
31
 
29
32
  Then /^\[error\] should be returned$/ do
30
- Dir.chdir(@app_dir) do
31
- result = %x[cap -T]
32
- result.match('error').should be_true
33
+ @out.match('Please').should be_true
34
+ end
35
+
36
+ When /^I execute mage:disable$/ do
37
+ Dir.chdir(@src_dir) do
38
+ @out = %x[cap mage:disable 2>&1]
39
+ end
40
+ end
41
+
42
+ Then /^the maintenance\.flag file should be written to current$/ do
43
+ File.exists?(File.join(@test_files_dir, "deployed", "current", "maintenance.flag")).should be_true
44
+ end
45
+
46
+ When /^I execute mage:enable$/ do
47
+ Dir.chdir(@src_dir) do
48
+ @out = %x[cap mage:enable 2>&1]
33
49
  end
50
+ end
51
+
52
+ Then /^the maintenance\.flag file should be removed from current$/ do
53
+ File.exists?(File.join(@test_files_dir, "deployed", "current", "maintenance.flag")).should be_false
34
54
  end
@@ -0,0 +1,9 @@
1
+ When /^I execute mage:indexer$/ do
2
+ Dir.chdir(@src_dir) do
3
+ @out = %x[cap mage:indexer 2>&1]
4
+ end
5
+ end
6
+
7
+ Then /^the Magento indexer should be executed$/ do
8
+ @out.match('php -f indexer.php -- reindexall').should be_true
9
+ end
@@ -0,0 +1,9 @@
1
+ When /^I execute mage:clean_log$/ do
2
+ Dir.chdir(@src_dir) do
3
+ @out = %x[cap mage:clean_log 2>&1]
4
+ end
5
+ end
6
+
7
+ Then /^the Magento log should be executed$/ do
8
+ @out.match('php -f log.php -- clean').should be_true
9
+ end
@@ -1,21 +1,21 @@
1
1
  When /^I execute magentify \.$/ do
2
- Dir.chdir(@app_dir) do
2
+ Dir.chdir(@src_dir) do
3
3
  system "magentify . > /dev/null 2>&1"
4
4
  end
5
5
  end
6
6
 
7
7
  Then /^Capfile should load mage\.rb$/ do
8
- File.open(File.join(@app_dir, "Capfile"), 'rb').read().match('mage\.rb').should be_true
8
+ File.open(File.join(@src_dir, "Capfile"), 'rb').read().match('mage\.rb').should be_true
9
9
  end
10
10
 
11
11
  When /^I execute cap \-T$/ do
12
- Dir.chdir(@app_dir) do
12
+ Dir.chdir(@src_dir) do
13
13
  system "cap -T > /dev/null 2>&1"
14
14
  end
15
15
  end
16
16
 
17
17
  Then /^mage tasks should be listed$/ do
18
- Dir.chdir(@app_dir) do
18
+ Dir.chdir(@src_dir) do
19
19
  result = %x[cap -T]
20
20
  result.match('Clear the Magento Cache').should be_true
21
21
  end
@@ -1,5 +1,5 @@
1
1
  When /^I execute deploy:setup$/ do
2
- Dir.chdir(@app_dir) do
2
+ Dir.chdir(@src_dir) do
3
3
  system "cap deploy:setup > /dev/null 2>&1"
4
4
  end
5
5
  end
@@ -4,9 +4,13 @@ require 'etc'
4
4
 
5
5
  Before do
6
6
  @test_files_dir = File.join(Dir.pwd, "_files")
7
- @app_dir = File.join(@test_files_dir, "app")
7
+ @src_dir = File.join(@test_files_dir, "src")
8
8
  @repo_dir = File.join(@test_files_dir, "repo")
9
9
 
10
10
  FileUtils.rm_r(@test_files_dir) if File.exists?(@test_files_dir)
11
11
  FileUtils.mkdir_p(@test_files_dir)
12
+ # Iinstall the latest version of the gem
13
+ system "gem uninstall magenify --version '>= 0' --executables --force > /dev/null 2>&1"
14
+ system "rake build > /dev/null 2>&1"
15
+ system "rake install > /dev/null 2>&1"
12
16
  end
@@ -10,7 +10,6 @@ set :scm_command, "<%= deploy_variables[:git_executable] %>"
10
10
 
11
11
  role :web, "localhost" # Your HTTP server, Apache/etc
12
12
  role :app, "localhost" # This may be the same as your `Web` server
13
- role :db, "localhost", :primary => true # This is where Rails migrations will run
14
13
 
15
14
  set :keep_releases, 3
16
15
 
@@ -10,7 +10,6 @@ set :scm_command, "<%= deploy_variables[:git_executable] %>"
10
10
 
11
11
  role :web, "localhost" # Your HTTP server, Apache/etc
12
12
  role :app, "localhost" # This may be the same as your `Web` server
13
- role :db, "localhost", :primary => true # This is where Rails migrations will run
14
13
 
15
14
  set :keep_releases, 3
16
15
 
data/lib/mage.rb CHANGED
@@ -4,12 +4,17 @@ load Gem.find_files('nonrails.rb').last.to_s
4
4
  # These variables MUST be set in the client capfiles. If they are not set,
5
5
  # the deploy will fail with an error.
6
6
  # =========================================================================
7
-
8
- _cset(:app_symlinks) {
9
- abort "[error] Please specify an array of symlinks to shared resources, set :app_symlinks, ['/media', .. '/staging']"
7
+ _cset(:app_symlinks) {
8
+ abort "Please specify an array of symlinks to shared resources, set :app_symlinks, ['/media', ./. '/staging']"
9
+ }
10
+ _cset(:app_shared_dirs) {
11
+ abort "Please specify an array of shared directories to be created, set :app_shared_dirs"
12
+ }
13
+ _cset(:app_shared_files) {
14
+ abort "Please specify an array of shared files to be symlinked, set :app_shared_files"
10
15
  }
11
- _cset(:app_shared_dirs) { abort "[error] Please specify, set :app_shared_dirs" }
12
- _cset(:app_shared_files) { abort "[error] Please specify, set :app_shared_files" }
16
+
17
+ _cset :compile, false
13
18
 
14
19
  namespace :mage do
15
20
  desc <<-DESC
@@ -24,7 +29,7 @@ namespace :mage do
24
29
  It is safe to run this task on servers that have already been set up; it \
25
30
  will not destroy any deployed revisions or data.
26
31
  DESC
27
- task :setup, :roles => :web, :except => { :no_release => true } do
32
+ task :setup, :roles => [:web, :app], :except => { :no_release => true } do
28
33
  if app_shared_dirs
29
34
  app_shared_dirs.each { |link| run "#{try_sudo} mkdir -p #{shared_path}#{link} && chmod g+w #{shared_path}#{link}"}
30
35
  end
@@ -40,7 +45,7 @@ namespace :mage do
40
45
  Any directories deployed from the SCM are first removed and then replaced with \
41
46
  symlinks to the same directories within the shared location.
42
47
  DESC
43
- task :finalize_update, :roles => :web, :except => { :no_release => true } do
48
+ task :finalize_update, :roles => [:web, :app], :except => { :no_release => true } do
44
49
  run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
45
50
 
46
51
  if app_symlinks
@@ -56,14 +61,12 @@ namespace :mage do
56
61
  # Add symlinks the directoris in the shared location
57
62
  app_shared_files.each { |link| run "ln -s #{shared_path}#{link} #{latest_release}#{link}" }
58
63
  end
59
- # TODO should add configoration for this happening post deployment.
60
- compiler
61
64
  end
62
65
 
63
66
  desc <<-DESC
64
67
  Clear the Magento Cache
65
68
  DESC
66
- task :cc, :roles => :web do
69
+ task :cc, :roles => [:web, :app] do
67
70
  run "cd #{current_path} && rm -rf var/cache/*"
68
71
  end
69
72
 
@@ -84,38 +87,41 @@ namespace :mage do
84
87
  desc <<-DESC
85
88
  Run the Magento compiler
86
89
  DESC
87
- task :compiler, :roles => :web do
88
- run "cd #{current_path}/shell && php -f compiler.php -- compile"
90
+ task :compiler, :roles => [:web, :app] do
91
+ if fetch(:compile, true)
92
+ run "cd #{current_path}/shell && php -f compiler.php -- compile"
93
+ end
89
94
  end
90
95
 
91
96
  desc <<-DESC
92
97
  Enable the Magento compiler
93
98
  DESC
94
- task :enable_compiler, :roles => :web do
99
+ task :enable_compiler, :roles => [:web, :app] do
95
100
  run "cd #{current_path}/shell && php -f compiler.php -- enable"
96
101
  end
97
102
 
98
103
  desc <<-DESC
99
104
  Disable the Magento compiler
100
105
  DESC
101
- task :disable_compiler, :roles => :web do
106
+ task :disable_compiler, :roles => [:web, :app] do
102
107
  run "cd #{current_path}/shell && php -f compiler.php -- disable"
103
108
  end
104
109
 
105
110
  desc <<-DESC
106
111
  Run the Magento indexer
107
112
  DESC
108
- task :indexer, :roles => :app do
113
+ task :indexer, :roles => [:web, :app] do
109
114
  run "cd #{current_path}/shell && php -f indexer.php -- reindexall"
110
115
  end
111
116
 
112
117
  desc <<-DESC
113
118
  Clean the Magento logs
114
119
  DESC
115
- task :clean_logs, :roles => :web do
120
+ task :clean_log, :roles => [:web, :app] do
116
121
  run "cd #{current_path}/shell && php -f log.php -- clean"
117
122
  end
118
123
  end
119
124
 
120
125
  after 'deploy:setup', 'mage:setup'
121
- after 'deploy:finalize_update', 'mage:finalize_update'
126
+ after 'deploy:finalize_update', 'mage:finalize_update'
127
+ after 'deploy:create_symlink', 'mage:compiler'
@@ -1,3 +1,3 @@
1
1
  module Magentify
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magentify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-08 00:00:00.000000000 Z
12
+ date: 2012-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: &70214939636340 !ruby/object:Gem::Requirement
16
+ requirement: &70222656570860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 2.5.10
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70214939636340
24
+ version_requirements: *70222656570860
25
25
  description: An extension to Capistrano to deploy Magento. Adding the specific requirements
26
26
  and additional tasks.
27
27
  email:
@@ -37,11 +37,18 @@ files:
37
37
  - README.md
38
38
  - Rakefile
39
39
  - bin/magentify
40
+ - cucumber.yml
41
+ - features/compiler.feature
40
42
  - features/deploy.feature
43
+ - features/indexer.feature
44
+ - features/log.feature
41
45
  - features/magentify.feature
42
46
  - features/setup.feature
43
47
  - features/step_definitions/common_steps.rb
48
+ - features/step_definitions/compiler_steps.rb
44
49
  - features/step_definitions/deploy_steps.rb
50
+ - features/step_definitions/indexer_steps.rb
51
+ - features/step_definitions/log_steps.rb
45
52
  - features/step_definitions/magentify_steps.rb
46
53
  - features/step_definitions/setup_steps.rb
47
54
  - features/support/env.rb
@@ -78,11 +85,17 @@ signing_key:
78
85
  specification_version: 3
79
86
  summary: Deploying Magento PHP applications with Capistrano.
80
87
  test_files:
88
+ - features/compiler.feature
81
89
  - features/deploy.feature
90
+ - features/indexer.feature
91
+ - features/log.feature
82
92
  - features/magentify.feature
83
93
  - features/setup.feature
84
94
  - features/step_definitions/common_steps.rb
95
+ - features/step_definitions/compiler_steps.rb
85
96
  - features/step_definitions/deploy_steps.rb
97
+ - features/step_definitions/indexer_steps.rb
98
+ - features/step_definitions/log_steps.rb
86
99
  - features/step_definitions/magentify_steps.rb
87
100
  - features/step_definitions/setup_steps.rb
88
101
  - features/support/env.rb