hof 22.9.1 → 22.10.1
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.
- package/CHANGELOG.md +16 -0
- package/README.md +30 -0
- package/config/hof-defaults.js +7 -1
- package/frontend/template-partials/translations/src/en/cookies.json +2 -2
- package/frontend/template-partials/views/cookies.html +6 -6
- package/frontend/template-partials/views/layout.html +2 -8
- package/frontend/template-partials/views/partials/cookie-banner.html +11 -7
- package/frontend/themes/gov-uk/styles/_cookie-banner.scss +0 -3
- package/lib/settings.js +2 -0
- package/package.json +5 -6
- package/.editorconfig +0 -10
- package/.github/workflows/automate-publish.yml +0 -38
- package/.github/workflows/automate-tag.yml +0 -78
- package/.istanbul.yml +0 -20
- package/codeReviewChecklist.md +0 -22
- package/pull_request_template.md +0 -16
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 2025-09-10, Version 22.10.1 (Stable), @dk4g
|
2
|
+
|
3
|
+
### Added
|
4
|
+
- Added `showCookiesBanner` configuration flag to control cookie banner display
|
5
|
+
- Automatically shows banner when `GA_TAG` or `GA_4_TAG` environment variables are present
|
6
|
+
- Defaults to `false` when no Google Analytics is configured
|
7
|
+
- Can be explicitly controlled via `SHOW_COOKIES_BANNER` environment variable
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
- Cookie banner now intelligently displays based on GA configuration
|
11
|
+
- Improved cookie consent UX by hiding banner when GA is not enabled
|
12
|
+
- **Layout template updated**: Projects that override the default `layout` template should update their custom templates to include the new `showCookiesBanner` logic. If you inherit from HOF's layout template, no action is required.
|
13
|
+
|
14
|
+
### Migration Notes
|
15
|
+
- **Custom Layout Templates**: If your project overrides the default HOF layout template, ensure your custom template includes the cookie banner conditional logic using the new `showCookiesBanner` configuration flag. Check the updated HOF layout template for reference implementation.
|
16
|
+
|
1
17
|
## 2025-09-09, Version 22.9.0 (Stable), @Rhodine-orleans-lindsay
|
2
18
|
### Fixed
|
3
19
|
- Fixed bug where if text on session-timeout page was not being populated when the browser back button is used.
|
package/README.md
CHANGED
@@ -859,6 +859,36 @@ You can also provide an array of healthcheck URLs with `healthcheckUrls`,
|
|
859
859
|
should you not want to throw a Cookies required error when requesting the app with specific URLs.
|
860
860
|
Kubernetes healthcheck URLs are provided as defaults if no overrides are supplied.
|
861
861
|
|
862
|
+
### Cookie Banner Control
|
863
|
+
|
864
|
+
> **Available from version 22.9.1**
|
865
|
+
|
866
|
+
| Variable | Description | Default | Example |
|
867
|
+
|----------|-------------|---------|---------|
|
868
|
+
| `SHOW_COOKIES_BANNER` | Controls whether the cookies banner is displayed | Auto-detected based on GA tags | `true`, `false` |
|
869
|
+
|
870
|
+
**Behavior:**
|
871
|
+
- If `SHOW_COOKIES_BANNER` is explicitly set, that value is used
|
872
|
+
- If not set, banner is automatically shown when `GA_TAG` or `GA_4_TAG` is present
|
873
|
+
- If no GA tags are configured, banner is hidden by default
|
874
|
+
|
875
|
+
**Examples:**
|
876
|
+
```bash
|
877
|
+
# Explicitly show banner regardless of GA configuration
|
878
|
+
SHOW_COOKIES_BANNER=true
|
879
|
+
|
880
|
+
# Hide banner even when GA tags are present
|
881
|
+
SHOW_COOKIES_BANNER=false
|
882
|
+
GA_TAG=UA-12345678-1
|
883
|
+
|
884
|
+
# Auto-detect (recommended) - shows banner when GA is configured
|
885
|
+
GA_TAG=UA-12345678-1 # Banner will show
|
886
|
+
GA_4_TAG=G-XXXXXXXXXX # Banner will show
|
887
|
+
# (no GA tags) # Banner will be hidden
|
888
|
+
```
|
889
|
+
|
890
|
+
**Note:** If you have a custom layout template that overrides the default HOF layout, you'll need to update it to include the new `showCookiesBanner` logic. Projects that inherit from the default HOF layout template will automatically receive this functionality.
|
891
|
+
|
862
892
|
## Service Unavailable
|
863
893
|
Allows a service to be paused when required and then resumed. It ensures that anyone using the service that lands on any part of the form is diverted to a "Service Unavailable" page which will communicate to the user that the service is not available at this time.
|
864
894
|
|
package/config/hof-defaults.js
CHANGED
@@ -25,8 +25,14 @@ const defaults = {
|
|
25
25
|
host: process.env.HOST || '0.0.0.0',
|
26
26
|
port: process.env.PORT || '8080',
|
27
27
|
env: process.env.NODE_ENV || 'development',
|
28
|
-
gaTagId: process.env.GA_TAG
|
28
|
+
gaTagId: process.env.GA_TAG,
|
29
29
|
ga4TagId: process.env.GA_4_TAG,
|
30
|
+
showCookiesBanner: parseBoolean(
|
31
|
+
process.env.SHOW_COOKIES_BANNER,
|
32
|
+
Boolean(process.env.GA_TAG || process.env.GA_4_TAG),
|
33
|
+
'SHOW_COOKIES_BANNER'
|
34
|
+
),
|
35
|
+
hasGoogleAnalytics: Boolean(process.env.GA_TAG || process.env.GA_4_TAG),
|
30
36
|
// added to allow support for multiple HOF forms using GTM to customize how they track page views
|
31
37
|
gtm: {
|
32
38
|
tagId: process.env.GTM_TAG || false,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"banner": {
|
3
|
-
"message": "
|
4
|
-
"link": "
|
3
|
+
"message": "We use some essential cookies to make this website work.",
|
4
|
+
"link": "View cookies"
|
5
5
|
},
|
6
6
|
"header": "Cookies",
|
7
7
|
"intro": "This service puts small files (known as ‘cookies’) onto your computer in order to:",
|
@@ -3,9 +3,9 @@
|
|
3
3
|
{{$propositionHeader}}{{/propositionHeader}}
|
4
4
|
|
5
5
|
{{$validationSummary}}
|
6
|
-
{{#
|
6
|
+
{{#hasGoogleAnalytics}}
|
7
7
|
{{> partials-cookie-notification}}
|
8
|
-
{{/
|
8
|
+
{{/hasGoogleAnalytics}}
|
9
9
|
{{/validationSummary}}
|
10
10
|
|
11
11
|
{{$header}}
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
{{$content}}
|
16
16
|
<p>{{intro}}</p>
|
17
|
-
{{^
|
17
|
+
{{^hasGoogleAnalytics}}
|
18
18
|
{{#intro-list}}
|
19
19
|
{{> partials-bullet-list}}
|
20
20
|
{{/intro-list}}
|
@@ -31,9 +31,9 @@
|
|
31
31
|
{{#session-cookies-table}}
|
32
32
|
{{> partials-session-cookies-table}}
|
33
33
|
{{/session-cookies-table}}
|
34
|
-
{{/
|
34
|
+
{{/hasGoogleAnalytics}}
|
35
35
|
|
36
|
-
{{#
|
36
|
+
{{#hasGoogleAnalytics}}
|
37
37
|
<div id="cookie-settings">
|
38
38
|
{{#intro-list-ga-tag}}
|
39
39
|
{{> partials-bullet-list}}
|
@@ -78,7 +78,7 @@
|
|
78
78
|
</form>
|
79
79
|
</div>
|
80
80
|
</div>
|
81
|
-
{{/
|
81
|
+
{{/hasGoogleAnalytics}}
|
82
82
|
|
83
83
|
{{/content}}
|
84
84
|
{{/layout}}
|
@@ -33,15 +33,9 @@
|
|
33
33
|
</div>
|
34
34
|
{{/main}}
|
35
35
|
{{$cookieMessage}}
|
36
|
-
{{#
|
36
|
+
{{#showCookiesBanner}}
|
37
37
|
{{> partials-cookie-banner}}
|
38
|
-
{{/
|
39
|
-
{{^gaTagId}}
|
40
|
-
<p class="no-ga-tag">
|
41
|
-
{{#t}}cookies.banner.message{{/t}}
|
42
|
-
<a href="/cookies">{{#t}}cookies.banner.link{{/t}}</a>
|
43
|
-
</p>
|
44
|
-
{{/gaTagId}}
|
38
|
+
{{/showCookiesBanner}}
|
45
39
|
{{/cookieMessage}}
|
46
40
|
{{$footerSupportLinks}}
|
47
41
|
<ul class="govuk-footer__inline-list">
|
@@ -4,24 +4,28 @@
|
|
4
4
|
<div class="govuk-grid-column-two-thirds">
|
5
5
|
<h2 class="govuk-cookie-banner__heading govuk-heading-m">Cookies on {{#appName}}{{appName}}{{/appName}}{{^appName}}this service{{/appName}}</h2>
|
6
6
|
<div class="govuk-cookie-banner__content">
|
7
|
-
<p class="govuk-body">
|
8
|
-
|
9
|
-
|
7
|
+
<p class="govuk-body">{{#t}}cookies.banner.message{{/t}}</p>
|
8
|
+
{{#hasGoogleAnalytics}}
|
9
|
+
<p class="govuk-body">We'd like to set additional cookies to understand how you use GOV.UK, remember your settings and improve government services.</p>
|
10
|
+
<p class="govuk-body">We also use cookies set by other sites to help us deliver content from their services.</p>
|
11
|
+
{{/hasGoogleAnalytics}}
|
10
12
|
</div>
|
11
13
|
</div>
|
12
14
|
</div>
|
13
15
|
<div id="cookie-banner-actions" class="govuk-button-group">
|
16
|
+
{{#hasGoogleAnalytics}}
|
14
17
|
<button id="accept-cookies-button" class="gem-c-button govuk-button" type="submit" data-module="gem-track-click" data-accept-cookies="true" data-track-category="cookieBanner" data-track-action="Cookie banner accepted" data-cookie-types="all">Accept additional cookies</button>
|
15
18
|
|
16
19
|
<button id="reject-cookies-button" class="gem-c-button govuk-button" type="submit" data-module="gem-track-click" data-reject-cookies="true" data-track-category="cookieBanner" data-track-action="Cookie banner rejected">Reject additional cookies</button>
|
17
|
-
|
18
|
-
|
20
|
+
{{/hasGoogleAnalytics}}
|
21
|
+
<a class="govuk-link" href="/cookies">{{#t}}cookies.banner.link{{/t}}</a>
|
19
22
|
</div>
|
20
23
|
</div>
|
24
|
+
|
21
25
|
<div class="gem-c-cookie-banner__confirmation govuk-width-container" hidden="" id="cookie-banner-submitted" >
|
22
26
|
<p class="gem-c-cookie-banner__confirmation-message" role="alert">
|
23
|
-
|
24
|
-
|
27
|
+
Your cookie preferences have been saved. You can <a class="govuk-link" data-module="gem-track-click" data-track-category="cookieBanner" data-track-action="Cookie banner settings clicked from confirmation" href="/cookies">change your cookie settings</a> at any time.
|
28
|
+
</p>
|
25
29
|
<div class="govuk-button-group">
|
26
30
|
<button class="gem-c-cookie-banner__hide-button govuk-button" id="hide-cookie-banner">Hide this message</button>
|
27
31
|
</div>
|
package/lib/settings.js
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "hof",
|
3
3
|
"description": "A bootstrap for HOF projects",
|
4
|
-
"version": "22.
|
4
|
+
"version": "22.10.1",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "index.js",
|
7
7
|
"author": "HomeOffice",
|
@@ -82,14 +82,14 @@
|
|
82
82
|
"nodemailer": "^6.6.3",
|
83
83
|
"nodemailer-ses-transport": "^1.5.1",
|
84
84
|
"nodemailer-stub-transport": "^1.1.0",
|
85
|
-
"notifications-node-client": "^8.2.
|
85
|
+
"notifications-node-client": "^8.2.1",
|
86
86
|
"redis": "^3.1.2",
|
87
87
|
"reqres": "^3.0.1",
|
88
88
|
"rimraf": "^3.0.2",
|
89
89
|
"sass": "^1.56.2",
|
90
90
|
"serve-static": "^1.14.1",
|
91
91
|
"uglify-js": "^3.14.3",
|
92
|
-
"underscore": "^1.13.
|
92
|
+
"underscore": "^1.13.7",
|
93
93
|
"urijs": "^1.19.11",
|
94
94
|
"uuid": "^8.3.2",
|
95
95
|
"winston": "^3.7.2"
|
@@ -104,8 +104,8 @@
|
|
104
104
|
"chai-subset": "^1.6.0",
|
105
105
|
"concat-stream": "^1.4.7",
|
106
106
|
"csv": "^5.3.2",
|
107
|
-
"eslint": "^
|
108
|
-
"eslint-config-hof": "^1.
|
107
|
+
"eslint": "^8.57.0",
|
108
|
+
"eslint-config-hof": "^1.3.4",
|
109
109
|
"funkie": "0.0.5",
|
110
110
|
"funkie-phantom": "0.0.1",
|
111
111
|
"istanbul": "^0.4.3",
|
@@ -141,7 +141,6 @@
|
|
141
141
|
"exit": "true"
|
142
142
|
},
|
143
143
|
"resolutions": {
|
144
|
-
"underscore": "^1.12.1",
|
145
144
|
"cached-path-relative": "^1.1.0",
|
146
145
|
"shell-quote": "^1.7.3"
|
147
146
|
}
|
package/.editorconfig
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
2
|
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
3
|
-
name: Automate_Publish
|
4
|
-
on:
|
5
|
-
workflow_run:
|
6
|
-
workflows: ["Automate_Tag"]
|
7
|
-
types:
|
8
|
-
- completed
|
9
|
-
jobs:
|
10
|
-
auto-publish:
|
11
|
-
runs-on: ubuntu-22.04
|
12
|
-
if: startsWith(github.ref, 'refs/heads/master')
|
13
|
-
steps:
|
14
|
-
- uses: actions/checkout@v4
|
15
|
-
with:
|
16
|
-
fetch-depth: 0
|
17
|
-
- uses: actions/setup-node@v4
|
18
|
-
with:
|
19
|
-
node-version: 20
|
20
|
-
registry-url: https://registry.npmjs.org/
|
21
|
-
- name: 'Get Previous tag'
|
22
|
-
id: previoustag
|
23
|
-
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
24
|
-
- uses: borales/actions-yarn@v3.0.0
|
25
|
-
with:
|
26
|
-
cmd: install --frozen-lockfile
|
27
|
-
- run: |
|
28
|
-
npm_tag="v$(npm dist-tags | cut -d' ' -f 2)"
|
29
|
-
git_tag="$(git describe --tags | cut -d'-' -f 1)"
|
30
|
-
if [ "$npm_tag" != "$git_tag" ] ; then npm publish; fi
|
31
|
-
env:
|
32
|
-
NODE_AUTH_TOKEN: ${{ secrets.npm_bot_token }}
|
33
|
-
- name: 'Publish Release'
|
34
|
-
uses: Roang-zero1/github-create-release-action@master
|
35
|
-
with:
|
36
|
-
created_tag: ${{ steps.previoustag.outputs.tag }}
|
37
|
-
env:
|
38
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
2
|
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
3
|
-
name: Automate_Tag
|
4
|
-
on: [push]
|
5
|
-
jobs:
|
6
|
-
test:
|
7
|
-
runs-on: ubuntu-22.04
|
8
|
-
strategy:
|
9
|
-
matrix:
|
10
|
-
node-version: [20.x]
|
11
|
-
redis-version: [4, 5, 6]
|
12
|
-
steps:
|
13
|
-
- uses: actions/checkout@v4
|
14
|
-
- uses: actions/setup-node@v4
|
15
|
-
with:
|
16
|
-
node-version: ${{ matrix.node-version }}
|
17
|
-
- name: Start Redis
|
18
|
-
uses: supercharge/redis-github-action@1.2.0
|
19
|
-
with:
|
20
|
-
redis-version: ${{ matrix.redis-version }}
|
21
|
-
- uses: borales/actions-yarn@v3.0.0
|
22
|
-
with:
|
23
|
-
cmd: install --frozen-lockfile
|
24
|
-
- run: npm test
|
25
|
-
|
26
|
-
auto-tag-patch:
|
27
|
-
needs: test
|
28
|
-
runs-on: ubuntu-22.04
|
29
|
-
if: |
|
30
|
-
startsWith(github.ref, 'refs/heads/master') &&
|
31
|
-
!contains(github.event.head_commit.message, '[MAJOR]') &&
|
32
|
-
!contains(github.event.head_commit.message, '[MINOR]')
|
33
|
-
steps:
|
34
|
-
- uses: actions/checkout@v4
|
35
|
-
- uses: actions/setup-node@v4
|
36
|
-
with:
|
37
|
-
node-version: 20
|
38
|
-
registry-url: https://registry.npmjs.org/
|
39
|
-
- run: |
|
40
|
-
git config --local user.email "$(git log --format='%ae' HEAD^!)"
|
41
|
-
git config --local user.name "$(git log --format='%an' HEAD^!)"
|
42
|
-
npm version patch
|
43
|
-
|
44
|
-
auto-tag-minor:
|
45
|
-
needs: test
|
46
|
-
runs-on: ubuntu-22.04
|
47
|
-
if: |
|
48
|
-
startsWith(github.ref, 'refs/heads/master') &&
|
49
|
-
!contains(github.event.head_commit.message, '[MAJOR]') &&
|
50
|
-
contains(github.event.head_commit.message, '[MINOR]')
|
51
|
-
steps:
|
52
|
-
- uses: actions/checkout@v4
|
53
|
-
- uses: actions/setup-node@v4
|
54
|
-
with:
|
55
|
-
node-version: 20
|
56
|
-
registry-url: https://registry.npmjs.org/
|
57
|
-
- run: |
|
58
|
-
git config --local user.email "$(git log --format='%ae' HEAD^!)"
|
59
|
-
git config --local user.name "$(git log --format='%an' HEAD^!)"
|
60
|
-
npm version minor
|
61
|
-
|
62
|
-
auto-tag-major:
|
63
|
-
needs: test
|
64
|
-
runs-on: ubuntu-22.04
|
65
|
-
if: |
|
66
|
-
startsWith(github.ref, 'refs/heads/master') &&
|
67
|
-
contains(github.event.head_commit.message, '[MAJOR]') &&
|
68
|
-
!contains(github.event.head_commit.message, '[MINOR]')
|
69
|
-
steps:
|
70
|
-
- uses: actions/checkout@v4
|
71
|
-
- uses: actions/setup-node@v4
|
72
|
-
with:
|
73
|
-
node-version: 20
|
74
|
-
registry-url: https://registry.npmjs.org/
|
75
|
-
- run: |
|
76
|
-
git config --local user.email "$(git log --format='%ae' HEAD^!)"
|
77
|
-
git config --local user.name "$(git log --format='%an' HEAD^!)"
|
78
|
-
npm version major
|
package/.istanbul.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
instrumentation:
|
2
|
-
root: .
|
3
|
-
extensions:
|
4
|
-
- .js
|
5
|
-
default-excludes: true
|
6
|
-
include-all-sources: true
|
7
|
-
check:
|
8
|
-
global:
|
9
|
-
statements: 80
|
10
|
-
lines: 80
|
11
|
-
branches: 80
|
12
|
-
functions: 80
|
13
|
-
reporting:
|
14
|
-
print: summary
|
15
|
-
reports:
|
16
|
-
- html
|
17
|
-
dir: ./coverage
|
18
|
-
report-config:
|
19
|
-
html:
|
20
|
-
dir: coverage
|
package/codeReviewChecklist.md
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# HOF code review checklist v1.0
|
2
|
-
|
3
|
-
This is a general guide on what you should check for when reviewing another team member's code.
|
4
|
-
|
5
|
-
## Fundamental checks
|
6
|
-
- [ ] Check for code format
|
7
|
-
- [ ] Check for duplicate code
|
8
|
-
- [ ] Check for if there are existing components in the framework already
|
9
|
-
- [ ] Check for copy and paste
|
10
|
-
- [ ] Check code readability (if the class, function and variable names are making sense, avoid using acronyms, check for simplicity, avoid complexity)
|
11
|
-
- [ ] Check if user inputs are sanitized
|
12
|
-
- [ ] Check if errors are handled
|
13
|
-
- [ ] Check if null / undefined values are checked before actions are performed on a variable (May not always be necessary)
|
14
|
-
- [ ] Check for performance (are there logic in loops that doesn't have to be executed each time? Could some tasks be added to a queue and performed later? etc)
|
15
|
-
|
16
|
-
## Advanced (optional if the ticket is low / medium impact) checks
|
17
|
-
- [ ] Check if the code is following SOLID principle, code maintainability
|
18
|
-
- [ ] Check if none functional requirements are needed (for example, should an audit log be stored for an action performed)
|
19
|
-
- [ ] Check the performance and efficiency of the tests
|
20
|
-
- [ ] Check to avoid the use of operations that only work in javascript (e.g. using && to return the object on the right if the statement on the left is true)
|
21
|
-
|
22
|
-
|
package/pull_request_template.md
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
## What?
|
2
|
-
## Why?
|
3
|
-
## How?
|
4
|
-
## Testing?
|
5
|
-
## Screenshots (optional)
|
6
|
-
## Anything Else? (optional)
|
7
|
-
## Check list
|
8
|
-
|
9
|
-
- [ ] I have reviewed my own pull request for linting issues (e.g. adding new lines)
|
10
|
-
- [ ] I have written tests (if relevant)
|
11
|
-
- [ ] I have created a JIRA number for my branch
|
12
|
-
- [ ] I have created a JIRA number for my commit
|
13
|
-
- [ ] I have followed the chris beams method for my commit https://cbea.ms/git-commit/
|
14
|
-
here is an [example commit](https://github.com/UKHomeOfficeForms/hof/commit/810959f391187c7c4af6db262bcd143b50093a6e)
|
15
|
-
- [ ] Ensure workflow jobs are passing especially tests
|
16
|
-
- [ ] I will squash the commits before merging
|