negroku 0.0.2 → 0.0.3

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/lib/negroku/cli.rb CHANGED
@@ -20,13 +20,12 @@ class App < Thor
20
20
  # Test for config
21
21
  if config.empty?
22
22
  say "[WARNING]".foreground(:red)
23
- say "It's recommended that you add some default settings to negroku before you create your app deployment\n\n"
24
- say "For example you can add your most common git urls using:\n"
25
- say "negroku repo add git@github.com:yourusername.git\n".foreground(:yellow)
26
- say "Also you can add your deployment servers urls using:\n"
23
+ say "It's recommended that you add some custom settings to negroku before you create your app deployment\n\n"
24
+ say "You can add your deployment servers urls using:\n"
27
25
  say "negroku target add my.deployment.com".foreground(:yellow)
28
26
  say "negroku target add 104.284.3.1\n".foreground(:yellow)
29
- unless yes? "Do you want to continue without adding default settings? [y/N]"
27
+ unless agree "You have not added custom settings! Do you want to continue? [y/n]", true
28
+ say "Goodbye"
30
29
  exit
31
30
  end
32
31
  end
@@ -53,33 +52,18 @@ class App < Thor
53
52
 
54
53
  # find local remote from git repo
55
54
  if File.directory?(".git")
56
- say "[INFO] The first repo was taken from the local git checkout remotes".color(:yellow)
57
- local_repo = %x(git remote -v | grep origin | grep push | awk '{print $2}').gsub(/\n/,"")
58
- menu.choice("#{local_repo}") do |command|
59
- say("Using #{command}")
60
- data[:repo] = command;
61
- end
62
- end
63
-
64
- # adds the repos in the config file if there is one
65
- if config[:repo]
66
- config[:repo].each do |val|
67
- repo_url = "#{val}/#{data[:application_name]}.git"
68
- # skip if the repo url is the same as the local one
69
- unless repo_url == local_repo
70
- menu.choice(repo_url) do |command|
71
- say("Using #{command}/#{data[:application_name]}.git")
72
- data[:repo] = command;
73
- end
55
+ local_repos = %x(git remote -v | awk '{print $2}' | uniq).split("\n")
56
+ local_repos.each do |url|
57
+ menu.choice(url) do |command|
58
+ say("Using #{command}")
59
+ data[:repo] = command;
74
60
  end
75
61
  end
76
- else
77
- say "[INFO] There are no repos in the default settings".color(:yellow)
78
62
  end
79
63
 
80
64
  # add other repo choice
81
65
  menu.choice(:other) {
82
- data[:repo] = ask "Type the url and username e.g. git@github.com:username: ".bright()
66
+ data[:repo] = ask "Type the url and username e.g. git@github.com:username/app-name.git: ".bright()
83
67
  }
84
68
  end
85
69
 
@@ -92,7 +76,7 @@ class App < Thor
92
76
  menu.select_by = :index
93
77
 
94
78
  # Adds the targets in the config file if there is one
95
- if config[:repo]
79
+ if config[:target]
96
80
  config[:target].each do |val|
97
81
  menu.choice(val) do |command|
98
82
  say("Using #{command}")
@@ -111,7 +95,7 @@ class App < Thor
111
95
  # Add custom domain
112
96
  say "\nCUSTOM DOMAIN"
113
97
  say "============="
114
- if yes? "Do you want to use #{data[:target_server].gsub(/^([a-z\d]*)/, data[:application_name])}? [Y/n]"
98
+ if agree "Do you want to use #{data[:target_server].gsub(/^([a-z\d]*)/, data[:application_name])}? [y/n]", true
115
99
  data[:domains] = data[:target_server].gsub(/^([a-z\d]*)/, data[:application_name])
116
100
  else
117
101
  data[:domains] = ask "Please enter the domains separated by spaces"
@@ -120,9 +104,13 @@ class App < Thor
120
104
 
121
105
  init(".", data)
122
106
 
107
+ puts "[Negroku] => Running capistrano task deploy:setup"
108
+ `cap deploy:setup`
109
+
123
110
  say "\n\nWhat to do next?\n".bright()
124
- say "You can try with cap -T to see the available tasks"
125
- say "Also you can check the config/deploy.rb file, you may want to change some things there"
111
+ say "You can try with " + "cap -T".color(:yellow) +" to see the available tasks"
112
+ say "Also you can check the " + "config/deploy.rb".color(:yellow) + " file, you may want to change some things there"
113
+ say "NOTE: If this is the first time the app is deployed, use the task " + "cap deploy:cold task".color(:yellow)
126
114
  say "\n HAPPY DEPLOY".foreground(:green)
127
115
  end
128
116
 
@@ -132,27 +120,6 @@ class App < Thor
132
120
  end
133
121
  end
134
122
 
135
- class Repo < Thor
136
-
137
- desc "add", "add new default repositories"
138
- def add(url=nil)
139
- if url.nil?
140
- url = ask("Type the url and username e.g. git@github.com:username")
141
- end
142
- saveConfig(:add, :repo, url)
143
- end
144
-
145
- desc "remove", "remove some repo"
146
- def remove
147
- puts "I will remove a repo"
148
- end
149
-
150
- desc "list", "show the repost"
151
- def list
152
- puts "I will list the target servers"
153
- end
154
- end
155
-
156
123
  class Target < Thor
157
124
  desc "add", "add new default target server"
158
125
  def add(host=nil)
@@ -160,6 +127,7 @@ class Target < Thor
160
127
  host = ask("Type the host or ip for the target machine")
161
128
  end
162
129
  saveConfig(:add, :target, host)
130
+ say "[Negroku] Added #{host}"
163
131
  end
164
132
 
165
133
  desc "remove", "remove some target"
@@ -202,7 +170,7 @@ class RemoteEnv < Thor
202
170
  # If nothing was sent
203
171
  elsif key.nil? && value.nil?
204
172
  # Check if the .rbenv-vars file exists and offer get the info from there
205
- if File.exist?(".rbenv-vars") && (yes? "Do you want to add variables from your local .rbenv-vars file [y/N]")
173
+ if File.exist?(".rbenv-vars") && (agree "Do you want to add variables from your local .rbenv-vars file [y/n]", true)
206
174
  choose do |menu|
207
175
  menu.prompt = "Please choose variable you want to add?".bright()
208
176
  menu.select_by = :index
@@ -227,7 +195,6 @@ end
227
195
  module Negroku
228
196
  class CLI < Thor
229
197
  register(App, 'app', 'app [COMMAND]', 'Application')
230
- register(Repo, 'repo', 'repo [COMMAND]', 'Repositories')
231
198
  register(Target, 'target', 'target [COMMAND]', 'Target servers')
232
199
  register(Konfig, 'config', 'config [COMMAND]', 'Configuration')
233
200
  register(RemoteEnv, 'env', 'env [COMMAND]', 'Remote environmental variables')
@@ -21,6 +21,10 @@ ssh_options[:forward_agent] = true
21
21
  ssh_options[:port] = 22
22
22
  default_run_options[:pty] = true
23
23
 
24
+ # Use the bundler capistrano task to deploy to the shared folder
25
+ require "bundler/capistrano"
26
+ set :bundle_flags, "--deployment --binstubs"
27
+
24
28
  ##
25
29
  # Load Deployment Tasks
26
30
  load_tasks('base')
@@ -1,7 +1,7 @@
1
1
  # Number of workers (Rule of thumb is 2 per CPU)
2
2
  # Just be aware that every worker needs to cache all classes and thus eat some
3
3
  # of your RAM.
4
- set_default :unicorn_workers, 2
4
+ set_default :unicorn_workers, 1
5
5
 
6
6
  # Workers timeout in the amount of seconds below, when the master kills it and
7
7
  # forks another one.
@@ -47,6 +47,7 @@ namespace :unicorn do
47
47
  end
48
48
 
49
49
  after "deploy", "unicorn:restart"
50
+ after "deploy:cold", "unicorn:start"
50
51
  end
51
52
 
52
53
 
@@ -16,6 +16,8 @@ set :branch, "production" # Optional, defaults to master
16
16
  # Web server configuration
17
17
  set :domains, "<%= data[:domains] %>"
18
18
 
19
- # Use the bundler capistrano task to deploy to the shared folder
20
- require "bundler/capistrano"
21
- set :bundle_flags, "--deployment --binstubs"
19
+ # Database
20
+ # set :migrate_env, "migration"
21
+
22
+ # Unicorn
23
+ set :unicorn_workers, 1
@@ -1,3 +1,3 @@
1
1
  module Negroku
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: negroku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
12
+ date: 2013-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano