bullet_train 1.0.28 → 1.0.29
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/app/views/bullet_train/partial_resolver.html.erb +2 -0
- data/app/views/devise/sessions/new.html.erb +0 -2
- data/app/views/layouts/docs.html.erb +4 -4
- data/config/locales/en/base.yml +6 -1
- data/lib/bullet_train/resolver.rb +148 -0
- data/lib/bullet_train/version.rb +1 -1
- data/lib/bullet_train.rb +1 -0
- data/lib/tasks/bullet_train_tasks.rake +31 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b21c5d19664f00d67f8d24604a6aadf16d34074b4471118893dc4245d52aa048
|
4
|
+
data.tar.gz: 68866b87e82a35d9005c0e75259f44f50a0b2607176e78d7de4f7d6f729a82be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8744327543da313a00acb719c0b838fb380c5ba10946291ecb3c7d0ba83c927a3cb98ecff024a93480ad0ed044bc1e171c91c8def9c4c58679ce2be5db4e6b51
|
7
|
+
data.tar.gz: 74d3acfc5ab9258eb3a3eaaea9e313757a26469404d04bfc5b0c0f210c2f60d3a39abe81d8d563d23a55d019ed813f55a583683d7d2ee24b23379a870cec23c6
|
@@ -5,20 +5,20 @@
|
|
5
5
|
<%
|
6
6
|
# we're going to use the
|
7
7
|
body = Nokogiri::HTML(@body)
|
8
|
-
title = body.css('h1').first.text.presence || t('
|
8
|
+
title = body.css('h1').first.text.presence || t('bullet_train.tagline')
|
9
9
|
first_paragraph = body.css('p').first
|
10
10
|
preceding_heading = first_paragraph&.xpath("preceding-sibling::h2")
|
11
|
-
description = [preceding_heading&.text, first_paragraph&.text].select(&:present?).join(" — ") || t('
|
11
|
+
description = [preceding_heading&.text, first_paragraph&.text].select(&:present?).join(" — ") || t('bullet_train.description')
|
12
12
|
image_url = "https://avatars.githubusercontent.com/u/5976880?s=280&v=4"
|
13
13
|
site_name = "Bullet Train Developer Documentation"
|
14
14
|
%>
|
15
15
|
|
16
16
|
<% content_for :title do %>
|
17
|
-
<title><%= [site_name, title, t('
|
17
|
+
<title><%= [site_name, title, t('bullet_train.tagline')].select(&:present?).uniq.first(2).reverse.join(' — ') %></title>
|
18
18
|
<% end %>
|
19
19
|
|
20
20
|
<%= render 'themes/light/layouts/head' %>
|
21
|
-
<meta content="<%= t('
|
21
|
+
<meta content="<%= t('bullet_train.keywords') %>" name="keywords" />
|
22
22
|
<meta content="<%= description.truncate(200) %>" name="description" />
|
23
23
|
<meta name="twitter:image:src" content="<%= image_url %>" />
|
24
24
|
<meta name="twitter:site" content="@bullettrainco" />
|
data/config/locales/en/base.yml
CHANGED
@@ -30,7 +30,12 @@
|
|
30
30
|
# available at https://guides.rubyonrails.org/i18n.html.
|
31
31
|
|
32
32
|
en:
|
33
|
-
|
33
|
+
bullet_train:
|
34
|
+
name: Bullet Train
|
35
|
+
tagline: The Ruby on Rails SaaS Template
|
36
|
+
description: Bullet Train is a Ruby on Rails SaaS-in-a-Box that saves developers weeks of effort.
|
37
|
+
keywords: bullet train ruby on rails saas template starter kit
|
38
|
+
support_email: ask@bullettrain.co
|
34
39
|
global:
|
35
40
|
or: Or
|
36
41
|
more: More
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'io/wait'
|
2
|
+
|
3
|
+
module BulletTrain
|
4
|
+
class Resolver
|
5
|
+
def initialize(needle)
|
6
|
+
@needle = needle
|
7
|
+
end
|
8
|
+
|
9
|
+
def run(eject: false, open: false, force: false, interactive: false)
|
10
|
+
# Try to figure out what kind of thing they're trying to look up.
|
11
|
+
source_file = calculate_source_file_details
|
12
|
+
|
13
|
+
if source_file[:absolute_path]
|
14
|
+
if source_file[:package_name].present?
|
15
|
+
puts ""
|
16
|
+
puts "Absolute path:".green
|
17
|
+
puts " #{source_file[:absolute_path]}".green
|
18
|
+
puts ""
|
19
|
+
puts "Package name:".green
|
20
|
+
puts " #{source_file[:package_name]}".green
|
21
|
+
puts ""
|
22
|
+
else
|
23
|
+
puts ""
|
24
|
+
puts "Project path:".green
|
25
|
+
puts " #{source_file[:project_path]}".green
|
26
|
+
puts ""
|
27
|
+
puts "Note: If this file was previously ejected from a package, we can no longer see which package it came from. However, it should say at the top of the file where it was ejected from.".yellow
|
28
|
+
puts ""
|
29
|
+
end
|
30
|
+
|
31
|
+
if interactive && !eject
|
32
|
+
puts "\nWould you like to eject the file into the local project? (y/n)\n"
|
33
|
+
input = $stdin.gets
|
34
|
+
$stdin.getc while $stdin.ready?
|
35
|
+
if input.first.downcase == 'y'
|
36
|
+
eject = true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
if eject
|
41
|
+
if source_file[:package_name]
|
42
|
+
if File.exist?(source_file[:project_path]) && !force
|
43
|
+
return puts "Can't eject! `#{source_file[:project_path]}` already exists!\n".red
|
44
|
+
else
|
45
|
+
`mkdir -p #{source_file[:project_path].split("/")[0...-1].join("/")}`
|
46
|
+
puts "Ejecting `#{source_file[:absolute_path]}` to `#{source_file[:project_path]}`".green
|
47
|
+
File.open("#{source_file[:project_path]}", "w+") do |file|
|
48
|
+
case source_file[:project_path].split(".").last
|
49
|
+
when "rb", "yml"
|
50
|
+
file.puts "# Ejected from `#{source_file[:package_name]}`.\n\n"
|
51
|
+
when "erb"
|
52
|
+
file.puts "<% # Ejected from `#{source_file[:package_name]}`. %>\n\n"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
`cat #{source_file[:absolute_path]} >> #{source_file[:project_path]}`.strip
|
56
|
+
end
|
57
|
+
|
58
|
+
# Just in case they try to open the file, open it from the new location.
|
59
|
+
source_file[:absolute_path] = source_file[:project_path]
|
60
|
+
else
|
61
|
+
puts "This file is already in the local project directory. Skipping ejection.".yellow
|
62
|
+
puts ""
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if interactive && !open
|
67
|
+
puts "\nWould you like to open `#{source_file[:absolute_path]}`? (y/n)\n"
|
68
|
+
input = $stdin.gets
|
69
|
+
$stdin.getc while $stdin.ready?
|
70
|
+
if input.first.downcase == 'y'
|
71
|
+
open = true
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
if open
|
76
|
+
path = source_file[:package_name] ? source_file[:absolute_path] : "#{source_file[:project_path]}"
|
77
|
+
puts "Opening `#{path}`.\n".green
|
78
|
+
exec "open #{path}"
|
79
|
+
end
|
80
|
+
else
|
81
|
+
puts "Couldn't resolve `#{@needle}`.".red
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def calculate_source_file_details
|
86
|
+
result = {
|
87
|
+
absolute_path: nil,
|
88
|
+
project_path: nil,
|
89
|
+
package_name: nil,
|
90
|
+
}
|
91
|
+
|
92
|
+
result[:absolute_path] = class_path || partial_path || file_path
|
93
|
+
|
94
|
+
if result[:absolute_path]
|
95
|
+
base_path = "bullet_train" + result[:absolute_path].split("/bullet_train").last
|
96
|
+
|
97
|
+
# Try to calculate which package the file is from, and what it's path is within that project.
|
98
|
+
["app", "config", "lib"].each do |directory|
|
99
|
+
regex = /\/#{directory}\//
|
100
|
+
if base_path.match?(regex)
|
101
|
+
project_path = "./#{directory}/#{base_path.rpartition(regex).last}"
|
102
|
+
package_name = base_path.rpartition(regex).first.split("/").last
|
103
|
+
# If the "package name" is actually just the local project directory.
|
104
|
+
if package_name == `pwd`.chomp.split("/").last
|
105
|
+
package_name = nil
|
106
|
+
end
|
107
|
+
|
108
|
+
result[:project_path] = project_path
|
109
|
+
result[:package_name] = package_name
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
result
|
115
|
+
end
|
116
|
+
|
117
|
+
def url?
|
118
|
+
@needle.match?(/https?:\/\//)
|
119
|
+
end
|
120
|
+
|
121
|
+
def class_path
|
122
|
+
begin
|
123
|
+
@needle.constantize
|
124
|
+
return Object.const_source_location(@needle).first
|
125
|
+
rescue NameError => _
|
126
|
+
return false
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def partial_path
|
131
|
+
begin
|
132
|
+
xray_path = ApplicationController.render(template: "bullet_train/partial_resolver", layout: nil, assigns: {needle: @needle}).lines[1].chomp
|
133
|
+
if xray_path.match(/<!--XRAY START \d+ (.*)-->/)
|
134
|
+
return $1
|
135
|
+
else
|
136
|
+
raise "It looks like Xray-rails isn't properly enabled?"
|
137
|
+
end
|
138
|
+
rescue ActionView::Template::Error => _
|
139
|
+
return nil
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def file_path
|
144
|
+
# We don't have to do anything here... the absolute path is what we're passed, and we just pass it back.
|
145
|
+
@needle
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
data/lib/bullet_train/version.rb
CHANGED
data/lib/bullet_train.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'io/wait'
|
2
|
+
|
1
3
|
namespace :bullet_train do
|
2
4
|
desc "Symlink registered gems in `./tmp/gems` so their views, etc. can be inspected by Tailwind CSS."
|
3
5
|
task :link_gems => :environment do
|
@@ -23,4 +25,33 @@ namespace :bullet_train do
|
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
28
|
+
|
29
|
+
desc "Figure out where something is coming from."
|
30
|
+
task :resolve, [:all_options] => :environment do |t, arguments|
|
31
|
+
ARGV.pop while ARGV.any?
|
32
|
+
|
33
|
+
arguments[:all_options]&.split&.each do |argument|
|
34
|
+
ARGV.push(argument)
|
35
|
+
end
|
36
|
+
|
37
|
+
if ARGV.include?("--interactive")
|
38
|
+
puts "\nOK, paste what you've got for us and hit <Return>!\n".blue
|
39
|
+
|
40
|
+
input = $stdin.gets.strip
|
41
|
+
$stdin.getc while $stdin.ready?
|
42
|
+
|
43
|
+
# Extract absolute paths from XRAY comments.
|
44
|
+
if input.match(/<!--XRAY START \d+ (.*)-->/)
|
45
|
+
input = $1
|
46
|
+
end
|
47
|
+
|
48
|
+
ARGV.unshift input.strip
|
49
|
+
end
|
50
|
+
|
51
|
+
if ARGV.first.present?
|
52
|
+
BulletTrain::Resolver.new(ARGV.first).run(eject: ARGV.include?("--eject"), open: ARGV.include?("--open"), force: ARGV.include?("--force"), interactive: ARGV.include?("--interactive"))
|
53
|
+
else
|
54
|
+
$stderr.puts "\n🚅 Usage: `bin/resolve [path, partial, or URL] (--eject) (--open)`\n".blue
|
55
|
+
end
|
56
|
+
end
|
26
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -450,6 +450,7 @@ files:
|
|
450
450
|
- app/views/account/users/_form.html.erb
|
451
451
|
- app/views/account/users/edit.html.erb
|
452
452
|
- app/views/account/users/show.html.erb
|
453
|
+
- app/views/bullet_train/partial_resolver.html.erb
|
453
454
|
- app/views/devise/confirmations/new.html.erb
|
454
455
|
- app/views/devise/mailer/confirmation_instructions.html.erb
|
455
456
|
- app/views/devise/mailer/password_change.html.erb
|
@@ -522,6 +523,7 @@ files:
|
|
522
523
|
- db/migrate/20211027002944_add_doorkeeper_application_to_users.rb
|
523
524
|
- lib/bullet_train.rb
|
524
525
|
- lib/bullet_train/engine.rb
|
526
|
+
- lib/bullet_train/resolver.rb
|
525
527
|
- lib/bullet_train/version.rb
|
526
528
|
- lib/colorizer.rb
|
527
529
|
- lib/string/emoji.rb
|