Commit d5bc2531 authored by Vadim Vlasov's avatar Vadim Vlasov

fix(appgate): make app-info an optional dependency

Pluginfiles pull the plugin from git, so a runtime dependency would make
every pipeline install app-info (Ruby 3.1+) even when it only uploads
with app tokens. The gem is now loaded lazily for org-key uploads without
bundle_id; when it is missing the error says how to add it or to pass
bundle_id.
Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent ed840b81
...@@ -35,22 +35,29 @@ bundle id and platform, or creates it on the first upload: ...@@ -35,22 +35,29 @@ bundle id and platform, or creates it on the first upload:
```ruby ```ruby
appgate_upload( appgate_upload(
api_key: ENV["APPGATE_ORG_API_KEY"], # agk_... api_key: ENV["APPGATE_API_KEY"], # agk_...
file_path: "build/MyApp.apk" file_path: "build/MyApp.apk"
) )
``` ```
- `platform` is detected from the file (`.ipa`, `.apk`/`.aab`, `.app.zip`/`.dmg`/`.pkg`, `.exe`/`.msi`/`.msix`/`.appx`...). - `platform` is detected from the file (`.ipa`, `.apk`/`.aab`, `.app.zip`/`.dmg`/`.pkg`, `.exe`/`.msi`/`.msix`/`.appx`...).
Set it for WebGL and for a plain `.zip` that is not a macOS app. Set it for WebGL and for a plain `.zip` that is not a macOS app.
- `bundle_id` is read from the build with the `app-info` gem. Set it for WebGL and for - `bundle_id` is read from the build with the optional `app-info` gem (Ruby 3.1+), which the
files it cannot be read from (e.g. a Windows `.exe`). plugin does not install. Either add it to your `Pluginfile` (or `Gemfile`) and run `bundle install`:
```ruby
gem "app-info"
```
or pass `bundle_id` yourself. Always pass it for WebGL and for files it cannot be read from
(e.g. a Windows `.exe`).
- `app_name` names the app if AppGate has to create it. - `app_name` names the app if AppGate has to create it.
- If several apps of the organization share the bundle id and platform, the upload fails - If several apps of the organization share the bundle id and platform, the upload fails
with their ids; pass `app_id` to pick one. with their ids; pass `app_id` to pick one.
```ruby ```ruby
appgate_upload( appgate_upload(
api_key: ENV["APPGATE_ORG_API_KEY"], api_key: ENV["APPGATE_API_KEY"],
file_path: "build/webgl.zip", file_path: "build/webgl.zip",
platform: "WebGL", platform: "WebGL",
bundle_id: "com.example.mygame.web", bundle_id: "com.example.mygame.web",
......
...@@ -34,6 +34,6 @@ Gem::Specification.new do |spec| ...@@ -34,6 +34,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency('fastlane', '>= 2.129.0') spec.add_development_dependency('fastlane', '>= 2.129.0')
spec.add_runtime_dependency 'faraday', '~> 1.0' spec.add_runtime_dependency 'faraday', '~> 1.0'
# Published as app-info, required as 'app_info'; reads bundle ids for the org API key flow. # app-info (required as 'app_info') is optional: only org-key uploads without `bundle_id` load it,
spec.add_runtime_dependency 'app-info', '>= 3.0' # so app-token pipelines do not pull it in or need its Ruby version.
end end
...@@ -142,7 +142,8 @@ module Fastlane ...@@ -142,7 +142,8 @@ module Fastlane
end end
UI.user_error!("Could not detect the platform of '#{File.basename(file_path)}'. " \ UI.user_error!("Could not detect the platform of '#{File.basename(file_path)}'. " \
"Pass `platform` (one of: #{PLATFORMS.join(', ')}).") "Pass `platform` (one of: #{PLATFORMS.join(', ')}); " \
"macOS .zip builds are recognized only with the optional app-info gem installed.")
end end
def self.extract_bundle_id(file_path, platform) def self.extract_bundle_id(file_path, platform)
...@@ -157,7 +158,11 @@ module Fastlane ...@@ -157,7 +158,11 @@ module Fastlane
AppInfo.parse(file_path) do |parser| AppInfo.parse(file_path) do |parser|
bundle_id = parser.bundle_id if parser.respond_to?(:bundle_id) bundle_id = parser.bundle_id if parser.respond_to?(:bundle_id)
end end
rescue StandardError, LoadError => e rescue LoadError
UI.user_error!("Reading the bundle id from '#{File.basename(file_path)}' needs the optional app-info gem. " \
"Add `gem \"app-info\"` to your Pluginfile (or Gemfile) and run `bundle install`, " \
"or pass `bundle_id` explicitly.")
rescue StandardError => e
UI.user_error!("Could not read bundle id from '#{File.basename(file_path)}' (#{e.message}). " \ UI.user_error!("Could not read bundle id from '#{File.basename(file_path)}' (#{e.message}). " \
"Pass `bundle_id` explicitly.") "Pass `bundle_id` explicitly.")
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment