immosquare-capistrano 0.1.5 → 0.1.7

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
  SHA256:
3
- metadata.gz: eebe27d1ff19f881f868149c9fe82c829815358786271ee294f30a99ed16d9ed
4
- data.tar.gz: a9c4a37203792db7eddb7e58e82f0cec4925e32c79b501c6513a6953d0c2844e
3
+ metadata.gz: 4d5ce30da4725609f237136b6fa05c3cae9668c128a9c10c7db824c26564df61
4
+ data.tar.gz: 7135f08dfb35aa6a54eda7c03ad8825df43c2f7aea822a813eb4a0fc161d67c1
5
5
  SHA512:
6
- metadata.gz: 64db57958d1e4efd8871e001e555c8162bbb46906e6ee62f69d9c678d4fd20ec9ad1bff9abe6207c8c2e38054b300c0843f7108088dc8d77c8627bf907234bcf
7
- data.tar.gz: 17736935e39783fd634cad578b0290c767dbf02b565ca803b1208ec74db75cfe1a4b244ca27c810c988f30d2e3b503a5a3410be4e356ab682ae060fac51e905d
6
+ metadata.gz: 91ffa7cba4f9af474bd1ae3a77f83199e740f49e44149f805fb8734759664b389ac13ec6ff9a686545810710c4d0673ac789e10bcae84aba9ae9bd7c2b2eab3c
7
+ data.tar.gz: ffe745d0bb6d5ad2c4570c3064e84a8ac0ce345feb938854a7ffcd5ed94f79df1c9b0de9236fa6528338bb6ac1c5e8cbb704f09dc6b719a51f6d420d1d6c6209
@@ -14,11 +14,5 @@ namespace :load do
14
14
  ## SolidQueue
15
15
  ##============================================================##
16
16
  set_if_empty :solid_queue_service_unit_name, -> { "solid_queue_#{fetch(:application)}_#{fetch(:stage)}" }
17
-
18
- ##============================================================##
19
- ## rvm
20
- ##============================================================##
21
- set_if_empty :rvm_ruby_version, -> { "default" }
22
- set_if_empty :rvm_map_bins, -> { ["gem", "rake", "ruby", "bundle"] }
23
17
  end
24
18
  end
@@ -1,6 +1,5 @@
1
1
  require_relative "defaults"
2
2
 
3
-
4
3
  ##============================================================##
5
4
  ## We load rvm tasks
6
5
  ##============================================================##
@@ -13,5 +12,9 @@ load File.expand_path("tasks/rvm.rake", __dir__)
13
12
  ##============================================================##
14
13
  Capistrano::DSL.stages.each do |stage|
15
14
  after stage, "rvm:hook"
16
- # after stage, "rvm:check"
17
15
  end
16
+
17
+ ##============================================================##
18
+ ## Update .ruby-gemset && ruby-version files
19
+ ##============================================================##
20
+ before "deploy:updated", "rvm:update_rvm_dot_files"
@@ -13,25 +13,89 @@ namespace :rvm do
13
13
  elsif test("[ -d #{rvm_system_path} ]")
14
14
  rvm_system_path
15
15
  else
16
- raise("RVM path not found on server. Please install RVM first")
16
+ error("RVM path not found on server. Please install RVM first")
17
+ exit(1)
17
18
  end
19
+ info "RVM path detected: #{rvm_path}"
20
+ rvm_bin_path = "#{rvm_path}/bin/rvm"
18
21
 
19
22
  ##============================================================##
20
- ## Log
23
+ ## Set the RVM command map
21
24
  ##============================================================##
22
- info "RVM path detected: #{rvm_path}"
23
-
25
+ SSHKit.config.command_map[:rvm] = rvm_bin_path
24
26
 
25
27
  ##============================================================##
26
- ## Set the RVM command map
28
+ ## Check if the RVM Ruby version is set
27
29
  ##============================================================##
28
- SSHKit.config.command_map[:rvm] = "#{rvm_path}/bin/rvm"
30
+ rvm_ruby_version = fetch(:rvm_ruby_version)
31
+ if rvm_ruby_version.nil?
32
+ error "rvm_ruby_version not set. Please set the rvm_ruby_version in your deploy.rb file with format ruby-x.y.z@your-app-name"
33
+ exit 1
34
+ elsif rvm_ruby_version !~ /^ruby-\d+\.\d+\.\d+@[a-z0-9\-_]+$/i
35
+ error "rvm_ruby_version format is invalid. Please set the rvm_ruby_version in your deploy.rb file with format ruby-x.y.z@your-app-name"
36
+ exit 1
37
+ end
38
+ info "rvm_ruby_version set: #{rvm_ruby_version}"
29
39
 
30
40
  ##============================================================##
31
41
  ## Set the RVM prefix for the commands
32
42
  ##============================================================##
33
- fetch(:rvm_map_bins).each do |command|
34
- SSHKit.config.command_map.prefix[command.to_sym].unshift("#{rvm_path}/bin/rvm #{fetch(:rvm_ruby_version)} do")
43
+ ["gem", "rake", "ruby", "bundle"].each do |command|
44
+ SSHKit.config.command_map.prefix[command.to_sym].unshift("#{rvm_bin_path} #{rvm_ruby_version} do")
45
+ end
46
+
47
+
48
+ ##============================================================##
49
+ ## Check if ruby version is installed
50
+ ##============================================================##
51
+ ruby_version = rvm_ruby_version.split("@").first
52
+ unless test("#{rvm_bin_path} #{ruby_version} do ruby --version")
53
+ error "Ruby version #{ruby_version} is not installed on the server. Please install it first with 'rvm install #{ruby_version}'"
54
+ exit 1
55
+ end
56
+ info "#{ruby_version} is installed on the server."
57
+
58
+ ##============================================================##
59
+ ## Check if gemset exists, if not create it
60
+ ##============================================================##
61
+ gemset_name = rvm_ruby_version.split("@").last
62
+ unless test("#{rvm_bin_path} #{rvm_ruby_version} do rvm gemset list | grep -wq #{gemset_name}")
63
+ info "Creating gemset #{gemset_name} for #{ruby_version}"
64
+ execute :rvm, "#{ruby_version} do rvm gemset create #{gemset_name}"
65
+ end
66
+ end
67
+ end
68
+
69
+ ##============================================================##
70
+ ## Update .ruby-gemset and .ruby-version files with
71
+ ## values from the rvm_ruby_version variable
72
+ ##============================================================##
73
+ task :update_rvm_dot_files do
74
+ on roles(:app) do
75
+ rvm_ruby_version = fetch(:rvm_ruby_version)
76
+ ruby_version = rvm_ruby_version.split("@").first
77
+ gemset_name = rvm_ruby_version.split("@").last
78
+
79
+ info "Updating .ruby-version file with #{ruby_version}"
80
+ info "Updating .ruby-gemset file with #{gemset_name}"
81
+
82
+ ##============================================================##
83
+ ## Mettre à jour les fichiers dans `release_path`
84
+ ## The gem capistrano-bundler launch
85
+ ## bundle config --local deployment true with the release_path
86
+ ##============================================================##
87
+ within release_path do
88
+ execute :echo, ruby_version.to_s, ">", ".ruby-version"
89
+ execute :echo, gemset_name.to_s, ">", ".ruby-gemset"
90
+ end
91
+
92
+ ##============================================================##
93
+ ## To have the same version in the current path to lauch
94
+ ## bundle exec commands from the current path
95
+ ##============================================================##
96
+ within current_path do
97
+ execute :echo, ruby_version.to_s, ">", ".ruby-version"
98
+ execute :echo, gemset_name.to_s, ">", ".ruby-gemset"
35
99
  end
36
100
  end
37
101
  end
@@ -1,3 +1,3 @@
1
1
  module ImmosquareCapistrano
2
- VERSION = "0.1.5".freeze
2
+ VERSION = "0.1.7".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - immosquare