capistrano-nvm-helper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c47e80a38392602cb78ab075dcc07095ca7f45420e322c0e08526cacad30ae04
4
+ data.tar.gz: 15c526f08d15386418af4d82a8de69c40ed8fa06222a2198350b9aa7b31afe33
5
+ SHA512:
6
+ metadata.gz: 59de74d2eb5d1d793de3e4a333e11819907a6a7c1ba1917608c0dd9af4e053fcb596d11870f83cb61f88d15e79b4a7b05a79e2ef379e17fdfd5d67380fe998f2
7
+ data.tar.gz: 3a343355a3e76518b4ebcd8089782acb6870fc2da642899fca5d80dffa85445ec58b0a0c7f55fb93e2aa1a8058c24cbe3b496d28d6ccac96dcd8c1017dd075d2
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Released]
2
+
3
+ ## [0.1.0] - 2023-10-26
4
+
5
+ - add NVM setup to Capistrano 3.x
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in capistrano-nvm-helper.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-nvm-helper (0.1.0)
5
+ capistrano (~> 3.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ airbrussh (1.5.0)
11
+ sshkit (>= 1.6.1, != 1.7.0)
12
+ capistrano (3.18.0)
13
+ airbrussh (>= 1.0.0)
14
+ i18n
15
+ rake (>= 10.0.0)
16
+ sshkit (>= 1.9.0)
17
+ concurrent-ruby (1.2.2)
18
+ i18n (1.14.1)
19
+ concurrent-ruby (~> 1.0)
20
+ net-scp (4.0.0)
21
+ net-ssh (>= 2.6.5, < 8.0.0)
22
+ net-ssh (7.2.0)
23
+ rake (13.0.6)
24
+ sshkit (1.21.5)
25
+ net-scp (>= 1.1.2)
26
+ net-ssh (>= 2.8.0)
27
+
28
+ PLATFORMS
29
+ x86_64-darwin-22
30
+
31
+ DEPENDENCIES
32
+ bundler
33
+ capistrano-nvm-helper!
34
+ rake
35
+
36
+ BUNDLED WITH
37
+ 2.3.9
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Encore Shao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Capistrano::Nvm::Helper
2
+
3
+ This gem provides idiomatic nvm support for Capistrano 3.x (and 3.x *only*).
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ $ bundle add capistrano-nvm-helper
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install capistrano-nvm-helper
14
+
15
+ ## Usage
16
+
17
+ Require in `Capfile` to use the default task:
18
+
19
+ ```ruby
20
+ require "capistrano/nvm-helper"
21
+ ```
22
+
23
+ Configurable options in `config/deploy.rb`:
24
+
25
+ ```ruby
26
+ set :nvm_type, :user # or :system
27
+ set :nvm_node, 'v14.16.1'
28
+
29
+ # in case you want to set nvm version from the file:
30
+ # set :nvm_node, File.read('.nvmrc').strip
31
+
32
+ set :nvm_prefix, "source #{fetch(:nvm_path)}/nvm.sh; "
33
+ set :nvm_map_bins, %w{rake gem bundle yarn rails}
34
+ ```
35
+
36
+ ## Rails
37
+
38
+ If you want to use nvm in your rails app deployment tasks (like `deploy:assets:precompile`), consider adding `rake` to `nvm_map_bins`.
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ekohe/capistrano-nvm-helper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ekohe/capistrano-nvm-helper/blob/main/CODE_OF_CONDUCT.md).
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
+
48
+ ## Code of Conduct
49
+
50
+ Everyone interacting in the Capistrano::Nvm::Helper project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ekohe/capistrano-nvm-helper/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/capistrano/nvm/helper/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "capistrano-nvm-helper"
7
+ spec.version = Capistrano::Nvm::Helper::VERSION
8
+ spec.authors = ["Encore Shao"]
9
+ spec.email = ["encore@ekohe.com"]
10
+
11
+ spec.summary = %q{NVM support for Capistrano 3.x}
12
+ spec.description = %q{NVM support for Capistrano 3.x}
13
+ spec.homepage = "https://github.com/ekohe/capistrano-nvm-helper"
14
+ spec.license = "MIT"
15
+
16
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/ekohe/capistrano-nvm-helper/CODE_OF_CONDUCT.md"
20
+ spec.metadata["changelog_uri"] = "https://github.com/ekohe/capistrano-nvm-helper/CHANGELOG.md"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency 'capistrano', '~> 3.1'
34
+
35
+ # For more information and examples about making a new gem, check out our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ spec.add_development_dependency 'bundler'
38
+ spec.add_development_dependency 'rake'
39
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Capistrano
4
+ module Nvm
5
+ module Helper
6
+ VERSION = "0.1.0"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "helper/version"
4
+
5
+ module Capistrano
6
+ module Nvm
7
+ module Helper
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ load File.expand_path("../tasks/nvm-helper.rake", __FILE__)
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :nvm do
4
+ task validate: :'nvm:wrapper' do
5
+ on release_roles(fetch(:nvm_roles)) do
6
+ nvm_node = fetch(:nvm_node)
7
+ if nvm_node.nil?
8
+ error "NVM: nvm_node is not set"
9
+ exit 1
10
+ end
11
+
12
+ nvm_node_path = fetch(:nvm_node_path)
13
+ nvm_node_path = [nvm_node_path] unless nvm_node_path.is_a?(Array)
14
+
15
+ unless test(nvm_node_path.map {|p| "[ -d #{p} ]" }.join(" || "))
16
+ error "NVM: #{nvm_node} is not installed or not found in any of #{nvm_node_path.join(" ")}"
17
+ exit 1
18
+ end
19
+ end
20
+ end
21
+
22
+ task :map_bins do
23
+ SSHKit.config.default_env.merge!({ node_version: "#{fetch(:nvm_node)}" })
24
+ nvm_prefix = fetch(:nvm_prefix, -> { "#{fetch(:nvm_exec_path)}" } )
25
+
26
+ fetch(:nvm_map_bins).each do |command|
27
+ SSHKit.config.command_map.prefix[command.to_sym].unshift(nvm_prefix)
28
+ end
29
+ end
30
+
31
+ task :wrapper do
32
+ on release_roles(fetch(:nvm_roles)) do
33
+ upload! StringIO.new(
34
+ "#!/bin/bash -e\nsource \"#{fetch(:nvm_path)}/nvm.sh\"\nnvm use $NODE_VERSION\nexec \"$@\""
35
+ ), "#{fetch(:nvm_exec_path)}"
36
+
37
+ execute :chmod, "+x", "#{fetch(:nvm_exec_path)}"
38
+ end
39
+ end
40
+ end
41
+
42
+ Capistrano::DSL.stages.each do |stage|
43
+ after stage, 'nvm:validate'
44
+ after stage, 'nvm:map_bins'
45
+ end
46
+
47
+ namespace :load do
48
+ task :defaults do
49
+ set :nvm_path, -> {
50
+ nvm_path = fetch(:nvm_custom_path)
51
+ nvm_path ||= if fetch(:nvm_type, :user) == :system
52
+ "/usr/local/nvm"
53
+ else
54
+ "$HOME/.nvm"
55
+ end
56
+ }
57
+
58
+ set :nvm_roles, fetch(:nvm_roles, :all)
59
+ set :nvm_node_path, -> {
60
+ [
61
+ "#{fetch(:nvm_path)}/#{fetch(:nvm_node)}",
62
+ "#{fetch(:nvm_path)}/versions/node/#{fetch(:nvm_node)}"
63
+ ]
64
+ }
65
+ set :nvm_map_bins, %w{node npm yarn}
66
+ set :nvm_exec_path, "#{fetch(:tmp_dir)}/nvm-exec-#{fetch(:application)}-#{fetch(:environment)}-#{fetch(:user)}.sh"
67
+ end
68
+ end
File without changes
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-nvm-helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Encore Shao
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: NVM support for Capistrano 3.x
56
+ email:
57
+ - encore@ekohe.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CHANGELOG.md
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - capistrano-nvm-helper.gemspec
69
+ - lib/capistrano-nvm-helper.rb
70
+ - lib/capistrano/nvm-helper.rb
71
+ - lib/capistrano/nvm/helper.rb
72
+ - lib/capistrano/nvm/helper/version.rb
73
+ - lib/capistrano/tasks/nvm-helper.rake
74
+ homepage: https://github.com/ekohe/capistrano-nvm-helper
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ homepage_uri: https://github.com/ekohe/capistrano-nvm-helper
79
+ source_code_uri: https://github.com/ekohe/capistrano-nvm-helper/CODE_OF_CONDUCT.md
80
+ changelog_uri: https://github.com/ekohe/capistrano-nvm-helper/CHANGELOG.md
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubygems_version: 3.1.6
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: NVM support for Capistrano 3.x
100
+ test_files: []