Giter Site home page Giter Site logo

stevenjmesser / fe-detection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nooshu/fe-detection

0.0 0.0 0.0 359 KB

Simple bash script to try to find what version of GOV.UK Frontend is being used on a service

License: MIT License

Shell 0.32% CSS 99.68%

fe-detection's Introduction

GOV.UK Frontend Detection

Bash script to try to find what version of GOV.UK Frontend is being used on a service. Point the script at a services CSS file to guess the version used.

Example command:

./bin/fe-test.sh -u https://raw.githubusercontent.com/alphagov/govuk-frontend/v4.3.0/dist/govuk-frontend-4.3.0.min.css

Use on a live services

Running the following command:

./bin/fe-test.sh -u https://create-energy-label.service.gov.uk/assets/static/css/main.css

Gives the following output:

✓ 1.0.0 present
✓ 1.1.0 present
✓ 1.2.0 present
✓ 1.3.0 present
✓ 2.0.0 present
✓ 2.1.0 present
✓ 2.2.0 present
✓ 2.5.0 present
✓ 2.6.0 present
✓ 2.7.0 present
✓ 2.9.0 present
✓ 2.10.0 present
✓ 2.11.0 present
✓ 3.0.0 present
✓ 3.1.0 present
✓ 3.3.0 present
✓ 3.6.0 present
✓ 3.7.0 present
✓ 3.8.0 present
✓ 3.9.0 present
✓ 3.10.0 present
✓ 3.11.0 present

So version 3.11.0 of GOV.UK Frontend is most likely being used on this service.

Use on a CSS file

Some services restrict the downloading of assets via curl, so you can download via the browser then pass them into the script using the -f flag:

./bin/fe-test.sh -f css-filename.css

Methodology

The 'dist` version of the CSS it taken and differences between versions are identified, then used to pin down a particular version of GOV.UK Frontend being used. Use the following command to do this:

curl -s https://raw.githubusercontent.com/alphagov/govuk-frontend/v4.3.0/dist/govuk-frontend-4.3.0.min.css | cssbeautify-cli -s > ./css/govuk-frontend-4.3.0.css

Generating diffs

For future reference it is possible to generate file diffs using git with the following command:

./generate-diffs.sh

Caveats

This is always going to be an approximate version test. If all services were using the dist version of the CSS it would be easy. But as service teams can pick / choose certain components to include in their build process. So at some point they may not include CSS that is being used to pin down a particular version.

Testing

Tests written using Bats: Bash Automated Testing System. Run using the bats fe-test.bats command.

Depends on:

To add a new version of GOV.UK Frontend

# Download and beautify the css
# e.g. curl -s https://raw.githubusercontent.com/alphagov/govuk-frontend/v4.3.0/dist/govuk-frontend-4.3.0.min.css | cssbeautify-cli -s > ./css/govuk-frontend-4.3.0.css
curl -s https://raw.githubusercontent.com/alphagov/govuk-frontend/v[VERSION]/dist/govuk-frontend-[VERSION].min.css | cssbeautify-cli -s > ./css/govuk-frontend-[VERSION].css

# generate the new diffs
./generate-diffs.sh

# Examine the new version diff looking for a unique change for this version
# Add version + unique change to `fe-test.sh`
# Add new test to `fe-test.bats` and run test
bats ./bin/fe-test.bats

fe-detection's People

Contributors

nooshu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.