From 22c594eb7958d028f5f8a6347b8d68ac0c19bce7 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 10 May 2022 20:57:09 -0700 Subject: [PATCH] Print out build info in console (#179) * Print out build info in console * Fix up build info printing per feedback --- web/pages/_app.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/web/pages/_app.tsx b/web/pages/_app.tsx index 242387be..3504df74 100644 --- a/web/pages/_app.tsx +++ b/web/pages/_app.tsx @@ -1,12 +1,28 @@ import 'tailwindcss/tailwind.css' import type { AppProps } from 'next/app' +import { useEffect } from 'react' import Head from 'next/head' import Script from 'next/script' import { usePreserveScroll } from 'web/hooks/use-preserve-scroll' +function printBuildInfo() { + // These are undefined if e.g. dev server + if (process.env.NEXT_PUBLIC_VERCEL_ENV) { + let env = process.env.NEXT_PUBLIC_VERCEL_ENV + let msg = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_MESSAGE + let owner = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER + let repo = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG + let sha = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + let url = `https://github.com/${owner}/${repo}/commit/${sha}` + console.info(`Build: ${env} / ${msg || '???'} / ${url}`) + } +} + function MyApp({ Component, pageProps }: AppProps) { usePreserveScroll() + useEffect(printBuildInfo) + return ( <>