lighthouse-matchers 1.0.2 → 1.0.3

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
  SHA256:
3
- metadata.gz: 39bae0e8641dae16dd253b900d90ccf0e96008353bebff86bacfc7007d4131ca
4
- data.tar.gz: 5ec2143cae768123fe66d882800513e1cf4d2e6194d74bb9297fde83bab999f7
3
+ metadata.gz: 4875808814d5062e018b2b97ca213d4970410e17d8815384faecf8515d7c3a54
4
+ data.tar.gz: 0c5987ca693dfb3fcf082ee4ae66453094b5c3a9421d72a6ee91b25b65d9767c
5
5
  SHA512:
6
- metadata.gz: e537f89cf5cb908ec7f4afe6ddfce0cdca25ac710ac7e8ee7365a53630e8b854ba9155f33c1e9c37ed59eae19d62e6194198715ad466f7268b5dd3e45ec66d36
7
- data.tar.gz: d9ce149527bf757d862d93baf1a1fdc3a5b60064c73d50d5304f5c5ffa36edde525b00a38ce6dc3c96c7516240e8e6b7a7c55a1ec4381a05275dde330da7b346
6
+ metadata.gz: 111ac3364c7917956c736fea0dd651df06219a4aef9ab5f7a9390bfa2a3707389aab6f53328da636f08909e545fbe520b5e3b55454d2fe07d441a5f9167f611c
7
+ data.tar.gz: 2b9dc90ee947fa25ab8c7103da174b068d893693a49496dd5d0fb7c946fcdc17413e7a6f99f08e29cbf3fefc430f157a902c946a14eb7dd5049a633f1178568e
@@ -18,4 +18,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
18
  ### Changed
19
19
  - Refactored auditing into a service object (@CaraHill)
20
20
  -
21
+ ## [1.0.3] - 2019-08-27
22
+ ### Added
23
+
24
+ - **chrome_flags** option to allow the Chrome launch behaviour of the `lighthouse` command. (#8)
25
+
21
26
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lighthouse-matchers (1.0.2)
4
+ lighthouse-matchers (1.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -26,7 +26,7 @@ You also need to have the `lighthouse` CLI tool available. The matchers will aut
26
26
  if you have added it to your `$PATH`, or if you have installed the tool using:
27
27
 
28
28
  * `npm install --save-dev lighthouse`
29
- * `yarn add --dev ligththouse`
29
+ * `yarn add --dev lighthouse`
30
30
 
31
31
  If you have the `lighthouse` CLI tool installed, but available elsewhere on your system, you can set the location manually.
32
32
  See [Configuration](#configuration) for further instructions.
@@ -102,6 +102,7 @@ All configuration keys are accessible against the `Lighthouse::Matchers` object.
102
102
  for the CLI. This setting can be used if the Lighthouse tool is installed in a non-standard location.
103
103
  * **`minimum_score`:** The default minimum score that audits must meet for the matcher to pass.
104
104
  The default value of this configuration setting is '100' - e.g. audits must fully comply to pass.
105
+ * **`chrome_flags`:** Any additional flags that should be passed to Chrome when Lighthouse launches a browser instance. As an example, running Lighthouse in Docker requires the normal headless Chrome flags (`--headless`, `--no-sandbox`) for Chrome to successfully start. Chrome flags can either be specified as an array (`["headless", "no-sandbox"]`) or as a string (`--headless --no-sandbox`).
105
106
 
106
107
  ## Compatibility
107
108
 
@@ -130,4 +131,4 @@ It is free software, and may be redistributed under the terms specified in the
130
131
  ## About Ackama
131
132
 
132
133
  Lighthouse Matchers is created and maintained by Ackama Group using our investment time scheme.
133
- We are passionate about using and contributing back to the open source community, and are available for hire.
134
+ We are passionate about using and contributing back to the open source community, and are available for hire.
@@ -1,6 +1,7 @@
1
- # frozen_string_literal: true
1
+ # frozen_string_literal: false
2
2
 
3
3
  require 'json'
4
+ require 'stringio'
4
5
 
5
6
  # Compares a url's actual score to the expected score.
6
7
  class AuditService
@@ -11,6 +12,7 @@ class AuditService
11
12
  @port = Lighthouse::Matchers.remote_debugging_port
12
13
  @runner = Lighthouse::Matchers.runner
13
14
  @cmd = Lighthouse::Matchers.lighthouse_cli
15
+ @chrome_flags = Lighthouse::Matchers.chrome_flags
14
16
  end
15
17
 
16
18
  def passing_score?
@@ -20,7 +22,12 @@ class AuditService
20
22
  private
21
23
 
22
24
  def opts
23
- "'#{@url}' --quiet --output=json #{"--port=#{@port}" if @port}".strip
25
+ "'#{@url}'".tap do |builder|
26
+ builder << ' --quiet'
27
+ builder << ' --output=json'
28
+ builder << " --port=#{@port}" if @port
29
+ builder << " --chrome-flags='#{@chrome_flags}'" if @chrome_flags
30
+ end.strip
24
31
  end
25
32
 
26
33
  def output
@@ -2,17 +2,18 @@
2
2
 
3
3
  require 'lighthouse/matchers/version'
4
4
 
5
+ ##
6
+ # Defines configuration and behaviours that are shared across the entire
7
+ # Lighthouse::Matchers namespace
5
8
  module Lighthouse
6
- ##
7
- # Defines configuration and behaviours that are shared across the entire
8
- # Lighthouse::Matchers namespace
9
- module Matchers
9
+ module Matchers # rubocop:disable Style/Documentation
10
10
  class Error < StandardError; end
11
11
  class << self
12
12
  attr_writer :minimum_score,
13
13
  :remote_debugging_port,
14
14
  :lighthouse_cli,
15
- :runner
15
+ :runner,
16
+ :chrome_flags
16
17
  attr_reader :remote_debugging_port
17
18
 
18
19
  def minimum_score
@@ -27,6 +28,13 @@ module Lighthouse
27
28
  @runner ||= proc { |cmd| `#{cmd}` }
28
29
  end
29
30
 
31
+ def chrome_flags
32
+ return unless @chrome_flags
33
+ return @chrome_flags unless @chrome_flags.is_a?(Array)
34
+
35
+ @chrome_flags.map { |f| "--#{f}" }.join(' ')
36
+ end
37
+
30
38
  private
31
39
 
32
40
  def guess_lighthouse_cli
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lighthouse
4
4
  module Matchers
5
- VERSION = '1.0.2'
5
+ VERSION = '1.0.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lighthouse-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh McArthur on behalf of Ackama
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-15 00:00:00.000000000 Z
11
+ date: 2019-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler