negroku 0.0.11 → 0.0.12
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 +4 -4
- data/lib/negroku/cli.rb +46 -35
- data/lib/negroku/helpers.rb +40 -16
- data/lib/negroku/tasks/base.rb +1 -5
- data/lib/negroku/tasks/unicorn.rb +0 -1
- data/lib/negroku/templates/deploy.rb.erb +4 -10
- data/lib/negroku/templates/production.rb.erb +14 -0
- data/lib/negroku/templates/staging.rb.erb +14 -0
- data/lib/negroku/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd62aa6eebe81dc9a711f56132ac7b4d3a095447
|
4
|
+
data.tar.gz: e18fb631a06f03b2746c79c5b655782f4f081c6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 |
|
58
|
-
say("Using #{
|
59
|
-
data[:repo] =
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
#
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
111
|
-
say "
|
112
|
-
say "
|
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
|
|
data/lib/negroku/helpers.rb
CHANGED
@@ -1,46 +1,70 @@
|
|
1
1
|
def init(target=".", data)
|
2
|
-
|
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(
|
13
|
+
if Dir.entries(target_path).include?("Capfile")
|
5
14
|
puts "[Negroku] => Found Capfile!"
|
6
15
|
else
|
7
16
|
puts "[Negroku] => Capifying!"
|
8
|
-
`capify #{
|
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?(
|
22
|
+
unless File.directory?(config_path)
|
15
23
|
puts "[Negroku] => Could not find the \"config\" folder. Creating it now!"
|
16
|
-
%x(mkdir #{
|
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?(
|
34
|
+
if File.exist?(deployfile)
|
21
35
|
puts "[Negroku] => Backing up deploy.rb"
|
22
|
-
old_versions = Dir.entries(
|
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 #{
|
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 #{
|
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(
|
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 #{
|
43
|
-
File.open(
|
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'
|
data/lib/negroku/tasks/base.rb
CHANGED
@@ -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:
|
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."
|
@@ -1,5 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
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
|
data/lib/negroku/version.rb
CHANGED
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.
|
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-
|
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
|