roku_builder 3.11.0 → 3.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6dbac3c0fec31e905833e19647dd92bb3d4864d
4
- data.tar.gz: 321dd14fbb7e7f5e6a29112958e0c5c66834927d
3
+ metadata.gz: 24f62ca635f6a690606f53980f4b2de0d3206525
4
+ data.tar.gz: 1d061880ae44bd0764ed4ec22583f2402749a917
5
5
  SHA512:
6
- metadata.gz: 55f1f1c4dd3b20aec47e227b28e4c69a028718c09adea8f068722129dc8ef03a3e467755c4f277cb7d5e6b8aa3c7d0fa081111fff9721fc72651600542fab1c5
7
- data.tar.gz: d2d4f21e3ad6591a33bff630560b837086a385d5d882b1b060572ccc8af4515e4975c66906e82bef628302848934227549467ed513f1e405c9f13d1fbd68037c
6
+ metadata.gz: 8583f7c075a0fce0cc992d0f215b27e0145b147a88da14b4785887a84e70e60f85ecb0b91d5548081850c4347b2457c3bab4f1644fde1abbdbeb21832fb23960
7
+ data.tar.gz: afe84a4778c8ac21c3c97cf450e73ec5215d80f67d9dfba5a2dbc034f4637c7b9e7479b0d362ae775a21b5008be08dd21b58d6104fd7ed8a14efbde9ddcf3327
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roku_builder (3.11.0)
5
- faraday (~> 0.10)
4
+ roku_builder (3.11.1)
5
+ faraday (~> 0.11)
6
6
  faraday-digestauth (~> 0.2)
7
7
  git (~> 1.3)
8
8
  net-ping (~> 2.0)
@@ -15,7 +15,7 @@ GEM
15
15
  specs:
16
16
  byebug (9.0.6)
17
17
  coderay (1.1.1)
18
- coveralls (0.8.17)
18
+ coveralls (0.8.19)
19
19
  json (>= 1.8, < 3)
20
20
  simplecov (~> 0.12.0)
21
21
  term-ansicolor (~> 1.3)
@@ -26,12 +26,12 @@ GEM
26
26
  eventmachine (>= 0.12.9)
27
27
  http_parser.rb (~> 0.6.0)
28
28
  eventmachine (1.2.1)
29
- faraday (0.10.1)
29
+ faraday (0.11.0)
30
30
  multipart-post (>= 1.2, < 3)
31
31
  faraday-digestauth (0.2.1)
32
32
  faraday (~> 0.7)
33
33
  net-http-digest_auth (~> 1.4)
34
- ffi (1.9.14)
34
+ ffi (1.9.17)
35
35
  formatador (0.2.5)
36
36
  git (1.3.0)
37
37
  guard (2.14.0)
@@ -50,12 +50,12 @@ GEM
50
50
  guard-compat (~> 1.0)
51
51
  multi_json (~> 1.8)
52
52
  http_parser.rb (0.6.0)
53
- json (2.0.2)
53
+ json (2.0.3)
54
54
  listen (3.1.5)
55
55
  rb-fsevent (~> 0.9, >= 0.9.4)
56
56
  rb-inotify (~> 0.9, >= 0.9.7)
57
57
  ruby_dep (~> 1.2)
58
- lumberjack (1.0.10)
58
+ lumberjack (1.0.11)
59
59
  method_source (0.8.2)
60
60
  mini_portile2 (2.1.0)
61
61
  minitest (5.10.1)
@@ -80,7 +80,7 @@ GEM
80
80
  slop (~> 3.4)
81
81
  rake (12.0.0)
82
82
  rb-fsevent (0.9.8)
83
- rb-inotify (0.9.7)
83
+ rb-inotify (0.9.8)
84
84
  ffi (>= 0.5.0)
85
85
  ruby_dep (1.5.0)
86
86
  rubyzip (1.2.0)
@@ -95,7 +95,7 @@ GEM
95
95
  tins (~> 1.0)
96
96
  thor (0.19.4)
97
97
  tins (1.13.0)
98
- yard (0.9.6)
98
+ yard (0.9.8)
99
99
 
100
100
  PLATFORMS
101
101
  ruby
@@ -114,4 +114,4 @@ DEPENDENCIES
114
114
  yard (~> 0.9)
115
115
 
116
116
  BUNDLED WITH
117
- 1.13.6
117
+ 1.13.7
data/README.md CHANGED
@@ -75,8 +75,10 @@ configuration options:
75
75
 
76
76
  Each stage has the following options:
77
77
 
78
- * branch: name of the branch for the given stage (if stage_method = git)
79
- * script: scripts to use to stage the app (if stage_method = script)
78
+ * branch: name of the branch for the given stage (if stage_method = git). If
79
+ using stage_method = stage then this can be removed.
80
+ * script: scripts to use to stage the app (if stage_method = script). If using
81
+ stage_method = git this can be removed.
80
82
  * script -> stage: script run form the app root directory to stage app
81
83
  * script -> unstage: script run form the app root directory to unstage app
82
84
  * key: has of key options for signing a package
data/bin/roku CHANGED
@@ -88,7 +88,7 @@ parser = OptionParser.new do |opts|
88
88
  options[:profile] = c
89
89
  end
90
90
 
91
- opts.on("--do-stage", "Command: Run the stager. Used for scripting. Always run --do-unscript after") do
91
+ opts.on("--do-stage", "Command: Run the stager. Used for scripting. Always run --do-unstage after") do
92
92
  options[:dostage] = true
93
93
  end
94
94
 
@@ -124,7 +124,7 @@ parser = OptionParser.new do |opts|
124
124
  options[:working] = true
125
125
  end
126
126
 
127
- opts.on("-c", "--current", "Use current directory to sideload or test. Overides any project config") do
127
+ opts.on("-c", "--current", "Use current directory to sideload or test. Overrides any project config") do
128
128
  options[:current] = true
129
129
  end
130
130
 
@@ -145,7 +145,7 @@ parser = OptionParser.new do |opts|
145
145
  options[:edit_params] = p
146
146
  end
147
147
 
148
- opts.on("--config CONFIG", "Set a custom config file. Default: '~/.roku_config.rb'") do |c|
148
+ opts.on("--config CONFIG", "Set a custom config file. Default: '~/.roku_config.json'") do |c|
149
149
  options[:config] = c
150
150
  end
151
151
 
data/config.json.example CHANGED
@@ -18,7 +18,8 @@
18
18
  "stage_method": "<git|script>",
19
19
  "stages":{
20
20
  "production": {
21
- "branch": "production",
21
+ "branch": "<branch>",
22
+ "script": {"stage": "<command to stage>", "unstage": "<command to unstage, optional>"},
22
23
  "key": "key1"
23
24
  }
24
25
  }
data/lib/roku_builder.rb CHANGED
@@ -124,6 +124,9 @@ module RokuBuilder
124
124
  # Unknown stage given
125
125
  UNKNOWN_STAGE = 7
126
126
 
127
+ # Missing out folder
128
+ MISSING_OUT_FOLDER = 8
129
+
127
130
 
128
131
  ### Execute Codes ###
129
132
 
@@ -163,7 +166,7 @@ end
163
166
 
164
167
  class ::Hash
165
168
  def deep_merge(second)
166
- merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
169
+ merger = proc { |_key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
167
170
  self.merge(second, &merger)
168
171
  end
169
172
  end
@@ -124,17 +124,16 @@ module RokuBuilder
124
124
  def self.update_configs(configs:, options:)
125
125
  if options[:build_version]
126
126
  configs[:package_config][:app_name_version] = "#{configs[:project_config][:app_name]} - #{configs[:stage]} - #{options[:build_version]}" if configs[:package_config]
127
- unless options[:outfile]
128
- pathname = File.join(options[:out_folder], "#{configs[:project_config][:app_name]}_#{configs[:stage]}_#{options[:build_version]}")
129
- if options[:out]
130
- configs[:package_config][:out_file] = File.join(options[:out_folder], options[:out_file]) if configs[:package_config]
131
- configs[:build_config][:outfile] = File.join(options[:out_folder], options[:out_file]) if configs[:build_config]
132
- else
133
- configs[:package_config][:out_file] = pathname+".pkg" if configs[:package_config]
134
- configs[:build_config][:outfile] = pathname+".zip" if configs[:build_config]
135
- end
136
- configs[:inspect_config][:pkg] = configs[:package_config][:out_file] if configs[:inspect_config] and configs[:package_config]
127
+ unless configs[:out][:file]
128
+ configs[:out][:file] = "#{configs[:project_config][:app_name]}_#{configs[:stage]}_#{options[:build_version]}"
129
+ end
130
+ pathname = File.join(configs[:out][:folder], configs[:out][:file])
131
+ configs[:package_config][:out_file] = pathname if configs[:package_config]
132
+ configs[:build_config][:out_file] = pathname if configs[:build_config]
133
+ if configs[:sideload_config] and options[:out]
134
+ configs[:sideload_config][:out_file] = pathname
137
135
  end
136
+ configs[:inspect_config][:pkg] = configs[:package_config][:out_file] if configs[:inspect_config] and configs[:package_config]
138
137
  end
139
138
  return configs
140
139
  end
@@ -21,7 +21,7 @@ module RokuBuilder
21
21
  #set project
22
22
  setup_project(config: config, options: options)
23
23
  #set outfile
24
- setup_outfile(options: options)
24
+ setup_outfile(options: options, configs: configs)
25
25
  # Create Device Config
26
26
  configs[:device_config] = config[:devices][options[:device].to_sym]
27
27
  return [UNKNOWN_DEVICE, nil, nil] unless configs[:device_config]
@@ -33,7 +33,8 @@ module RokuBuilder
33
33
  return [UNKNOWN_STAGE, nil, nil] unless stage
34
34
  setup_sideload_config(configs: configs, options: options)
35
35
  setup_package_config(config: config, configs: configs, options: options, stage: stage)
36
- setup_simple_configs(config: config, configs: configs, options: options, logger: logger)
36
+ setup_active_configs(config: config, configs: configs, options: options)
37
+ setup_simple_configs(config: config, configs: configs, options: options)
37
38
  return [SUCCESS, configs]
38
39
  end
39
40
 
@@ -67,23 +68,22 @@ module RokuBuilder
67
68
 
68
69
  # Setup the out folder/file options
69
70
  # @param options [Hash] The options hash
70
- def self.setup_outfile(options:)
71
- options[:out_folder] = nil
72
- options[:out_file] = nil
71
+ def self.setup_outfile(options:, configs:)
72
+ configs[:out] = {file: nil, folder: nil}
73
73
  if options[:out]
74
74
  if options[:out].end_with?(".zip") or options[:out].end_with?(".pkg") or options[:out].end_with?(".jpg")
75
- options[:out_folder], options[:out_file] = Pathname.new(options[:out]).split.map{|p| p.to_s}
76
- if options[:out_folder] = "." and not options[:out].start_with?(".")
77
- options[:out_folder] = nil
75
+ configs[:out][:folder], configs[:out][:file] = Pathname.new(options[:out]).split.map{|p| p.to_s}
76
+ if configs[:out][:folder] == "." and not options[:out].start_with?(".")
77
+ configs[:out][:folder] = nil
78
78
  else
79
- options[:out_folder] = File.expand_path(options[:out_folder])
79
+ configs[:out][:folder] = File.expand_path(configs[:out][:folder])
80
80
  end
81
81
  else
82
- options[:out_folder] = options[:out]
82
+ configs[:out][:folder] = options[:out]
83
83
  end
84
84
  end
85
- unless options[:out_folder]
86
- options[:out_folder] = "/tmp"
85
+ unless configs[:out][:folder]
86
+ configs[:out][:folder] = "/tmp"
87
87
  end
88
88
  end
89
89
  private_class_method :setup_outfile
@@ -196,8 +196,8 @@ module RokuBuilder
196
196
  password: configs[:key][:password],
197
197
  app_name_version: "#{configs[:project_config][:app_name]} - #{stage}"
198
198
  }
199
- if options[:out_file]
200
- configs[:package_config][:out_file] = File.join(options[:out_folder], options[:out_file])
199
+ if configs[:out][:file]
200
+ configs[:package_config][:out_file] = File.join(configs[:out][:folder], configs[:out][:file])
201
201
  end
202
202
  # Create Inspector Config
203
203
  configs[:inspect_config] = {
@@ -208,20 +208,11 @@ module RokuBuilder
208
208
  end
209
209
  private_class_method :setup_package_config
210
210
 
211
- # Setup other configs
211
+ # Setup configs for active methods, monitoring and navigating
212
212
  # @param configs [Hash] The parsed configs hash
213
213
  # @param options [Hash] The options hash
214
214
  # @param logger [Logger] System logger
215
- def self.setup_simple_configs(config:, configs:, options:, logger:)
216
- # Create Manifest Config
217
- configs[:manifest_config] = {
218
- root_dir: configs[:project_config][:directory]
219
- }
220
- # Create Deeplink Config
221
- configs[:deeplink_config] = {options: options[:deeplink]}
222
- if options[:app_id]
223
- configs[:deeplink_config][:app_id] = options[:app_id]
224
- end
215
+ def self.setup_active_configs(config:, configs:, options:)
225
216
  # Create Monitor Config
226
217
  if options[:monitor]
227
218
  configs[:monitor_config] = {type: options[:monitor].to_sym}
@@ -241,14 +232,31 @@ module RokuBuilder
241
232
  commands = options[:navigate].split(/, */).map{|c| c.to_sym}
242
233
  configs[:navigate_config] = {commands: commands}
243
234
  end
235
+ end
236
+ private_class_method :setup_active_configs
237
+
238
+ # Setup other configs
239
+ # @param configs [Hash] The parsed configs hash
240
+ # @param options [Hash] The options hash
241
+ # @param logger [Logger] System logger
242
+ def self.setup_simple_configs(config:, configs:, options:)
243
+ # Create Manifest Config
244
+ configs[:manifest_config] = {
245
+ root_dir: configs[:project_config][:directory]
246
+ }
247
+ # Create Deeplink Config
248
+ configs[:deeplink_config] = {options: options[:deeplink]}
249
+ if options[:app_id]
250
+ configs[:deeplink_config][:app_id] = options[:app_id]
251
+ end
244
252
  # Create Text Config
245
253
  configs[:text_config] = {text: options[:text]}
246
254
  # Create Test Config
247
255
  configs[:test_config] = {sideload_config: configs[:sideload_config]}
248
256
  #Create screencapture config
249
257
  configs[:screencapture_config] = {
250
- out_folder: options[:out_folder],
251
- out_file: options[:out_file]
258
+ out_folder: configs[:out][:folder],
259
+ out_file: configs[:out][:file]
252
260
  }
253
261
  if options[:screen]
254
262
  configs[:screen_config] = {type: options[:screen].to_sym}
@@ -54,14 +54,10 @@ module RokuBuilder
54
54
  }
55
55
  end
56
56
  if config[:keys]
57
- config[:keys].each {|key,key_config|
58
- validate_key(codes: codes, key: key_config)
59
- }
57
+ config[:keys].each {|_key,key_config| validate_key(codes: codes, key: key_config) }
60
58
  end
61
59
  if config[:input_mapping]
62
- config[:input_mapping].each_value {|info|
63
- validate_mapping(codes: codes, mapping: info)
64
- }
60
+ config[:input_mapping].each_value {|info| validate_mapping(codes: codes, mapping: info) }
65
61
  end
66
62
  codes.uniq!
67
63
  codes.push(0) if codes.empty?
@@ -184,7 +180,6 @@ module RokuBuilder
184
180
 
185
181
  def self.validate_mapping(codes:, mapping:)
186
182
  errors=[
187
- [INVALID_MAPPING_INFO, mapping.nil?],
188
183
  [INVALID_MAPPING_INFO, (mapping.count != 2)]
189
184
  ]
190
185
  process_errors(codes: codes, errors: errors)
@@ -28,12 +28,16 @@ module RokuBuilder
28
28
  load_code, config, configs = ConfigManager.load_config(options: options, logger: logger)
29
29
  ErrorHandler.handle_load_codes(options: options, load_code: load_code, logger: logger)
30
30
 
31
+ # Check Configs
32
+ configs_code = validate_configs(configs: configs)
33
+ ErrorHandler.handle_configs_codes(configs_code: configs_code, logger: logger)
34
+
31
35
  # Check devices
32
36
  device_code, configs = check_devices(options: options, config: config, configs: configs, logger: logger)
33
37
  ErrorHandler.handle_device_codes(device_code: device_code, logger: logger)
34
38
 
35
39
  # Run Commands
36
- command_code = execute_commands(options: options, config: config, configs: configs, logger: logger)
40
+ command_code = execute_commands(options: options, configs: configs, logger: logger)
37
41
  ErrorHandler.handle_command_codes(command_code: command_code, logger: logger)
38
42
  end
39
43
 
@@ -102,11 +106,22 @@ module RokuBuilder
102
106
  end
103
107
  private_class_method :validate_depricated_commands
104
108
 
109
+ # Validate config hash
110
+ # @param configs [Hash] The Configs hash
111
+ # @return [Integer] Status code for command validation
112
+ def self.validate_configs(configs:)
113
+ unless Dir.exist?(configs[:out][:folder])
114
+ return MISSING_OUT_FOLDER
115
+ end
116
+ VALID
117
+ end
118
+ private_class_method :validate_configs
119
+
105
120
  # Run commands
106
121
  # @param options [Hash] The options hash
107
122
  # @return [Integer] Return code for options handeling
108
123
  # @param logger [Logger] system logger
109
- def self.execute_commands(options:, config:, configs:, logger:)
124
+ def self.execute_commands(options:, configs:, logger:)
110
125
  command = (commands & options.keys).first
111
126
  if ControllerCommands.simple_commands.keys.include?(command)
112
127
  params = ControllerCommands.simple_commands[command]
@@ -48,6 +48,9 @@ module RokuBuilder
48
48
  success = nil
49
49
  if stager.stage
50
50
  loader = Loader.new(**config)
51
+ build_version = ManifestManager.build_version(**configs[:manifest_config])
52
+ options[:build_version] = build_version
53
+ configs = ConfigManager.update_configs(configs: configs, options: options)
51
54
  success = loader.sideload(**configs[:sideload_config])[0]
52
55
  end
53
56
  stager.unstage
@@ -68,14 +71,13 @@ module RokuBuilder
68
71
  stager = Stager.new(**configs[:stage_config])
69
72
  loader = Loader.new(**loader_config)
70
73
  packager = Packager.new(**configs[:device_config])
71
- inspector = Inspector.new(**configs[:device_config])
72
74
  logger.warn "Packaging working directory" if options[:working]
73
75
  if stager.stage
74
76
  # Sideload #
75
77
  code, build_version = loader.sideload(**configs[:sideload_config])
76
- return code unless code = SUCCESS
78
+ return code unless code == SUCCESS
77
79
  # Key #
78
- success = keyer.rekey(**configs[:key])
80
+ _success = keyer.rekey(**configs[:key])
79
81
  # Package #
80
82
  options[:build_version] = build_version
81
83
  configs = ConfigManager.update_configs(configs: configs, options: options)
@@ -84,23 +86,30 @@ module RokuBuilder
84
86
  return FAILED_SIGNING unless success
85
87
  # Inspect #
86
88
  if options[:inspect]
87
- info = inspector.inspect(configs[:inspect_config])
88
- inspect_logger = Logger.new(STDOUT)
89
- inspect_logger.formatter = proc {|_severity, _datetime, _progname, msg|
90
- "%s\n\r" % [msg]
91
- }
92
- inspect_logger.unknown "=============================================================="
93
- inspect_logger.unknown "App Name: #{info[:app_name]}"
94
- inspect_logger.unknown "Dev ID: #{info[:dev_id]}"
95
- inspect_logger.unknown "Creation Date: #{info[:creation_date]}"
96
- inspect_logger.unknown "dev.zip: #{info[:dev_zip]}"
97
- inspect_logger.unknown "=============================================================="
89
+ inspect_package(configs: configs)
98
90
  end
99
91
  end
100
92
  stager.unstage
101
93
  logger.info "App Packaged; staged using #{stager.method}"
102
94
  SUCCESS
103
95
  end
96
+
97
+ def self.inspect_package(configs:)
98
+ inspector = Inspector.new(**configs[:device_config])
99
+ info = inspector.inspect(configs[:inspect_config])
100
+ inspect_logger = Logger.new(STDOUT)
101
+ inspect_logger.formatter = proc {|_severity, _datetime, _progname, msg|
102
+ "%s\n\r" % [msg]
103
+ }
104
+ inspect_logger.unknown "=============================================================="
105
+ inspect_logger.unknown "App Name: #{info[:app_name]}"
106
+ inspect_logger.unknown "Dev ID: #{info[:dev_id]}"
107
+ inspect_logger.unknown "Creation Date: #{info[:creation_date]}"
108
+ inspect_logger.unknown "dev.zip: #{info[:dev_zip]}"
109
+ inspect_logger.unknown "=============================================================="
110
+ end
111
+ private_class_method :inspect_package
112
+
104
113
  # Run Build
105
114
  # @param options [Hash] user options
106
115
  # @param configs [Hash] parsed configs
@@ -75,6 +75,19 @@ module RokuBuilder
75
75
  end
76
76
  end
77
77
 
78
+ # Handle codes returned from configuring
79
+ # @param configure_code [Integer] the error code returned by configure
80
+ # @param logger [Logger] system logger
81
+ def self.handle_configs_codes(configs_code:, logger:)
82
+ case configs_code
83
+ when MISSING_OUT_FOLDER
84
+ logger.fatal 'The folder passed in the command line options does not exist.'
85
+ abort
86
+ when VALID
87
+ logger.debug 'Configs OK'
88
+ end
89
+ end
90
+
78
91
  # Handle codes returned from checking devices
79
92
  # @param device_code [Integer] the error code returned by check_devices
80
93
  # @param logger [Logger] system logger