enhancements for footer version with prod support

This commit is contained in:
keyan 2023-06-01 12:57:31 -05:00
parent 4c1f0af41b
commit 3de8df5ab5
5 changed files with 19 additions and 18 deletions

View File

@ -43,9 +43,6 @@ LND_CONNECT_ADDRESS=03cc1d0932bb99b0697f5b5e5961b83ab7fd66f1efc4c9f5c7bad66c1bcb
NEXTAUTH_SECRET=3_0W_PhDRZVanbeJsZZGIEljexkKoGbL6qGIqSwTjjI
JWT_SIGNING_PRIVATE_KEY={"kty":"oct","kid":"FvD__hmeKoKHu2fKjUrWbRKfhjimIM4IKshyrJG4KSM","alg":"HS512","k":"3_0W_PhDRZVanbeJsZZGIEljexkKoGbL6qGIqSwTjjI"}
# git version
NEXT_PUBLIC_COMMIT_HASH=0de1343
# prisma db url
DATABASE_URL="postgresql://sn:password@db:5432/stackernews?schema=public"

View File

@ -320,7 +320,10 @@ export default function Footer ({ noLinks }) {
</Link>
</span>
</small>
<div className="version">version <a href={`https://github.com/stackernews/stacker.news/commit/${version}`}>{version}</a></div>
{version &&
<div className={styles.version}>
running <a className='text-reset' href={`https://github.com/stackernews/stacker.news/commit/${version}`}>{version}</a>
</div>}
</Container>
</footer>
)

View File

@ -19,3 +19,10 @@
.contrastLink svg {
fill: var(--theme-color);
}
.version {
margin: auto;
font-size: 75%;
margin-top: .15rem;
color: var(--theme-grey) !important;
}

View File

@ -13,24 +13,24 @@ const corsHeaders = [
}
]
const commitHash = isProd
? require('fs').readFileSync('version.txt', 'utf8').slice(0, 7)
: require('child_process').execSync('git rev-parse HEAD').toString().slice(0, 7)
module.exports = withPWA({
dest: 'public',
register: true,
customWorkerDir: 'sw'
})(
withPlausibleProxy()({
env: {
NEXT_PUBLIC_COMMIT_HASH: commitHash
},
compress: false,
experimental: {
scrollRestoration: true
},
generateBuildId: process.env.NODE_ENV === 'development'
? undefined
: async () => {
// use the app version which eb doesn't otherwise give us
// as the build id
const { RuntimeSources } = require('/opt/elasticbeanstalk/deployment/app_version_manifest.json') // eslint-disable-line
return Object.keys(RuntimeSources['stacker.news'])[0]
},
generateBuildId: isProd ? commitHash : undefined,
// Use the CDN in production and localhost for development.
assetPrefix: isProd ? 'https://a.stacker.news' : undefined,
async headers () {

View File

@ -631,9 +631,3 @@ div[contenteditable]:focus,
color: #212529;
}
}
.version {
margin: auto;
font-size: x-small;
color: var(--theme-grey) !important;
}