tomo 1.4.0 → 1.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e70a81efc32a7a80b37b26edc668de8daa510e7954884a3711d71ced6ef1bf8
4
- data.tar.gz: eef6788e4b36c1cdad66170b6b616af8a08f890bc089a6c70e6a12132a061911
3
+ metadata.gz: 431bd4cb252a935eb41e8b847e503ea681bc5dd633a3106f201758a2e45fffa1
4
+ data.tar.gz: 1e036f6ac85a2906cb3f7d8e6f39ea2edf434a6bf00d6124a7a9f8ca89d9d555
5
5
  SHA512:
6
- metadata.gz: 4425384a896b364775994859d7ea4307cac1abcbd507514d6f7289d6a684f6263cd7b17d250d280f6f2ccd596ed47f5d8f0871337dd5b69895aa74a0ea9c718e
7
- data.tar.gz: 57a0929d3e1be161c7830449226327ee1c4f0e20f4949658ec02287c436c4fbb12e8a7f819a4525266beb29a8abd6381285aae27e21b6e753ac27028783dca1f
6
+ metadata.gz: 8b11ac0a2cadff9fe301a56c2f3e9652f7ce4cc25ae9d59c8153ca342fb904510f1cd630cb6fd43565f198d9310e492689c9cb5c2a203b96ee253ea182b1a8f1
7
+ data.tar.gz: fcc17f36a7ae4555a31176607b3ae0a80e48842ae3473213ab511c25151c46d8b6458999468744d8a725c41ecc1585ad0b9f20b6651da68f31f5c6d4904bf5cb
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Matt Brictson
3
+ Copyright (c) 2021 Matt Brictson
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Tomo
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/tomo.svg)](https://rubygems.org/gems/tomo)
4
- [![Travis](https://img.shields.io/travis/mattbrictson/tomo.svg?label=travis)](https://travis-ci.org/mattbrictson/tomo)
5
4
  [![Circle](https://circleci.com/gh/mattbrictson/tomo/tree/main.svg?style=shield)](https://app.circleci.com/pipelines/github/mattbrictson/tomo?branch=main)
6
5
  [![Code Climate](https://codeclimate.com/github/mattbrictson/tomo/badges/gpa.svg)](https://codeclimate.com/github/mattbrictson/tomo)
7
6
 
@@ -78,7 +78,7 @@ module Tomo
78
78
  return [argv, []] if index == argv.length - 1 && Completions.active?
79
79
 
80
80
  before = argv[0...index]
81
- after = argv[(index + 1)..-1]
81
+ after = argv[(index + 1)..]
82
82
 
83
83
  [before, after]
84
84
  end
@@ -1,4 +1,5 @@
1
1
  require "erb"
2
+ require "fileutils"
2
3
 
3
4
  module Tomo
4
5
  module Commands
@@ -94,25 +95,19 @@ module Tomo
94
95
  File.exist?(".rubocop.yml")
95
96
  end
96
97
 
97
- def erb_2_2_or_later?
98
- erb_version = Gem::Version.new(ERB.version[/\d[\d.]+/])
99
- Gem::Requirement.new(">= 2.2").satisfied_by?(erb_version)
100
- end
98
+ # Does a .ruby-version file exist match the executing RUBY_VERSION?
99
+ def using_ruby_version_file?
100
+ return false unless File.exist?(".ruby-version")
101
101
 
102
- def ruby_version_file?
103
- File.exist?(".ruby-version")
102
+ IO.read(".ruby-version").rstrip == RUBY_VERSION
103
+ rescue IOError
104
+ false
104
105
  end
105
106
 
106
107
  def config_rb_template(app)
107
108
  path = File.expand_path("../templates/config.rb.erb", __dir__)
108
109
  template = IO.read(path)
109
-
110
- # TODO: remove once we drop Ruby 2.5 support?
111
- if erb_2_2_or_later?
112
- ERB.new(template, trim_mode: "-").result(binding)
113
- else
114
- ERB.new(template, nil, "-").result(binding)
115
- end
110
+ ERB.new(template, trim_mode: "-").result(binding)
116
111
  end
117
112
  end
118
113
  end
@@ -55,7 +55,7 @@ module Tomo
55
55
 
56
56
  def scan_for_plugins
57
57
  Gem.find_latest_files("#{PLUGIN_PREFIX}/*.rb").map do |file|
58
- file[%r{#{PLUGIN_PREFIX}/(.+).rb$}, 1].tr("/", "-")
58
+ file[%r{#{PLUGIN_PREFIX}/(.+).rb$}o, 1].tr("/", "-")
59
59
  end.uniq.sort
60
60
  end
61
61
  end
@@ -17,11 +17,22 @@ module Tomo
17
17
  private
18
18
 
19
19
  def gem_suggestion
20
- if Tomo.bundled?
21
- "\nYou may need to add #{yellow(gem_name)} to your Gemfile."
22
- else
23
- "\nYou may need to install the #{yellow(gem_name)} gem."
20
+ return "\nYou may need to add #{yellow(gem_name)} to your Gemfile." if Tomo.bundled?
21
+
22
+ messages = ["\nYou may need to install the #{yellow(gem_name)} gem."]
23
+ if present_in_gemfile?
24
+ messages << "\nTry prefixing the tomo command with #{blue('bundle exec')} to fix this error."
24
25
  end
26
+
27
+ messages.join
28
+ end
29
+
30
+ def present_in_gemfile?
31
+ return false unless File.file?("Gemfile")
32
+
33
+ IO.read("Gemfile").match?(/^\s*gem ['"]#{Regexp.quote(gem_name)}['"]/)
34
+ rescue IOError
35
+ false
25
36
  end
26
37
  end
27
38
  end
@@ -11,15 +11,13 @@ module Tomo
11
11
  end
12
12
 
13
13
  def to_a
14
- @_suggestions ||= begin
15
- if defined?(DidYouMean::SpellChecker)
16
- checker = DidYouMean::SpellChecker.new(dictionary: dictionary)
17
- suggestions = checker.correct(word)
18
- suggestions || []
19
- else
20
- []
21
- end
22
- end
14
+ @_suggestions ||= if defined?(DidYouMean::SpellChecker)
15
+ checker = DidYouMean::SpellChecker.new(dictionary: dictionary)
16
+ suggestions = checker.correct(word)
17
+ suggestions || []
18
+ else
19
+ []
20
+ end
23
21
  end
24
22
 
25
23
  def to_console
@@ -11,7 +11,7 @@ module Tomo::Plugin
11
11
  defaults bundler_config_path: ".bundle/config",
12
12
  bundler_deployment: true,
13
13
  bundler_gemfile: nil,
14
- bundler_jobs: "4",
14
+ bundler_jobs: nil,
15
15
  bundler_path: "%{shared_path}/bundle",
16
16
  bundler_retry: "3",
17
17
  bundler_version: nil,
@@ -21,7 +21,7 @@ module Tomo::Plugin
21
21
  releases_path: "%{deploy_to}/releases",
22
22
  revision_log_path: "%{deploy_to}/revisions.log",
23
23
  shared_path: "%{deploy_to}/shared",
24
- tmp_path: "/tmp/tomo",
24
+ tmp_path: "/tmp/tomo-#{SecureRandom.alphanumeric(8)}",
25
25
  tomo_config_file_path: nil, # determined at runtime
26
26
  run_args: [] # determined at runtime
27
27
  )
@@ -41,7 +41,7 @@ module Tomo::Plugin::Core
41
41
  current = read_current_release
42
42
 
43
43
  remote.chdir(paths.releases) do
44
- releases = remote.list_files.grep(/^#{RELEASE_REGEXP}$/).sort
44
+ releases = remote.list_files.grep(/^#{RELEASE_REGEXP}$/o).sort
45
45
  desired_count -= 1 if releases.delete(current)
46
46
  return if releases.length <= desired_count
47
47
 
@@ -122,7 +122,7 @@ module Tomo::Plugin::Core
122
122
  result = remote.run("readlink", paths.current, raise_on_error: false, silent: true)
123
123
  return nil if result.failure?
124
124
 
125
- result.stdout.strip[%r{/(#{RELEASE_REGEXP})$}, 1]
125
+ result.stdout.strip[%r{/(#{RELEASE_REGEXP})$}o, 1]
126
126
  end
127
127
  end
128
128
  end
@@ -38,6 +38,10 @@ module Tomo::Plugin::Puma
38
38
  remote.attach "journalctl", "-q", raw("--user-unit=#{service.name.shellescape}"), *settings[:run_args]
39
39
  end
40
40
 
41
+ def tail_log
42
+ remote.attach "journalctl -q --user-unit=#{service.name.shellescape} -f"
43
+ end
44
+
41
45
  private
42
46
 
43
47
  def port
@@ -60,6 +60,8 @@ module Tomo::Plugin::Rbenv
60
60
  version = remote.capture("cat", path, raise_on_error: false).strip
61
61
  return version unless version.empty?
62
62
 
63
+ return RUBY_VERSION if dry_run?
64
+
63
65
  die <<~REASON
64
66
  Could not guess ruby version from .ruby-version file.
65
67
  Use the :rbenv_ruby_version setting to specify the version of ruby to install.
@@ -29,7 +29,7 @@ module Tomo
29
29
  private
30
30
 
31
31
  def slice(*keys)
32
- Hash[keys.map { |key| [key, fiber_locals[key]] }]
32
+ keys.map { |key| [key, fiber_locals[key]] }.to_h
33
33
  end
34
34
 
35
35
  def fiber_locals
@@ -10,7 +10,7 @@ module Tomo
10
10
  end
11
11
 
12
12
  def call
13
- hash = Hash[settings.keys.map { |name| [name, fetch(name)] }]
13
+ hash = settings.keys.map { |name| [name, fetch(name)] }.to_h
14
14
  dump_settings(hash) if Tomo.debug?
15
15
  hash
16
16
  end
@@ -82,7 +82,7 @@ module Tomo
82
82
  end
83
83
 
84
84
  def export_env
85
- exports = @env.reject { |_, value| value.nil? }
85
+ exports = @env.compact
86
86
  return if exports.empty?
87
87
 
88
88
  [
@@ -14,7 +14,7 @@ host "user@hostname.or.ip.address"
14
14
 
15
15
  set application: <%= app.inspect %>
16
16
  set deploy_to: "/var/www/%{application}"
17
- <% unless ruby_version_file? -%>
17
+ <% unless using_ruby_version_file? -%>
18
18
  set rbenv_ruby_version: <%= RUBY_VERSION.inspect %>
19
19
  <% end -%>
20
20
  set nodenv_node_version: <%= node_version&.inspect || "nil # FIXME" %>
@@ -113,9 +113,7 @@ module Tomo
113
113
  end
114
114
 
115
115
  def build_dir
116
- @_build_dir ||= begin
117
- File.join(Dir.tmpdir, "tomo_docker_#{SecureRandom.hex(8)}")
118
- end
116
+ @_build_dir ||= File.join(Dir.tmpdir, "tomo_docker_#{SecureRandom.hex(8)}")
119
117
  end
120
118
  end
121
119
  end
@@ -165,7 +165,7 @@ class Service < Unit
165
165
  end
166
166
 
167
167
  def parse
168
- config = Hash[spec.scan(/^([^\s=]+)=\s*(\S.*?)\s*$/)]
168
+ config = spec.scan(/^([^\s=]+)=\s*(\S.*?)\s*$/).to_h
169
169
  working_dir = config["WorkingDirectory"] || File.expand_path("~")
170
170
  executable = config.fetch("ExecStart") do
171
171
  raise "#{name} is missing ExecStart attribute"
data/lib/tomo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tomo
2
- VERSION = "1.4.0".freeze
2
+ VERSION = "1.8.0".freeze
3
3
  end
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: 1.4.0
4
+ version: 1.8.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: 2020-10-28 00:00:00.000000000 Z
11
+ date: 2021-04-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Tomo is a feature-rich deployment tool that contains everything you need
14
14
  to deploy a basic Rails app out of the box. It has an opinionated, production-tested
@@ -181,14 +181,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
181
  requirements:
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
- version: 2.5.0
184
+ version: 2.6.0
185
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  requirements:
187
187
  - - ">="
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  requirements: []
191
- rubygems_version: 3.1.4
191
+ rubygems_version: 3.2.15
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: A friendly CLI for deploying Rails apps ✨