negroku 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de78c5247527b3b8887d4e8fcf3e1c605922e884
4
- data.tar.gz: 0480b92ed105a7a8b6ef356e46b82b0d96181148
3
+ metadata.gz: fd62aa6eebe81dc9a711f56132ac7b4d3a095447
4
+ data.tar.gz: e18fb631a06f03b2746c79c5b655782f4f081c6d
5
5
  SHA512:
6
- metadata.gz: 1e875b138af00e89a8dfd318129225cc9d78c5d9d6b193b87f0ee0a610d2eed9743fe3251e25a550198a17fe97d64b025919fc447871585aeadb8b46405cd61c
7
- data.tar.gz: 1b1c4c15c8bf80b630f57c8b26f0d6b60015e68c726bfd535ba75df5c3f5778c022c390c77cac3cb128efc36d4a883e62879ab1f1a10b6ea17442de08180af8b
6
+ metadata.gz: e407926f1919bcfce737429d097409646b62c1fc46485f1232b7f92d5cfe24bb7c510da865a0fb2c579379e6d493f47f6fb6d70430bb44527014eb793b8fb662
7
+ data.tar.gz: a52b3184d06a31a1c0f3093542c7b672728ff424d83f2094719182dc1fb41b4e986c8af26d10ea113a5fad9b34d30cd6780022c1e03999b748f0b2afe1416864
data/lib/negroku/cli.rb CHANGED
@@ -54,9 +54,9 @@ class App < Thor
54
54
  if File.directory?(".git")
55
55
  local_repos = %x(git remote -v | awk '{print $2}' | uniq).split("\n")
56
56
  local_repos.each do |url|
57
- menu.choice(url) do |command|
58
- say("Using #{command}")
59
- data[:repo] = command;
57
+ menu.choice(url) do |server|
58
+ say("Using #{server}")
59
+ data[:repo] = server;
60
60
  end
61
61
  end
62
62
  end
@@ -68,48 +68,59 @@ class App < Thor
68
68
  end
69
69
 
70
70
  # The application target deploy server
71
- choose do |menu|
72
-
73
- say "\nTARGET SERVERS"
74
- say "=============="
75
- menu.prompt = "Please choose your deployment server?".bright()
76
- menu.select_by = :index
77
-
78
- # Adds the targets in the config file if there is one
79
- if config[:target]
80
- config[:target].each do |val|
81
- menu.choice(val) do |command|
82
- say("Using #{command}")
83
- data[:target_server] = command;
71
+ say "\nTARGET SERVERS"
72
+ say "==============\n"
73
+ %w(staging production).each do |stage|
74
+
75
+ # Stage title
76
+ puts "\n#{stage.upcase}".foreground(:green)
77
+
78
+ # Ask server
79
+ choose do |menu|
80
+ menu.prompt = "Please choose your #{stage} deployment server?".bright()
81
+ menu.select_by = :index
82
+
83
+ # Adds the targets in the config file if there is one
84
+ if config[:target]
85
+ config[:target].each do |val|
86
+ menu.choice(val) do |server|
87
+ say("Using #{server} for #{stage}")
88
+ data[:"#{stage}_server"] = server;
89
+ end
84
90
  end
91
+ else
92
+ say "[INFO] There are no target urls in the default settings".color(:yellow)
85
93
  end
86
- else
87
- say "[INFO] There are no target urls in the default settings".color(:yellow)
88
- end
89
94
 
90
- menu.choice(:other) {
91
- data[:target_server] = ask "Type the hostname or ip of the server to deploy to:".bright()
92
- }
93
- end
95
+ menu.choice(:other) {
96
+ data[:"#{stage}_server"] = ask "Type the hostname or ip of the #{stage} server to deploy to:".bright()
97
+ }
98
+ end
94
99
 
95
- # Add custom domain
96
- say "\nCUSTOM DOMAIN"
97
- say "============="
98
- if agree "Do you want to use #{data[:target_server].gsub(/^([a-z\d]*)/, data[:application_name])}? [y/n]", true
99
- data[:domains] = data[:target_server].gsub(/^([a-z\d]*)/, data[:application_name])
100
- else
101
- data[:domains] = ask "Please enter the domains separated by spaces"
100
+ # Add custom domain
101
+ case stage
102
+ when "staging"
103
+ domain = data[:"#{stage}_server"].gsub(/^([a-z\d]*)/, data[:application_name])
104
+ when "production"
105
+ domain = "www.#{data[:application_name]}.com"
106
+ end
107
+ if agree "Do you want to use #{domain}? [y/n]", true
108
+ data[:"#{stage}_domains"] = domain
109
+ else
110
+ data[:"#{stage}_domains"] = ask "Please enter the domains separated by spaces"
111
+ end
102
112
  end
103
113
 
104
-
105
114
  init(".", data)
106
115
 
107
116
  say "\n\nWhat to do next?\n".bright()
108
- say "Setup your app running " + "cap deploy:setup".color(:yellow)
117
+ say "Setup your app running " + "cap deploy:setup".color(:yellow) + " then " + "cap deploy:cold".color(:yellow)
109
118
  say "You can try with " + "cap -T".color(:yellow) +" to see the available tasks"
110
- say "Also you can check the " + "config/deploy.rb".color(:yellow) + " file, you may want to change some things there"
111
- say "NOTE: If this is the first time the app is deployed, use the task " + "cap deploy:cold".color(:yellow)
112
- say "\n HAPPY DEPLOY".foreground(:green)
119
+ say "Also you can check the following files, you may want to change some things there"
120
+ say "config/deploy.rb".color(:yellow)
121
+ say "config/deploy/staging.rb".color(:yellow)
122
+ say "config/deploy/production.rb".color(:yellow)
123
+ say "\nHAPPY DEPLOY".foreground(:green)
113
124
  end
114
125
  end
115
126
 
@@ -1,46 +1,70 @@
1
1
  def init(target=".", data)
2
- puts target
2
+
3
+ # Main locations
4
+ target_path = File.expand_path(target)
5
+ config_path = File.join(target_path, "config")
6
+ deploy_path = File.join(target_path, "config", "deploy")
7
+ capfile = File.join(target_path, "Capfile")
8
+ deployfile = File.join(config_path, "deploy.rb")
9
+ stagingfile = File.join(deploy_path, "staging.rb")
10
+ productionfile = File.join(deploy_path, "production.rb")
11
+
3
12
  # Create the cap file if not found
4
- if Dir.entries(target).include?("Capfile")
13
+ if Dir.entries(target_path).include?("Capfile")
5
14
  puts "[Negroku] => Found Capfile!"
6
15
  else
7
16
  puts "[Negroku] => Capifying!"
8
- `capify #{File.expand_path(target)}`
17
+ `capify #{target_path}`
18
+ `rm `
9
19
  end
10
- path = File.expand_path(target)
11
- capfile = File.expand_path(File.join(target, "Capfile"))
12
20
 
13
21
  # Find or create config folder
14
- unless File.directory?(File.join(path, "config"))
22
+ unless File.directory?(config_path)
15
23
  puts "[Negroku] => Could not find the \"config\" folder. Creating it now!"
16
- %x(mkdir #{File.join(path, 'config')})
24
+ %x(mkdir #{config_path})
25
+ end
26
+
27
+ # Find or create deploy folder
28
+ unless File.directory?(deploy_path)
29
+ puts "[Negroku] => Could not find the \"deploy\" folder. Creating it now!"
30
+ %x(mkdir #{deploy_path})
17
31
  end
18
32
 
19
33
  # replace and rename older deploy.rb
20
- if File.exist?(File.join(path, "config", "deploy.rb"))
34
+ if File.exist?(deployfile)
21
35
  puts "[Negroku] => Backing up deploy.rb"
22
- old_versions = Dir.entries(File.join(path, 'config')).map {|entree| entree if entree =~ /deploy\.old\.(\d+)\.rb$/}.compact!
36
+ old_versions = Dir.entries(config_path).map {|entree| entree if entree =~ /deploy\.old\.(\d+)\.rb$/}.compact!
23
37
  if old_versions.empty?
24
- %x(mv #{File.join(path, 'config', 'deploy.rb')} #{File.join(path, 'config', 'deploy.old.1.rb')})
38
+ %x(mv #{deployfile} #{File.join(config_path, 'deploy.old.1.rb')})
25
39
  else
26
40
  version = old_versions.last.match('^deploy\.old\.(\d+)\.rb$')[1].to_i + 1
27
- %x(mv #{File.join(path, 'config', 'deploy.rb')} #{File.join(path, 'config', "deploy.old.#{version}.rb")})
41
+ %x(mv #{deployfile} #{File.join(config_path, "deploy.old.#{version}.rb")})
28
42
  end
29
- else
30
- puts "[Negroku] => Could not find deploy.rb. Creating a new one!"
31
43
  end
32
44
 
33
45
  # Create the new deploy
34
46
  puts "[Negroku] => Writing new deploy.rb."
35
47
  erb = File.read(File.join(File.dirname(__FILE__), 'templates', 'deploy.rb.erb'))
36
- File.open(File.join(path, 'config', 'deploy.rb'), 'w') do |f|
48
+ File.open(deployfile, 'w') do |f|
49
+ f.write ERB.new(erb).result(binding)
50
+ end
51
+
52
+ # Create the new configuration stages
53
+ puts "[Negroku] => Writing new deploy/staging.rb"
54
+ erb = File.read(File.join(File.dirname(__FILE__), 'templates', 'staging.rb.erb'))
55
+ File.open(stagingfile, 'w') do |f|
56
+ f.write ERB.new(erb).result(binding)
57
+ end
58
+ puts "[Negroku] => Writing new deploy/production.rb"
59
+ erb = File.read(File.join(File.dirname(__FILE__), 'templates', 'production.rb.erb'))
60
+ File.open(productionfile, 'w') do |f|
37
61
  f.write ERB.new(erb).result(binding)
38
62
  end
39
63
 
40
64
  # checks for both require "negroku" and require "negroku/initializer"
41
65
  unless File.open(File.join('Capfile'), 'r').read.include?('require "negroku"')
42
- puts "[Negroku] => Adding Negroku Loader inside #{path}/Capfile."
43
- File.open(File.join(path, 'Capfile'), "a") do |cfile|
66
+ puts "[Negroku] => Adding Negroku Loader inside #{capfile}."
67
+ File.open(capfile, "a") do |cfile|
44
68
  cfile << <<-capfile
45
69
  \n
46
70
  load 'deploy/assets'
@@ -12,11 +12,7 @@ end
12
12
 
13
13
  # Review and modify the tasks below on a per-app/language/framework basis.
14
14
  namespace :deploy do
15
- after "deploy:update_code", "deploy:post"
16
- desc "Performs the post-deploy tasks."
17
- task :post do
18
- migrate
19
- end
15
+ after "deploy:update_code", "deploy:migrate"
20
16
 
21
17
  after "deploy:setup", "deploy:setup_shared"
22
18
  desc "Sets up additional folders/files after deploy:setup."
@@ -37,7 +37,6 @@ namespace :unicorn do
37
37
  run "#{sudo} mv /tmp/unicorn.rb #{shared_path}/config/"
38
38
  end
39
39
 
40
- after "deploy", "unicorn:restart"
41
40
  after "deploy:cold", "unicorn:start"
42
41
  after 'deploy:restart', 'unicorn:restart'
43
42
  end
@@ -1,5 +1,7 @@
1
- # Servers and their roles.
2
- server "<%= data[:target_server] %>", :web, :app, :db, primary: true
1
+ # Set server stages
2
+ set :stages, %w(production staging)
3
+ set :default_stage, "staging"
4
+ require 'capistrano/ext/multistage'
3
5
 
4
6
  # Server-side information.
5
7
  set :application, "<%= data[:application_name] %>"
@@ -9,16 +11,8 @@ set :deploy_to, "/home/#{user}/applications/#{application}"
9
11
  # Repository (if any) configuration.
10
12
  set :deploy_via, :remote_cache
11
13
  set :repository, "<%= data[:repo] %>"
12
- set :branch, "production" # Optional, defaults to master
13
- # set :remote, "negroku" # Optional, defaults to origin
14
14
  # set :git_enable_submodules, 1
15
15
 
16
- # Web server configuration
17
- set :domains, "<%= data[:domains] %>"
18
-
19
- # Rails
20
- # set :rails_env, "production"
21
-
22
16
  # Database
23
17
  # set :migrate_env, "migration"
24
18
 
@@ -0,0 +1,14 @@
1
+ ## PRODUCTION CONFIGURATION
2
+
3
+ # Servers and their roles.
4
+ server "<%= data[:production_server] %>", :web, :app, :db, primary: true
5
+
6
+ # Web server configuration
7
+ set :domains, "<%= data[:production_domains] %>"
8
+
9
+ # Source
10
+ set :branch, "production" # Optional, defaults to master
11
+ # set :remote, "origin" # Optional, defaults to origin
12
+
13
+ # Rails
14
+ # set :rails_env, "production" # Optional, defaults to production
@@ -0,0 +1,14 @@
1
+ ## STAGING CONFIGURATION
2
+
3
+ # Servers and their roles.
4
+ server "<%= data[:staging_server] %>", :web, :app, :db, primary: true
5
+
6
+ # Web server configuration
7
+ set :domains, "<%= data[:staging_domains] %>"
8
+
9
+ # Source
10
+ set :branch, "production" # Optional, defaults to master
11
+ # set :remote, "origin" # Optional, defaults to origin
12
+
13
+ # Rails
14
+ # set :rails_env, "staging" # Optional, defaults to production
@@ -1,3 +1,3 @@
1
1
  module Negroku
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: negroku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Ignacio Donoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-14 00:00:00.000000000 Z
11
+ date: 2013-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -101,6 +101,8 @@ files:
101
101
  - lib/negroku/tasks/templates/unicorn.erb
102
102
  - lib/negroku/tasks/unicorn.rb
103
103
  - lib/negroku/templates/deploy.rb.erb
104
+ - lib/negroku/templates/production.rb.erb
105
+ - lib/negroku/templates/staging.rb.erb
104
106
  - lib/negroku/version.rb
105
107
  - lib/negroku.rb
106
108
  - README.md