-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from PublicHealthEngland/development
Essential updates and improvements No conflict detected.
- Loading branch information
Showing
43 changed files
with
1,008 additions
and
5,477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
REACT_APP_BASE_URL=http://localhost:3000 | ||
REACT_APP_MAIN_CDN=c19pubdev.azureedge.net | ||
REACT_APP_DOWNLOADS_CDN=c19downloadsdev.azureedge.net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Build and deploy Node.js app to Azure Web App - Covid19StaticSTAGING | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: Set up Node.js version | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.13.0' | ||
|
||
- name: Install dependencies | ||
run: | | ||
npm install -g yarn | ||
npm install | ||
yarn install | ||
# NOTE: Do NOT use trailing slashes in the URLs. | ||
# ATTENTION: `BASE_URL` must have the HTTP(S) protocol, but other URLs must not. | ||
- name: Build yarn | ||
env: | ||
CI: false | ||
BUILD_ENV: staging | ||
BASE_URL: https://Covid19StaticStaging.azureedge.net | ||
MAIN_CDN: c19pub.azureedgestaging.net | ||
DOWNLOADS_CDN: c19downloadsstaging.azureedge.net | ||
NODE_ENV: production | ||
|
||
run: | | ||
yarn run build | ||
- name: 'Deploy to Azure Web App' | ||
uses: azure/webapps-deploy@v1 | ||
with: | ||
app-name: 'Covid19StaticSTAGING' | ||
slot-name: 'production' | ||
publish-profile: ${{ secrets.AzureAppServiceStaging }} | ||
package: ./build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
"use strict"; | ||
|
||
const | ||
fs = require("fs"), | ||
path = require("path"), | ||
replaceStream = require("replacestream"); | ||
|
||
|
||
/** | ||
* Default variables. | ||
* | ||
* .. note:: The behaviour of this function depends on two environment variables: | ||
* Either the `BUILD_ENV` should be set to one of `development`, `staging` | ||
* or `production`; or `NODE_ENV` must be set to `production`. | ||
* | ||
* .. note:: Do **NOT** use trailing slashes in the URL. | ||
* | ||
* .. attention:: `BASE_URL` must have the HTTP(S) protocol, but other URLs must not. | ||
* | ||
* @returns { {}|{DOWNLOADS_CDN: string, BASE_URL: string, MAIN_CDN: string} } | ||
*/ | ||
const extractEnvVars = () => { | ||
|
||
const prod = { | ||
BASE_URL: "https://coronavirus.data.gov.uk", | ||
MAIN_CDN: "c19pub.azureedge.net", | ||
DOWNLOADS_CDN: "c19downloads.azureedge.net" | ||
}; | ||
|
||
if ( process.env.NODE_ENV === "production" && !process.env.hasOwnProperty("BUILD_ENV")) | ||
return prod; | ||
|
||
|
||
switch (process.env.BUILD_ENV) { | ||
case "development": | ||
return { | ||
BASE_URL: "https://covid19statdev.azureedge.net", | ||
MAIN_CDN: "c19pub.azureedgedev.net", | ||
DOWNLOADS_CDN: "c19downloadsdev.azureedge.net" | ||
} | ||
|
||
case "staging": | ||
return { | ||
BASE_URL: "https://Covid19StaticStaging.azureedge.net", | ||
MAIN_CDN: "c19pub.azureedgestaging.net", | ||
DOWNLOADS_CDN: "c19downloadsstaging.azureedge.net" | ||
} | ||
|
||
case "production": | ||
return prod | ||
|
||
default: | ||
return {} | ||
|
||
} | ||
|
||
}; // extractEnvVars | ||
|
||
|
||
/** | ||
* Extracts ".js" and ".html" files in `directory` and its subdirectories | ||
* and returns an array of absolute paths. | ||
* | ||
* @param directory { string } | ||
* @returns { string[] } | ||
*/ | ||
const getFiles = (directory) => { | ||
|
||
return fs | ||
.readdirSync(directory, { withFileTypes: true }) | ||
.reduce((acc, item) => [ | ||
...acc, | ||
...item.isDirectory() | ||
? getFiles(path.join(directory, item.name)) | ||
: [ path.join(directory, item.name) ] | ||
], []) | ||
.filter(file => /\.(js|html)$/i.exec(file)) | ||
|
||
}; // getFiles | ||
|
||
|
||
/** | ||
* Replaces placeholders formatted as `%key%` with environment | ||
* variables defined using the same key. | ||
* | ||
* @returns { Promise<void> } | ||
*/ | ||
const main = async () => { | ||
|
||
const | ||
directory = path.join(__dirname, "..", "build"), | ||
files = getFiles(directory), | ||
Replacements = { | ||
...extractEnvVars(), | ||
...process.env | ||
}; | ||
|
||
for ( const file of files ) { | ||
|
||
const tmpFile = `${ file }.tmp`; | ||
|
||
await new Promise((resolve, reject) => { | ||
const stream = Object | ||
.keys(Replacements) | ||
.reduce((stream, key) => | ||
stream | ||
.pipe(replaceStream(`%${ key }%`, Replacements[key])) | ||
.pipe(replaceStream(`%REACT_APP_${ key }%`, Replacements[key])), | ||
fs.createReadStream(file) | ||
) | ||
.pipe(fs.createWriteStream(tmpFile)); | ||
|
||
stream.on("finish", resolve); | ||
stream.on("error", reject); | ||
}); | ||
|
||
fs.unlinkSync(file); | ||
fs.copyFileSync(tmpFile, file); | ||
fs.unlinkSync(tmpFile); | ||
|
||
} | ||
|
||
}; // main | ||
|
||
|
||
main().catch(err => { | ||
console.error(err); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from "react"; | ||
|
||
|
||
export const ArrowUp = () => { | ||
|
||
return <svg role={ "presentation" } | ||
focusable={ "false" } | ||
className={ "back-to-top" } | ||
xmlns={ "http://www.w3.org/2000/svg" } | ||
width={ "13" } | ||
height={ "17" } | ||
viewBox={ "0 0 13 17" }> | ||
<path fill={ "currentColor" } | ||
d={ "M6.5 0L0 6.5 1.4 8l4-4v12.7h2V4l4.3 4L13 6.4z" }/> | ||
</svg> | ||
|
||
}; // ArrowUp | ||
|
||
|
||
export const CaretUp = () => { | ||
|
||
return <svg height={ "12" } | ||
viewBox={ "0 0 1200 1200" } | ||
width={ "20" } | ||
xmlns={ "http://www.w3.org/2000/svg" }> | ||
<path d={ `m1036.571442,526.857147q0,26 -19,45t-45,19l-896,0q-26,0 -45,-19t-19, | ||
-45t19,-45l448,-448q19,-19 45,-19t45,19l448,448q19,19 19,45z` }/> | ||
</svg> | ||
|
||
}; // CaretUp | ||
|
||
|
||
export const CaretDown = () => { | ||
|
||
return <svg width={ "20" } | ||
height={ "12" } | ||
viewBox={ "0 0 1200 1200" } | ||
xmlns={ "http://www.w3.org/2000/svg" }> | ||
<path d={ `m1038.43512,83.653076q0,26 -19,45l-448,448q-19,19 -45,19t-45,-19l-448, | ||
-448q-19,-19 -19,-45t19,-45t45,-19l896,0q26,0 45,19t19,45z` }/> | ||
</svg> | ||
|
||
}; // CaretDown | ||
|
||
|
||
export const CaretUpDown = () => { | ||
|
||
return <svg height={ "20" } | ||
width={ "24" } | ||
viewBox={ "0 0 25 36" } | ||
xmlns="http://www.w3.org/2000/svg"> | ||
<path d={ `m25.105327,18.861907q0,0.477077 -0.348634,0.825711l-8.220412, | ||
8.220412q-0.348634,0.348634 -0.825711,0.348634t-0.825711,-0.348634l-8.220412, | ||
-8.220412q-0.348634,-0.348634 -0.348634,-0.825711t0.348634,-0.825711t0.825711, | ||
-0.348634l16.440824,0q0.477077,0 0.825711,0.348634t0.348634,0.825711zm0, | ||
-7.046067q0,0.477077 -0.348634,0.825711t-0.825711,0.348634l-16.440824,0q-0.477077, | ||
0 -0.825711,-0.348634t-0.348634,-0.825711t0.348634,-0.825711l8.220412, | ||
-8.220412q0.348634,-0.348634 0.825711,-0.348634t0.825711,0.348634l8.220412, | ||
8.220412q0.348634,0.348634 0.348634,0.825711z` }/> | ||
</svg> | ||
|
||
}; // Unsorted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Icons" |
Oops, something went wrong.