bullet_train-themes-light 1.0.43 → 1.0.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/light/application.css +1 -0
- data/app/assets/stylesheets/light/devise.css +15 -0
- data/app/assets/stylesheets/light/tailwind/dark-mode.css +11 -1
- data/app/views/themes/light/_alert.html.erb +1 -1
- data/app/views/themes/light/fields/_field.html.erb +2 -2
- data/app/views/themes/light/layouts/_account.html.erb +13 -21
- data/app/views/themes/light/layouts/_devise.html.erb +1 -1
- data/lib/bullet_train/themes/light/custom_theme_file_replacer.rb +9 -3
- data/lib/bullet_train/themes/light/version.rb +1 -1
- data/lib/bullet_train/themes/light.rb +1 -0
- data/lib/tasks/application.rb +177 -0
- data/lib/tasks/bullet_train/themes/light_tasks.rake +13 -142
- 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: d63e69ed21f864e2c966cb7077c16bf4253d783982aa3fb0482fcfcae4094c1e
|
4
|
+
data.tar.gz: 32fc62dfbe0d979b1c66b2276a54b59b99132d7c2981525175e545ac1ce168ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddf7d29cbd347d0ec62853f2f09c9f4e44be1f13b762d5b13fbdbbaebcf1907a8f83916ec8f00d0c9793034817a657a1af924a21af992044129bf1a1c8deecb7
|
7
|
+
data.tar.gz: 01ffc7eb739b75d5df0ef6a735aa374e13503e86ca523cd412ef8c88800bf15d4f85d6f8b17a3390580e6a516cb2b9584fbffbeb6dfb7db6afe3a523a54aff90
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This takes care of the window's contents shifting when the
|
3
|
+
* scrollbar appears and disappears during the turn.css animation
|
4
|
+
*/
|
5
|
+
|
6
|
+
/* Chrome, Safari and Opera */
|
7
|
+
.devise_layout::-webkit-scrollbar {
|
8
|
+
display: none;
|
9
|
+
}
|
10
|
+
|
11
|
+
/* Firefox and Edge */
|
12
|
+
.devise_layout {
|
13
|
+
-ms-overflow-style: none;
|
14
|
+
scrollbar-width: none;
|
15
|
+
}
|
@@ -178,8 +178,18 @@
|
|
178
178
|
}
|
179
179
|
|
180
180
|
trix-toolbar {
|
181
|
+
@apply opacity-50 !important;
|
182
|
+
|
183
|
+
&.visible {
|
184
|
+
@apply opacity-100 !important;
|
185
|
+
}
|
186
|
+
|
181
187
|
.trix-button-group, .trix-button {
|
182
|
-
@apply border-darkPrimary-
|
188
|
+
@apply border-darkPrimary-400 !important;
|
189
|
+
}
|
190
|
+
|
191
|
+
.trix-button:disabled::before {
|
192
|
+
@apply opacity-25;
|
183
193
|
}
|
184
194
|
}
|
185
195
|
|
@@ -5,7 +5,7 @@ form ||= current_fields_form
|
|
5
5
|
# returns a struct with `label`, `placeholder`, and `help` methods.
|
6
6
|
labels = labels_for(form, method)
|
7
7
|
options ||= {}
|
8
|
-
options[:id] ||=
|
8
|
+
options[:id] ||= form.field_id(method)
|
9
9
|
# options[:disabled] ||= !field_editable?(form.object, method) if user_signed_in?
|
10
10
|
options[:placeholder] ||= labels.placeholder if labels.placeholder
|
11
11
|
other_options ||= {}
|
@@ -64,7 +64,7 @@ end
|
|
64
64
|
<% end %>
|
65
65
|
|
66
66
|
<% # any help text. %>
|
67
|
-
<% if content_for?(:help) || other_options[:help] || content_for?(:after_help) %>
|
67
|
+
<% if content_for?(:help) || other_options[:help].present? || content_for?(:after_help) %>
|
68
68
|
<p class="mt-1.5 text-xs text-gray-500 dark:text-gray-400">
|
69
69
|
<%= yield :help %>
|
70
70
|
<% flush_content_for :help %>
|
@@ -9,8 +9,6 @@
|
|
9
9
|
<div class="h-screen md:h-auto overflow-hidden md:rounded-lg flex shadow main-container"
|
10
10
|
data-controller="mobile-menu"
|
11
11
|
data-mobile-menu-hidden-class="hidden"
|
12
|
-
data-mobile-menu-show-event-name-value="mobile-menu:show"
|
13
|
-
data-mobile-menu-hide-event-name-value="mobile-menu:hide"
|
14
12
|
>
|
15
13
|
|
16
14
|
<% menu = capture do %>
|
@@ -19,7 +17,8 @@
|
|
19
17
|
|
20
18
|
<div class="lg:hidden absolute right-0">
|
21
19
|
<button class="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white dark:ring-transparent"
|
22
|
-
|
20
|
+
id="mobile-menu-close"
|
21
|
+
data-action="mobile-menu#close"
|
23
22
|
>
|
24
23
|
<span class="sr-only">Close Application Menu</span>
|
25
24
|
<svg class="h-6 w-6 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
|
@@ -56,20 +55,13 @@
|
|
56
55
|
|
57
56
|
<div class="lg:hidden hidden"
|
58
57
|
data-mobile-menu-target="wrapper"
|
59
|
-
|
60
|
-
data-controller="reveal"
|
61
|
-
data-reveal-away-value="true"
|
62
|
-
data-reveal-hide-keys-value="escape"
|
63
|
-
|
64
|
-
data-action="mobile-menu:show->reveal#show mobile-menu:hide->reveal#hide mobile-menu-toggle->reveal#toggle reveal:hidden->mobile-menu#hideWrapper"
|
58
|
+
id="mobile-menu-backdrop"
|
65
59
|
>
|
66
60
|
<div class="fixed inset-0 flex z-40">
|
67
61
|
<button
|
68
|
-
data-
|
69
|
-
|
70
|
-
|
71
|
-
data-reveal
|
72
|
-
data-transition
|
62
|
+
data-mobile-menu-target="revealable"
|
63
|
+
data-action="mobile-menu#close"
|
64
|
+
|
73
65
|
data-transition-enter="transition-opacity ease-linear duration-200"
|
74
66
|
data-transition-enter-start="opacity-0"
|
75
67
|
data-transition-enter-end="opacity-100"
|
@@ -77,14 +69,13 @@
|
|
77
69
|
data-transition-leave-start="opacity-100"
|
78
70
|
data-transition-leave-end="opacity-0"
|
79
71
|
|
80
|
-
class="fixed inset-0" aria-hidden="true"
|
72
|
+
class="hidden fixed inset-0" aria-hidden="true"
|
81
73
|
>
|
82
74
|
<div class="absolute inset-0 bg-light-gradient opacity-75"></div>
|
83
75
|
</button>
|
84
76
|
<div
|
85
|
-
|
86
|
-
|
87
|
-
data-transition
|
77
|
+
data-mobile-menu-target="revealable"
|
78
|
+
|
88
79
|
data-transition-enter="transition ease-in-out duration-200 transform"
|
89
80
|
data-transition-enter-start="-trandarkPrimary-x-full"
|
90
81
|
data-transition-enter-end="trandarkPrimary-x-0"
|
@@ -92,7 +83,7 @@
|
|
92
83
|
data-transition-leave-start="trandarkPrimary-x-0"
|
93
84
|
data-transition-leave-end="-trandarkPrimary-x-full"
|
94
85
|
|
95
|
-
class="relative flex-1 flex flex-col max-w-xs w-full pb-4 bg-
|
86
|
+
class="hidden relative flex-1 flex flex-col max-w-xs w-full pb-4 bg-darkPrimary-800 shadow-xl"
|
96
87
|
>
|
97
88
|
<%= menu %>
|
98
89
|
</div>
|
@@ -109,8 +100,9 @@
|
|
109
100
|
<div class="flex flex-col w-0 flex-1 overflow-y-auto bg-gray-100 dark:bg-darkPrimary-800 lg:border-l dark:border-gray-500">
|
110
101
|
<main class="flex-1 relative z-0 focus:outline-none" tabindex="0">
|
111
102
|
<div class="flex flex-row items-center shadow-sm electron-draggable">
|
112
|
-
<button class="
|
113
|
-
|
103
|
+
<button class="lg:hidden h-12 w-12 ml-1 flex-none inline-flex items-center justify-center rounded-md text-gray-500 hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500"
|
104
|
+
id="mobile-menu-open"
|
105
|
+
data-action="mobile-menu#open"
|
114
106
|
>
|
115
107
|
<span class="sr-only">Open Application Menu</span>
|
116
108
|
<svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<%= render 'shared/layouts/head' %>
|
5
5
|
</head>
|
6
|
-
<body class="bg-light-gradient text-gray-700 text-sm font-normal electron-draggable dark:bg-dark-gradient dark:text-darkPrimary-300">
|
6
|
+
<body class="devise_layout bg-light-gradient text-gray-700 text-sm font-normal electron-draggable dark:bg-dark-gradient dark:text-darkPrimary-300">
|
7
7
|
<div data-turn-enter data-turn-exit>
|
8
8
|
<%= yield %>
|
9
9
|
</div>
|
@@ -34,8 +34,12 @@ module BulletTrain
|
|
34
34
|
custom_gem_file[:file_name] = adjust_directory_hierarchy(custom_gem_file[:file_name], original_theme)
|
35
35
|
|
36
36
|
# The content in the main app should replace the cloned gem files.
|
37
|
-
|
38
|
-
BulletTrain::Themes::Light::FileReplacer.
|
37
|
+
begin
|
38
|
+
if custom_gem_file[:must_compare] && !BulletTrain::Themes::Light::FileReplacer.files_have_same_content?(custom_gem_file[:file_name], main_app_file)
|
39
|
+
BulletTrain::Themes::Light::FileReplacer.replace_content(old: custom_gem_file[:file_name], new: main_app_file)
|
40
|
+
end
|
41
|
+
rescue Errno::ENOENT => _
|
42
|
+
puts "Skipping \`#{main_app_file}\` because it isn't present."
|
39
43
|
end
|
40
44
|
|
41
45
|
# Only rename file names that still have the original theme in them, i.e. - ./tailwind.config.light.js
|
@@ -166,7 +170,9 @@ module BulletTrain
|
|
166
170
|
"./app/assets/stylesheets/#{custom_theme}.tailwind.css",
|
167
171
|
"./app/javascript/application.#{custom_theme}.js",
|
168
172
|
"./app/lib/bullet_train/themes/#{custom_theme}.rb",
|
169
|
-
Dir.glob("./app/views/themes/#{custom_theme}/**/*.html.erb")
|
173
|
+
Dir.glob("./app/views/themes/#{custom_theme}/**/*.html.erb"),
|
174
|
+
"./tailwind.mailer.#{custom_theme}.config.js",
|
175
|
+
"./tailwind.#{custom_theme}.config.js",
|
170
176
|
].flatten
|
171
177
|
end
|
172
178
|
|
@@ -9,6 +9,7 @@ module BulletTrain
|
|
9
9
|
module Light
|
10
10
|
# TODO Not sure this is the right place for this in the long-term.
|
11
11
|
mattr_accessor :color, default: :blue
|
12
|
+
mattr_accessor :original_devise_path
|
12
13
|
|
13
14
|
class Theme < BulletTrain::Themes::TailwindCss::Theme
|
14
15
|
def directory_order
|
@@ -0,0 +1,177 @@
|
|
1
|
+
module BulletTrain
|
2
|
+
module Themes
|
3
|
+
module Application
|
4
|
+
def self.eject_theme(theme_name, ejected_theme_name)
|
5
|
+
theme_parts = theme_name.humanize.split.map { |str| str.capitalize }
|
6
|
+
constantized_theme = theme_parts.join
|
7
|
+
humanized_theme = theme_parts.join(" ")
|
8
|
+
|
9
|
+
theme_base_path = `bundle show --paths bullet_train-themes-#{theme_name}`.chomp
|
10
|
+
puts "Ejecting from #{humanized_theme} theme in `#{theme_base_path}`."
|
11
|
+
|
12
|
+
puts "Ejecting Tailwind configuration into `./tailwind.#{ejected_theme_name}.config.js`."
|
13
|
+
`cp #{theme_base_path}/tailwind.#{theme_name}.config.js #{Rails.root}/tailwind.#{ejected_theme_name}.config.js`
|
14
|
+
|
15
|
+
puts "Ejecting Tailwind mailer configuration into `./tailwind.mailer.#{ejected_theme_name}.config.js`."
|
16
|
+
`cp #{theme_base_path}/tailwind.mailer.#{theme_name}.config.js #{Rails.root}/tailwind.mailer.#{ejected_theme_name}.config.js`
|
17
|
+
%x(sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/#{theme_name}/#{ejected_theme_name}/g" #{Rails.root}/tailwind.mailer.#{ejected_theme_name}.config.js)
|
18
|
+
|
19
|
+
puts "Ejecting stylesheets into `./app/assets/stylesheets/#{ejected_theme_name}`."
|
20
|
+
`mkdir #{Rails.root}/app/assets/stylesheets`
|
21
|
+
`cp -R #{theme_base_path}/app/assets/stylesheets/#{theme_name} #{Rails.root}/app/assets/stylesheets/#{ejected_theme_name}`
|
22
|
+
`cp -R #{theme_base_path}/app/assets/stylesheets/#{theme_name}.tailwind.css #{Rails.root}/app/assets/stylesheets/#{ejected_theme_name}.tailwind.css`
|
23
|
+
%x(sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/light/#{ejected_theme_name}/g" #{Rails.root}/app/assets/stylesheets/#{ejected_theme_name}.tailwind.css)
|
24
|
+
|
25
|
+
puts "Ejecting JavaScript into `./app/javascript/application.#{ejected_theme_name}.js`."
|
26
|
+
`cp #{theme_base_path}/app/javascript/application.#{theme_name}.js #{Rails.root}/app/javascript/application.#{ejected_theme_name}.js`
|
27
|
+
|
28
|
+
puts "Ejecting all theme partials into `./app/views/themes/#{ejected_theme_name}`."
|
29
|
+
`mkdir #{Rails.root}/app/views/themes`
|
30
|
+
`cp -R #{theme_base_path}/app/views/themes/#{theme_name} #{Rails.root}/app/views/themes/#{ejected_theme_name}`
|
31
|
+
%x(sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/#{theme_name}/#{ejected_theme_name}/g" #{Rails.root}/app/views/themes/#{ejected_theme_name}/layouts/_head.html.erb)
|
32
|
+
|
33
|
+
puts "Cutting local `Procfile.dev` over from `#{theme_name}` to `#{ejected_theme_name}`."
|
34
|
+
%x(sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/#{theme_name}/#{ejected_theme_name}/g" #{Rails.root}/Procfile.dev)
|
35
|
+
|
36
|
+
puts "Cutting local `package.json` over from `#{theme_name}` to `#{ejected_theme_name}`."
|
37
|
+
%x(sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/#{theme_name}/#{ejected_theme_name}/g" #{Rails.root}/package.json)
|
38
|
+
|
39
|
+
# Stub out the class that represents this theme and establishes its inheritance structure.
|
40
|
+
target_path = "#{Rails.root}/app/lib/bullet_train/themes/#{ejected_theme_name}.rb"
|
41
|
+
puts "Stubbing out a class that represents this theme in `.#{target_path}`."
|
42
|
+
`mkdir -p #{Rails.root}/app/lib/bullet_train/themes`
|
43
|
+
`cp #{theme_base_path}/lib/bullet_train/themes/#{theme_name}.rb #{target_path}`
|
44
|
+
%x(sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/module #{constantized_theme}/module #{ejected_theme_name.titlecase}/g" #{target_path})
|
45
|
+
%x(sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/TailwindCss/#{constantized_theme}/g" #{target_path})
|
46
|
+
%x(sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/#{theme_name}/#{ejected_theme_name}/g" #{target_path})
|
47
|
+
["require", "TODO", "mattr_accessor"].each do |thing_to_remove|
|
48
|
+
`grep -v #{thing_to_remove} #{target_path} > #{target_path}.tmp`
|
49
|
+
`mv #{target_path}.tmp #{target_path}`
|
50
|
+
end
|
51
|
+
`standardrb --fix #{target_path}`
|
52
|
+
|
53
|
+
puts "Cutting local project over from `#{theme_name}` to `#{ejected_theme_name}` in `app/helpers/application_helper.rb`."
|
54
|
+
%x(sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/:#{theme_name}/:#{ejected_theme_name}/g" #{Rails.root}/app/helpers/application_helper.rb)
|
55
|
+
|
56
|
+
puts "You must restart `bin/dev` at this point, because of the changes to `Procfile.dev` and `package.json`."
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.release_theme(original_theme_name, args)
|
60
|
+
if original_theme_name != "light"
|
61
|
+
puts "You can only release new themes based off of Bullet Train's Light theme. Please eject a new theme from there, and publish your gem once you've finished making changes.".red
|
62
|
+
exit 1
|
63
|
+
end
|
64
|
+
|
65
|
+
puts "Preparing to release your custom theme: ".blue + args[:theme_name]
|
66
|
+
puts ""
|
67
|
+
puts "Before we make a new Ruby gem for your theme, you'll have to set up a GitHub repository first.".blue
|
68
|
+
puts "Hit <Return> and we'll open a browser to GitHub where you can create a new repository.".blue
|
69
|
+
puts "Make sure you name the repository ".blue + "bullet_train-themes-#{args[:theme_name]}"
|
70
|
+
puts ""
|
71
|
+
puts "When you're done, copy the SSH path from the new repository and return here.".blue
|
72
|
+
ask "We'll ask you to paste it to us in the next step."
|
73
|
+
`#{Gem::Platform.local.os == "linux" ? "xdg-open" : "open"} https://github.com/new`
|
74
|
+
|
75
|
+
ssh_path = ask "OK, what was the SSH path? (It should look like `git@github.com:your-account/your-new-repo.git`.)"
|
76
|
+
puts ""
|
77
|
+
puts "Great, you're all set.".blue
|
78
|
+
puts "We'll take it from here, so sit back and enjoy the ride 🚄️".blue
|
79
|
+
puts ""
|
80
|
+
puts "Creating a Ruby gem for ".blue + "#{args[:theme_name]}..."
|
81
|
+
|
82
|
+
Dir.mkdir("local") unless Dir.exist?("./local")
|
83
|
+
if Dir.exist?("./local/bullet_train-themes-#{args[:theme_name]}")
|
84
|
+
raise "You already have a repository named `bullet_train-themes-#{args[:theme_name]}` in `./local`.\n" \
|
85
|
+
"Make sure you delete it first to create an entirely new gem."
|
86
|
+
end
|
87
|
+
`git clone git@github.com:bullet-train-co/bullet_train-themes-light.git ./local/bullet_train-themes-#{args[:theme_name]}`
|
88
|
+
|
89
|
+
custom_file_replacer = BulletTrain::Themes::Light::CustomThemeFileReplacer.new(args[:theme_name])
|
90
|
+
custom_file_replacer.replace_theme("light", args[:theme_name])
|
91
|
+
|
92
|
+
work_tree_flag = "--work-tree=local/bullet_train-themes-#{args[:theme_name]}"
|
93
|
+
git_dir_flag = "--git-dir=local/bullet_train-themes-#{args[:theme_name]}/.git"
|
94
|
+
path = "./local/bullet_train-themes-#{args[:theme_name]}"
|
95
|
+
|
96
|
+
# Set up the proper remote.
|
97
|
+
`git #{work_tree_flag} #{git_dir_flag} remote set-url origin #{ssh_path}`
|
98
|
+
`git #{work_tree_flag} #{git_dir_flag} add .`
|
99
|
+
`git #{work_tree_flag} #{git_dir_flag} commit -m "Add initial files"`
|
100
|
+
|
101
|
+
# Build the gem.
|
102
|
+
`(cd #{path} && gem build bullet_train-themes-#{args[:theme_name]}.gemspec)`
|
103
|
+
`git #{work_tree_flag} #{git_dir_flag} add .`
|
104
|
+
`git #{work_tree_flag} #{git_dir_flag} commit -m "Build gem"`
|
105
|
+
|
106
|
+
# Commit the deleted files on the main application.
|
107
|
+
`git add .`
|
108
|
+
`git commit -m "Remove #{args[:theme_name]} files from application"`
|
109
|
+
|
110
|
+
# Push the gem's source code, but not the last commit in the main application.
|
111
|
+
`git #{work_tree_flag} #{git_dir_flag} push -u origin main`
|
112
|
+
|
113
|
+
puts ""
|
114
|
+
puts ""
|
115
|
+
puts "You're all set! Copy and paste the following commands to publish your gem:".blue
|
116
|
+
puts "cd ./local/bullet_train-themes-#{args[:theme_name]}"
|
117
|
+
puts "gem push bullet_train-themes-#{args[:theme_name]}-1.0.gem && cd ../../"
|
118
|
+
puts ""
|
119
|
+
puts "You may have to wait for some time until the gem can be downloaded via the Gemfile.".blue
|
120
|
+
puts "After a few minutes, run the following command in your main application:".blue
|
121
|
+
puts "bundle add bullet_train-themes-#{args[:theme_name]}"
|
122
|
+
puts "rake bullet_train:themes:#{args[:theme_name]}:install"
|
123
|
+
puts ""
|
124
|
+
puts "Then you'll be ready to use your custom gem in your Bullet Train application.".blue
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.install_theme(theme_name)
|
128
|
+
# Grabs the current theme from
|
129
|
+
# def current_theme
|
130
|
+
# :theme_name
|
131
|
+
# end
|
132
|
+
current_theme_regexp = /(^ :)(.*)/
|
133
|
+
current_theme = nil
|
134
|
+
|
135
|
+
new_lines = []
|
136
|
+
[
|
137
|
+
"./app/helpers/application_helper.rb",
|
138
|
+
"./Procfile.dev",
|
139
|
+
"./package.json"
|
140
|
+
].each do |file|
|
141
|
+
File.open(file, "r") do |f|
|
142
|
+
new_lines = f.readlines
|
143
|
+
new_lines = new_lines.map do |line|
|
144
|
+
# Make sure we get the current theme before trying to replace it in any of the files.
|
145
|
+
# We grab it from the first file in the array above.
|
146
|
+
current_theme = line.scan(current_theme_regexp).flatten.last if line.match?(current_theme_regexp)
|
147
|
+
|
148
|
+
line.gsub!(/#{current_theme}/, theme_name) unless current_theme.nil?
|
149
|
+
line
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
File.open(file, "w") do |f|
|
154
|
+
f.puts new_lines.join
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def self.clean_theme(theme_name, args)
|
160
|
+
theme_base_path = `bundle show --paths bullet_train-themes-#{theme_name}`.chomp
|
161
|
+
`find app/views/themes/#{args[:theme]} | grep html.erb`.lines.map(&:chomp).each do |path|
|
162
|
+
_, file = path.split("app/views/themes/#{args[:theme]}/")
|
163
|
+
original_theme_path = "#{theme_base_path}/app/views/themes/#{theme_name}/#{file}"
|
164
|
+
if File.read(path) == File.read(original_theme_path)
|
165
|
+
puts "No changes in \`#{path}\` since being ejected. Removing."
|
166
|
+
`rm #{path}`
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.ask(string)
|
172
|
+
puts string.blue
|
173
|
+
$stdin.gets.strip
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -1,160 +1,31 @@
|
|
1
|
+
require "tasks/application"
|
2
|
+
|
1
3
|
namespace :bullet_train do
|
2
4
|
namespace :themes do
|
3
5
|
namespace :light do
|
4
6
|
desc "Fork the \"Light\" theme into your local repository."
|
5
7
|
task :eject, [:destination] => :environment do |task, args|
|
6
|
-
|
7
|
-
puts "Ejecting from Light theme in `#{theme_base_path}`."
|
8
|
-
|
9
|
-
puts "Ejecting Tailwind configuration into `./tailwind.#{args[:destination]}.config.js`."
|
10
|
-
`cp #{theme_base_path}/tailwind.light.config.js #{Rails.root}/tailwind.#{args[:destination]}.config.js`
|
11
|
-
|
12
|
-
puts "Ejecting Tailwind mailer configuration into `./tailwind.mailer.#{args[:destination]}.config.js`."
|
13
|
-
`cp #{theme_base_path}/tailwind.mailer.light.config.js #{Rails.root}/tailwind.mailer.#{args[:destination]}.config.js`
|
14
|
-
`sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/light/#{args[:destination]}/g" #{Rails.root}/tailwind.mailer.#{args[:destination]}.config.js`
|
15
|
-
|
16
|
-
puts "Ejecting stylesheets into `./app/assets/stylesheets/#{args[:destination]}`."
|
17
|
-
`mkdir #{Rails.root}/app/assets/stylesheets`
|
18
|
-
`cp -R #{theme_base_path}/app/assets/stylesheets/light #{Rails.root}/app/assets/stylesheets/#{args[:destination]}`
|
19
|
-
`cp -R #{theme_base_path}/app/assets/stylesheets/light.tailwind.css #{Rails.root}/app/assets/stylesheets/#{args[:destination]}.tailwind.css`
|
20
|
-
`sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/light/#{args[:destination]}/g" #{Rails.root}/app/assets/stylesheets/#{args[:destination]}.tailwind.css`
|
21
|
-
|
22
|
-
puts "Ejecting JavaScript into `./app/javascript/application.#{args[:destination]}.js`."
|
23
|
-
`cp #{theme_base_path}/app/javascript/application.light.js #{Rails.root}/app/javascript/application.#{args[:destination]}.js`
|
24
|
-
|
25
|
-
puts "Ejecting all theme partials into `./app/views/themes/#{args[:destination]}`."
|
26
|
-
`mkdir #{Rails.root}/app/views/themes`
|
27
|
-
`cp -R #{theme_base_path}/app/views/themes/light #{Rails.root}/app/views/themes/#{args[:destination]}`
|
28
|
-
`sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/light/#{args[:destination]}/g" #{Rails.root}/app/views/themes/#{args[:destination]}/layouts/_head.html.erb`
|
29
|
-
|
30
|
-
puts "Cutting local `Procfile.dev` over from `light` to `#{args[:destination]}`."
|
31
|
-
`sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/light/#{args[:destination]}/g" #{Rails.root}/Procfile.dev`
|
32
|
-
|
33
|
-
puts "Cutting local `package.json` over from `light` to `#{args[:destination]}`."
|
34
|
-
`sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/light/#{args[:destination]}/g" #{Rails.root}/package.json`
|
35
|
-
|
36
|
-
# Stub out the class that represents this theme and establishes its inheritance structure.
|
37
|
-
target_path = "#{Rails.root}/app/lib/bullet_train/themes/#{args[:destination]}.rb"
|
38
|
-
puts "Stubbing out a class that represents this theme in `.#{target_path}`."
|
39
|
-
`mkdir -p #{Rails.root}/app/lib/bullet_train/themes`
|
40
|
-
`cp #{theme_base_path}/lib/bullet_train/themes/light.rb #{target_path}`
|
41
|
-
`sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/module Light/module #{args[:destination].titlecase}/g" #{target_path}`
|
42
|
-
`sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/TailwindCss/Light/g" #{target_path}`
|
43
|
-
`sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/light/#{args[:destination]}/g" #{target_path}`
|
44
|
-
["require", "TODO", "mattr_accessor"].each do |thing_to_remove|
|
45
|
-
`grep -v #{thing_to_remove} #{target_path} > #{target_path}.tmp`
|
46
|
-
`mv #{target_path}.tmp #{target_path}`
|
47
|
-
end
|
48
|
-
`standardrb --fix #{target_path}`
|
49
|
-
|
50
|
-
puts "Cutting local project over from `light` to `#{args[:destination]}` in `app/helpers/application_helper.rb`."
|
51
|
-
`sed -i #{'""' if `echo $OSTYPE`.include?("darwin")} "s/:light/:#{args[:destination]}/g" #{Rails.root}/app/helpers/application_helper.rb`
|
52
|
-
|
53
|
-
puts "You must restart `bin/dev` at this point, because of the changes to `Procfile.dev` and `package.json`."
|
8
|
+
BulletTrain::Themes::Application.eject_theme(get_theme_name_from_task(task), args[:destination])
|
54
9
|
end
|
55
10
|
|
56
11
|
desc "Publish your custom theme theme as a Ruby gem."
|
57
12
|
task :release, [:theme_name] => :environment do |task, args|
|
58
|
-
|
59
|
-
puts ""
|
60
|
-
puts "Before we make a new Ruby gem for your theme, you'll have to set up a GitHub repository first.".blue
|
61
|
-
puts "Hit <Return> and we'll open a browser to GitHub where you can create a new repository.".blue
|
62
|
-
puts "Make sure you name the repository ".blue + "bullet_train-themes-#{args[:theme_name]}"
|
63
|
-
puts ""
|
64
|
-
puts "When you're done, copy the SSH path from the new repository and return here.".blue
|
65
|
-
ask "We'll ask you to paste it to us in the next step."
|
66
|
-
`#{Gem::Platform.local.os == "linux" ? "xdg-open" : "open"} https://github.com/new`
|
67
|
-
|
68
|
-
ssh_path = ask "OK, what was the SSH path? (It should look like `git@github.com:your-account/your-new-repo.git`.)"
|
69
|
-
puts ""
|
70
|
-
puts "Great, you're all set.".blue
|
71
|
-
puts "We'll take it from here, so sit back and enjoy the ride 🚄️".blue
|
72
|
-
puts ""
|
73
|
-
puts "Creating a Ruby gem for ".blue + "#{args[:theme_name]}..."
|
74
|
-
|
75
|
-
Dir.mkdir("local") unless Dir.exist?("./local")
|
76
|
-
if Dir.exist?("./local/bullet_train-themes-#{args[:theme_name]}")
|
77
|
-
raise "You already have a repository named `bullet_train-themes-#{args[:theme_name]}` in `./local`.\n" \
|
78
|
-
"Make sure you delete it first to create an entirely new gem."
|
79
|
-
end
|
80
|
-
`git clone git@github.com:bullet-train-co/bullet_train-themes-light.git ./local/bullet_train-themes-#{args[:theme_name]}`
|
81
|
-
|
82
|
-
custom_file_replacer = BulletTrain::Themes::Light::CustomThemeFileReplacer.new(args[:theme_name])
|
83
|
-
custom_file_replacer.replace_theme("light", args[:theme_name])
|
84
|
-
|
85
|
-
work_tree_flag = "--work-tree=local/bullet_train-themes-#{args[:theme_name]}"
|
86
|
-
git_dir_flag = "--git-dir=local/bullet_train-themes-#{args[:theme_name]}/.git"
|
87
|
-
path = "./local/bullet_train-themes-#{args[:theme_name]}"
|
88
|
-
|
89
|
-
# Set up the proper remote.
|
90
|
-
`git #{work_tree_flag} #{git_dir_flag} remote set-url origin #{ssh_path}`
|
91
|
-
`git #{work_tree_flag} #{git_dir_flag} add .`
|
92
|
-
`git #{work_tree_flag} #{git_dir_flag} commit -m "Add initial files"`
|
93
|
-
|
94
|
-
# Build the gem.
|
95
|
-
`(cd #{path} && gem build bullet_train-themes-#{args[:theme_name]}.gemspec)`
|
96
|
-
`git #{work_tree_flag} #{git_dir_flag} add .`
|
97
|
-
`git #{work_tree_flag} #{git_dir_flag} commit -m "Build gem"`
|
98
|
-
|
99
|
-
# Commit the deleted files on the main application.
|
100
|
-
`git add .`
|
101
|
-
`git commit -m "Remove #{args[:theme_name]} files from application"`
|
102
|
-
|
103
|
-
# Push the gem's source code, but not the last commit in the main application.
|
104
|
-
`git #{work_tree_flag} #{git_dir_flag} push -u origin main`
|
105
|
-
|
106
|
-
puts ""
|
107
|
-
puts ""
|
108
|
-
puts "You're all set! Copy and paste the following commands to publish your gem:".blue
|
109
|
-
puts "cd ./local/bullet_train-themes-#{args[:theme_name]}"
|
110
|
-
puts "gem push bullet_train-themes-#{args[:theme_name]}-1.0.gem && cd ../../"
|
111
|
-
puts ""
|
112
|
-
puts "You may have to wait for some time until the gem can be downloaded via the Gemfile.".blue
|
113
|
-
puts "After a few minutes, run the following command in your main application:".blue
|
114
|
-
puts "bundle add bullet_train-themes-#{args[:theme_name]}"
|
115
|
-
puts ""
|
116
|
-
puts "Then you'll be ready to use your custom gem in your Bullet Train application.".blue
|
13
|
+
BulletTrain::Themes::Application.release_theme(get_theme_name_from_task(task), args)
|
117
14
|
end
|
118
15
|
|
119
16
|
desc "Install this theme to your main application."
|
120
|
-
task :install do |
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
# Grabs the current theme from
|
125
|
-
# def current_theme
|
126
|
-
# :theme_name
|
127
|
-
# end
|
128
|
-
current_theme_regexp = /(^ :)(.*)/
|
129
|
-
current_theme = nil
|
130
|
-
|
131
|
-
new_lines = []
|
132
|
-
[
|
133
|
-
"./app/helpers/application_helper.rb",
|
134
|
-
"./Procfile.dev",
|
135
|
-
"./package.json"
|
136
|
-
].each do |file|
|
137
|
-
File.open(file, "r") do |f|
|
138
|
-
new_lines = f.readlines
|
139
|
-
new_lines = new_lines.map do |line|
|
140
|
-
# Make sure we get the current theme before trying to replace it in any of the files.
|
141
|
-
# We grab it from the first file in the array above.
|
142
|
-
current_theme = line.scan(current_theme_regexp).flatten.last if line.match?(current_theme_regexp)
|
143
|
-
|
144
|
-
line.gsub!(/#{current_theme}/, theme_name) unless current_theme.nil?
|
145
|
-
line
|
146
|
-
end
|
147
|
-
end
|
17
|
+
task :install do |task|
|
18
|
+
BulletTrain::Themes::Application.install_theme(get_theme_name_from_task(task))
|
19
|
+
end
|
148
20
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
end
|
21
|
+
desc "List view partials in theme that haven't changed since ejection from \"Light\"."
|
22
|
+
task :clean, [:theme] => :environment do |task, args|
|
23
|
+
BulletTrain::Themes::Application.clean_theme(get_theme_name_from_task(task), args)
|
153
24
|
end
|
154
25
|
|
155
|
-
|
156
|
-
|
157
|
-
|
26
|
+
# Grabs the theme name from task, i.e. - bullet_train:theme:light:eject.
|
27
|
+
def get_theme_name_from_task(task)
|
28
|
+
task.name.split(":")[2]
|
158
29
|
end
|
159
30
|
end
|
160
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train-themes-light
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.48
|
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-
|
11
|
+
date: 2022-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- app/assets/stylesheets/light/actiontext.css
|
69
69
|
- app/assets/stylesheets/light/application.css
|
70
70
|
- app/assets/stylesheets/light/bulk_actions.css
|
71
|
+
- app/assets/stylesheets/light/devise.css
|
71
72
|
- app/assets/stylesheets/light/electron.css
|
72
73
|
- app/assets/stylesheets/light/fields/cloudinary_image.css
|
73
74
|
- app/assets/stylesheets/light/fields/date_field.css
|
@@ -128,6 +129,7 @@ files:
|
|
128
129
|
- lib/bullet_train/themes/light/engine.rb
|
129
130
|
- lib/bullet_train/themes/light/file_replacer.rb
|
130
131
|
- lib/bullet_train/themes/light/version.rb
|
132
|
+
- lib/tasks/application.rb
|
131
133
|
- lib/tasks/bullet_train/themes/light_tasks.rake
|
132
134
|
- tailwind.light.config.js
|
133
135
|
homepage: https://github.com/bullet-train-co/bullet_train-themes-light
|