capistrano-opscomplete 0.6.7 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 342b22962198a630ea6f41463f0cd69cbb5e6edfdd0d66df3b2fe24c5ff81397
4
- data.tar.gz: 9ded78666b373b6322e0981dc1fad8ad5c6012549bfab62b7740120f54f4972d
3
+ metadata.gz: 39158f12f3935cff8bc3d2c39b6d252c7ac594de47bad9c35fa83463d8dbec03
4
+ data.tar.gz: aefdd1684fa67a31f19a1e9520edc82139ded5f5569b324cafaa5afa9c8a1e9e
5
5
  SHA512:
6
- metadata.gz: 99e89af95cf85d01a9a2deb3d43e914c72f3725f1070b099c0b502d0417ba64663d5ec3c5cb740ea801ba7bc05ac96b1d02d2c3728985c370cd4c2698fdc35bf
7
- data.tar.gz: 354a993896fb9b019b5be292dec3a3dbe9b76fbbba780e5a982b72474a9585829eab2f8feab03c3387a9dd74e84e74bb7466f9bc628677bd4ad9c6bb2a02496b
6
+ metadata.gz: 9639dc1c7d2a77fee4088ac466e428c5e60691ae82e802a7c32dc990008d6b7ef568daac73e0bfec16e489bc2038e91431f0bdd1600919ec3d30e57e8b6d354d
7
+ data.tar.gz: df97a9b57171097b35ce78222d0d073ecfcab37c42f3d362c52e96d5ae68cae23a610b33cfc80017828723ab479567881f0dd23c8183424211681387432a9f6f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [1.0.2] - 2022-07-29
2
+ ### Changed
3
+ - Improve error message for missing Node.js version
4
+
5
+ ## [1.0.1] - 2021-03-16
6
+
7
+ ### Fixed
8
+ - Made it possible to use `--dry-run` ([#27](https://github.com/makandra/capistrano-opscomplete/issues/27)
9
+
10
+ ## [1.0.0] - 2021-03-16
11
+
12
+ ### Changed
13
+ - Version bump to 1.0 and switch to semantic versioning: There were no breaking changes
14
+ - Remove rbenv dependency for our opscomplete infrastructure
15
+
1
16
  ## [0.6.7] - 2021-02-05
2
17
 
3
18
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,37 +1,37 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-opscomplete (0.6.7)
4
+ capistrano-opscomplete (1.0.2)
5
5
  capistrano (>= 3.0, < 4.0.0)
6
6
  rake
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- airbrussh (1.4.0)
11
+ airbrussh (1.4.1)
12
12
  sshkit (>= 1.6.1, != 1.7.0)
13
- ast (2.4.0)
14
- capistrano (3.11.2)
13
+ ast (2.4.2)
14
+ capistrano (3.17.0)
15
15
  airbrussh (>= 1.0.0)
16
16
  i18n
17
17
  rake (>= 10.0.0)
18
18
  sshkit (>= 1.9.0)
19
- concurrent-ruby (1.1.6)
20
- i18n (1.8.4)
19
+ concurrent-ruby (1.1.10)
20
+ i18n (1.12.0)
21
21
  concurrent-ruby (~> 1.0)
22
22
  jaro_winkler (1.5.4)
23
- makandra-rubocop (4.2.0)
23
+ makandra-rubocop (4.4.0)
24
24
  rubocop (~> 0.76.0)
25
25
  rubocop-rails (~> 2.3.2)
26
- net-scp (2.0.0)
27
- net-ssh (>= 2.6.5, < 6.0.0)
28
- net-ssh (5.2.0)
29
- parallel (1.19.1)
30
- parser (2.7.0.2)
31
- ast (~> 2.4.0)
26
+ net-scp (1.2.1)
27
+ net-ssh (>= 2.6.5)
28
+ net-ssh (7.0.1)
29
+ parallel (1.20.1)
30
+ parser (3.0.1.1)
31
+ ast (~> 2.4.1)
32
32
  rack (2.2.3)
33
33
  rainbow (3.0.0)
34
- rake (13.0.1)
34
+ rake (13.0.6)
35
35
  rubocop (0.76.0)
36
36
  jaro_winkler (~> 1.5.1)
37
37
  parallel (~> 1.10)
@@ -42,11 +42,11 @@ GEM
42
42
  rubocop-rails (2.3.2)
43
43
  rack (>= 1.1)
44
44
  rubocop (>= 0.72.0)
45
- ruby-progressbar (1.10.1)
46
- sshkit (1.20.0)
45
+ ruby-progressbar (1.11.0)
46
+ sshkit (1.21.2)
47
47
  net-scp (>= 1.1.2)
48
48
  net-ssh (>= 2.8.0)
49
- unicode-display_width (1.6.0)
49
+ unicode-display_width (1.6.1)
50
50
 
51
51
  PLATFORMS
52
52
  ruby
@@ -57,4 +57,4 @@ DEPENDENCIES
57
57
  makandra-rubocop (~> 4)
58
58
 
59
59
  BUNDLED WITH
60
- 2.1.4
60
+ 2.3.10
data/README.md CHANGED
@@ -111,11 +111,11 @@ More specifically this task will:
111
111
  1) The value of `:opscomplete_ruby_version` from your capistrano config. Leave this empty unless you want to override the desired version.
112
112
  2) A file in the `release_path` on the server (e.g. `/var/www/staging.myapp.biz/releases/20180523234205/.ruby-version`)
113
113
  3) A file in the current working directory of your local checkout (e.g. `/home/user/code/myapp/.ruby-version`)
114
- - If the desired version is not installed, it checks if it can be installed using `ruby-build` and installs it.
115
- - Check if `rbenv global` version is set according to application's `.ruby-version` file. Change it if required.
114
+ - If the desired version is not installed, it checks if it can be installed and installs it.
115
+ - Check if the global version is set according to application's `.ruby-version` file. Change it if required.
116
116
  - Install `bundler`. It is tried to determine the version that was used to create the `Gemfile.lock` (`BUNDLED WITH`) if it is present.
117
117
  - Install `geordi` gem if required.
118
- - Run `rbenv rehash` if required.
118
+ - Rehash the shims if required.
119
119
 
120
120
  **Note:** If, for any reason, no `.ruby-version` file can be found in your release or current working directory, you may set the following option in `deploy.rb`:
121
121
 
data/gem_graph.png ADDED
Binary file
@@ -3,19 +3,7 @@ module Capistrano
3
3
  # A whole capistrano/rake namespace, for grouping our helpers and tasks
4
4
  module Opscomplete
5
5
  def managed_ruby?
6
- test("[ -f #{rbenv_root_path}/.ruby_managed_by_makandra ]")
7
- end
8
-
9
- def rbenv_ruby_build_path
10
- "#{rbenv_root_path}/plugins/ruby-build"
11
- end
12
-
13
- def rbenv_repo_url
14
- 'https://github.com/rbenv/rbenv.git'
15
- end
16
-
17
- def ruby_build_repo_url
18
- 'https://github.com/rbenv/ruby-build.git'
6
+ test(:ruby_update_management_tool, 'managed')
19
7
  end
20
8
 
21
9
  def app_ruby_version
@@ -64,57 +52,40 @@ module Capistrano
64
52
  end
65
53
  end
66
54
 
67
- def rbenv_installable_rubies
68
- rbenv_installable_rubies = capture(:rbenv, :install, '--list-all').split("\n")
69
- rbenv_installable_rubies.map!(&:strip)
70
- rbenv_installable_rubies.delete('Available version:')
71
- rbenv_installable_rubies
55
+ def ruby_installable_versions
56
+ ruby_installable_versions = capture(:ruby_installable_versions).split("\n")
57
+ ruby_installable_versions.map!(&:strip)
58
+ ruby_installable_versions
72
59
  end
73
60
 
74
- def rbenv_root_path
75
- capture(:rbenv, :root)
76
- end
77
-
78
- def rbenv_installed_rubies
79
- if test("[ -d #{rbenv_root_path}/versions ]")
80
- rbenv_installed_rubies = capture(:ls, '-1', "#{rbenv_root_path}/versions").split("\n")
81
- rbenv_installed_rubies.map!(&:strip)
82
- else
83
- warn("Could not look up installed versions from missing '.rbenv/versions' directory. This is probably the first ruby install for this rbenv.")
84
- []
85
- end
86
- end
87
-
88
- def rbenv_exec(*args)
89
- execute(:rbenv, :exec, *args)
61
+ def ruby_installed_versions
62
+ ruby_installed_versions = capture(:ruby_installed_versions).split("\n")
63
+ ruby_installed_versions.map!(&:strip)
64
+ warn('Could not look up installed versions. This is probably the first ruby install.') if ruby_installed_versions.empty?
65
+ ruby_installed_versions
90
66
  end
91
67
 
92
68
  def gem_installed?(name, version = nil)
93
69
  if version
94
- test(:rbenv, :exec, "gem query --quiet --installed --version '#{version}' --name-matches '^#{name}$'")
70
+ test(:ruby_installed_gem, name, '--version', "'#{version}'")
95
71
  else
96
- test(:rbenv, :exec, :gem, :query, "--quiet --installed --name-matches ^#{name}$")
72
+ test(:ruby_installed_gem, name)
97
73
  end
98
74
  end
99
75
 
100
76
  def gem_install(name, version = nil, force = false)
101
77
  if version
102
- rbenv_exec('gem install', name, '--no-document', '--version', "'#{version}'", force ? '--force' : '')
78
+ execute(:ruby_install_gem, name, '--version', "'#{version}'", force ? '--force' : '')
103
79
  else
104
- rbenv_exec('gem install', name, '--no-document')
80
+ execute(:ruby_install_gem, name)
105
81
  end
106
82
  end
107
83
 
108
- def rubygems_install(version)
109
- rbenv_exec("gem update --no-document --system '#{version}'")
110
- end
111
-
112
84
  def managed_nodejs?
113
- test("[ -f ${HOME}/.nodejs_managed_by_makandra ]")
85
+ test('[ -f ${HOME}/.nodejs_managed_by_makandra ]')
114
86
  end
115
87
 
116
88
  def app_nodejs_version
117
-
118
89
  # 1) Get version from capistrano configuration (highest precedence, 'override')
119
90
  if fetch(:opscomplete_nodejs_version)
120
91
  debug("Using version from :opscomplete_nodejs_version setting: #{fetch(:opscomplete_nodejs_version)}.")
@@ -140,6 +111,10 @@ module Capistrano
140
111
  nodejs_installed_versions = capture(:nodejs_installed_versions).split("\n")
141
112
  nodejs_installed_versions.map!(&:strip)
142
113
  end
114
+
115
+ def validation_error!(message)
116
+ raise Capistrano::ValidationError, message unless dry_run?
117
+ end
143
118
  end
144
119
  end
145
120
  end
@@ -14,8 +14,7 @@ namespace :opscomplete do
14
14
  on roles fetch(:nodejs_roles, :all) do |host|
15
15
  warn("#{host}: Managed Node.js environment! Won't do any changes to nodejs version.") if managed_nodejs?
16
16
  unless capture(:nodejs_get_version, release_path) == app_nodejs_version
17
- raise Capistrano::ValidationError,
18
- "#{host}: Node.js version is not set according to application\'s .node-version or .nvmrc file. Use cap opscomplete:nodejs:ensure."
17
+ validation_error!("#{host}: Node.js version is not set according to application\'s .node-version or .nvmrc file. Use cap opscomplete:nodejs:ensure.")
19
18
  end
20
19
  info("#{host}: Node.js #{app_nodejs_version} is installed.")
21
20
  end
@@ -33,7 +32,7 @@ namespace :opscomplete do
33
32
  invoke('opscomplete:nodejs:update_nodejs_build')
34
33
  on roles fetch(:nodejs_roles, :all) do |host|
35
34
  if managed_nodejs?
36
- raise Capistrano::ValidationError, "#{host}: Managed Node.js environment! Won't do any changes to Node.js version."
35
+ validation_error!("#{host}: Managed Node.js environment! Won't do any changes to Node.js version.")
37
36
  end
38
37
  if nodejs_installed_versions.include?(app_nodejs_version)
39
38
  info("#{host}: Node.js #{app_nodejs_version} is installed.")
@@ -43,10 +42,11 @@ namespace :opscomplete do
43
42
  execute(:nodejs_install_version, "'#{app_nodejs_version}'")
44
43
  end
45
44
  else
46
- info("#{host}: Check if the configured Node.js version is part of the installable versions")
47
- execute :nodejs_installable_versions
48
- raise Capistrano::ValidationError,
49
- "#{host}: Configured Node.js version is neither installed nor installable."
45
+ error("#{host}: Check if the configured Node.js version: #{app_nodejs_version} is not an installable version")
46
+ info("These are the ten latest versions:")
47
+ info(nodejs_installable_versions.slice(-10,10).join(', '))
48
+
49
+ validation_error!("#{host}: Configured Node.js version: #{app_nodejs_version} is not installable.")
50
50
  end
51
51
  execute(:nodejs_set_version, "'#{app_nodejs_version}'")
52
52
  end
@@ -9,80 +9,69 @@ namespace :opscomplete do
9
9
  end
10
10
 
11
11
  namespace :ruby do
12
- # desc 'Rehash rbenv shims (run this after installing executables).'
13
- task :rehash do
14
- on roles fetch(:rbenv_roles, :all) do
15
- execute(:rbenv, :rehash)
16
- end
17
- end
18
-
19
- desc 'Check if rbenv global Ruby version is set according to application\'s .ruby-version.'
12
+ desc 'Check if Ruby version is set according to application\'s .ruby-version.'
20
13
  task :check do
21
14
  on roles fetch(:rbenv_roles, :all) do |host|
22
15
  warn("#{host}: Managed Ruby environment! Won't do any changes to ruby version.") if managed_ruby?
23
- unless capture(:rbenv, :global) == app_ruby_version
24
- raise Capistrano::ValidationError,
25
- "#{host}: Ruby version is not set according to application\'s .ruby-version file. Use cap opscomplete:ruby:ensure."
16
+ unless capture(:ruby_get_current_version) == app_ruby_version
17
+ validation_error!("#{host}: Ruby version is not set according to application\'s .ruby-version file. Use cap opscomplete:ruby:ensure.")
26
18
  end
27
19
  info("#{host}: Ruby #{app_ruby_version} is installed.")
28
20
  end
29
21
  end
30
22
 
31
- # desc 'Install rbenv plugin ruby-build'
23
+ desc 'Install Ruby version management tool dependencies'
32
24
  task :install_ruby_build do
33
25
  on roles fetch(:rbenv_roles, :all) do
34
- next if test "[ -d #{rbenv_ruby_build_path} ]"
35
- execute :git, :clone, ruby_build_repo_url, rbenv_ruby_build_path
26
+ execute(:ruby_update_management_tool, :install_build)
36
27
  end
37
28
  end
38
29
 
39
- # desc 'Update rbenv plugin ruby-build'
30
+ desc 'Update Ruby version management tool'
40
31
  task :update_ruby_build do
41
32
  on roles fetch(:rbenv_roles, :all) do
42
- if test "[ -d #{rbenv_ruby_build_path} ]"
43
- within rbenv_ruby_build_path do
44
- execute :git, :pull, '-q'
45
- end
46
- else
47
- warn('Could not find ruby-build.')
48
- end
33
+ execute(:ruby_update_management_tool, :update_build)
49
34
  end
50
35
  end
51
36
 
52
- # desc 'Install bundler gem'
37
+ desc 'Rehash shims (run this after installing executables).'
38
+ task :rehash do
39
+ on roles fetch(:rbenv_roles, :all) do
40
+ execute(:ruby_update_management_tool, :rehash)
41
+ end
42
+ end
43
+
44
+ desc 'Install bundler gem'
53
45
  task :install_bundler do
54
46
  on roles fetch(:rbenv_roles, :all) do
55
47
  # manually specified version will take precedence
56
48
  specific_bundler_version = fetch(:bundler_version, app_gemfile_bundled_with_version)
57
-
58
49
  if specific_bundler_version
59
50
  # We have to set force = true to overwrite the binary
60
51
  gem_install('bundler', specific_bundler_version, true) unless gem_installed?('bundler', specific_bundler_version)
61
52
  else
62
53
  gem_install('bundler') unless gem_installed?('bundler')
63
54
  end
64
- set :rbenv_needs_rehash, true
65
55
  end
66
56
  end
67
57
 
68
- # desc 'Install geordi gem'
58
+ desc 'Install geordi gem'
69
59
  task :install_geordi do
70
60
  on roles fetch(:rbenv_roles, :all) do
71
61
  gem_install('geordi') unless gem_installed?('geordi')
72
- set :rbenv_needs_rehash, true
73
62
  end
74
63
  end
75
64
 
65
+ desc 'Install RubyGems'
76
66
  task :install_rubygems do
77
67
  on roles fetch(:rbenv_roles, :all) do
78
- # if no rubygems_version was set, we use and don't check the rubygems version installed by rbenv
68
+ # if no rubygems_version was set, we use and don't check the installed rubygems version
79
69
  if fetch(:rubygems_version, false)
80
- current_rubygems_version = capture(:rbenv, :exec, :gem, '--version').chomp
70
+ current_rubygems_version = capture(:ruby_get_current_version, :rubygems).chomp
81
71
  info("Ensuring requested RubyGems version #{fetch(:rubygems_version)}")
82
72
  next if current_rubygems_version == fetch(:rubygems_version)
83
73
  info("Previously installed RubyGems version was #{current_rubygems_version}")
84
- rbenv_exec(:gem, :update, '--no-document', '--system', "'#{fetch(:rubygems_version)}'")
85
- set :rbenv_needs_rehash, true
74
+ execute(:ruby_install_version, :rubygems, "'#{fetch(:rubygems_version)}'")
86
75
  end
87
76
  end
88
77
  end
@@ -92,29 +81,27 @@ namespace :opscomplete do
92
81
  invoke('opscomplete:ruby:update_ruby_build')
93
82
  on roles fetch(:rbenv_roles, :all) do |host|
94
83
  if managed_ruby?
95
- raise Capistrano::ValidationError, "#{host}: Managed Ruby environment! Won't do any changes to Ruby version."
84
+ validation_error!("#{host}: Managed Ruby environment! Won't do any changes to Ruby version.")
96
85
  end
97
- if rbenv_installed_rubies.include?(app_ruby_version)
86
+ if ruby_installed_versions.include?(app_ruby_version)
98
87
  info("#{host}: Ruby #{app_ruby_version} is installed.")
99
- elsif rbenv_installable_rubies.include?(app_ruby_version)
88
+ elsif ruby_installable_versions.include?(app_ruby_version)
100
89
  info("#{host}: Configured Ruby version is not installed, but available for installation.")
101
90
  with tmpdir: fetch(:tmp_dir) do
102
- execute(:rbenv, :install, "'#{app_ruby_version}'")
91
+ execute(:ruby_install_version, "'#{app_ruby_version}'")
103
92
  end
104
- set :rbenv_needs_rehash, true
105
93
  else
106
- raise Capistrano::ValidationError,
107
- "#{host}: Configured Ruby version is neither installed nor installable using ruby-install."
94
+ validation_error!("#{host}: Configured Ruby version is neither installed nor installable.")
108
95
  end
109
- unless capture(:rbenv, :global) == app_ruby_version
96
+ unless capture(:ruby_get_current_version) == app_ruby_version
110
97
  set :ruby_modified, true
111
- execute(:rbenv, :global, "'#{app_ruby_version}'")
98
+ execute(:ruby_set_version, "'#{app_ruby_version}'")
112
99
  end
113
100
  end
114
101
  invoke('opscomplete:ruby:install_rubygems')
115
102
  invoke('opscomplete:ruby:install_bundler')
116
103
  invoke('opscomplete:ruby:install_geordi')
117
- invoke('opscomplete:ruby:rehash') if fetch(:rbenv_needs_rehash, false)
104
+ invoke('opscomplete:ruby:rehash')
118
105
  end
119
106
 
120
107
  desc 'resets the global ruby version and gems to Gemfile and .ruby-version in current_path.'
@@ -125,16 +112,14 @@ namespace :opscomplete do
125
112
  if test("[ -f #{current_ruby_version_file_path} ]")
126
113
  execute(:rbenv, :global, capture(:cat, current_ruby_version_file_path))
127
114
  else
128
- raise Capistrano::ValidationError,
129
- "#{host}: Missing .ruby-version in #{current_path}. Won't set a new global version."
115
+ validation_error!("#{host}: Missing .ruby-version in #{current_path}. Won't set a new global version.")
130
116
  end
131
117
  if test("[ -f '#{current_path}/.bundle/config' ]")
132
118
  debug("#{host}: Found #{current_path}/.bundle/config, running bundle pristine.")
133
119
  set :bundle_gemfile, -> { current_path.join('Gemfile') }
134
120
  execute(:bundle, :pristine)
135
121
  else
136
- raise Capistrano::ValidationError,
137
- "Unable to find #{current_path}/.bundle/config, won't run bundle pristine."
122
+ validation_error!("Unable to find #{current_path}/.bundle/config, won't run bundle pristine.")
138
123
  end
139
124
  end
140
125
  end
@@ -144,10 +129,10 @@ namespace :opscomplete do
144
129
  task :broken_gems_warning do
145
130
  on roles fetch(:rbenv_roles, :all) do |host|
146
131
  if fetch(:ruby_modified, false)
147
- warn("Deploy failed and the ruby version has been modified in this deploy.")
148
- warn("If this was a minor ruby version upgrade your running application may run into issues with native gem extensions.")
149
- warn("If your deploy failed before deploy:symlink:release you may run bundle exec `cap #{fetch(:stage)} opscomplete:ruby:reset`.")
150
- warn("Please refer https://makandracards.com/makandra/477884-bundler-in-deploy-mode-shares-gems-between-patch-level-ruby-versions")
132
+ warn('Deploy failed and the ruby version has been modified in this deploy.')
133
+ warn('If this was a minor ruby version upgrade your running application may run into issues with native gem extensions.')
134
+ warn("If your deploy failed before deploy:symlink:release you may run bundle exec 'cap #{fetch(:stage)} opscomplete:ruby:reset'.")
135
+ warn('Please refer https://makandracards.com/makandra/477884-bundler-in-deploy-mode-shares-gems-between-patch-level-ruby-versions')
151
136
  else
152
137
  debug("#{host}: Ruby not modified in current deploy.")
153
138
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Opscomplete
3
- VERSION = '0.6.7'.freeze
3
+ VERSION = '1.0.2'.freeze
4
4
  end
5
5
  end
@@ -6,4 +6,4 @@ require 'rake'
6
6
  load File.expand_path('opscomplete/ruby.rake', __dir__)
7
7
  load File.expand_path('opscomplete/nodejs.rake', __dir__)
8
8
  load File.expand_path('opscomplete/supervisor.rake', __dir__)
9
- load File.expand_path('../opscomplete/hooks.rb', __FILE__)
9
+ load File.expand_path('opscomplete/hooks.rb', __dir__)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-opscomplete
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makandra Operations
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-05 00:00:00.000000000 Z
11
+ date: 2022-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: makandra-rubocop
@@ -89,6 +89,7 @@ files:
89
89
  - bin/console
90
90
  - bin/setup
91
91
  - capistrano-opscomplete.gemspec
92
+ - gem_graph.png
92
93
  - lib/capistrano-opscomplete.rb
93
94
  - lib/capistrano/dsl/opscomplete.rb
94
95
  - lib/capistrano/opscomplete.rb