tomo 1.17.0 → 1.18.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: 6202b071b5584a5fc5b2db693130e5160585b784822b2b220ff3685c4272f53c
4
- data.tar.gz: 6c35312e003c7c00153a7ddf8d5c2761f19b9c16aa72d8f74b271f25b5f1d69c
3
+ metadata.gz: c340ddcd3ab2385834e3611bd577a7858cbd3f61136c19d8797d552eb15f6a4b
4
+ data.tar.gz: ab367d0bb86bd69f92255a4550f839f0bba0efbee83d67b9fd18e7117ca83973
5
5
  SHA512:
6
- metadata.gz: 3c1a3a5edc2e67bd5d1aa77231534ca36d379214a9d4fade127d81ae810cfd75137d600f8018c44d171c41a6d0d6abacbc2986cef629de661747fd2199997f4d
7
- data.tar.gz: efd002dc923b18b4aa48f98d2fa79069c1713fbc604614a68f0fe1b9bc0477de591b83a280edfe1ea2c8fcf398408394a095bd56d8fab27f58ddba7c5748d2d9
6
+ metadata.gz: 7659312aa674e8c3bdb26c18fc9dbbf5369a0530873eb07db16584b68dd2dd995af71bb0fe742532a4b16310554d77ff9c3a4a2c986e254c408f22834c6a6eeb
7
+ data.tar.gz: a4052c634e67510b0467b10d4f053e7993d593eb8a449abb8e660fdb8a39b794c473726f05d221515d24ba76b1d7fdf9b8baeb99dde7d8a00c6cecd0fff85f29
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Tomo
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/tomo.svg)](https://rubygems.org/gems/tomo)
4
- [![Build Status](https://mattbrictson.semaphoreci.com/badges/tomo/branches/main.svg?style=shields)](https://mattbrictson.semaphoreci.com/projects/tomo)
5
- [![Code Climate](https://codeclimate.com/github/mattbrictson/tomo/badges/gpa.svg)](https://codeclimate.com/github/mattbrictson/tomo)
3
+ [![Gem Version](https://img.shields.io/gem/v/tomo)](https://rubygems.org/gems/tomo)
4
+ [![Gem Downloads](https://img.shields.io/gem/dt/tomo)](https://www.ruby-toolbox.com/projects/tomo)
5
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mattbrictson/tomo/ci.yml)](https://github.com/mattbrictson/tomo/actions/workflows/ci.yml)
6
+ [![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/mattbrictson/tomo)](https://codeclimate.com/github/mattbrictson/tomo)
6
7
 
7
8
  Tomo is a friendly command-line tool for deploying Rails apps.
8
9
 
@@ -45,7 +45,7 @@ module Tomo
45
45
 
46
46
  # Don't complete the =value part of long switch unless the user has
47
47
  # already typed at least up to the = sign.
48
- return true if cand.match?(/\A--.*=/) && !word.match?(/\A--.*=/)
48
+ true if cand.match?(/\A--.*=/) && !word.match?(/\A--.*=/)
49
49
  end
50
50
 
51
51
  # bash tokenizes the user's input prior to completion, and expects the
@@ -26,7 +26,7 @@ module Tomo
26
26
  attr_reader :banner_proc, :options
27
27
 
28
28
  def options_help
29
- width = options.map(&:first).map(&:length).max
29
+ width = options.map { |opt| opt.first.length }.max
30
30
  options.each_with_object([]) do |(spec, desc), help|
31
31
  help << "#{Colors.yellow(spec.ljust(width))} #{desc}"
32
32
  end.join("\n")
@@ -30,11 +30,9 @@ module Tomo
30
30
 
31
31
  app = args.first || current_dir_name || "default"
32
32
  app = app.gsub(/([^\w-]|_)+/, "_").downcase
33
- FileUtils.mkdir_p(".tomo/plugins")
34
-
35
- # TODO: use a template for this file
36
- FileUtils.touch(".tomo/plugins/#{app}.rb")
37
33
 
34
+ FileUtils.mkdir_p(".tomo/plugins")
35
+ File.write(".tomo/plugins/#{app}.rb", plugin_rb_template)
38
36
  File.write(DEFAULT_CONFIG_PATH, config_rb_template(app))
39
37
 
40
38
  logger.info(green("✔ Created #{DEFAULT_CONFIG_PATH}"))
@@ -71,10 +69,22 @@ module Tomo
71
69
  nil
72
70
  end
73
71
 
74
- def git_branch
72
+ def git_main_branch
75
73
  return unless File.file?(".git/config")
76
74
 
77
- `git rev-parse --abbrev-ref HEAD`.chomp
75
+ # If "main" or "master" is in the list of branch names, use that
76
+ branch = (%w[main master] & `git branch`.scan(/^\W*(.+)$/).flatten).first
77
+
78
+ # If not, use the current branch
79
+ if branch.nil?
80
+ branch = if `git --version`[/\d+\.\d+/].to_f >= 2.22
81
+ `git branch --show-current`.chomp
82
+ else
83
+ `git rev-parse --abbrev-ref HEAD`.chomp
84
+ end
85
+ end
86
+
87
+ branch.empty? ? nil : branch
78
88
  rescue SystemCallError
79
89
  nil
80
90
  end
@@ -119,6 +129,12 @@ module Tomo
119
129
  template = File.read(path)
120
130
  ERB.new(template, trim_mode: "-").result(binding)
121
131
  end
132
+
133
+ def plugin_rb_template
134
+ path = File.expand_path("../templates/plugin.rb.erb", __dir__)
135
+ template = File.read(path)
136
+ ERB.new(template, trim_mode: "-").result(binding)
137
+ end
122
138
  end
123
139
  end
124
140
  end
@@ -5,6 +5,7 @@ module Tomo::Plugin::Bundler
5
5
  CONFIG_SETTINGS = %i[
6
6
  bundler_deployment
7
7
  bundler_gemfile
8
+ bundler_ignore_messages
8
9
  bundler_jobs
9
10
  bundler_path
10
11
  bundler_retry
@@ -8,13 +8,14 @@ module Tomo::Plugin
8
8
  tasks Tomo::Plugin::Bundler::Tasks
9
9
  helpers Tomo::Plugin::Bundler::Helpers
10
10
 
11
- defaults bundler_config_path: ".bundle/config",
12
- bundler_deployment: true,
13
- bundler_gemfile: nil,
14
- bundler_jobs: nil,
15
- bundler_path: "%{shared_path}/bundle",
16
- bundler_retry: "3",
17
- bundler_version: nil,
18
- bundler_without: %w[development test]
11
+ defaults bundler_config_path: ".bundle/config",
12
+ bundler_deployment: true,
13
+ bundler_gemfile: nil,
14
+ bundler_ignore_messages: true,
15
+ bundler_jobs: nil,
16
+ bundler_path: "%{shared_path}/bundle",
17
+ bundler_retry: "3",
18
+ bundler_version: nil,
19
+ bundler_without: %w[development test]
19
20
  end
20
21
  end
@@ -81,7 +81,7 @@ module Tomo::Plugin::Puma
81
81
 
82
82
  def setup_directories
83
83
  files = [service.path, socket.path].compact
84
- dirs = files.map(&:dirname).map(&:to_s)
84
+ dirs = files.map { |f| f.dirname.to_s }
85
85
  remote.mkdir_p dirs.uniq
86
86
  end
87
87
 
@@ -17,10 +17,10 @@ module Tomo
17
17
  @promises = []
18
18
  end
19
19
 
20
- def post(*args, &block)
20
+ def post(...)
21
21
  return if failure?
22
22
 
23
- promises << future_on(executor, *args, &block)
23
+ promises << future_on(executor, ...)
24
24
  .on_rejection_using(executor) do |reason|
25
25
  self.failure = reason
26
26
  end
@@ -22,7 +22,7 @@ module Tomo
22
22
  indent = threads > 1 ? " = " : ""
23
23
  if threads > 1 && step.applicable_tasks.length > 1
24
24
  desc << "#{indent}IN SEQUENCE:"
25
- indent.sub!(/=/, " ")
25
+ indent.sub!("=", " ")
26
26
  end
27
27
  desc << step.explain.gsub(/^/, indent)
28
28
  end
@@ -39,7 +39,7 @@ module Tomo
39
39
  end
40
40
 
41
41
  def dump_settings(hash)
42
- key_len = hash.keys.map(&:to_s).map(&:length).max
42
+ key_len = hash.keys.map { |k| k.to_s.length }.max
43
43
  dump = "Settings: {\n"
44
44
  hash.to_a.sort_by(&:first).each do |key, value|
45
45
  justified_key = "#{key}:".ljust(key_len + 1)
@@ -67,7 +67,7 @@ module Tomo
67
67
  def shell_join(*command)
68
68
  return command.first.to_s if command.length == 1
69
69
 
70
- command.flatten.compact.map(&:to_s).map(&:shellescape).join(" ")
70
+ command.flatten.compact.map { |arg| arg.to_s.shellescape }.join(" ")
71
71
  end
72
72
 
73
73
  def cd_chdir
@@ -22,7 +22,7 @@ set nodenv_node_version: <%= node_version&.inspect || "nil # FIXME" %>
22
22
  <% end -%>
23
23
  set nodenv_install_yarn: <%= yarn_version ? "true" : "false" %>
24
24
  set git_url: <%= git_origin_url&.inspect || "nil # FIXME" %>
25
- set git_branch: <%= git_branch&.inspect || "nil # FIXME" %>
25
+ set git_branch: <%= git_main_branch&.inspect || "nil # FIXME" %>
26
26
  set git_exclusions: %w[
27
27
  .tomo/
28
28
  spec/
@@ -0,0 +1 @@
1
+ # https://tomo-deploy.com/tutorials/writing-custom-tasks/
data/lib/tomo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tomo
2
- VERSION = "1.17.0".freeze
2
+ VERSION = "1.18.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.17.0
4
+ version: 1.18.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: 2023-06-13 00:00:00.000000000 Z
11
+ date: 2023-08-15 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
@@ -145,6 +145,7 @@ files:
145
145
  - lib/tomo/task_api.rb
146
146
  - lib/tomo/task_library.rb
147
147
  - lib/tomo/templates/config.rb.erb
148
+ - lib/tomo/templates/plugin.rb.erb
148
149
  - lib/tomo/testing.rb
149
150
  - lib/tomo/testing/Dockerfile
150
151
  - lib/tomo/testing/cli_extensions.rb
@@ -189,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
190
  - !ruby/object:Gem::Version
190
191
  version: '0'
191
192
  requirements: []
192
- rubygems_version: 3.4.13
193
+ rubygems_version: 3.4.18
193
194
  signing_key:
194
195
  specification_version: 4
195
196
  summary: A friendly CLI for deploying Rails apps ✨