homura-runtime 0.2.6 → 0.2.7
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/CHANGELOG.md +10 -0
- data/exe/homura-build +37 -6
- data/lib/cloudflare_workers/build_support.rb +1 -1
- data/lib/cloudflare_workers/version.rb +1 -1
- data/lib/cloudflare_workers.rb +5 -0
- 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: b1a1cd099709c81d7dfba2a41d071ab47f343c253f5826a031107011903706c9
|
|
4
|
+
data.tar.gz: 54dcad51d26b66db5da83a6245ee3402418bd1af891cee59627b61f0c7760fc7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17be34147d20fe3c90c5bf50b5e1aa3fc0f0fa659e519659243566b3828bf7ffae88b1d129589ff34916b7406a650d1aed652500de4f5ba6e0400c5e00e5aae9
|
|
7
|
+
data.tar.gz: e5a79b2eff5c805f2b06c83843dd99a1614d99defab71d1be52a8634046b1eb97f51f2e07f80ab8b41543e3b0b559c88d483bc70a00e429fafbc8b4ec9daf41d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.7 (2026-04-24)
|
|
4
|
+
|
|
5
|
+
- Auto-detect standalone app entrypoints from `config.ru`, `app/hello.rb`, then
|
|
6
|
+
`app/app.rb`, and accept `config.ru` inputs by compiling a temporary Ruby copy
|
|
7
|
+
under the hood.
|
|
8
|
+
- Add the project root to standalone Opal load paths so standard
|
|
9
|
+
`require_relative 'app/app'` config.ru setups compile without extra wrappers.
|
|
10
|
+
- Synthesize `HTTP_HOST` from the request URL inside the Rack env so absolute
|
|
11
|
+
redirects preserve the current host and non-default port in local dev.
|
|
12
|
+
|
|
3
13
|
## 0.2.6 (2026-04-24)
|
|
4
14
|
|
|
5
15
|
- Remove the shipped `cloudflare-workers-build` filename entirely and keep the
|
data/exe/homura-build
CHANGED
|
@@ -37,7 +37,7 @@ end
|
|
|
37
37
|
options = {
|
|
38
38
|
root: Dir.pwd,
|
|
39
39
|
standalone: false,
|
|
40
|
-
opal_input: ENV['HOMURA_OPAL_INPUT']
|
|
40
|
+
opal_input: ENV['HOMURA_OPAL_INPUT'],
|
|
41
41
|
opal_output: ENV['HOMURA_OPAL_OUTPUT'] || 'build/hello.no-exit.mjs',
|
|
42
42
|
patch_input: ENV['HOMURA_OPAL_PATCH_INPUT'],
|
|
43
43
|
setup_import: nil,
|
|
@@ -100,6 +100,7 @@ def run_opal_homura!(root, opal_input, opal_output)
|
|
|
100
100
|
argv = [
|
|
101
101
|
'bundle', 'exec', 'opal',
|
|
102
102
|
'-c', '-E', '--esm', '--no-source-map',
|
|
103
|
+
'-I', '.',
|
|
103
104
|
'-I', 'build/auto_await/app', '-I', 'build/auto_await', '-I', 'app',
|
|
104
105
|
'-I', 'gems/homura-runtime/lib',
|
|
105
106
|
'-I', 'gems/sinatra-homura/lib',
|
|
@@ -147,6 +148,26 @@ def write_entrypoint!(root, out_path, setup:, bundle:, worker_mod:)
|
|
|
147
148
|
File.write(root.join(out_path), body)
|
|
148
149
|
end
|
|
149
150
|
|
|
151
|
+
def resolve_opal_input(root, explicit_input)
|
|
152
|
+
return explicit_input if explicit_input
|
|
153
|
+
|
|
154
|
+
candidates = ['config.ru', 'app/hello.rb', 'app/app.rb']
|
|
155
|
+
found = candidates.find { |path| root.join(path).file? }
|
|
156
|
+
return found if found
|
|
157
|
+
|
|
158
|
+
abort("homura build: no default entrypoint found (looked for #{candidates.join(', ')})")
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def prepare_opal_input(root, input_path)
|
|
162
|
+
rel = Pathname(input_path)
|
|
163
|
+
rel = root.join(rel).relative_path_from(root) if rel.absolute?
|
|
164
|
+
return [rel.to_s, nil] unless rel.extname == '.ru'
|
|
165
|
+
|
|
166
|
+
tmp = root.join(".homura-build-#{rel.basename}.rb")
|
|
167
|
+
File.write(tmp, root.join(rel).read)
|
|
168
|
+
[tmp.relative_path_from(root).to_s, tmp]
|
|
169
|
+
end
|
|
170
|
+
|
|
150
171
|
unless options[:standalone]
|
|
151
172
|
run!(['ruby', 'bin/inline-routes-for-opal'], chdir: root)
|
|
152
173
|
run!(
|
|
@@ -184,11 +205,16 @@ unless options[:standalone]
|
|
|
184
205
|
chdir: root
|
|
185
206
|
)
|
|
186
207
|
|
|
187
|
-
opal_in = Pathname(options[:opal_input])
|
|
208
|
+
opal_in = Pathname(resolve_opal_input(root, options[:opal_input]))
|
|
188
209
|
opal_out = Pathname(options[:opal_output])
|
|
189
210
|
opal_in = root.join(opal_in) unless opal_in.absolute?
|
|
190
211
|
opal_out = root.join(opal_out) unless opal_out.absolute?
|
|
191
|
-
|
|
212
|
+
prepared_in, temp_input = prepare_opal_input(root, opal_in)
|
|
213
|
+
begin
|
|
214
|
+
run_opal_homura!(root, prepared_in, opal_out.relative_path_from(root).to_s)
|
|
215
|
+
ensure
|
|
216
|
+
FileUtils.rm_f(temp_input) if temp_input
|
|
217
|
+
end
|
|
192
218
|
else
|
|
193
219
|
CloudflareWorkers::BuildSupport.ensure_standalone_runtime(root, current_file: __FILE__)
|
|
194
220
|
run!(
|
|
@@ -218,12 +244,17 @@ else
|
|
|
218
244
|
chdir: root
|
|
219
245
|
)
|
|
220
246
|
|
|
221
|
-
opal_in = Pathname(options[:opal_input])
|
|
247
|
+
opal_in = Pathname(resolve_opal_input(root, options[:opal_input]))
|
|
222
248
|
opal_out = Pathname(options[:opal_output])
|
|
223
249
|
opal_in = root.join(opal_in) unless opal_in.absolute?
|
|
224
250
|
opal_out = root.join(opal_out) unless opal_out.absolute?
|
|
225
|
-
|
|
226
|
-
|
|
251
|
+
prepared_in, temp_input = prepare_opal_input(root, opal_in)
|
|
252
|
+
begin
|
|
253
|
+
run_opal_standalone!(root, prepared_in, opal_out.relative_path_from(root).to_s,
|
|
254
|
+
with_db: options[:with_db])
|
|
255
|
+
ensure
|
|
256
|
+
FileUtils.rm_f(temp_input) if temp_input
|
|
257
|
+
end
|
|
227
258
|
end
|
|
228
259
|
|
|
229
260
|
patch_rel = Pathname(patch_target)
|
|
@@ -61,7 +61,7 @@ module CloudflareWorkers
|
|
|
61
61
|
hv = vendor_from_gemfile(root)
|
|
62
62
|
load_paths << hv.to_s if hv
|
|
63
63
|
|
|
64
|
-
load_paths += ['build/auto_await/app', 'app']
|
|
64
|
+
load_paths += ['.', 'build/auto_await/app', 'app']
|
|
65
65
|
[
|
|
66
66
|
gem_lib(RUNTIME_GEM_NAME, loaded_specs: loaded_specs),
|
|
67
67
|
gem_vendor(RUNTIME_GEM_NAME, loaded_specs: loaded_specs),
|
data/lib/cloudflare_workers.rb
CHANGED
|
@@ -204,6 +204,11 @@ module Rack
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
copy_headers_into_env(js_req, env)
|
|
207
|
+
env['HTTP_HOST'] = if port == (scheme == 'https' ? '443' : '80')
|
|
208
|
+
host
|
|
209
|
+
else
|
|
210
|
+
"#{host}:#{port}"
|
|
211
|
+
end
|
|
207
212
|
|
|
208
213
|
# Cloudflare-specific extras under their own namespace, per the
|
|
209
214
|
# Rack convention that env keys other than the standard ones
|