rat_deployer 0.5.0 → 1.0.0

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: d8370c118d92b2f06d327225481cb3d592a11167
4
- data.tar.gz: a03cf3b020a9d3e38d99c6f1fa3adf56aa078e0d
3
+ metadata.gz: 262cf16b057028e511cd9d5e4e9396248c0cd725
4
+ data.tar.gz: c08531236e1d4ec9257344c42e367812239b7f19
5
5
  SHA512:
6
- metadata.gz: e6626360686e73f7d236290cd3e842748b6d4b64f41afba11f0d4c8fb0125d71b76a895be6156b42c52c8b04db37d3f3e147c1fe7ccdbad94cbe031f1df63963
7
- data.tar.gz: 7a2f2e575bb63d46e7eb7a074fb14e43e4f13f909e2fb0015030d9329e56e10b99f06f7c776c39fdab1a1ead62e972916053a073f7f6dc3d07ba1f07da47ed08
6
+ metadata.gz: cbbc4deeef649ba8bf002bfdd14bdcf99633624a301bf074e494ea4c3393a11c2b72e1d3fca01915a8e2e4f8dfedf929cc767576b79af8d8296791a37cd2ecd7
7
+ data.tar.gz: dec480736bdfc188b5b3e9c66e0f88b8651fc4d5063950d7741a69b3b2a3a01c84b809b1cc77f3e56c516dff1f850a1c8b0f65305a7827db98f056b4273075be
@@ -1,88 +1,15 @@
1
1
  require 'thor'
2
2
  require 'fileutils'
3
- require 'active_support/core_ext/string/strip'
4
3
 
5
- require 'rat_deployer/command'
6
- require 'rat_deployer/notifier'
4
+ require 'rat_deployer/commands/compose'
5
+ require 'rat_deployer/commands/deploy'
6
+ require 'rat_deployer/commands/docker'
7
7
 
8
8
  module RatDeployer
9
9
  # The main Thor subclass
10
10
  class Cli < Thor
11
- include RatDeployer::Command
12
-
13
- desc 'deploy', 'deploys current environment'
14
- def deploy(*services)
15
- RatDeployer::Notifier.notify_deploy_start
16
- do_deploy(*services)
17
- RatDeployer::Notifier.notify_deploy_end
18
- rescue StandardError => e
19
- RatDeployer::Notifier.notify <<-STR.strip_heredoc
20
- Failed deploy on #{RatDeployer::Config.env}
21
- Reason:
22
- #{e.message}
23
- STR
24
- raise e
25
- end
26
-
27
- desc 'compose ARGS...', 'runs docker-compose command with default flags'
28
- def compose(cmd, *cmd_flags, silent: false)
29
- run(
30
- [
31
- 'docker-compose',
32
- compose_flags,
33
- cmd,
34
- cmd_flags
35
- ].flatten.join(' '),
36
- silent: silent
37
- )
38
- .fetch(:output)
39
- end
40
-
41
- desc 'docker ARGS...', 'runs docker command with default flags'
42
- def docker(cmd, *cmd_flags)
43
- flags = []
44
-
45
- if RatDeployer::Config.remote
46
- flags.unshift(RatDeployer::Config.remote_machine_flags)
47
- end
48
-
49
- cmd = run "docker #{flags.join(' ')} #{cmd} #{cmd_flags.join(' ')}"
50
- cmd.fetch(:output)
51
- end
52
-
53
- private
54
-
55
- def do_deploy(*services)
56
- if services.any?
57
- services_str = services.join(' ')
58
- compose("pull #{services_str}")
59
- compose("up -d --no-deps --force-recreate #{services_str}")
60
- else
61
- compose('pull')
62
- compose('up -d')
63
- end
64
- end
65
-
66
- def compose_flags
67
- env = RatDeployer::Config.env
68
- project_name = RatDeployer::Config.all.fetch('project_name')
69
-
70
- config_files =
71
- RatDeployer::Config.for_env['config_files'] || %W[
72
- config/default.yml
73
- config/#{env}.yml
74
- ]
75
-
76
- flags = [
77
- config_files.map { |cf| "-f #{cf}" },
78
- "-p #{project_name}_#{env}"
79
- ]
80
-
81
- if RatDeployer::Config.remote
82
- flags.unshift(RatDeployer::Config.remote_machine_flags)
83
- end
84
-
85
- flags
86
- end
11
+ include Commands::Compose::Extension
12
+ include Commands::Deploy::Extension
13
+ include Commands::Docker::Extension
87
14
  end
88
15
  end
@@ -32,6 +32,11 @@ module RatDeployer
32
32
  all.fetch('images', {})
33
33
  end
34
34
 
35
+ def self.project_name
36
+ (for_env['project_name'] || all.fetch('project_name'))
37
+ .gsub(/\{env\}/, env)
38
+ end
39
+
35
40
  def self.remote_machine_flags
36
41
  machine = for_env.fetch('machine')
37
42
 
@@ -1,3 +1,3 @@
1
1
  module RatDeployer
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rat_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Oga