inline_forms_installer 7.13.13 → 7.13.15
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/lib/inline_forms_installer/app_template.rb +1 -14
- data/lib/inline_forms_installer/create_log.rb +32 -2
- data/lib/inline_forms_installer/creator.rb +46 -10
- data/lib/inline_forms_installer/installer_core.rb +25 -10
- data/lib/inline_forms_installer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 319140371cfe43d88e69997ed93a4c4cc0f7c54e58c798aa07c1d8c8852889fd
|
|
4
|
+
data.tar.gz: 8920203814f2d9f501d5e6d63ab83aed04f841568c9a85af6b39153038cc6be0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69a36158a145eb14e7f49b01f8463d5b3bb5823c1415a77dc6965b86c3dae188a4f4f9ea201fcc79c1eb170f8e4c8838ef2e0e8e494c29b0326e1f75ea9cb778
|
|
7
|
+
data.tar.gz: 48b4b8030aa45c72b8e5c98ad90dcf95b0fd753a5902b0913e30777bea564fd8cbfa37aca25d18ade3252ecac58b4040129d652cc6024f144a30fec4c7d19de3
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if RVM.current && ENV["skiprvm"] != "true"
|
|
4
|
-
RVM.chdir(File.expand_path(".")) do
|
|
5
|
-
say "Working directory is #{`pwd`}"
|
|
6
|
-
RVM.use_from_path! "."
|
|
7
|
-
rvm_gemset = %x[rvm current]
|
|
8
|
-
say "RVM GEMSET is now #{rvm_gemset}"
|
|
9
|
-
say "Installing using gemset : #{RVM.current.environment_name}", :green
|
|
10
|
-
end
|
|
11
|
-
else
|
|
12
|
-
say "Installing without RVM", :green
|
|
13
|
-
end
|
|
14
|
-
|
|
1
|
+
# RVM gemset switch happens in installer_core.rb after .ruby-gemset is written.
|
|
15
2
|
apply(File.join(__dir__, "installer_core.rb"))
|
|
@@ -14,15 +14,45 @@ module InlineFormsInstaller
|
|
|
14
14
|
File.expand_path(File.join(app_name, "log", basename_for(started_at)))
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def write_header(path, started_at: Time.now, display_path: nil)
|
|
18
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
19
|
+
shown = display_path || path
|
|
20
|
+
File.open(path, "w") do |f|
|
|
21
|
+
f.puts "=== inline_forms create install log ==="
|
|
22
|
+
f.puts "started: #{started_at.iso8601}"
|
|
23
|
+
f.puts "Install log: #{shown}"
|
|
24
|
+
f.puts ""
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def append_summary(path, started_at:, duration_s:, inline_forms_version:, installer_version:, bundle_ok:, test_summary:)
|
|
29
|
+
append_section(
|
|
30
|
+
path,
|
|
31
|
+
"install summary",
|
|
32
|
+
<<~TEXT
|
|
33
|
+
finished: #{Time.now.iso8601}
|
|
34
|
+
duration: #{duration_s}s
|
|
35
|
+
inline_forms: #{inline_forms_version}
|
|
36
|
+
inline_forms_installer: #{installer_version}
|
|
37
|
+
bundle check: #{bundle_ok ? "ok" : "FAILED"}
|
|
38
|
+
tests: #{test_summary}
|
|
39
|
+
Install log: #{path}
|
|
40
|
+
TEXT
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
17
44
|
def tee_rails_new(app_name, shell_command, started_at: Time.now)
|
|
18
45
|
final = final_path(app_name, started_at)
|
|
19
46
|
tmp = File.expand_path(basename_for(started_at))
|
|
20
|
-
ENV["INLINE_FORMS_INSTALLER_LOG"] =
|
|
47
|
+
ENV["INLINE_FORMS_INSTALLER_LOG"] = tmp
|
|
48
|
+
ENV["INLINE_FORMS_INSTALLER_LOG_DISPLAY"] = final
|
|
21
49
|
ENV["INLINE_FORMS_CREATE_STARTED_AT"] = started_at.iso8601
|
|
22
50
|
|
|
51
|
+
write_header(tmp, started_at: started_at, display_path: final)
|
|
52
|
+
|
|
23
53
|
ok = system(
|
|
24
54
|
"bash", "-c",
|
|
25
|
-
"#{shell_command} 2>&1 | tee #{Shellwords.escape(tmp)}; exit ${PIPESTATUS[0]}"
|
|
55
|
+
"#{shell_command} 2>&1 | tee -a #{Shellwords.escape(tmp)}; exit ${PIPESTATUS[0]}"
|
|
26
56
|
)
|
|
27
57
|
|
|
28
58
|
if ok && File.directory?(app_name)
|
|
@@ -129,27 +129,63 @@ module InlineFormsInstaller
|
|
|
129
129
|
exit 1
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
-
print_create_summary(app_name, log_path, started_at)
|
|
132
|
+
print_create_summary(app_name, log_path, started_at, install_example?)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
def
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
def test_summary_from_log(log_path, ran_example)
|
|
136
|
+
return "(not run — create without --example)" unless ran_example
|
|
137
|
+
return "(install log missing)" unless log_path.to_s != "" && File.file?(log_path)
|
|
138
|
+
|
|
139
|
+
summary = File.read(log_path).lines.reverse.find { |l| l =~ /\d+ runs,/ }
|
|
140
|
+
return summary.strip if summary
|
|
141
|
+
|
|
142
|
+
"(see install log — no Minitest summary line)"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def bundle_check_ok?(app_name)
|
|
146
|
+
app_dir = File.expand_path(app_name)
|
|
147
|
+
return false unless File.directory?(app_dir)
|
|
148
|
+
|
|
149
|
+
if !options[:skiprvm] && defined?(RVM) && RVM.current
|
|
150
|
+
require "rvm"
|
|
151
|
+
RVM.chdir(app_dir) do
|
|
152
|
+
RVM.use_from_path! "."
|
|
153
|
+
system("bundle", "check", out: File::NULL, err: File::NULL)
|
|
154
|
+
end
|
|
155
|
+
else
|
|
156
|
+
Dir.chdir(app_dir) do
|
|
157
|
+
system("bundle", "check", out: File::NULL, err: File::NULL)
|
|
158
|
+
end
|
|
140
159
|
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def print_create_summary(app_name, log_path, started_at, ran_example)
|
|
163
|
+
duration = (Time.now - started_at).round(1)
|
|
164
|
+
bundle_ok = bundle_check_ok?(app_name)
|
|
165
|
+
|
|
166
|
+
test_summary = test_summary_from_log(log_path, ran_example)
|
|
167
|
+
|
|
168
|
+
if_ver = InlineFormsInstaller.inline_forms_version
|
|
169
|
+
inst_ver = InlineFormsInstaller::VERSION
|
|
141
170
|
|
|
142
|
-
|
|
143
|
-
|
|
171
|
+
InlineFormsInstaller::CreateLog.append_summary(
|
|
172
|
+
log_path,
|
|
173
|
+
started_at: started_at,
|
|
174
|
+
duration_s: duration,
|
|
175
|
+
inline_forms_version: if_ver,
|
|
176
|
+
installer_version: inst_ver,
|
|
177
|
+
bundle_ok: bundle_ok,
|
|
178
|
+
test_summary: test_summary
|
|
179
|
+
)
|
|
144
180
|
|
|
145
181
|
say ""
|
|
146
182
|
say "Install complete (#{duration}s)", :green
|
|
147
|
-
say " inline_forms #{
|
|
183
|
+
say " inline_forms #{if_ver} / inline_forms_installer #{inst_ver}", :green
|
|
148
184
|
say " bundle check: #{bundle_ok ? 'ok' : 'FAILED'}", bundle_ok ? :green : :red
|
|
149
185
|
say " tests: #{test_summary}", :green
|
|
150
186
|
say "Install log: #{log_path}", :green
|
|
151
187
|
end
|
|
152
|
-
private :print_create_summary
|
|
188
|
+
private :print_create_summary, :test_summary_from_log, :bundle_check_ok?
|
|
153
189
|
end
|
|
154
190
|
end
|
|
155
191
|
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "shellwords"
|
|
2
2
|
|
|
3
3
|
INSTALLER_ROOT = File.expand_path(ENV.fetch("INLINE_FORMS_INSTALLER_ROOT", File.expand_path("..", __dir__)))
|
|
4
4
|
INLINE_FORMS_ROOT = File.expand_path(ENV.fetch("INLINE_FORMS_ROOT", INSTALLER_ROOT))
|
|
5
5
|
require File.join(INSTALLER_ROOT, "lib", "inline_forms_installer", "create_log")
|
|
6
6
|
|
|
7
|
+
def use_app_rvm_gemset!
|
|
8
|
+
return if ENV["skiprvm"] == "true"
|
|
9
|
+
return unless (gemset = ENV["inline_forms_rvm_gemset"]).to_s != ""
|
|
10
|
+
return unless defined?(RVM) && RVM.current
|
|
11
|
+
|
|
12
|
+
require "rvm"
|
|
13
|
+
say "Working directory is #{Dir.pwd}", :green
|
|
14
|
+
RVM.use_from_path! "."
|
|
15
|
+
say "Installing using gemset: #{RVM.current.environment_name}", :green
|
|
16
|
+
end
|
|
17
|
+
|
|
7
18
|
def bundle_install!
|
|
8
19
|
say "- Running bundle install..."
|
|
9
20
|
unless system("bundle", "install")
|
|
@@ -20,11 +31,12 @@ create_file ".ruby-version", "#{ENV.fetch('ruby_version', 'ruby-4.0.4')}\n"
|
|
|
20
31
|
if (gemset = ENV["inline_forms_rvm_gemset"]).to_s != ""
|
|
21
32
|
create_file ".ruby-gemset", "#{gemset}\n"
|
|
22
33
|
end
|
|
34
|
+
use_app_rvm_gemset!
|
|
23
35
|
|
|
24
36
|
# Rails 7 dropped --skip-gemfile, so `rails new` always writes its own Gemfile.
|
|
25
37
|
# Remove it so our `create_file` below does not prompt for overwrite.
|
|
26
38
|
remove_file 'Gemfile' if File.exist?('Gemfile')
|
|
27
|
-
create_file 'Gemfile', "# created by
|
|
39
|
+
create_file 'Gemfile', "# created by inline_forms_installer #{ENV['inline_forms_installer_version']} on #{Date.today}\n"
|
|
28
40
|
|
|
29
41
|
# `rails new` is invoked with whatever the system `rails` binary points at
|
|
30
42
|
# (often Rails 8.x), so the generated `config/application.rb` may carry
|
|
@@ -1056,18 +1068,21 @@ if ENV['install_example'] == 'true'
|
|
|
1056
1068
|
end
|
|
1057
1069
|
|
|
1058
1070
|
say "- Running example regression tests (bundle exec rails test)..."
|
|
1059
|
-
|
|
1060
|
-
if
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1071
|
+
log_path = ENV["INLINE_FORMS_INSTALLER_LOG"].to_s
|
|
1072
|
+
test_cmd = if log_path != ""
|
|
1073
|
+
"bundle exec rails test 2>&1 | tee -a #{Shellwords.escape(log_path)}"
|
|
1074
|
+
else
|
|
1075
|
+
"bundle exec rails test 2>&1"
|
|
1076
|
+
end
|
|
1077
|
+
test_ok = system("bash", "-c", "#{test_cmd}; exit ${PIPESTATUS[0]}")
|
|
1078
|
+
abort "ERROR: bundle exec rails test failed during --example install. See #{log_path}" unless test_ok
|
|
1066
1079
|
|
|
1067
1080
|
say "\nDone! Example app (Photo + Apartment + Owner) is ready.", :yellow
|
|
1068
1081
|
say " cd #{File.basename(Dir.pwd)} && rvm use . && bundle exec rails s", :yellow
|
|
1069
1082
|
say " http://localhost:3000/apartments — #{ENV["email"]} / #{ENV["password"]}", :yellow
|
|
1070
|
-
|
|
1083
|
+
log_path = ENV["INLINE_FORMS_INSTALLER_LOG_DISPLAY"].to_s
|
|
1084
|
+
log_path = ENV["INLINE_FORMS_INSTALLER_LOG"].to_s if log_path.empty?
|
|
1085
|
+
if log_path != ""
|
|
1071
1086
|
say " Install log: #{log_path}", :yellow
|
|
1072
1087
|
end
|
|
1073
1088
|
end
|