tomo 0.4.1 → 0.5.0
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 +4 -4
- data/README.md +2 -2
- data/lib/tomo/plugin/nodenv/tasks.rb +60 -0
- data/lib/tomo/plugin/nodenv.rb +13 -0
- data/lib/tomo/plugin/puma/tasks.rb +21 -4
- data/lib/tomo/plugin/puma.rb +3 -1
- data/lib/tomo/templates/config.rb.erb +9 -5
- data/lib/tomo/version.rb +1 -1
- metadata +4 -4
- data/lib/tomo/plugin/nvm/tasks.rb +0 -61
- data/lib/tomo/plugin/nvm.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43daca76a8f7fc58c99f3365f71d6ef1349643879d5237f9be63fcf956a1a238
|
4
|
+
data.tar.gz: 5a37ebc5429e0feb93fd2591fd268ee0544de08145a950d3f3f37bab50b9a58e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06f34c6c9d0ea370e6fc3cd1095874b53b423edae499b88f8ed7789ee308bbacd69324fadcab590b3e264ebdaf4093129708358744f6e9ded69ef7c7432b8c71
|
7
|
+
data.tar.gz: 605619d1fc09d99eee6c244adba219cd263c0b00d4975f06a3ea1110699a0a0f64cf5226be1a69ff80491906c9e51e35da2be2a8ef2fffc683b214ffee5fd770
|
data/README.md
CHANGED
@@ -169,12 +169,12 @@ Read the [Writing Custom Tasks](https://tomo-deploy.com/tutorials/writing-custom
|
|
169
169
|
- [bundler](https://tomo-deploy.com/plugins/bundler/)
|
170
170
|
- [env](https://tomo-deploy.com/plugins/env/)
|
171
171
|
- [git](https://tomo-deploy.com/plugins/git/)
|
172
|
-
- [
|
172
|
+
- [nodenv](https://tomo-deploy.com/plugins/nodenv/)
|
173
173
|
- [puma](https://tomo-deploy.com/plugins/puma/)
|
174
174
|
- [rails](https://tomo-deploy.com/plugins/rails/)
|
175
175
|
- [rbenv](https://tomo-deploy.com/plugins/rbenv/)
|
176
176
|
- Tutorials
|
177
|
-
- [Deploying Rails From Scratch](https://tomo-deploy.com/tutorials/deploying-rails-from-scratch/)
|
177
|
+
- [Deploying Rails From Scratch](https://tomo-deploy.com/tutorials/deploying-rails-from-scratch/)
|
178
178
|
- [Writing Custom Tasks](https://tomo-deploy.com/tutorials/writing-custom-tasks/)
|
179
179
|
- [Publishing a Plugin](https://tomo-deploy.com/tutorials/publishing-a-plugin/) [TODO]
|
180
180
|
- API
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "shellwords"
|
2
|
+
|
3
|
+
module Tomo::Plugin::Nodenv
|
4
|
+
class Tasks < Tomo::TaskLibrary
|
5
|
+
def install
|
6
|
+
run_installer
|
7
|
+
modify_bashrc
|
8
|
+
install_node
|
9
|
+
install_yarn
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def run_installer
|
15
|
+
install_url = "https://github.com/nodenv/nodenv-installer/raw/master/bin/nodenv-installer"
|
16
|
+
remote.env PATH: raw("$HOME/.nodenv/bin:$HOME/.nodenv/shims:$PATH") do
|
17
|
+
remote.run("curl -fsSL #{install_url.shellescape} | bash")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def modify_bashrc
|
22
|
+
existing_rc = remote.capture("cat", paths.bashrc, raise_on_error: false)
|
23
|
+
return if existing_rc.include?("nodenv init")
|
24
|
+
|
25
|
+
remote.write(text: <<~BASHRC + existing_rc, to: paths.bashrc)
|
26
|
+
if [ -d $HOME/.nodenv ]; then
|
27
|
+
export PATH="$HOME/.nodenv/bin:$PATH"
|
28
|
+
eval "$(nodenv init -)"
|
29
|
+
fi
|
30
|
+
BASHRC
|
31
|
+
end
|
32
|
+
|
33
|
+
def install_node
|
34
|
+
require_setting :nodenv_node_version
|
35
|
+
node_version = settings[:nodenv_node_version]
|
36
|
+
|
37
|
+
unless node_installed?(node_version)
|
38
|
+
remote.run "nodenv install #{node_version.shellescape}"
|
39
|
+
end
|
40
|
+
remote.run "nodenv global #{node_version.shellescape}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def install_yarn
|
44
|
+
version = settings[:nodenv_yarn_version]
|
45
|
+
return remote.run "npm i -g yarn@#{version.shellescape}" if version
|
46
|
+
|
47
|
+
logger.info "No :nodenv_yarn_version specified; "\
|
48
|
+
"skipping yarn installation."
|
49
|
+
end
|
50
|
+
|
51
|
+
def node_installed?(version)
|
52
|
+
versions = remote.capture("nodenv versions", raise_on_error: false)
|
53
|
+
if versions.include?(version)
|
54
|
+
logger.info("Node #{version} is already installed.")
|
55
|
+
return true
|
56
|
+
end
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -3,10 +3,8 @@ module Tomo::Plugin::Puma
|
|
3
3
|
def restart
|
4
4
|
return if try_restart
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
remote.bundle("exec", "puma", "--daemon", *control_options)
|
9
|
-
end
|
6
|
+
logger.info "Puma is not running. Starting it now."
|
7
|
+
start
|
10
8
|
end
|
11
9
|
|
12
10
|
private
|
@@ -26,6 +24,25 @@ module Tomo::Plugin::Puma
|
|
26
24
|
true
|
27
25
|
end
|
28
26
|
|
27
|
+
def start
|
28
|
+
require_settings :puma_stdout_path, :puma_stderr_path
|
29
|
+
|
30
|
+
ensure_output_directory
|
31
|
+
|
32
|
+
remote.chdir(paths.current) do
|
33
|
+
remote.bundle(
|
34
|
+
"exec", "puma", "--daemon", *control_options,
|
35
|
+
raw(">"), paths.puma_stdout,
|
36
|
+
raw("2>"), paths.puma_stderr
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def ensure_output_directory
|
42
|
+
dirs = [paths.puma_stdout, paths.puma_stderr].map(&:dirname).map(&:to_s)
|
43
|
+
remote.mkdir_p dirs.uniq
|
44
|
+
end
|
45
|
+
|
29
46
|
def control_options
|
30
47
|
require_settings :puma_control_token, :puma_control_url
|
31
48
|
|
data/lib/tomo/plugin/puma.rb
CHANGED
@@ -7,6 +7,8 @@ module Tomo::Plugin
|
|
7
7
|
tasks Tomo::Plugin::Puma::Tasks
|
8
8
|
|
9
9
|
defaults puma_control_token: "tomo",
|
10
|
-
puma_control_url: "tcp://127.0.0.1:9293"
|
10
|
+
puma_control_url: "tcp://127.0.0.1:9293",
|
11
|
+
puma_stderr_path: "%<shared_path>/log/puma.err",
|
12
|
+
puma_stdout_path: "%<shared_path>/log/puma.out"
|
11
13
|
end
|
12
14
|
end
|
@@ -2,7 +2,7 @@ plugin "git"
|
|
2
2
|
plugin "env"
|
3
3
|
plugin "bundler"
|
4
4
|
plugin "rails"
|
5
|
-
plugin "
|
5
|
+
plugin "nodenv"
|
6
6
|
plugin "puma"
|
7
7
|
plugin "rbenv"
|
8
8
|
plugin "./plugins/<%= app %>.rb"
|
@@ -11,9 +11,9 @@ host "user@hostname.or.ip.address"
|
|
11
11
|
|
12
12
|
set application: <%= app.inspect %>
|
13
13
|
set deploy_to: "/var/www/%<application>"
|
14
|
-
set nvm_node_version: <%= node_version&.inspect || "nil # FIXME" %>
|
15
|
-
set nvm_yarn_version: <%= yarn_version.inspect %>
|
16
14
|
set rbenv_ruby_version: <%= RUBY_VERSION.inspect %>
|
15
|
+
set nodenv_node_version: <%= node_version&.inspect || "nil # FIXME" %>
|
16
|
+
set nodenv_yarn_version: <%= yarn_version.inspect %>
|
17
17
|
set git_url: <%= git_origin_url&.inspect || "nil # FIXME" %>
|
18
18
|
set git_branch: "master"
|
19
19
|
set git_exclusions: %w[
|
@@ -22,8 +22,9 @@ set git_exclusions: %w[
|
|
22
22
|
test/
|
23
23
|
]
|
24
24
|
set env_vars: {
|
25
|
-
RAILS_ENV: "production",
|
26
25
|
RACK_ENV: "production",
|
26
|
+
RAILS_ENV: "production",
|
27
|
+
RAILS_SERVE_STATIC_FILES: "1",
|
27
28
|
DATABASE_URL: :prompt,
|
28
29
|
SECRET_KEY_BASE: :prompt
|
29
30
|
}
|
@@ -32,6 +33,9 @@ set linked_dirs: %w[
|
|
32
33
|
log
|
33
34
|
node_modules
|
34
35
|
public/assets
|
36
|
+
tmp/cache
|
37
|
+
tmp/pids
|
38
|
+
tmp/sockets
|
35
39
|
]
|
36
40
|
|
37
41
|
setup do
|
@@ -40,7 +44,7 @@ setup do
|
|
40
44
|
run "git:clone"
|
41
45
|
run "git:create_release"
|
42
46
|
run "core:symlink_shared"
|
43
|
-
run "
|
47
|
+
run "nodenv:install"
|
44
48
|
run "rbenv:install"
|
45
49
|
run "bundler:upgrade_bundler"
|
46
50
|
run "bundler:install"
|
data/lib/tomo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brictson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -218,8 +218,8 @@ files:
|
|
218
218
|
- lib/tomo/plugin/git.rb
|
219
219
|
- lib/tomo/plugin/git/helpers.rb
|
220
220
|
- lib/tomo/plugin/git/tasks.rb
|
221
|
-
- lib/tomo/plugin/
|
222
|
-
- lib/tomo/plugin/
|
221
|
+
- lib/tomo/plugin/nodenv.rb
|
222
|
+
- lib/tomo/plugin/nodenv/tasks.rb
|
223
223
|
- lib/tomo/plugin/puma.rb
|
224
224
|
- lib/tomo/plugin/puma/tasks.rb
|
225
225
|
- lib/tomo/plugin/rails.rb
|
@@ -1,61 +0,0 @@
|
|
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
|
data/lib/tomo/plugin/nvm.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require_relative "nvm/tasks"
|
2
|
-
|
3
|
-
module Tomo::Plugin
|
4
|
-
module Nvm
|
5
|
-
extend Tomo::PluginDSL
|
6
|
-
|
7
|
-
defaults bashrc_path: ".bashrc",
|
8
|
-
nvm_version: "0.34.0",
|
9
|
-
nvm_node_version: nil,
|
10
|
-
nvm_yarn_version: nil
|
11
|
-
|
12
|
-
tasks Tomo::Plugin::Nvm::Tasks
|
13
|
-
end
|
14
|
-
end
|