Module: Drakkon::Build
- Defined in:
- lib/drakkon/build.rb
Overview
Run Command for CLI
Class Method Summary collapse
- .args(raw = nil) ⇒ Object
-
.build!(list, context, package = '--package') ⇒ Object
DEW THE BUILD.
- .force_fonts? ⇒ Boolean
- .force_images? ⇒ Boolean
- .force_manifest? ⇒ Boolean
-
.go!(raw, publish = '--package') ⇒ Object
General Run rubocop:disable Metrics/AbcSize.
-
.metadata_version(context) ⇒ Object
rubocop:enable Metrics/AbcSize.
- .platform_setup ⇒ Object
- .platforms ⇒ Object
- .prompt ⇒ Object
- .version_dir ⇒ Object
Class Method Details
.args(raw = nil) ⇒ Object
4 5 6 7 8 |
# File 'lib/drakkon/build.rb', line 4 def self.args(raw = nil) @args ||= raw @args end |
.build!(list, context, package = '--package') ⇒ Object
DEW THE BUILD
81 82 83 |
# File 'lib/drakkon/build.rb', line 81 def self.build!(list, context, package = '--package') "PATH=#{version_dir}:$PATH dragonruby-publish #{package} --platforms=#{list} #{context}" end |
.force_fonts? ⇒ Boolean
93 94 95 |
# File 'lib/drakkon/build.rb', line 93 def self.force_fonts? args.include?('fonts') end |
.force_images? ⇒ Boolean
89 90 91 |
# File 'lib/drakkon/build.rb', line 89 def self.force_images? args.include?('images') end |
.force_manifest? ⇒ Boolean
97 98 99 |
# File 'lib/drakkon/build.rb', line 97 def self.force_manifest? args.include?('manifest') end |
.go!(raw, publish = '--package') ⇒ Object
General Run rubocop:disable Metrics/AbcSize
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/drakkon/build.rb', line 12 def self.go!(raw, publish = '--package') Settings.ready? args(raw) Settings.update(:platforms, platform_setup) unless Settings.platforms? builder = if args.empty? Settings.platforms else platforms.select { |i| args.any? { |a| i.include? a } } end if builder.empty? LogBot.fatal('Build', "No valid platforms found! #{args.inspect.pastel(:red)} : #{builder.inspect.pastel(:red)}") exit(0) end list = builder.join(',') LogBot.info('Build', "Building for platforms: #{list}") # Save Current Directory before changing to Version Directory context = Dir.pwd context_name = File.basename(context) version = (context) # Yes... build.build! :D Dir.chdir(version_dir) do # Clean Up Accidental Leftovers FileUtils.rm_r(context_name) if Dir.exist? context_name # DragonRuby Publish doesn't like symlinks or PATH... FileUtils.cp_r(context, context_name) # Clean Builds Dir FileUtils.rm_r(Dir['builds/*']) # Remove Project's Builds Directory / Copied Version FileUtils.rm_r("#{context_name}/builds") if Dir.exist? "#{context_name}/builds" # Execute system build!(list, context_name, publish) # Preflight FileUtils.mkdir_p("#{context}/builds") FileUtils.mkdir_p("#{context}/builds/#{version}") # Copy back to Project Dir FileUtils.cp_r(Dir['builds/*'], "#{context}/builds/#{version}/") # Copy Settings copy = Settings.config.dig(:builds, :copy) if copy FileUtils.mkdir_p("#{copy}/#{version}") FileUtils.cp(Dir['builds/*.zip'], "#{copy}/#{version}/") end # Clean Up FileUtils.rm_r(context_name) end end |
.metadata_version(context) ⇒ Object
rubocop:enable Metrics/AbcSize
76 77 78 |
# File 'lib/drakkon/build.rb', line 76 def self.(context) File.read("#{context}/metadata/game_metadata.txt").split("\n").find { |y| y.include? 'version' }.split('=').last end |
.platform_setup ⇒ Object
101 102 103 |
# File 'lib/drakkon/build.rb', line 101 def self.platform_setup prompt.multi_select('Select Platforms to build for (these will be the future default):', platforms, filter: true) end |
.platforms ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/drakkon/build.rb', line 105 def self.platforms %w[ windows-amd64 linux-amd64 macos android-0 android googleplay-0 googleplay html5-0 html5 linux-raspberrypi mac-0 oculusquest-0 oculusquest ] end |
.prompt ⇒ Object
123 124 125 |
# File 'lib/drakkon/build.rb', line 123 def self.prompt TTY::Prompt.new(active_color: :cyan, interrupt: :exit) end |