roku_builder 3.8.5 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e69a8b0a723f44c117d5ad9ae4522dbb7aad0eb
4
- data.tar.gz: 7255b70fa5193336e44fa93252310e6b0accea2a
3
+ metadata.gz: 3f57f3dc9e27633cf6455dd16f475e29c3ad4ac7
4
+ data.tar.gz: 0d772e6d322cd620e17a6ad861ec6188a77fbaa6
5
5
  SHA512:
6
- metadata.gz: 4c6ea13b6683e837ae814c9fd4132527711ee1935404010905c73a6466d3ea39be566a49900045e5124530009fbfd552c314171892ccd51022a744786ecff999
7
- data.tar.gz: c9b6a34923ff4b7d47c02d635ded9633e0aa151d7bc90cacc5883105c875a5f8d1738094e559882f3e0788cfea40458378b343e7759789c1a87a4fda92cdfa32
6
+ metadata.gz: 9e5f2ac10ed8c2788e5105b117db686cbedb628be12894b9a1867474dbeee934ff739359157ad471d34de1fb05d2c15a47e7460b9cce48daa7db40b74f7e5fe2
7
+ data.tar.gz: 41774f8096866ae56473ad8d9bbd970ece9403728ac88e680d7558550c85adfdfcc51a458a7b4842bd625b9ec5c05b132bc913c946bdaf8762d702264a715074
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roku_builder (3.8.5)
4
+ roku_builder (3.9.0)
5
5
  faraday (~> 0.9)
6
6
  faraday-digestauth (~> 0.2)
7
7
  git (~> 1.3)
8
- net-ping (~> 1.7)
8
+ net-ping (~> 2.0)
9
9
  net-telnet (~> 0.1)
10
10
  nokogiri (~> 1.6)
11
11
  rubyzip (~> 1.2)
@@ -67,7 +67,7 @@ GEM
67
67
  multipart-post (2.0.0)
68
68
  nenv (0.3.0)
69
69
  net-http-digest_auth (1.4)
70
- net-ping (1.7.8)
70
+ net-ping (2.0.1)
71
71
  net-telnet (0.1.1)
72
72
  nokogiri (1.6.8)
73
73
  mini_portile2 (~> 2.1.0)
data/README.md CHANGED
@@ -308,7 +308,6 @@ directory:
308
308
 
309
309
  ## Improvements
310
310
 
311
- * Account for missing folders or files
312
311
  * Increase testing
313
312
  * Config Unit Tests
314
313
  * Intergration Tests
data/bin/roku CHANGED
@@ -12,7 +12,12 @@ options = {}
12
12
  options[:config] = '~/.roku_config.json'
13
13
  options[:update_manifest] = false
14
14
 
15
- OptionParser.new do |opts|
15
+ logger = Logger.new(STDOUT)
16
+ logger.formatter = proc {|severity, datetime, _progname, msg|
17
+ "[%s #%s] %5s: %s\n\r" % [datetime.strftime("%Y-%m-%d %H:%M:%S.%4N"), $$, severity, msg]
18
+ }
19
+
20
+ parser = OptionParser.new do |opts|
16
21
  opts.banner = "Usage: roku <command> [options]"
17
22
 
18
23
  opts.on("-l", "--sideload", "Command: Sideload an app") do
@@ -75,11 +80,11 @@ OptionParser.new do |opts|
75
80
  options[:profile] = c
76
81
  end
77
82
 
78
- opts.on("--do-stage", "Command: Run the stager. Used for scripting. Alwasy run --do-unscript after") do
83
+ opts.on("--do-stage", "Command: Run the stager. Used for scripting. Always run --do-unscript after") do
79
84
  options[:dostage] = true
80
85
  end
81
86
 
82
- opts.on("--do-unstage", "Command: Run the unstager. Used for scripting. Alwasy run --do-script first") do
87
+ opts.on("--do-unstage", "Command: Run the unstager. Used for scripting. Always run --do-script first") do
83
88
  options[:dounstage] = true
84
89
  end
85
90
 
@@ -178,6 +183,12 @@ OptionParser.new do |opts|
178
183
  puts RokuBuilder::VERSION
179
184
  exit
180
185
  end
181
- end.parse!
186
+ end
187
+
188
+ begin
189
+ parser.parse!
190
+ RokuBuilder::Controller.run(options: options, logger: logger)
191
+ rescue OptionParser::ParseError => e
192
+ logger.fatal e.message
193
+ end
182
194
 
183
- RokuBuilder::Controller.run(options: options)
data/config.json.example CHANGED
@@ -19,12 +19,15 @@
19
19
  "stages":{
20
20
  "production": {
21
21
  "branch": "production",
22
- "key": {
23
- "keyed_pkg": "<path/to/signed/pkg>",
24
- "password": "<password for pkg>"
25
- }
22
+ "key": "key1"
26
23
  }
27
24
  }
28
25
  }
26
+ },
27
+ "keys": {
28
+ "key1": {
29
+ "keyed_pkg": "<path/to/signed/package>",
30
+ "password": "<password>"
31
+ }
29
32
  }
30
33
  }
@@ -32,7 +32,7 @@ module RokuBuilder
32
32
  stage = setup_stage_config(configs: configs, options: options, logger: logger)[1]
33
33
  return [UNKNOWN_STAGE, nil, nil] unless stage
34
34
  setup_sideload_config(configs: configs, options: options)
35
- setup_package_config(configs: configs, options: options, stage: stage)
35
+ setup_package_config(config: config, configs: configs, options: options, stage: stage)
36
36
  setup_simple_configs(configs: configs, options: options, logger: logger)
37
37
  return [SUCCESS, configs]
38
38
  end
@@ -135,11 +135,11 @@ module RokuBuilder
135
135
  if options[:ref]
136
136
  stage_config[:key] = options[:ref]
137
137
  else
138
- return nil unless project_config[:stages][stage]
138
+ return [nil, nil] unless project_config[:stages][stage]
139
139
  stage_config[:key] = project_config[:stages][stage][:branch]
140
140
  end
141
141
  when :script
142
- return nil unless project_config[:stages][stage]
142
+ return [nil, nil] unless project_config[:stages][stage]
143
143
  stage_config[:key] = project_config[:stages][stage][:script]
144
144
  end
145
145
  configs[:stage_config] = stage_config
@@ -182,10 +182,13 @@ module RokuBuilder
182
182
  # @param configs [Hash] The parsed configs hash
183
183
  # @param options [Hash] The options hash
184
184
  # @param stage [Symbol] The stage to package
185
- def self.setup_package_config(configs:, options:, stage:)
185
+ def self.setup_package_config(config:, configs:, options:, stage:)
186
186
  if options[:package] or options[:key]
187
187
  # Create Key Config
188
188
  configs[:key] = configs[:project_config][:stages][stage][:key]
189
+ if configs[:key].class == String
190
+ configs[:key] = config[:keys][configs[:key].to_sym]
191
+ end
189
192
  end
190
193
  if options[:package]
191
194
  # Create Package Config
@@ -20,7 +20,8 @@ module RokuBuilder
20
20
  STAGE_MISSING_BRANCH = 16
21
21
  STAGE_MISSING_SCRIPT = 17
22
22
  PROJECT_STAGE_METHOD_BAD = 18
23
-
23
+ KEY_MISSING_PATH = 19
24
+ KEY_MISSING_PASSWORD = 20
24
25
 
25
26
  MISSING_STAGE_METHOD = -1
26
27
 
@@ -50,6 +51,11 @@ module RokuBuilder
50
51
  end
51
52
  }
52
53
  end
54
+ if config[:keys]
55
+ config[:keys].each {|key,key_config|
56
+ validate_key(codes: codes, key: key_config)
57
+ }
58
+ end
53
59
  codes.uniq!
54
60
  codes.push(0) if codes.empty?
55
61
  codes
@@ -79,6 +85,8 @@ module RokuBuilder
79
85
  "A project stage is missing its branch.",
80
86
  "A project stage is missing its script.",
81
87
  "A project as an invalid stage method.",
88
+ "A key is missing its keyed package path.",
89
+ "A key is missing its password.", #20
82
90
  #===============WARNINGS===============#
83
91
  "A project is missing its stage method."
84
92
  ]
@@ -150,6 +158,20 @@ module RokuBuilder
150
158
  end
151
159
  private_class_method :validate_stage
152
160
 
161
+ # Validates a roku config project
162
+ # @param codes [Array] array of error codes
163
+ # @param project [Hash] project config object
164
+ def self.validate_key(codes:, key:)
165
+ errors= [
166
+ [KEY_MISSING_PATH, (!key[:keyed_pkg])],
167
+ [KEY_MISSING_PATH, (key[:keyed_pkg] == "<path/to/signed/package>")],
168
+ [KEY_MISSING_PASSWORD, (!key[:password])],
169
+ [KEY_MISSING_PASSWORD, (key[:password] == "<password>")],
170
+ ]
171
+ process_errors(codes: codes, errors: errors)
172
+ end
173
+ private_class_method :validate_key
174
+
153
175
  def self.process_errors(codes:, errors:)
154
176
  errors.each do |error|
155
177
  codes.push(error[0]) if error[1]
@@ -7,11 +7,7 @@ module RokuBuilder
7
7
 
8
8
  # Run the builder
9
9
  # @param options [Hash] The options hash
10
- def self.run(options:)
11
- logger = Logger.new(STDOUT)
12
- logger.formatter = proc {|severity, datetime, _progname, msg|
13
- "[%s #%s] %5s: %s\n\r" % [datetime.strftime("%Y-%m-%d %H:%M:%S.%4N"), $$, severity, msg]
14
- }
10
+ def self.run(options:, logger:)
15
11
  if options[:debug]
16
12
  logger.level = Logger::DEBUG
17
13
  elsif options[:verbose]
@@ -49,7 +49,7 @@ module RokuBuilder
49
49
  success = loader.sideload(**configs[:sideload_config])[0]
50
50
  end
51
51
  stager.unstage
52
- unless success == FAILED_SIDELOAD
52
+ if success == SUCCESS
53
53
  logger.info "App Sideloaded; staged using #{stager.method}"
54
54
  end
55
55
  success
@@ -113,6 +113,10 @@ module RokuBuilder
113
113
  abort
114
114
  when BAD_PRINT_ATTRIBUTE
115
115
  logger.fatal "Unknown print attribute"
116
+ abort
117
+ when MISSING_MANIFEST
118
+ logger.fatal 'Manifest file missing'
119
+ abort
116
120
  end
117
121
  end
118
122
 
@@ -17,7 +17,10 @@ module RokuBuilder
17
17
  unless payload.keys.count > 0
18
18
  @logger.warn "No options sent to launched app"
19
19
  else
20
- path = "#{path}?#{parameterize(payload)}"
20
+ payload = parameterize(payload)
21
+ path = "#{path}?#{payload}"
22
+ @logger.info "Deeplink:"
23
+ @logger.info payload
21
24
  end
22
25
 
23
26
  conn = multipart_connection(port: 8060)
@@ -21,15 +21,19 @@ module RokuBuilder
21
21
  build_version = nil
22
22
  if infile
23
23
  build_version = ManifestManager.build_version(root_dir: infile)
24
+ return [MISSING_MANIFEST, nil] if outfile == MISSING_MANIFEST
24
25
  outfile = infile
25
26
  else
26
27
  # Update manifest
27
28
  if update_manifest
28
29
  build_version = ManifestManager.update_build(root_dir: @root_dir)
30
+ return [MISSING_MANIFEST, nil] if outfile == MISSING_MANIFEST
29
31
  else
30
32
  build_version = ManifestManager.build_version(root_dir: @root_dir)
33
+ return [MISSING_MANIFEST, nil] if outfile == MISSING_MANIFEST
31
34
  end
32
35
  outfile = build(build_version: build_version, content: content)
36
+ return [MISSING_MANIFEST, nil] if outfile == MISSING_MANIFEST
33
37
  end
34
38
  path = "/plugin_install"
35
39
  # Connect to roku and upload file
@@ -55,6 +59,7 @@ module RokuBuilder
55
59
  # @return [String] Path of the build
56
60
  def build(build_version: nil, outfile: nil, content: nil)
57
61
  build_version = ManifestManager.build_version(root_dir: @root_dir) unless build_version
62
+ return MISSING_MANIFEST if build_version == MISSING_MANIFEST
58
63
  content ||= {}
59
64
  unless content and content[:folders]
60
65
  content[:folders] = Dir.entries(@root_dir).select {|entry| File.directory? File.join(@root_dir, entry) and !(entry =='.' || entry == '..') }
@@ -69,10 +74,14 @@ module RokuBuilder
69
74
  # Add folders to zip
70
75
  content[:folders].each do |folder|
71
76
  base_folder = File.join(@root_dir, folder)
72
- entries = Dir.entries(base_folder)
73
- entries.delete(".")
74
- entries.delete("..")
75
- writeEntries(@root_dir, entries, folder, content[:excludes], io)
77
+ if File.exist?(base_folder)
78
+ entries = Dir.entries(base_folder)
79
+ entries.delete(".")
80
+ entries.delete("..")
81
+ writeEntries(@root_dir, entries, folder, content[:excludes], io)
82
+ else
83
+ @logger.warn "Missing Folder: #{base_folder}"
84
+ end
76
85
  end
77
86
  # Add file to zip
78
87
  writeEntries(@root_dir, content[:files], "", content[:excludes], io)
@@ -114,7 +123,11 @@ module RokuBuilder
114
123
  writeEntries(root_dir, subdir, zipFilePath, excludes, io)
115
124
  else
116
125
  unless excludes.include?(zipFilePath)
117
- io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, "rb").read()) }
126
+ if File.exist?(diskFilePath)
127
+ io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, "rb").read()) }
128
+ else
129
+ @logger.warn "Missing File: #{diskFilePath}"
130
+ end
118
131
  end
119
132
  end
120
133
  }
@@ -9,7 +9,7 @@ module RokuBuilder
9
9
  # @param root_dir [String] Path to the root directory for the app
10
10
  # @return [String] Build version on success, empty string otherwise
11
11
  def self.update_build(root_dir:)
12
-
12
+ return MISSING_MANIFEST unless self.check_manifest(root_dir: root_dir)
13
13
  build_version = self.build_version(root_dir: root_dir).split(".")
14
14
  if 2 == build_version.length
15
15
  iteration = build_version[1].to_i + 1
@@ -24,14 +24,17 @@ module RokuBuilder
24
24
  self.build_version(root_dir: root_dir)
25
25
  end
26
26
 
27
+
27
28
  # Retrive the build version from the manifest file
28
29
  # @param root_dir [String] Path to the root directory for the app
29
30
  # @return [String] Build version on success, empty string otherwise
30
31
  def self.build_version(root_dir:)
32
+ return MISSING_MANIFEST unless self.check_manifest(root_dir: root_dir)
31
33
  read_manifest(root_dir: root_dir)[:build_version]
32
34
  end
33
35
 
34
36
  def self.read_manifest(root_dir:)
37
+ return MISSING_MANIFEST unless self.check_manifest(root_dir: root_dir)
35
38
  attrs = {}
36
39
  get_attrs = lambda { |file|
37
40
  file.each_line do |line|
@@ -90,6 +93,23 @@ module RokuBuilder
90
93
  end
91
94
  end
92
95
 
96
+ # Check to make sure that the manifest file exists
97
+ # @param root_dir [String] Path to the root directory for the app
98
+ # @return [Boolean] True if manifest exists, false otherwise
99
+ def self.check_manifest(root_dir:)
100
+ return false unless File.exist?(root_dir)
101
+ if File.directory?(root_dir)
102
+ path = File.join(root_dir, 'manifest')
103
+ return false unless File.exist?(path)
104
+ elsif File.extname(root_dir) == ".zip"
105
+ Zip::File.open(root_dir) do |zip_file|
106
+ entry = zip_file.glob("manifest").first
107
+ return false unless entry
108
+ end
109
+ end
110
+ true
111
+ end
112
+
93
113
  # Returns the default manafest values
94
114
  # @return [Hash] default manifest values
95
115
  def self.default_params
@@ -2,5 +2,5 @@
2
2
 
3
3
  module RokuBuilder
4
4
  # Version of the RokuBuilder Gem
5
- VERSION = "3.8.5"
5
+ VERSION = "3.9.0"
6
6
  end
data/roku_builder.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "faraday", "~> 0.9"
25
25
  spec.add_dependency "faraday-digestauth", "~> 0.2"
26
26
  spec.add_dependency "git", "~> 1.3"
27
- spec.add_dependency "net-ping", "~> 1.7"
27
+ spec.add_dependency "net-ping", "~> 2.0"
28
28
  spec.add_dependency "net-telnet", "~> 0.1"
29
29
  spec.add_dependency "nokogiri", "~> 1.6"
30
30
 
@@ -142,23 +142,18 @@ class ControllerTest < Minitest::Test
142
142
  ]
143
143
  tests.each do |test|
144
144
  logger = Minitest::Mock.new
145
- logger.expect(:formatter=, nil) do |proc_object|
146
- proc_object.class == Proc and proc_object.arity == 4
147
- end
148
145
  logger.expect(:level=, nil, [test[:level]])
149
- Logger.stub(:new, logger) do
150
- RokuBuilder::Controller.stub(:validate_options, nil) do
151
- RokuBuilder::ErrorHandler.stub(:handle_options_codes, nil) do
152
- RokuBuilder::Controller.stub(:configure, nil) do
153
- RokuBuilder::ErrorHandler.stub(:handle_configure_codes, nil) do
154
- RokuBuilder::ConfigManager.stub(:load_config, nil) do
155
- RokuBuilder::ErrorHandler.stub(:handle_load_codes, nil) do
156
- RokuBuilder::Controller.stub(:check_devices, nil) do
157
- RokuBuilder::ErrorHandler.stub(:handle_device_codes, nil) do
158
- RokuBuilder::Controller.stub(:execute_commands, nil) do
159
- RokuBuilder::ErrorHandler.stub(:handle_command_codes, nil) do
160
- RokuBuilder::Controller.run(options: test[:options])
161
- end
146
+ RokuBuilder::Controller.stub(:validate_options, nil) do
147
+ RokuBuilder::ErrorHandler.stub(:handle_options_codes, nil) do
148
+ RokuBuilder::Controller.stub(:configure, nil) do
149
+ RokuBuilder::ErrorHandler.stub(:handle_configure_codes, nil) do
150
+ RokuBuilder::ConfigManager.stub(:load_config, nil) do
151
+ RokuBuilder::ErrorHandler.stub(:handle_load_codes, nil) do
152
+ RokuBuilder::Controller.stub(:check_devices, nil) do
153
+ RokuBuilder::ErrorHandler.stub(:handle_device_codes, nil) do
154
+ RokuBuilder::Controller.stub(:execute_commands, nil) do
155
+ RokuBuilder::ErrorHandler.stub(:handle_command_codes, nil) do
156
+ RokuBuilder::Controller.run(options: test[:options], logger: logger)
162
157
  end
163
158
  end
164
159
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roku_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.5
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - greeneca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.7'
75
+ version: '2.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.7'
82
+ version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: net-telnet
85
85
  requirement: !ruby/object:Gem::Requirement