tomo 1.9.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b347feb8b896066cf3f8eaac7cf198ec33d6db5bc20cb38184d56663c598e5bb
4
- data.tar.gz: 0ba677e51d1801797e2a2606151a60e5d9efa83399e4e460c11d11e2266ef33f
3
+ metadata.gz: a949853f699c7d894efa675295a631ddb1ebd0ba04e900fa4efdea449d4288d7
4
+ data.tar.gz: 745d7827bcb35a468de96aadb74c0fdc7971074f82b5b3965a7f76e75962d19b
5
5
  SHA512:
6
- metadata.gz: 00f7909c1c5e127befd071815bd291737b7a20007f81fff555303f3f0bfeca39b64170249939f90605442c1f14f34b304c5ec2d464fa83f108fc14a0214bffb8
7
- data.tar.gz: f5e0b06636a553137f534a50efeb1b3165033e3099f646f40a597e7df9f6d07d3beb90716b712a0c20d364db7cfcf368e58fbafa0071185b3bbc68b75d7a1fbc
6
+ metadata.gz: b2b129d2422bf0e5fd22ed2d693d73bd7552d70f57fc2381206987fd69cbda811f1121304397a23a0a8db5ac26bb1c807a658506672bfa80ee765b5abd13103f
7
+ data.tar.gz: 2217e9de8c4f4445343297afc51c661a986d5cca5a61c718569efec1f23557200f4ab64585203a99380fa50373beeeec3ff772bc10d7d6d556e6a5867649e0d6
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Matt Brictson
3
+ Copyright (c) 2022 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
@@ -240,6 +240,10 @@ host "app2@example.com"
240
240
 
241
241
  Next run `tomo setup` for _both_ apps; this will set everything up for both users on the remote host (environment variables, rbenv, etc.). You can now deploy both apps to the same host, with the confidence that their configurations will be kept cleanly separated.
242
242
 
243
+ #### Does tomo support git submodules?
244
+
245
+ No, not out of the box. However, you can extend tomo with an additional task for submodules; see the solution in [PR #220](https://github.com/mattbrictson/tomo/pull/220#pullrequestreview-979249573) suggested by [@numbcoder](https://github.com/numbcoder).
246
+
243
247
  ## Support
244
248
 
245
249
  This project is a labor of love and I can only spend a few hours a week maintaining it, at most. If you'd like to help by submitting a pull request, or if you've discovered a bug that needs my attention, please let me know. Check out [CONTRIBUTING.md](https://github.com/mattbrictson/tomo/blob/main/CONTRIBUTING.md) to get started. Happy hacking! —Matt
@@ -35,7 +35,7 @@ module Tomo
35
35
  # TODO: use a template for this file
36
36
  FileUtils.touch(".tomo/plugins/#{app}.rb")
37
37
 
38
- IO.write(DEFAULT_CONFIG_PATH, config_rb_template(app))
38
+ File.write(DEFAULT_CONFIG_PATH, config_rb_template(app))
39
39
 
40
40
  logger.info(green("✔ Created #{DEFAULT_CONFIG_PATH}"))
41
41
  end
@@ -99,14 +99,24 @@ module Tomo
99
99
  def using_ruby_version_file?
100
100
  return false unless File.exist?(".ruby-version")
101
101
 
102
- IO.read(".ruby-version").rstrip == RUBY_VERSION
102
+ File.read(".ruby-version").rstrip == RUBY_VERSION
103
+ rescue IOError
104
+ false
105
+ end
106
+
107
+ # Does a .node-version file exist match `node --version`?
108
+ def using_node_version_file?
109
+ return false unless File.exist?(".node-version")
110
+
111
+ version = File.read(".node-version").rstrip
112
+ !version.empty? && version == node_version
103
113
  rescue IOError
104
114
  false
105
115
  end
106
116
 
107
117
  def config_rb_template(app)
108
118
  path = File.expand_path("../templates/config.rb.erb", __dir__)
109
- template = IO.read(path)
119
+ template = File.read(path)
110
120
  ERB.new(template, trim_mode: "-").result(binding)
111
121
  end
112
122
  end
@@ -13,7 +13,7 @@ module Tomo
13
13
  raise_file_not_found(path) unless File.file?(path)
14
14
 
15
15
  Tomo.logger.debug("Loading plugin from #{path.inspect}")
16
- script = IO.read(path)
16
+ script = File.read(path)
17
17
  plugin = define_anonymous_plugin_class
18
18
  plugin.class_eval(script, path.to_s, 1)
19
19
 
@@ -20,7 +20,7 @@ module Tomo
20
20
 
21
21
  def filter(tasks, host:)
22
22
  roles = host.roles
23
- roles = roles.empty? ? [""] : roles
23
+ roles = [""] if roles.empty?
24
24
  tasks.select do |task|
25
25
  roles.any? { |role| match?(task, role) }
26
26
  end
@@ -31,7 +31,7 @@ module Tomo
31
31
  attr_reader :globs
32
32
 
33
33
  def match?(task, role)
34
- task_globs = globs.keys.select { |glob| glob.match?(task) }
34
+ task_globs = globs.keys.select { |glob| glob.match?(task) } # rubocop:disable Style/SelectByRegexp
35
35
  return true if task_globs.empty?
36
36
 
37
37
  roles = globs.values_at(*task_globs).flatten
@@ -30,7 +30,7 @@ module Tomo
30
30
  def present_in_gemfile?
31
31
  return false unless File.file?("Gemfile")
32
32
 
33
- IO.read("Gemfile").match?(/^\s*gem ['"]#{Regexp.quote(gem_name)}['"]/)
33
+ File.read("Gemfile").match?(/^\s*gem ['"]#{Regexp.quote(gem_name)}['"]/)
34
34
  rescue IOError
35
35
  false
36
36
  end
@@ -14,7 +14,7 @@ module Tomo
14
14
  def self.from_config_rb(path=DEFAULT_CONFIG_PATH)
15
15
  ProjectNotFoundError.raise_with(path: path) unless File.file?(path)
16
16
  Tomo.logger.debug("Loading configuration from #{path.inspect}")
17
- config_rb = IO.read(path)
17
+ config_rb = File.read(path)
18
18
 
19
19
  new.tap do |config|
20
20
  config.path = File.expand_path(path)
@@ -98,7 +98,7 @@ module Tomo
98
98
  def visible_range
99
99
  max_visible = [8, options.length].min
100
100
 
101
- offset = [0, position - max_visible / 2].max
101
+ offset = [0, position - (max_visible / 2)].max
102
102
  adjusted_offset = [offset, options.length - max_visible].min
103
103
 
104
104
  adjusted_offset...(adjusted_offset + max_visible)
@@ -3,6 +3,14 @@ require "time"
3
3
 
4
4
  module Tomo::Plugin::Git
5
5
  class Tasks < Tomo::TaskLibrary
6
+ def config
7
+ user_name = settings[:git_user_name] || remote.host.user
8
+ user_email = settings[:git_user_email] || "#{remote.host.user}@example.com"
9
+
10
+ remote.git("config", "--global", "user.name", user_name)
11
+ remote.git("config", "--global", "user.email", user_email)
12
+ end
13
+
6
14
  def clone
7
15
  require_setting :git_url
8
16
 
@@ -12,6 +12,8 @@ module Tomo::Plugin
12
12
  git_exclusions: [],
13
13
  git_env: { GIT_SSH_COMMAND: "ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no" },
14
14
  git_ref: nil,
15
- git_url: nil
15
+ git_url: nil,
16
+ git_user_name: nil,
17
+ git_user_email: nil
16
18
  end
17
19
  end
@@ -31,8 +31,7 @@ module Tomo::Plugin::Nodenv
31
31
  end
32
32
 
33
33
  def install_node
34
- require_setting :nodenv_node_version
35
- node_version = settings[:nodenv_node_version]
34
+ node_version = settings[:nodenv_node_version] || extract_node_ver_from_version_file
36
35
 
37
36
  remote.run "nodenv install #{node_version.shellescape}" unless node_installed?(node_version)
38
37
  remote.run "nodenv global #{node_version.shellescape}"
@@ -57,5 +56,16 @@ module Tomo::Plugin::Nodenv
57
56
  end
58
57
  false
59
58
  end
59
+
60
+ def extract_node_ver_from_version_file
61
+ path = paths.release.join(".node-version")
62
+ version = remote.capture("cat", path, raise_on_error: false).strip
63
+ return version unless version.empty?
64
+
65
+ die <<~REASON
66
+ Could not guess node version from .node-version file.
67
+ Use the :nodenv_node_version setting to specify the version of node to install.
68
+ REASON
69
+ end
60
70
  end
61
71
  end
@@ -29,7 +29,7 @@ module Tomo
29
29
  private
30
30
 
31
31
  def slice(*keys)
32
- keys.map { |key| [key, fiber_locals[key]] }.to_h
32
+ keys.to_h { |key| [key, fiber_locals[key]] }
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 = settings.keys.map { |name| [name, fetch(name)] }.to_h
13
+ hash = settings.keys.to_h { |name| [name, fetch(name)] }
14
14
  dump_settings(hash) if Tomo.debug?
15
15
  hash
16
16
  end
data/lib/tomo/task_api.rb CHANGED
@@ -25,7 +25,7 @@ module Tomo
25
25
  path = File.expand_path(path, working_path) if working_path && path.start_with?(".")
26
26
 
27
27
  Runtime::TemplateNotFoundError.raise_with(path: path) unless File.file?(path)
28
- template = IO.read(path)
28
+ template = File.read(path)
29
29
  ERB.new(template).result(binding)
30
30
  end
31
31
 
@@ -17,7 +17,9 @@ set deploy_to: "/var/www/%{application}"
17
17
  <% unless using_ruby_version_file? -%>
18
18
  set rbenv_ruby_version: <%= RUBY_VERSION.inspect %>
19
19
  <% end -%>
20
+ <% unless using_node_version_file? -%>
20
21
  set nodenv_node_version: <%= node_version&.inspect || "nil # FIXME" %>
22
+ <% end -%>
21
23
  set nodenv_install_yarn: <%= yarn_version ? "true" : "false" %>
22
24
  set git_url: <%= git_origin_url&.inspect || "nil # FIXME" %>
23
25
  set git_branch: <%= git_branch&.inspect || "nil # FIXME" %>
@@ -31,6 +33,7 @@ set env_vars: {
31
33
  RAILS_ENV: "production",
32
34
  RAILS_LOG_TO_STDOUT: "1",
33
35
  RAILS_SERVE_STATIC_FILES: "1",
36
+ BOOTSNAP_CACHE_DIR: "tmp/bootsnap-cache",
34
37
  DATABASE_URL: :prompt,
35
38
  SECRET_KEY_BASE: :prompt
36
39
  }
@@ -48,6 +51,7 @@ set linked_dirs: %w[
48
51
  setup do
49
52
  run "env:setup"
50
53
  run "core:setup_directories"
54
+ run "git:config"
51
55
  run "git:clone"
52
56
  run "git:create_release"
53
57
  run "core:symlink_shared"
@@ -1,4 +1,4 @@
1
- FROM ubuntu:20.04
1
+ FROM ubuntu:22.04
2
2
  WORKDIR /provision
3
3
  COPY ./tomo_test_ed25519.pub /root/.ssh/authorized_keys
4
4
  COPY ./ubuntu_setup.sh ./
@@ -69,8 +69,8 @@ module Tomo
69
69
  attr_reader :container_id, :image_id, :private_key_path
70
70
 
71
71
  def pull_base_image_if_needed
72
- images = Local.capture('docker images --format "{{.ID}}" ubuntu:20.04')
73
- Local.capture("docker pull ubuntu:20.04") if images.strip.empty?
72
+ images = Local.capture('docker images --format "{{.ID}}" ubuntu:22.04')
73
+ Local.capture("docker pull ubuntu:22.04") if images.strip.empty?
74
74
  end
75
75
 
76
76
  def set_up_private_key
@@ -63,9 +63,9 @@ class Unit
63
63
  def self.find(name)
64
64
  path = File.join(File.expand_path("~/.config/systemd/user/"), name)
65
65
  raise "Unknown unit: #{name}" unless File.file?(path)
66
- return Service.new(name, IO.read(path)) if name.end_with?(".service")
66
+ return Service.new(name, File.read(path)) if name.end_with?(".service")
67
67
 
68
- new(name, IO.read(path))
68
+ new(name, File.read(path))
69
69
  end
70
70
 
71
71
  def initialize(name, spec)
data/lib/tomo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tomo
2
- VERSION = "1.9.0".freeze
2
+ VERSION = "1.12.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.9.0
4
+ version: 1.12.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: 2021-08-07 00:00:00.000000000 Z
11
+ date: 2022-06-18 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
@@ -173,6 +173,7 @@ metadata:
173
173
  source_code_uri: https://github.com/mattbrictson/tomo
174
174
  homepage_uri: https://github.com/mattbrictson/tomo
175
175
  documentation_uri: https://tomo-deploy.com/
176
+ rubygems_mfa_required: 'true'
176
177
  post_install_message:
177
178
  rdoc_options: []
178
179
  require_paths:
@@ -181,14 +182,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
182
  requirements:
182
183
  - - ">="
183
184
  - !ruby/object:Gem::Version
184
- version: 2.6.0
185
+ version: '2.6'
185
186
  required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  requirements:
187
188
  - - ">="
188
189
  - !ruby/object:Gem::Version
189
190
  version: '0'
190
191
  requirements: []
191
- rubygems_version: 3.2.24
192
+ rubygems_version: 3.3.16
192
193
  signing_key:
193
194
  specification_version: 4
194
195
  summary: A friendly CLI for deploying Rails apps ✨