This package offers shared functionality across the three websites that make GovWifi.
govwifi-shared-frontend
is used by:
npm install govwifi-shared-frontend
;- include the file
dist/govwifi-shared-frontend.js
: it will install itself inwindow.GovWifi
; - Add a page load event listener and plug the API described below.
Cookies functions are scoped to GovWifi.cookies
.
Checks whether cookie policy is defined and prompts the user with a
dialog to define it if not. The dialog will prepend a
div#cookie-banner
node to the document's body.
Indicate whether the user has agreed to that category of cookies. The
only category at the moment is analytics
(and essential
, but that
will always return true).
Amend the cookie policy to allow or disable the given
categoryName
. If categoryName
is not recognised do nothing.
-
Create a branch from the main branch and make any necessary code or library updates.
-
Update the “version” in
package.json
. Additional features or major code changes trigger a major version bump. Dependabot updates are minor release changes. For more information review semantic versioning docs. -
If you’ve updated any libraries run
npm install
.This will update the
package-lock.json
file which also must be committed. -
Raise a PR. Once approved, merge the PR into the main branch.
The release package must be uploaded to GitHub as part of the release process so it can be downloaded by the repos which use govwifi-shared-frontend
.
-
Run the following from the root project directory:
$ npx webpack build --config ./webpack.config.js --stats verbose
This creates a “distribution” folder or
dist
. Thedist
contents are configured via webpack in thewebpack.config.js
file. -
Use
npm
to generate a compressed distribution package of the JS code which we will upload to GitHub:$ npm pack
This will create a
.tgz
file at the directory’s root with a naming structure like this:{name}-{release-version}.tgz
.
Navigate to the govwifi-shared-frontend
"Releases" page.
Click "Draft new release", then follow the release version process:
- Under "Choose tag", create a new tag for the release or use an existing tag if it's appropriate.
- Use the release version number for the "Release title"
- Add a useful description of the changes in the release, including links to Dependabot PRs if applicable.
- Click on "Attach binaries by dropping them here or selecting them."
- Attach the
govwifi-shared-frontend-{release-version}.tgz
file created earlier.
Once the new version of the project has been released in GitHub, we need to update the package.json
files in the GovWifi repos which use govwifi-shared-frontend
.
govwifi-admin
govwifi-product-page
govwifi-tech-docs
For each of these projects, complete the following steps:
- Create a new branch
update-govwifi-shared-frontend
from the main branch. - In the repo's
package.json
, update the "govwifi-shared-frontend" dependency to point to the new release version:Use the link address of the"dependencies": { ... "govwifi-shared-frontend": "https://github.com/alphagov/govwifi-shared-frontend/releases/download/v{release-version}/govwifi-shared-frontend-{release-version}.tgz" },
.tgz
file found in the "Assets" section of thegovwifi-shared-frontend
"Releases" page. - Run
npm install
to pull in the new release. - Test the app locally to see if the update has caused any breaking changes.
- Commit the changes (this should just be
package.json
andpackage-lock.json
) and raise a PR. - Once the PR is merged follow the stated deployment process for the repo.
- add webpack to streamline distribution
- add tests