capistrano-asdf 0.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +18 -0
- data/capistrano-asdf.gemspec +1 -1
- data/lib/capistrano/tasks/asdf.rake +68 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 277839d3d4ad728956156c2fec0afbcfdf73a755eaa2541aa17a467b98c01a3a
|
4
|
+
data.tar.gz: 2d8325ebea40c7a07c3fdf45769dd5ca8100f48843bb571ba2bd902dae377286
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce2a4e798d087ddcfda6755ab8e8ec22fbdee55d3449283c5030d468b2e910d0d81966601eb0ec16e6d8f4438ea8860907d09964b3c5859e550fdde00fe853ef
|
7
|
+
data.tar.gz: 9d9d82d1d05ad8f3211a3d1bee0adde946990ecd4e0bca2fffdc17b7d60ada50e14202275c63ca21c7afaa1b3b13419d4efb16d2d05b8d1b5699daddc1de9715
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.1.0
|
2
|
+
|
3
|
+
Upload and use an ASDF wrapper to fully load ASDF environnement before executing commands.
|
4
|
+
The wrapper is generated in `<shared_path>/asdf-wrapper` by default, but can be generated elsewhere by setting `:asdf_custom_wrapper_path` capistrano variable.
|
5
|
+
|
6
|
+
## 1.0.0
|
7
|
+
|
8
|
+
Add asdf:install and asdf:add_plugins tasks
|
9
|
+
|
1
10
|
## 0.0.3
|
2
11
|
|
3
12
|
Add some configuration options:
|
data/README.md
CHANGED
@@ -84,6 +84,24 @@ This gem adds new tasks `asdf:map_*` before `deploy` task.
|
|
84
84
|
It loads the ASDF tools environment for capistrano when it wants to run
|
85
85
|
some tools related programs like `rake`, `gem`, `bundle`, `node`, `npm` ...
|
86
86
|
|
87
|
+
## Generate and upload the ASDF commands wrapper
|
88
|
+
|
89
|
+
The ASDF wrapper is needed to correctly run the mapped commands.
|
90
|
+
Since the wrapper is an executable script, it can be used in Systemd units.
|
91
|
+
|
92
|
+
$ cap production asdf:upload_wrapper
|
93
|
+
|
94
|
+
This task is automaticaly called before `asdf:check`
|
95
|
+
|
96
|
+
## Install required tools
|
97
|
+
|
98
|
+
If you want your tools (ruby, nodejs) to be installed, you can use the `asdf:install` task to
|
99
|
+
preform plugins add and then install of required versions from your `.tool-versions`.
|
100
|
+
`asdf:install` will automaticaly add necessary plugins running `asdf:add_plugins`.
|
101
|
+
If you want to change the plugins to install you may set `:asdf_tools` accordingly.
|
102
|
+
|
103
|
+
$ cap production asdf:install
|
104
|
+
|
87
105
|
## Check your configuration
|
88
106
|
|
89
107
|
If you want to check your configuration you can use the `asdf:check` task to
|
data/capistrano-asdf.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "capistrano-asdf"
|
7
|
-
gem.version = '
|
7
|
+
gem.version = '1.1.0'
|
8
8
|
gem.licenses = ['MIT']
|
9
9
|
gem.authors = ["Jean-Baptiste Poix"]
|
10
10
|
gem.email = ["jbpoix@inosophia.com"]
|
@@ -5,18 +5,75 @@ ASDF_DEFAULT_RUBY_BINS = %w{rake gem bundle ruby rails}
|
|
5
5
|
# Nodejs related bin
|
6
6
|
ASDF_DEFAULT_NODEJS_BINS = %w{node npm yarn}
|
7
7
|
|
8
|
+
ASDF_DEFAULT_WRAPPER_TEMPALTES = %{
|
9
|
+
#!/usr/bin/env bash
|
10
|
+
|
11
|
+
. @@ASDF_USER_PATH@@/asdf.sh
|
12
|
+
exec "$@"
|
13
|
+
}
|
14
|
+
|
8
15
|
namespace :asdf do
|
16
|
+
desc "Upload ASDF wrapper to the target host"
|
17
|
+
task :upload_wrapper do
|
18
|
+
on roles(fetch(:asdf_roles, :all)) do
|
19
|
+
wrapper_content = ASDF_DEFAULT_WRAPPER_TEMPALTES.gsub('@@ASDF_USER_PATH@@', fetch(:asdf_path))
|
20
|
+
need_to_upload_wrapper = true
|
21
|
+
# Check if the wrapper already exists
|
22
|
+
if test("[ -f #{fetch(:asdf_wrapper_path)} ]")
|
23
|
+
# Check if md5sum is available on the target host
|
24
|
+
if test("which md5sum")
|
25
|
+
else
|
26
|
+
info "md5sum is not available on the target host, we can't check the wrapper integrity"
|
27
|
+
need_to_upload_wrapper = false
|
28
|
+
end
|
29
|
+
# Check if the wrapper is the same as the one we want to upload using a md5 checksum
|
30
|
+
if capture("md5sum #{fetch(:asdf_wrapper_path)}").split.first == Digest::MD5.hexdigest(wrapper_content)
|
31
|
+
need_to_upload_wrapper = false
|
32
|
+
else
|
33
|
+
info "ASDF wrapper already exists on the target host but is different from the one we want to upload"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
if need_to_upload_wrapper
|
37
|
+
upload! StringIO.new(wrapper_content), "#{fetch(:asdf_wrapper_path)}"
|
38
|
+
execute("chmod +x #{fetch(:asdf_wrapper_path)}")
|
39
|
+
else
|
40
|
+
info "ASDF wrapper already exists on the target host"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
9
45
|
desc "Prints the ASDF tools versions on the target host"
|
10
46
|
task :check do
|
11
47
|
on roles(fetch(:asdf_roles, :all)) do
|
12
|
-
execute("
|
48
|
+
execute("#{fetch(:asdf_wrapper_path)} asdf current")
|
13
49
|
end
|
14
50
|
end
|
15
|
-
|
51
|
+
|
52
|
+
desc "Install ASDF tools versions based on the .tool-versions of your project"
|
53
|
+
task :install do
|
54
|
+
on roles(fetch(:asdf_roles, :all)) do
|
55
|
+
execute("#{fetch(:asdf_wrapper_path)} asdf install")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Add ASDF plugins specified in :asdf_tools"
|
60
|
+
task :add_plugins do
|
61
|
+
on roles(fetch(:asdf_roles, :all)) do
|
62
|
+
already_installed_plugins = capture("#{fetch(:asdf_wrapper_path)} asdf plugin list")&.split
|
63
|
+
fetch(:asdf_tools)&.each do |asdf_tool|
|
64
|
+
if already_installed_plugins.include?(asdf_tool)
|
65
|
+
info "#{asdf_tool} Already installed"
|
66
|
+
else
|
67
|
+
execute("#{fetch(:asdf_wrapper_path)} asdf plugin add #{asdf_tool}")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
16
73
|
task :map_ruby_bins do
|
17
74
|
if fetch(:asdf_tools).include?('ruby')
|
18
75
|
fetch(:asdf_map_ruby_bins).each do |mapped_command|
|
19
|
-
SSHKit.config.command_map.prefix[mapped_command.to_sym].unshift("
|
76
|
+
SSHKit.config.command_map.prefix[mapped_command.to_sym].unshift("#{fetch(:asdf_wrapper_path)}")
|
20
77
|
end
|
21
78
|
end
|
22
79
|
end
|
@@ -24,13 +81,17 @@ namespace :asdf do
|
|
24
81
|
task :map_nodejs_bins do
|
25
82
|
if fetch(:asdf_tools).include?('nodejs')
|
26
83
|
fetch(:asdf_map_nodejs_bins).each do |mapped_command|
|
27
|
-
SSHKit.config.command_map.prefix[mapped_command.to_sym].unshift("
|
84
|
+
SSHKit.config.command_map.prefix[mapped_command.to_sym].unshift("#{fetch(:asdf_wrapper_path)}")
|
28
85
|
end
|
29
86
|
end
|
30
87
|
end
|
31
88
|
|
32
89
|
end
|
33
90
|
|
91
|
+
before 'asdf:install', 'asdf:add_plugins'
|
92
|
+
after 'deploy:check', 'asdf:check'
|
93
|
+
before 'asdf:check', 'asdf:upload_wrapper'
|
94
|
+
|
34
95
|
Capistrano::DSL.stages.each do |stage|
|
35
96
|
after stage, 'asdf:map_ruby_bins'
|
36
97
|
after stage, 'asdf:map_nodejs_bins'
|
@@ -42,6 +103,9 @@ namespace :load do
|
|
42
103
|
asdf_path = fetch(:asdf_custom_path)
|
43
104
|
asdf_path ||= ASDF_USER_PATH
|
44
105
|
}
|
106
|
+
set :asdf_wrapper_path, -> {
|
107
|
+
fetch(:asdf_custom_wrapper_path) || "#{shared_path}/asdf-wrapper"
|
108
|
+
}
|
45
109
|
|
46
110
|
set :asdf_tools, fetch(:asdf_tools, ASDF_DEFAULT_TOOLS)
|
47
111
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-asdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Baptiste Poix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.7.
|
78
|
+
rubygems_version: 2.7.6
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: ASDF integration for Capistrano
|