summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichał Dudziński <[email protected]>2021-04-10 19:36:50 +0200
committerAmir Rajan <[email protected]>2021-05-26 16:19:13 -0500
commitbfab20c9a8a5f2abc5cf2b834c662ea89ad4adde (patch)
tree1957caa8133d391b3aa2d85ae4757a2dedcdea4f
parentd5115606c96b0fe0affd72e6e0b72edce7e51042 (diff)
downloaddragonruby-game-toolkit-contrib-bfab20c9a8a5f2abc5cf2b834c662ea89ad4adde.tar.gz
dragonruby-game-toolkit-contrib-bfab20c9a8a5f2abc5cf2b834c662ea89ad4adde.zip
iOS wizard: determine version from either opts or metadata file
-rw-r--r--dragon/ios_wizard.rb31
-rw-r--r--dragon/itch_wizard.rb37
-rw-r--r--dragon/metadata.rb41
3 files changed, 67 insertions, 42 deletions
diff --git a/dragon/ios_wizard.rb b/dragon/ios_wizard.rb
index 9383749..81bd88e 100644
--- a/dragon/ios_wizard.rb
+++ b/dragon/ios_wizard.rb
@@ -1,3 +1,4 @@
+# Contributors outside of DragonRuby who also hold Copyright: Michał Dudziński
# Copyright 2019 DragonRuby LLC
# MIT License
# ios_wizard.rb has been released under MIT (*only this file*).
@@ -11,6 +12,8 @@ class WizardException < Exception
end
class IOSWizard
+ include Metadata
+
def initialize
@doctor_executed_at = 0
end
@@ -84,15 +87,19 @@ class IOSWizard
def start opts = nil
@opts = opts || {}
- if !(@opts.is_a? Hash) || !($gtk.args.fn.eq_any? @opts[:env], :dev, :prod)
+ unless $gtk.args.fn.eq_any? @opts[:env], :dev, :prod
raise WizardException.new(
- "* $wizards.ios.start needs to be provided an environment option.",
- "** For development builds type: $wizards.ios.start env: :dev",
- "** For production builds type: $wizards.ios.start env: :prod"
- )
+ "* $wizards.ios.start needs to be provided an environment option.",
+ "** For development builds type: $wizards.ios.start env: :dev",
+ "** For production builds type: $wizards.ios.start env: :prod"
+ )
end
@production_build = (@opts[:env] == :prod)
+
+ @version = determine_app_version @opts
+ log_info "I will be using version: '#{@version}'" if @production_build
+
@steps = steps_development_build
@steps = steps_production_build if @production_build
@certificate_name = nil
@@ -235,6 +242,15 @@ class IOSWizard
log_info "App name is: #{@app_name}."
end
+ def determine_app_version opts
+ version = @opts[:version]
+ unless version
+ version = get_metadata[:version]
+ version = version.start_with?('#') ? '1.0' : version.split('=').last
+ end
+ version.to_s
+ end
+
def provisioning_profile_xml environment
xml = $gtk.read_file (provisioning_profile_path environment)
scrubbed = xml.each_line.map do |l|
@@ -798,7 +814,7 @@ XML
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>5.2</string>
+ <string>:version</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
@@ -806,7 +822,7 @@ XML
<string>iPhoneOS</string>
</array>
<key>CFBundleVersion</key>
- <string>5.2</string>
+ <string>:version</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
@@ -890,6 +906,7 @@ XML
info_plist_string.gsub!(":app_name", @app_name)
info_plist_string.gsub!(":app_id", @app_id)
+ info_plist_string.gsub!(":version", @version);
$gtk.write_file_root "tmp/ios/#{@app_name}.app/Info.plist", info_plist_string.strip
diff --git a/dragon/itch_wizard.rb b/dragon/itch_wizard.rb
index d87d07c..c0a69de 100644
--- a/dragon/itch_wizard.rb
+++ b/dragon/itch_wizard.rb
@@ -3,6 +3,8 @@
# itch_wizard.rb has been released under MIT (*only this file*).
class ItchWizard
+ include Metadata
+
def steps
[
:check_metadata,
@@ -10,41 +12,6 @@ class ItchWizard
]
end
- def metadata_file_path
- "metadata/game_metadata.txt"
- end
-
- def get_metadata
- metadata = $gtk.read_file metadata_file_path
-
- if !metadata
- write_blank_metadata
- metadata = $gtk.read_file metadata_file_path
- end
-
- dev_id, dev_title, game_id, game_title, version, icon = *metadata.each_line.to_a
-
- {
- dev_id: dev_id.strip,
- dev_title: dev_title.strip,
- game_id: game_id.strip,
- game_title: game_title.strip,
- version: version.strip,
- icon: icon.strip
- }
- end
-
- def write_blank_metadata
- $gtk.write_file metadata_file_path, <<-S.strip
-#devid=myname
-#devtitle=My Name
-#gameid=mygame
-#gametitle=My Game
-#version=0.1
-#icon=metadata/icon.png
-S
- end
-
def check_metadata
metadata_text = $gtk.read_file metadata_file_path
if !metadata_text
diff --git a/dragon/metadata.rb b/dragon/metadata.rb
new file mode 100644
index 0000000..88d9b60
--- /dev/null
+++ b/dragon/metadata.rb
@@ -0,0 +1,41 @@
+# Contributors outside of DragonRuby who also hold Copyright: Michał Dudziński
+# Copyright 2021 DragonRuby LLC
+# MIT License
+# metadata.rb has been released under MIT (*only this file*).
+
+module Metadata
+ def metadata_file_path
+ "metadata/game_metadata.txt"
+ end
+
+ def get_metadata
+ metadata = $gtk.read_file metadata_file_path
+
+ if !metadata
+ write_blank_metadata
+ metadata = $gtk.read_file metadata_file_path
+ end
+
+ dev_id, dev_title, game_id, game_title, version, icon = *metadata.each_line.to_a
+
+ {
+ dev_id: dev_id.strip,
+ dev_title: dev_title.strip,
+ game_id: game_id.strip,
+ game_title: game_title.strip,
+ version: version.strip,
+ icon: icon.strip
+ }
+ end
+
+ def write_blank_metadata
+ $gtk.write_file metadata_file_path, <<-S.strip
+#devid=myname
+#devtitle=My Name
+#gameid=mygame
+#gametitle=My Game
+#version=0.1
+#icon=metadata/icon.png
+S
+ end
+end