From e37e3760acc92e7b79d3869286442f7ea52ae62f Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Fri, 31 Jul 2026 16:33:51 +0200 Subject: [PATCH] godot support --- apps/api/app/admin/softwares.rb | 4 ++-- .../controllers/api/software_controller.rb | 2 +- .../api/software_highlighted_controller.rb | 2 +- apps/api/app/controllers/update_controller.rb | 2 +- .../software_updater/godot_service.rb | 22 +++++++++++++++++++ apps/api/app/services/update_service.rb | 3 ++- apps/api/spec/services/update_service_spec.rb | 12 ++++++++++ 7 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 apps/api/app/services/software_updater/godot_service.rb diff --git a/apps/api/app/admin/softwares.rb b/apps/api/app/admin/softwares.rb index a8274ba..ca53579 100644 --- a/apps/api/app/admin/softwares.rb +++ b/apps/api/app/admin/softwares.rb @@ -37,7 +37,7 @@ ActiveAdmin.register Software do filter :name filter :title filter :author - filter :platform, as: :select, collection: %w[tic80 ebitengine love c64] + filter :platform, as: :select, collection: %w[tic80 ebitengine love c64 godot] filter :status, as: :select, collection: %w[development demo released archived] filter :highlighted @@ -93,7 +93,7 @@ ActiveAdmin.register Software do f.input :name f.input :title f.input :author - f.input :platform, as: :select, collection: %w[tic80 ebitengine love c64] + f.input :platform, as: :select, collection: %w[tic80 ebitengine love c64 godot] f.input :status, as: :select, collection: %w[development demo released archived] f.input :highlighted f.input :license diff --git a/apps/api/app/controllers/api/software_controller.rb b/apps/api/app/controllers/api/software_controller.rb index 6da6dfb..0e30f1b 100644 --- a/apps/api/app/controllers/api/software_controller.rb +++ b/apps/api/app/controllers/api/software_controller.rb @@ -37,7 +37,7 @@ class Api::SoftwareController < ApiController property :desc, String, desc: "Short description" property :story, String, desc: "Long description / story" property :license, String, desc: "License type" - property :platform, String, desc: "Platform (tic80, love, ebitengine, c64)" + property :platform, String, desc: "Platform (tic80, love, ebitengine, c64, godot)" property :status, String, desc: "Status (active, inactive)" property :highlighted, :boolean, desc: "Currently highlighted" property :imageUrl, String, desc: "Default image URL" diff --git a/apps/api/app/controllers/api/software_highlighted_controller.rb b/apps/api/app/controllers/api/software_highlighted_controller.rb index 35489ef..4af2f8a 100644 --- a/apps/api/app/controllers/api/software_highlighted_controller.rb +++ b/apps/api/app/controllers/api/software_highlighted_controller.rb @@ -13,7 +13,7 @@ class Api::SoftwareHighlightedController < ApiController property :desc, String, desc: "Short description" property :story, String, desc: "Long description / story" property :license, String, desc: "License type" - property :platform, String, desc: "Platform (tic80, love, ebitengine, c64)" + property :platform, String, desc: "Platform (tic80, love, ebitengine, c64, godot)" property :status, String, desc: "Status" property :highlighted, :boolean, desc: "Highlighted flag" property :imageUrl, String, desc: "Default image URL" diff --git a/apps/api/app/controllers/update_controller.rb b/apps/api/app/controllers/update_controller.rb index f60735e..381742b 100644 --- a/apps/api/app/controllers/update_controller.rb +++ b/apps/api/app/controllers/update_controller.rb @@ -6,7 +6,7 @@ class UpdateController < ApiController api :GET, "/update", "Update software version in database" param :secret, String, required: true, desc: "Authorization secret" - param :platform, String, required: false, desc: "Platform (tic80, love, ebitengine, c64)" + param :platform, String, required: false, desc: "Platform (tic80, love, ebitengine, c64, godot)" param :name, String, required: false, desc: "Software name" param :version, String, required: true, desc: "Version string" returns code: 200, desc: "Plain text 'Updated'" diff --git a/apps/api/app/services/software_updater/godot_service.rb b/apps/api/app/services/software_updater/godot_service.rb new file mode 100644 index 0000000..ce4882c --- /dev/null +++ b/apps/api/app/services/software_updater/godot_service.rb @@ -0,0 +1,22 @@ +module SoftwareUpdater + class GodotService < BaseService + def update(name, version) + versioned = "#{name}-#{version}" + extract_zip_to_dir("#{versioned}.html.zip", versioned) + + metadata = parse_json_metadata(full_path("#{versioned}.metadata.json")) + site_url = metadata.delete(:site) + + ActiveRecord::Base.transaction do + software = update_or_create_software(metadata.merge(platform: "godot")) + upsert_external_link(software.id, "Source Code", site_url) if site_url.present? + + create_release_if_not_exists( + software_id: software.id, + version: version, + html_folder_path: full_path(versioned) + ) + end + end + end +end diff --git a/apps/api/app/services/update_service.rb b/apps/api/app/services/update_service.rb index 36f3059..39ef998 100644 --- a/apps/api/app/services/update_service.rb +++ b/apps/api/app/services/update_service.rb @@ -3,7 +3,8 @@ class UpdateService "tic80" => "SoftwareUpdater::Tic80Service", "ebitengine" => "SoftwareUpdater::EbitengineService", "love" => "SoftwareUpdater::LoveService", - "c64" => "SoftwareUpdater::C64Service" + "c64" => "SoftwareUpdater::C64Service", + "godot" => "SoftwareUpdater::GodotService" }.freeze def update(input) diff --git a/apps/api/spec/services/update_service_spec.rb b/apps/api/spec/services/update_service_spec.rb index a551d78..c195d8b 100644 --- a/apps/api/spec/services/update_service_spec.rb +++ b/apps/api/spec/services/update_service_spec.rb @@ -19,5 +19,17 @@ RSpec.describe UpdateService do expect(mock_service).to have_received(:update).with("game", "1.0") end + + it "routes godot platform to GodotService" do + input = UpdateInputDto.new(platform: "godot", name: "game", version: "1.0") + mock_service = instance_double(SoftwareUpdater::GodotService) + + allow(SoftwareUpdater::GodotService).to receive(:new).and_return(mock_service) + allow(mock_service).to receive(:update) + + described_class.new.update(input) + + expect(mock_service).to have_received(:update).with("game", "1.0") + end end end