govuk_publishing_components 17.10.0 → 17.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +21 -0
  3. data/app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss +10 -10
  4. data/app/views/govuk_publishing_components/components/_feedback.html.erb +1 -1
  5. data/app/views/govuk_publishing_components/components/docs/accordion.yml +2 -1
  6. data/app/views/govuk_publishing_components/components/docs/layout_footer.yml +1 -1
  7. data/app/views/govuk_publishing_components/components/docs/layout_for_admin.yml +3 -16
  8. data/app/views/govuk_publishing_components/components/docs/layout_header.yml +1 -1
  9. data/app/views/govuk_publishing_components/components/docs/modal_dialogue.yml +2 -2
  10. data/app/views/govuk_publishing_components/components/docs/skip_link.yml +1 -1
  11. data/app/views/govuk_publishing_components/components/docs/tabs.yml +1 -2
  12. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +2 -5
  13. data/lib/govuk_publishing_components/version.rb +1 -1
  14. data/node_modules/accessible-autocomplete/package.json +1 -1
  15. data/node_modules/graceful-fs/package.json +15 -15
  16. data/node_modules/graceful-fs/polyfills.js +16 -9
  17. data/node_modules/jsx-ast-utils/CHANGELOG.md +4 -0
  18. data/node_modules/jsx-ast-utils/__tests__/helper.js +41 -3
  19. data/node_modules/jsx-ast-utils/__tests__/src/elementType-test.js +4 -1
  20. data/node_modules/jsx-ast-utils/__tests__/src/getProp-test.js +4 -1
  21. data/node_modules/jsx-ast-utils/__tests__/src/{getPropLiteralValue-test.js → getPropLiteralValue-babelparser-test.js} +23 -5
  22. data/node_modules/jsx-ast-utils/__tests__/src/getPropLiteralValue-flowparser-test.js +522 -0
  23. data/node_modules/jsx-ast-utils/__tests__/src/{getPropValue-test.js → getPropValue-babelparser-test.js} +38 -5
  24. data/node_modules/jsx-ast-utils/__tests__/src/getPropValue-flowparser-test.js +938 -0
  25. data/node_modules/jsx-ast-utils/__tests__/src/hasProp-test.js +4 -1
  26. data/node_modules/jsx-ast-utils/__tests__/src/propName-test.js +4 -1
  27. data/node_modules/jsx-ast-utils/lib/values/expressions/TypeCastExpression.js +19 -0
  28. data/node_modules/jsx-ast-utils/lib/values/expressions/index.js +8 -2
  29. data/node_modules/jsx-ast-utils/package.json +17 -14
  30. data/node_modules/jsx-ast-utils/src/values/expressions/TypeCastExpression.js +13 -0
  31. data/node_modules/jsx-ast-utils/src/values/expressions/index.js +3 -0
  32. data/node_modules/pkg-conf/package.json +1 -1
  33. metadata +8 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb40dbb228473a0c7840005b58db8e5a1994627bd21b7c9a6898e93014a999f4
4
- data.tar.gz: 7d66875ffa318b5e5ea481528253c8b7a9979f1473a0cdefa4f597d6e8238795
3
+ metadata.gz: 76d238b015dfdc0aa0df5463c851ecae9a9bc0e58a1474717cc1e8cefa239c2d
4
+ data.tar.gz: d834c8caf23380a76293386e68d7286e9aa80b67965a4e263ac72485a6037c40
5
5
  SHA512:
6
- metadata.gz: 3dbe531235d53da0bf57de7b7e56a4176ff1ff57f53676bfa35c01a7fced257734a4576a71f98abb5991cebeb11e8e12eb4af1bb577c677f36a33a90d8c7ad43
7
- data.tar.gz: 3e0bd7c28bf4bc1727d3238e0d3d39f1126de5306111cb00b91b7162c0803b6d6847c8564a21f896a2c0d7b905aa2abd493097c6004410277b82d5271cafadeb
6
+ metadata.gz: 3b89dd2b19bd421bbc377c2f2f4faf938ce17eff10a8cca2c5c5f0fb8933eadb7fc3545ccc717c95e7cbdc4b7e31e936d24debc1eadcb98c553234a06fdceca6
7
+ data.tar.gz: 920f537e83fe6a78445c09b5b7b36b991cea4e10010740fd20fd82e2b1c1a5db298a97250e7b2291d00c9121b2b8b63f1b8e311636e89d8c0418baf6aa370a9d
@@ -20,6 +20,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
20
20
  this.$promptQuestions = $element.find('.js-prompt-questions')
21
21
  this.$promptSuccessMessage = $element.find('.js-prompt-success')
22
22
  this.$somethingIsWrongForm = $element.find('#something-is-wrong')
23
+ this.$surveyForm = $element.find('#page-is-not-useful')
24
+ this.$surveyWrapper = $element.find('#survey-wrapper')
23
25
 
24
26
  var that = this
25
27
  var jshiddenClass = 'js-hidden'
@@ -49,6 +51,17 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
49
51
  revealInitialPrompt()
50
52
  })
51
53
 
54
+ this.$pageIsNotUsefulButton.on('click', function (e) {
55
+ var gaClientId
56
+ var dummyGaClientId = '111111111.1111111111'
57
+ if (window.GOVUK.cookie('_ga') === null || window.GOVUK.cookie('_ga') === '') {
58
+ gaClientId = dummyGaClientId
59
+ } else {
60
+ gaClientId = window.GOVUK.cookie('_ga').split('.').slice(-2).join('.')
61
+ }
62
+ setHiddenValuesNotUsefulForm(gaClientId)
63
+ })
64
+
52
65
  $element.find('form').on('submit', function (e) {
53
66
  e.preventDefault()
54
67
  var $form = $(this)
@@ -90,6 +103,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
90
103
  that.$somethingIsWrongForm.append($('<input type="hidden" name="referrer">').val(document.referrer || 'unknown'))
91
104
  }
92
105
 
106
+ function setHiddenValuesNotUsefulForm (gaClientId) {
107
+ var currentPathName = window.location.pathname.replace(/[^\s=?&]+(?:@|%40)[^\s=?&]+/, '[email]')
108
+ var finalPathName = encodeURI(currentPathName)
109
+
110
+ that.$surveyForm.append($('<input name="email_survey_signup[ga_client_id]" type="hidden">').val(gaClientId || '0'))
111
+ that.$surveyWrapper.append('<a href="https://www.smartsurvey.co.uk/s/gov-uk-banner/?c=' + finalPathName + '&amp;gcl=' + gaClientId + '" class="gem-c-feedback__email-link govuk-link" id="take-survey" target="_blank" rel="noopener noreferrer">Don’t have an email address?</a>')
112
+ }
113
+
93
114
  function updateAriaAttributes (linkClicked) {
94
115
  linkClicked.attr('aria-expanded', true)
95
116
  $('#' + linkClicked.attr('aria-controls')).attr('aria-hidden', false)
@@ -1,31 +1,31 @@
1
1
  .gem-c-translation-nav {
2
2
  @include responsive-top-margin;
3
3
  @include govuk-text-colour;
4
- @include core-16;
5
- margin-bottom: $gutter;
6
- border-bottom: 1px solid $border-colour;
4
+ @include govuk-font(16);
5
+ margin-bottom: govuk-spacing(6);
6
+ border-bottom: 1px solid $govuk-border-colour;
7
7
  }
8
8
 
9
9
  .gem-c-translation-nav__list {
10
- @extend %contain-floats;
10
+ @include govuk-clearfix;
11
11
  list-style: none;
12
- margin: 0 (-$gutter-one-third);
12
+ margin: 0 (- govuk-spacing(2));
13
13
  padding: 0;
14
14
  }
15
15
 
16
16
  .gem-c-translation-nav__list-item {
17
17
  float: left;
18
- padding-left: $gutter-one-third;
19
- padding-right: $gutter-one-third;
20
- margin-bottom: $gutter-one-third;
21
- border-right: 1px solid $border-colour;
18
+ padding-left: govuk-spacing(2);
19
+ padding-right: govuk-spacing(2);
20
+ margin-bottom: govuk-spacing(2);
21
+ border-right: 1px solid $govuk-border-colour;
22
22
  height: 16px;
23
23
 
24
24
  .direction-rtl & {
25
25
  direction: rtl;
26
26
  float: right;
27
27
  text-align: start;
28
- border-left: 1px solid $border-colour;
28
+ border-left: 1px solid $govuk-border-colour;
29
29
  border-right: 0;
30
30
  }
31
31
  }
@@ -14,5 +14,5 @@
14
14
  <div class="gem-c-feedback <%= margin_top_class %>" data-module="feedback">
15
15
  <%= render "govuk_publishing_components/components/feedback/yes_no_banner" %>
16
16
  <%= render "govuk_publishing_components/components/feedback/problem_form", url_without_pii: url_without_pii %>
17
- <%= render "govuk_publishing_components/components/feedback/survey_signup_form", path_without_pii: path_without_pii %>
17
+ <%= render "govuk_publishing_components/components/feedback/survey_signup_form"%>
18
18
  </div>
@@ -3,7 +3,8 @@ description: The accordion component lets users show and hide sections of relate
3
3
  govuk_frontend_components:
4
4
  - accordion
5
5
  body: |
6
- This component is based on the [design system accordion component](https://design-system.service.gov.uk/components/accordion/) and is currently experimental. If using this component, please feed back any research findings to the design team.
6
+ This component is based on the [design system accordion component](https://design-system.service.gov.uk/components/accordion/)
7
+ and is currently experimental. If using this component, please feed back any research findings to the Design System team.
7
8
 
8
9
  accessibility_criteria: |
9
10
  The accordion must:
@@ -1,4 +1,4 @@
1
- name: Layout footer (experimental)
1
+ name: Layout footer
2
2
  description: The footer provides copyright, licensing and other information
3
3
  govuk_frontend_components:
4
4
  - footer
@@ -1,25 +1,12 @@
1
- name: Admin layout (experimental)
1
+ name: Admin layout
2
2
  description: A layout to be used by admin applications
3
3
  body: |
4
- This component is experimental. Breaking changes are likely and we'll not release
5
- major version of the gem for these changes. Typically you'll use this together
6
- with the [layout header component](/component-guide/layout_header) and the
4
+ Typically you'll use this together with the
5
+ [layout header component](/component-guide/layout_header) and the
7
6
  [layout footer component](/component-guide/layout_footer).
8
7
 
9
8
  Because it is an entire HTML document, this component can only be [previewed on a separate page](/admin).
10
9
 
11
- Inside this component you can use a number of classes provided by govuk-frontend:
12
-
13
- - [Typography classes](https://design-system.service.gov.uk/styles/typography/) like `.govuk-link`, `.govuk-heading`
14
- - [Layout grid classes](https://design-system.service.gov.uk/styles/layout/) like `.govuk-grid-column-two-thirds`
15
- - [Spacing classes](https://design-system.service.gov.uk/styles/spacing/) like `.govuk-!-margin-bottom-3`
16
- - [List classes](https://design-system.service.gov.uk/styles/typography/#lists) like `.govuk-list` and `.govuk-list--bullet`
17
- - [Section break classes](https://design-system.service.gov.uk/styles/typography/#section-break) like `.govuk-section-break`
18
- - The `.govuk-visually-hidden` class to hide things
19
-
20
- Be *very* careful when using one of these classes, prefer to use a component
21
- instead of consuming govuk-frontend directly.
22
-
23
10
  display_preview: false
24
11
  display_html: true
25
12
  accessibility_criteria: |
@@ -1,4 +1,4 @@
1
- name: Layout header (experimental)
1
+ name: Layout header
2
2
  description: The header provides the crown logo, product or service name and navigation
3
3
  body: |
4
4
  Requires the specification of the environment (development, integration,
@@ -3,9 +3,9 @@ description: Shows only one section, with no other navigation options, until the
3
3
  body: |
4
4
  Use where the application has gotten into a state from which it shouldn’t or can’t proceed without input from the user or the state of the current page needs to be preserved.
5
5
 
6
- In a document-centric application, for instance, adding an inline image might need the user to supply an image file, alternative text, caption and credits if not using an existing image. In other context, the user may need to search for a specific item before proceeding.
7
-
8
6
  Modal instances are automatically initialised and their state can be changed programmatically using bounded functions (e.g. `$modalDialogue.open()` and `$modalDialogue.close()`)
7
+
8
+ This component is currently experimental. If you are using it, please feed back any research findings to the Content Publisher team.
9
9
  accessibility_criteria: |
10
10
  The modal dialogue box must:
11
11
 
@@ -1,4 +1,4 @@
1
- name: Skip link (experimental)
1
+ name: Skip link
2
2
  description: Skip link component helps keyboard-only users skip to the main content on a page
3
3
  govuk_frontend_components:
4
4
  - skip-link
@@ -2,8 +2,7 @@ name: "Tabs (experimental)"
2
2
  description: "The tabs component lets users toggle between related sections of content."
3
3
  body: |
4
4
  This component is based on the [design system tabs component](https://design-system.service.gov.uk/components/tabs/)
5
- and is currently experimental. If using this component, please feed back any research findings to the
6
- design team.
5
+ and is currently experimental. If using this component, please feed back any research findings to the Design System team.
7
6
 
8
7
  The tabs component lets users navigate between related sections of content on a single page,
9
8
  displaying one section at a time. Note that they are not intended to be used to navigate
@@ -13,12 +13,10 @@
13
13
  role="button">Close</a>
14
14
 
15
15
  <div class="gem-c-feedback__grid-row">
16
- <div class="gem-c-feedback__column-two-thirds">
16
+ <div class="gem-c-feedback__column-two-thirds" id="survey-wrapper">
17
17
  <div class="gem-c-feedback__error-summary js-hidden js-errors" tabindex="-1"></div>
18
18
 
19
19
  <input name="email_survey_signup[survey_id]" type="hidden" value="footer_satisfaction_survey">
20
- <input name="email_survey_signup[survey_source]" type="hidden" value="<%= path_without_pii %>">
21
- <input name="email_survey_signup[ga_client_id]" type="hidden" value="1627485790.1515403243">
22
20
 
23
21
  <h3 class="gem-c-feedback__form-heading">Help us improve GOV.UK</h3>
24
22
  <p id="survey_explanation" class="gem-c-feedback__form-paragraph">To help us improve GOV.UK, we’d like to know more about your visit today. We’ll send you a link to a feedback form. It will take only 2 minutes to fill in. Don’t worry we won’t send you spam or share your email address with anyone.</p>
@@ -34,9 +32,8 @@
34
32
  } %>
35
33
 
36
34
  <%= render "govuk_publishing_components/components/button", {
37
- text: "Send me the survey"
35
+ text: "Send me the survey",
38
36
  } %>
39
- <a href="https://www.smartsurvey.co.uk/s/gov-uk-banner/?c=<%= path_without_pii %>&amp;gcl=1627485790.1515403243" class="gem-c-feedback__email-link govuk-link" id="take-survey" target="_blank" rel="noopener noreferrer">Don’t have an email address?</a>
40
37
  </div>
41
38
  </div>
42
39
  </form>
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '17.10.0'.freeze
2
+ VERSION = '17.11.0'.freeze
3
3
  end
@@ -49,7 +49,7 @@
49
49
  "/"
50
50
  ],
51
51
  "_resolved": "git://github.com/alphagov/accessible-autocomplete.git#3523dd9fffc70cbd9f6f555f75863c33a709f49e",
52
- "_shasum": "85f976262e0a13d4f1da00ca3cef9162a2114bb0",
52
+ "_shasum": "197dcc4e36fdfd37ba46f43f76f71c8c460e2783",
53
53
  "_shrinkwrap": null,
54
54
  "_spec": "accessible-autocomplete@git://github.com/alphagov/accessible-autocomplete.git#add-multiselect-support",
55
55
  "_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ",
@@ -15,19 +15,19 @@
15
15
  ],
16
16
  "_from": "graceful-fs@>=4.1.2 <5.0.0",
17
17
  "_hasShrinkwrap": false,
18
- "_id": "graceful-fs@4.1.15",
18
+ "_id": "graceful-fs@4.2.0",
19
19
  "_inCache": true,
20
20
  "_location": "/graceful-fs",
21
- "_nodeVersion": "10.12.0",
21
+ "_nodeVersion": "12.4.0",
22
22
  "_npmOperationalInternal": {
23
23
  "host": "s3://npm-registry-packages",
24
- "tmp": "tmp/graceful-fs_4.1.15_1541364714631_0.3224551402569402"
24
+ "tmp": "tmp/graceful-fs_4.2.0_1561577965134_0.17208797293985856"
25
25
  },
26
26
  "_npmUser": {
27
27
  "name": "isaacs",
28
28
  "email": "i@izs.me"
29
29
  },
30
- "_npmVersion": "6.4.1",
30
+ "_npmVersion": "6.9.0",
31
31
  "_phantomChildren": {},
32
32
  "_requested": {
33
33
  "raw": "graceful-fs@^4.1.2",
@@ -45,8 +45,8 @@
45
45
  "/load-json-file",
46
46
  "/pkg-conf/load-json-file"
47
47
  ],
48
- "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz",
49
- "_shasum": "ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00",
48
+ "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz",
49
+ "_shasum": "8d8fdc73977cb04104721cb53666c1ca64cd328b",
50
50
  "_shrinkwrap": null,
51
51
  "_spec": "graceful-fs@^4.1.2",
52
52
  "_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ/node_modules/flat-cache",
@@ -59,20 +59,20 @@
59
59
  "import-fresh": "^2.0.0",
60
60
  "mkdirp": "^0.5.0",
61
61
  "rimraf": "^2.2.8",
62
- "tap": "^12.0.1"
62
+ "tap": "^12.7.0"
63
63
  },
64
64
  "directories": {
65
65
  "test": "test"
66
66
  },
67
67
  "dist": {
68
- "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==",
69
- "shasum": "ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00",
70
- "tarball": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz",
68
+ "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==",
69
+ "shasum": "8d8fdc73977cb04104721cb53666c1ca64cd328b",
70
+ "tarball": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz",
71
71
  "fileCount": 7,
72
- "unpackedSize": 25938,
73
- "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb31vrCRA9TVsSAnZWagAAjMYP/2AwGCPcxbX+2ZBkpyRq\nJ85zkTLDdO2AhSNpgApHrPFbvQ2MYSedMmA/tuNOILCd2zulEvadRZLSW5zI\nHUkRFdU20ByFJoLMvoGm8EY9gEnQ3lpIvh6lmgNSYhQhm5khE0XHQ4sAs9YW\nV61Qr4yqKvkxXrMpElTgzkCfEZ79pNzZ58lE0Qvqmcp3OTczsOimh+w5UIUu\nt/GMZpsmLC4VHTj+hSRqYsh8HJFt9Nl2ahXK08eGAroZMRgRY5hA/9aJ2bA7\nHpuyqMH2wjbaJRnT8ORLfgfJ9a8xO+VzIp0ueAWpAjAaCtbC2dKF3/YJ8Bn6\nZUaCWMM1PZG1BIM/4g/q++OV7o9NgJvqjvjMmVZKanzUMBwfD9ygwFcP8oNF\nlLSR4GU6itDJo2oqdtsrTsfDe35sNTl3kwyhMqZPWFlNJ5C02jmeH2qPtc9s\n69lGDH5JNBBKOmJXV9WKfN+mOSXniBnUsUVu0vAm/y9nY1GZQiAlI5MfIW+T\n1a+K2cGakv6c+b2bO6ExwnIjWPwEpKNlPYHdjLv01GoT9qZRh2guD5RBJqDj\nbNToHu3zR6po45ekShHykoFDz3F+mOKWKyfQ1F3Z+z+8udFk7xbO4vxRTC4M\nq1HSgomC6uFS+RRNVhmTS2L4S1izPDbozKOUU+rpk4hQMBhTLgf7nQ0Bates\nG+db\r\n=Fpd7\r\n-----END PGP SIGNATURE-----\r\n"
72
+ "unpackedSize": 26173,
73
+ "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdE8ntCRA9TVsSAnZWagAAhkMP/1wpAg/eCBxcFvsgN55w\n3WotZ+6HJqOB+j5nNC0s78Pqc4E+g9VXNuvKVXlDyx7DwXudJgwY3L2hnmVX\nLItj62qFJ3Zn5KayYsYKnUEWM5/I1iYyExsy+6aQs2KfEAqnQgjcSA3ZN+Pf\nmVLv5NGrtrA/erF8CFjMtApK4GggPSZYjWV8ykWGoZTen67QBbQbwygooM13\ncvfXrVUA80lR00/Yy9pFZcjfijt/2jW427t6LxpevrONA4dviVWg8R+l02Gm\nnrIpvCoqt+FWtnBtJu/K+nORmFdpvetixhNkZY0DDJ+FBW1Qqg5pVHkpcXF+\ngTSGJpGvt2p04y5ZXPNnBx7mL37Nt9zblHnY4tJpzDXE11RSnrRc59cE/6UK\nS58TpbUrNdTNgYH9I0KkLXQ7zWgl1TxUDhEtyOAIH97M8z7XYblGLViv5pQT\nPTJnG61H5EVMC5AJKgnImPhpoS5kofNdp8oKOPQ+2GwsITwNv/RJi/86/3GR\n1QlFu4oW6E/tCg3KkskL3KN04Ohgm3rdJZUXG5t/cQTiGlk0H1CVjDiG/yMW\nWOIpO8EAuN7MkCukI4rKgYhR3BxzJ+N1tdw0sSb80x9/6JmUh9Bl4pZvdH2V\naWVdsJX/KoT6xjwiX5vi8p0fCIQswggUKAvRVygKDKuhKz+ubbtbXtQFwuJF\nwsmn\r\n=YcR0\r\n-----END PGP SIGNATURE-----\r\n"
74
74
  },
75
- "gitHead": "26456e3deb4a5e85363e92f9015bcefd3b6b13ba",
75
+ "gitHead": "585df780323740a2b562677caa08a80de1f56c62",
76
76
  "homepage": "https://github.com/isaacs/node-graceful-fs#readme",
77
77
  "keywords": [
78
78
  "fs",
@@ -106,10 +106,10 @@
106
106
  "url": "git+https://github.com/isaacs/node-graceful-fs.git"
107
107
  },
108
108
  "scripts": {
109
- "postpublish": "git push origin --all; git push origin --tags",
109
+ "postpublish": "git push origin --follow-tags",
110
110
  "postversion": "npm publish",
111
111
  "preversion": "npm test",
112
112
  "test": "node test.js | tap -"
113
113
  },
114
- "version": "4.1.15"
114
+ "version": "4.2.0"
115
115
  }
@@ -272,18 +272,24 @@ function patch (fs) {
272
272
  }
273
273
  }
274
274
 
275
-
276
275
  function statFix (orig) {
277
276
  if (!orig) return orig
278
277
  // Older versions of Node erroneously returned signed integers for
279
278
  // uid + gid.
280
- return function (target, cb) {
281
- return orig.call(fs, target, function (er, stats) {
282
- if (!stats) return cb.apply(this, arguments)
283
- if (stats.uid < 0) stats.uid += 0x100000000
284
- if (stats.gid < 0) stats.gid += 0x100000000
279
+ return function (target, options, cb) {
280
+ if (typeof options === 'function') {
281
+ cb = options
282
+ options = null
283
+ }
284
+ function callback (er, stats) {
285
+ if (stats) {
286
+ if (stats.uid < 0) stats.uid += 0x100000000
287
+ if (stats.gid < 0) stats.gid += 0x100000000
288
+ }
285
289
  if (cb) cb.apply(this, arguments)
286
- })
290
+ }
291
+ return options ? orig.call(fs, target, options, callback)
292
+ : orig.call(fs, target, callback)
287
293
  }
288
294
  }
289
295
 
@@ -291,8 +297,9 @@ function patch (fs) {
291
297
  if (!orig) return orig
292
298
  // Older versions of Node erroneously returned signed integers for
293
299
  // uid + gid.
294
- return function (target) {
295
- var stats = orig.call(fs, target)
300
+ return function (target, options) {
301
+ var stats = options ? orig.call(fs, target, options)
302
+ : orig.call(fs, target)
296
303
  if (stats.uid < 0) stats.uid += 0x100000000
297
304
  if (stats.gid < 0) stats.gid += 0x100000000
298
305
  return stats;
@@ -1,3 +1,7 @@
1
+ 2.2.1 / 2019-06-30
2
+ ==================
3
+ - (improvement) Account for TypeCastExpression in the utils
4
+
1
5
  2.2.0 / 2019-06-25
2
6
  ==================
3
7
  - (fix) Fix getLiteralPropValue for TS-specific node types.
@@ -5,11 +5,17 @@ const nodeVersion = parseInt(process.version.match(/^v(\d+)\./)[1], 10);
5
5
 
6
6
  export const fallbackToBabylon = nodeVersion < 6;
7
7
 
8
- const parser = fallbackToBabylon ? require('babylon') : require('@babel/parser');
8
+ let parserName;
9
+ const babelParser = fallbackToBabylon ? require('babylon') : require('@babel/parser');
10
+ const flowParser = require('flow-parser');
9
11
 
10
12
  const defaultPlugins = ['jsx', 'functionBind', 'estree', 'objectRestSpread', 'optionalChaining'];
11
13
  let plugins = [...defaultPlugins];
12
14
 
15
+ export function setParserName(name) {
16
+ parserName = name;
17
+ }
18
+
13
19
  export function changePlugins(pluginOrFn) {
14
20
  if (Array.isArray(pluginOrFn)) {
15
21
  plugins = pluginOrFn;
@@ -25,11 +31,43 @@ beforeEach(() => {
25
31
  });
26
32
 
27
33
  function parse(code) {
28
- return parser.parse(code, { plugins });
34
+ if (parserName === undefined) {
35
+ throw new Error('No parser specified');
36
+ }
37
+ if (parserName === 'babel') {
38
+ try {
39
+ return babelParser.parse(code, { plugins });
40
+ } catch (_) {
41
+ // eslint-disable-next-line no-console
42
+ console.warn(`Failed to parse with ${fallbackToBabylon ? 'babylon' : 'Babel'} parser.`);
43
+ }
44
+ }
45
+ if (parserName === 'flow') {
46
+ try {
47
+ return flowParser.parse(code, { plugins });
48
+ } catch (_) {
49
+ // eslint-disable-next-line no-console
50
+ console.warn('Failed to parse with the Flow parser');
51
+ }
52
+ }
53
+ throw new Error(`The parser ${parserName} is not yet supported for testing.`);
29
54
  }
30
55
 
31
56
  export function getOpeningElement(code) {
32
- return parse(code).program.body[0].expression.openingElement;
57
+ const parsedCode = parse(code);
58
+ let body;
59
+ if (parsedCode.program) {
60
+ // eslint-disable-next-line prefer-destructuring
61
+ body = parsedCode.program.body;
62
+ } else {
63
+ // eslint-disable-next-line prefer-destructuring
64
+ body = parsedCode.body;
65
+ }
66
+ if (Array.isArray(body) && body[0] != null) {
67
+ return body[0].expression.openingElement;
68
+ }
69
+
70
+ return null;
33
71
  }
34
72
 
35
73
  export function extractProp(code, prop = 'foo') {
@@ -1,9 +1,12 @@
1
1
  /* eslint-env mocha */
2
2
  import assert from 'assert';
3
- import { getOpeningElement } from '../helper';
3
+ import { getOpeningElement, setParserName } from '../helper';
4
4
  import elementType from '../../src/elementType';
5
5
 
6
6
  describe('elementType tests', () => {
7
+ beforeEach(() => {
8
+ setParserName('babel');
9
+ });
7
10
  it('should export a function', () => {
8
11
  const expected = 'function';
9
12
  const actual = typeof elementType;
@@ -1,9 +1,12 @@
1
1
  /* eslint-env mocha */
2
2
  import assert from 'assert';
3
- import { getOpeningElement } from '../helper';
3
+ import { getOpeningElement, setParserName } from '../helper';
4
4
  import getProp from '../../src/getProp';
5
5
 
6
6
  describe('getProp', () => {
7
+ beforeEach(() => {
8
+ setParserName('babel');
9
+ });
7
10
  it('should export a function', () => {
8
11
  const expected = 'function';
9
12
  const actual = typeof getProp;