Class: DeploYML::CLI
- Inherits:
-
Thor
- Object
- Thor
- DeploYML::CLI
- Defined in:
- lib/deployml/cli.rb
Overview
Instance Method Summary collapse
-
#config ⇒ Object
Configures the server for the specified environment.
-
#deploy ⇒ Object
Cold-deploys into the specified environment.
-
#environment ⇒ Environment
protected
The selected environment.
-
#exec(command) ⇒ Object
Executes a command in the specified environment.
-
#find_root ⇒ Pathname
protected
Finds the root of the project, starting at the current working directory and ascending upwards.
-
#install ⇒ Object
Installs any needed dependencies in the specified environment.
-
#migrate ⇒ Object
Migrates the database for the specified environment.
-
#project ⇒ Project
protected
The project.
-
#rake(task) ⇒ Object
Invokes a rake task in the specified environment.
-
#redeploy ⇒ Object
Redeploys into the specified environment.
-
#restart ⇒ Object
Restarts the server in the specified environment.
-
#setup ⇒ Object
Sets up the specified environment.
-
#ssh ⇒ Object
Starts an SSH session with the specified environment.
-
#start ⇒ Object
Starts the server in the specified environment.
-
#status(message) ⇒ Object
protected
Prints a status message.
-
#stop ⇒ Object
Stops the server in the specified environment.
-
#update ⇒ Object
Updates the deployment repository of the specified environment.
Instance Method Details
#config ⇒ Object
Configures the server for the specified environment.
130 131 132 133 134 135 136 |
# File 'lib/deployml/cli.rb', line 130 def config status 'Configuring ...' project.config!([:environment]) status 'Configured' end |
#deploy ⇒ Object
Cold-deploys into the specified environment.
194 195 196 197 198 199 200 |
# File 'lib/deployml/cli.rb', line 194 def deploy status 'Deploying ...' project.deploy!([:environment]) status 'Deployed' end |
#environment ⇒ Environment (protected)
The selected environment.
266 267 268 |
# File 'lib/deployml/cli.rb', line 266 def environment project.environment([:environment]) end |
#exec(command) ⇒ Object
Executes a command in the specified environment.
26 27 28 |
# File 'lib/deployml/cli.rb', line 26 def exec(command) environment.exec(command) end |
#find_root ⇒ Pathname (protected)
Finds the root of the project, starting at the current working directory and ascending upwards.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/deployml/cli.rb', line 229 def find_root Pathname.pwd.ascend do |root| config_dir = root.join(Project::CONFIG_DIR) if config_dir.directory? config_file = config_dir.join(Project::CONFIG_FILE) return root if config_file.file? environments_dir = config_dir.join(Project::ENVIRONMENTS_DIR) return root if environments_dir.directory? end end shell.say "Could not find '#{Project::CONFIG_FILE}' in any parent directories", :red exit -1 end |
#install ⇒ Object
Installs any needed dependencies in the specified environment.
98 99 100 101 102 103 104 |
# File 'lib/deployml/cli.rb', line 98 def install status 'Installing ...' project.install!([:environment]) status 'Installed' end |
#migrate ⇒ Object
Migrates the database for the specified environment.
114 115 116 117 118 119 120 |
# File 'lib/deployml/cli.rb', line 114 def migrate status 'Migrating ...' project.migrate!([:environment]) status 'Migrated' end |
#project ⇒ Project (protected)
The project.
254 255 256 |
# File 'lib/deployml/cli.rb', line 254 def project @project ||= Project.new(find_root) end |
#rake(task) ⇒ Object
Invokes a rake task in the specified environment.
42 43 44 |
# File 'lib/deployml/cli.rb', line 42 def rake(task) environment.rake(task,*([:args])) end |
#redeploy ⇒ Object
Redeploys into the specified environment.
210 211 212 213 214 215 216 |
# File 'lib/deployml/cli.rb', line 210 def redeploy status 'Redeploying ...' project.redeploy!([:environment]) status 'Redeployed' end |
#restart ⇒ Object
Restarts the server in the specified environment.
178 179 180 181 182 183 184 |
# File 'lib/deployml/cli.rb', line 178 def restart status 'Restarting ...' project.restart!([:environment]) status 'Restarted' end |
#setup ⇒ Object
Sets up the specified environment.
66 67 68 69 70 71 72 |
# File 'lib/deployml/cli.rb', line 66 def setup status 'Setting up ...' project.setup!([:environment]) status 'Setup' end |
#ssh ⇒ Object
Starts an SSH session with the specified environment.
54 55 56 |
# File 'lib/deployml/cli.rb', line 54 def ssh environment.ssh end |
#start ⇒ Object
Starts the server in the specified environment.
146 147 148 149 150 151 152 |
# File 'lib/deployml/cli.rb', line 146 def start status 'Starting ...' project.start!([:environment]) status 'Started' end |
#status(message) ⇒ Object (protected)
Prints a status message.
276 277 278 |
# File 'lib/deployml/cli.rb', line 276 def status() shell.say_status "[#{[:environment]}]", end |
#stop ⇒ Object
Stops the server in the specified environment.
162 163 164 165 166 167 168 |
# File 'lib/deployml/cli.rb', line 162 def stop status 'Stopping ...' project.stop!([:environment]) status 'Stopped' end |
#update ⇒ Object
Updates the deployment repository of the specified environment.
82 83 84 85 86 87 88 |
# File 'lib/deployml/cli.rb', line 82 def update status 'Updating' project.update!([:environment]) status 'Updated' end |