tomo-plugin-nvm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 057132602164a73e3a455d838272a51cf9b68cc24359a893fd630678b92dca7d
4
+ data.tar.gz: c334cbe6963109da02a5e5abed98eba3fcdbebd6e7fae2e166a6a7b65335504c
5
+ SHA512:
6
+ metadata.gz: f542e37a63471d6807903a704f210efd339478992104a54449f0931b3048ab6b6587bbced4c4107fa238ba8919c66f1bbb3367afb232a3fd38d95d3c9b73ac26
7
+ data.tar.gz: ccfcd1847db29268bb70e6f6ede6f7165ce8b08a5ea26f4bba7da349378a99c358466e8f0120dc2f9684c0b06150c6f400d9bc94a175c0966de997685c1f9be9
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Matt Brictson
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.
@@ -0,0 +1,79 @@
1
+ # tomo-plugin-nvm
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/tomo-plugin-nvm.svg)](https://rubygems.org/gems/tomo-plugin-nvm)
4
+ [![Travis](https://img.shields.io/travis/mattbrictson/tomo-plugin-nvm.svg?label=travis)](https://travis-ci.org/mattbrictson/tomo-plugin-nvm)
5
+ [![Circle](https://circleci.com/gh/mattbrictson/tomo-plugin-nvm.svg?style=shield)](https://circleci.com/gh/mattbrictson/tomo-plugin-nvm)
6
+ [![Code Climate](https://codeclimate.com/github/mattbrictson/tomo-plugin-nvm/badges/gpa.svg)](https://codeclimate.com/github/mattbrictson/tomo-plugin-nvm)
7
+
8
+ This is a [tomo](https://github.com/mattbrictson/tomo) plugin to manage node and yarn via nvm (instead of using the [nodenv tasks](https://tomo-deploy.com/plugins/nodenv/) that are built into tomo).
9
+
10
+ ---
11
+
12
+ - [Installation](#installation)
13
+ - [Support](#support)
14
+ - [License](#license)
15
+ - [Code of conduct](#code-of-conduct)
16
+ - [Contribution guide](#contribution-guide)
17
+
18
+ ## Installation
19
+
20
+ Run:
21
+
22
+ ```
23
+ $ gem install tomo-plugin-nvm
24
+ ```
25
+
26
+ Or add it to your Gemfile:
27
+
28
+ ```ruby
29
+ gem "tomo-plugin-nvm"
30
+ ```
31
+
32
+ Then add the following to `.tomo/config.rb`:
33
+
34
+ ```ruby
35
+ plugin "nvm"
36
+
37
+ set nvm_node_version: "10.16.0" # required
38
+ set nvm_yarn_version: "1.16.0" # optional
39
+
40
+ setup do
41
+ # Place this task before any steps that require node/yarn
42
+ run "nvm:install"
43
+ end
44
+ ```
45
+
46
+ ## Settings
47
+
48
+ | Name | Purpose | Default |
49
+ | ------------------ | -------------------------------------------- | ----------- |
50
+ | `bashrc_path` | Location of the deploy user’s `.bashrc` file | `".bashrc"` |
51
+ | `nvm_version` | Version of nvm to install | `"0.34.0"` |
52
+ | `nvm_node_version` | Version of node to install | `nil` |
53
+ | `nvm_yarn_version` | Version of yarn to install | `nil` |
54
+
55
+ ## Tasks
56
+
57
+ ### nvm:install
58
+
59
+ Installs nvm, uses nvm to install node, and makes the desired version of node the global default version for the deploy user. During installation, the user’s bashrc file is modified so that nvm is automatically loaded for interactive and non-interactive shells.
60
+
61
+ You must supply a value for the `nvm_node_version` setting for this task to work. If the `nvm_yarn_version` setting is specified, yarn is also installed globally via npm. This setting is optional.
62
+
63
+ `nvm:install` is intended for use as a [setup](https://tomo-deploy.com/commands/setup/) task.
64
+
65
+ ## Support
66
+
67
+ If you want to report a bug, or have ideas, feedback or questions about the gem, [let me know via GitHub issues](https://github.com/mattbrictson/tomo-plugin-nvm/issues/new) and I will do my best to provide a helpful answer. Happy hacking!
68
+
69
+ ## License
70
+
71
+ The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
72
+
73
+ ## Code of conduct
74
+
75
+ Everyone interacting in this project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
76
+
77
+ ## Contribution guide
78
+
79
+ Pull requests are welcome!
@@ -0,0 +1,16 @@
1
+ require "tomo"
2
+ require_relative "nvm/tasks"
3
+ require_relative "nvm/version"
4
+
5
+ module Tomo::Plugin
6
+ module Nvm
7
+ extend Tomo::PluginDSL
8
+
9
+ defaults bashrc_path: ".bashrc",
10
+ nvm_version: "0.34.0",
11
+ nvm_node_version: nil,
12
+ nvm_yarn_version: nil
13
+
14
+ tasks Tomo::Plugin::Nvm::Tasks
15
+ end
16
+ end
@@ -0,0 +1,61 @@
1
+ require "shellwords"
2
+
3
+ module Tomo::Plugin::Nvm
4
+ class Tasks < Tomo::TaskLibrary
5
+ def install
6
+ remote.mkdir_p raw("$HOME/.nvm")
7
+ modify_bashrc
8
+ run_installer
9
+ install_node
10
+ install_yarn
11
+ end
12
+
13
+ private
14
+
15
+ def run_installer
16
+ require_setting :nvm_version
17
+
18
+ nvm_version = settings[:nvm_version]
19
+ install_url = "https://raw.githubusercontent.com/creationix/nvm/"\
20
+ "v#{nvm_version}/install.sh"
21
+ remote.run("curl -o- #{install_url.shellescape} | bash")
22
+ end
23
+
24
+ def modify_bashrc
25
+ existing_rc = remote.capture("cat", paths.bashrc, raise_on_error: false)
26
+ return if existing_rc.include?("nvm.sh")
27
+
28
+ remote.write(text: <<~BASHRC + existing_rc, to: paths.bashrc)
29
+ export NVM_DIR="$HOME/.nvm"
30
+ [ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh"
31
+
32
+ BASHRC
33
+ end
34
+
35
+ def install_node
36
+ require_setting :nvm_node_version
37
+ node_version = settings[:nvm_node_version]
38
+
39
+ unless node_installed?(node_version)
40
+ remote.run "nvm", "install", node_version
41
+ end
42
+ remote.run "nvm", "alias", "default", node_version
43
+ end
44
+
45
+ def install_yarn
46
+ version = settings[:nvm_yarn_version]
47
+ return remote.run "npm i -g yarn@#{version.shellescape}" if version
48
+
49
+ logger.info "No :nvm_yarn_version specified; skipping yarn installation."
50
+ end
51
+
52
+ def node_installed?(version)
53
+ versions = remote.capture("nvm ls", raise_on_error: false)
54
+ if versions.include?("v#{version}")
55
+ logger.info("Node #{version} is already installed.")
56
+ return true
57
+ end
58
+ false
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,7 @@
1
+ module Tomo
2
+ module Plugin
3
+ module Nvm
4
+ VERSION = "0.1.0".freeze
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tomo-plugin-nvm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Brictson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tomo
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-ci
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-reporters
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '12.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '12.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.71.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.71.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.4.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.4.0
125
+ description:
126
+ email:
127
+ - opensource@mattbrictson.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - LICENSE.txt
133
+ - README.md
134
+ - lib/tomo/plugin/nvm.rb
135
+ - lib/tomo/plugin/nvm/tasks.rb
136
+ - lib/tomo/plugin/nvm/version.rb
137
+ homepage: https://github.com/mattbrictson/tomo-plugin-nvm
138
+ licenses:
139
+ - MIT
140
+ metadata:
141
+ bug_tracker_uri: https://github.com/mattbrictson/tomo-plugin-nvm/issues
142
+ changelog_uri: https://github.com/mattbrictson/tomo-plugin-nvm/releases
143
+ source_code_uri: https://github.com/mattbrictson/tomo-plugin-nvm
144
+ homepage_uri: https://github.com/mattbrictson/tomo-plugin-nvm
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: 2.4.0
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubygems_version: 3.0.4
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: ''
164
+ test_files: []