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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 040522701135611fb98f42262dde130ed4abf544dbcab5d61cb4bac8c4cdb381
4
- data.tar.gz: 59e927280fe2d3de6d027e8adcd6ae432174225d7cf619ff26fc4b4982520864
3
+ metadata.gz: 319140371cfe43d88e69997ed93a4c4cc0f7c54e58c798aa07c1d8c8852889fd
4
+ data.tar.gz: 8920203814f2d9f501d5e6d63ab83aed04f841568c9a85af6b39153038cc6be0
5
5
  SHA512:
6
- metadata.gz: 578ebcf29d67df3e127a0eff5049a8cb2799fd9abb503ac89c5487e36f11ae475d5a4cfbf37bbdd8efeb69ade61caa8d1267aa9d88ed3f74dcd008abc4d9d402
7
- data.tar.gz: 95fa9bfad065ed0810f84093baa5b513a207ae2cc2fe3b5ac182b3e2baf46ae70a09a32eee095242f6f208ed3263e0fb00d38ae04d47bebd7129d2cac9b39092
6
+ metadata.gz: 69a36158a145eb14e7f49b01f8463d5b3bb5823c1415a77dc6965b86c3dae188a4f4f9ea201fcc79c1eb170f8e4c8838ef2e0e8e494c29b0326e1f75ea9cb778
7
+ data.tar.gz: 48b4b8030aa45c72b8e5c98ad90dcf95b0fd753a5902b0913e30777bea564fd8cbfa37aca25d18ade3252ecac58b4040129d652cc6024f144a30fec4c7d19de3
@@ -1,15 +1,2 @@
1
- require "rvm"
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"] = final
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 print_create_summary(app_name, log_path, started_at)
136
- duration = (Time.now - started_at).round(1)
137
- bundle_ok = false
138
- Dir.chdir(app_name) do
139
- bundle_ok = system("bundle", "check", out: File::NULL, err: File::NULL)
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
- test_summary = ENV["INLINE_FORMS_CREATE_TEST_SUMMARY"].to_s
143
- test_summary = "(not run — create without --example)" if test_summary.empty?
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 #{InlineFormsInstaller.inline_forms_version} / inline_forms_installer #{InlineFormsInstaller::VERSION}", :green
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 "open3"
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 inline_forms #{ENV['inline_forms_version']} on #{Date.today}\n"
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
- test_out, test_status = Open3.capture2e("bundle", "exec", "rails", "test")
1060
- if (log_path = ENV["INLINE_FORMS_INSTALLER_LOG"]).to_s != ""
1061
- InlineFormsInstaller::CreateLog.append_section(log_path, "bundle exec rails test", test_out)
1062
- end
1063
- summary_line = test_out.lines.reverse.find { |l| l =~ /\d+ runs,/ }
1064
- ENV["INLINE_FORMS_CREATE_TEST_SUMMARY"] = summary_line&.strip || "failed (no summary line)"
1065
- abort "ERROR: bundle exec rails test failed during --example install.\n#{test_out}" unless test_status.success?
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
- if (log_path = ENV["INLINE_FORMS_INSTALLER_LOG"]).to_s != ""
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
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineFormsInstaller
3
- VERSION = "7.13.13"
3
+ VERSION = "7.13.15"
4
4
 
5
5
  # Written into generated apps' `.ruby-version` (must match gemspec `required_ruby_version`).
6
6
  TARGET_RUBY_VERSION = "ruby-4.0.4"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms_installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.13.13
4
+ version: 7.13.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares