From 1811d1c7ff3415f5783d8b73de2ac2c21c3d7b76 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sat, 6 Jun 2020 09:36:38 -0700 Subject: [PATCH] Add current build id to footer --- .travis.yml | 3 +-- modules/client/browse/App.js | 9 ++++++++- modules/client/browse/FolderViewer.js | 2 +- modules/client/main/App.js | 21 ++++++++++++++------- rollup.config.js | 10 ++++++++++ 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 45ecd29..1cad51a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,7 @@ before_install: script: - yarn lint - yarn test -- NODE_ENV=$([ "$TRAVIS_BRANCH" == "master" ] && echo "production" || echo "staging") - yarn build +- NODE_ENV=$([ "$TRAVIS_BRANCH" == "master" ] && echo "production" || echo "staging") BUILD_ID=${TRAVIS_COMMIT:0:8} yarn build deploy: - provider: gae skip_cleanup: true diff --git a/modules/client/browse/App.js b/modules/client/browse/App.js index dcf8173..7305200 100644 --- a/modules/client/browse/App.js +++ b/modules/client/browse/App.js @@ -11,6 +11,8 @@ import { TwitterIcon, GitHubIcon } from './Icons.js'; import SelectDownArrow from './images/SelectDownArrow.png'; +const buildId = process.env.BUILD_ID; + const globalStyles = css` html { box-sizing: border-box; @@ -382,7 +384,12 @@ export default function App({ justifyContent: 'space-between' }} > -

© {new Date().getFullYear()} UNPKG

+

+ Build: {buildId} +

+

+ © {new Date().getFullYear()} UNPKG +

@@ -97,15 +99,15 @@ function Stats({ data }) { } export default function App() { - const [stats, setStats] = useState( + let [stats, setStats] = useState( typeof window === 'object' && window.localStorage && window.localStorage.savedStats ? JSON.parse(window.localStorage.savedStats) : null ); - const hasStats = !!(stats && !stats.error); - const stringStats = JSON.stringify(stats); + let hasStats = !!(stats && !stats.error); + let stringStats = JSON.stringify(stats); useEffect(() => { window.localStorage.savedStats = stringStats; @@ -414,7 +416,12 @@ export default function App() { justifyContent: 'space-between' }} > -

© {new Date().getFullYear()} UNPKG

+

+ Build: {buildId} +

+

+ © {new Date().getFullYear()} UNPKG +

{ @@ -48,6 +56,7 @@ const client = ['browse', 'main'].map(entryName => { } }), replace({ + 'process.env.BUILD_ID': JSON.stringify(buildId), 'process.env.NODE_ENV': JSON.stringify( process.env.NODE_ENV || 'development' ) @@ -85,6 +94,7 @@ const server = { emitFiles: false }), replace({ + 'process.env.BUILD_ID': JSON.stringify(buildId), 'process.env.CLOUDFLARE_EMAIL': JSON.stringify( process.env.CLOUDFLARE_EMAIL ),