Skip to content

Commit 820295f

Browse files
Generate Falcon serve configuration.
Assisted-By: devx/b3414b50-d642-461b-95a8-8f773c4d087b
1 parent 7a01a41 commit 820295f

6 files changed

Lines changed: 26 additions & 3 deletions

File tree

bake/utopia/site.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def initialize(...)
1818
SETUP_ROOT = File.expand_path("../../setup", __dir__)
1919

2020
# Configuration files which should be installed/updated:
21-
CONFIGURATION_FILES = [".gitignore", "config/application.rb", "config/environment.rb", "falcon.rb", "gems.rb", "bake.rb", "test/website.rb", "fixtures/website.rb"]
21+
CONFIGURATION_FILES = [".gitignore", "config/application.rb", "config/environment.rb", "config/serve.rb", "falcon.rb", "gems.rb", "bake.rb", "test/website.rb", "fixtures/website.rb"]
2222

2323
# Directories that should exist:
2424
DIRECTORIES = ["config", "lib", "pages", "public", "bake", "fixtures", "test"]

gems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
gem "rubocop-md"
3232
gem "rubocop-socketry"
3333

34-
gem "falcon"
34+
gem "falcon", "~> 0.57"
3535
gem "async-websocket"
3636
gem "sus-fixtures-async-http"
3737

setup/site/config/serve.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2026, by Samuel Williams.
5+
6+
require "utopia/application"
7+
8+
run Utopia::Application.load(File.expand_path("application.rb", __dir__))

setup/site/gems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
end
2828

2929
group :production do
30-
gem "falcon"
30+
gem "falcon", "~> 0.57"
3131
end

test/utopia/application.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,17 @@ def initialize(message:)
136136
expect(response.status).to be == 404
137137
end
138138
end
139+
140+
it "loads the generated serve configuration" do
141+
path = File.expand_path("../../setup/site/config/serve.rb", __dir__)
142+
application = Protocol::HTTP::Middleware.load(path)
143+
response = application.call(Protocol::HTTP::Request["GET", "/"])
144+
145+
expect(application).to be_a(Utopia::Application)
146+
expect(response.status).to be == 301
147+
expect(response.headers["location"]).to be == "/welcome/index"
148+
ensure
149+
response&.close
150+
application&.close
151+
end
139152
end

test/utopia/command.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def install_packages(dir)
5757
expect(site_files).to be(:include?, file)
5858
end
5959

60+
expect(File.file?(File.join(root, "config/serve.rb"))).to be == true
61+
6062
expect(
6163
system("bundle", "exec", "bake", "test", chdir: root)
6264
).to be == true

0 commit comments

Comments
 (0)