Skip to content

Commit

Permalink
feat: build info
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Sep 24, 2023
1 parent 36f5bb4 commit 328aad4
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 13 deletions.
4 changes: 2 additions & 2 deletions components/admin/home/events-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ const { data: events } = useEvents()
{{ event.name }}
</td>
<td class="label-cell">
{{ dayjs(event.startDateTime).format('DD-MM-YYYY hh:mm') }}
{{ dayjs(event.startDateTime).format('DD-MM-YYYY HH:mm') }}
</td>
<td class="label-cell">
{{ dayjs(event.endDateTime).format('DD-MM-YYYY hh:mm') }}
{{ dayjs(event.endDateTime).format('DD-MM-YYYY HH:mm') }}
</td>
<td class="numeric-cell">
{{ event.attendees.length }}
Expand Down
2 changes: 1 addition & 1 deletion components/app/home/news.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const { data: news, isLoading: newsIsLoading } = useNewsArticles()
<f7Card v-for="article in news" :key="article.id" class="m-0!">
<f7CardHeader class="h-45 rounded-[16px]! overflow-hidden bg-center bg-contain relative" valign="bottom" :style="`background-image: url(${article.heroImageUrl})`">
<div class="absolute inset-0 bg-gradient-to-b from-transparent dark:to-black/70 to-white/70" />
<span class="z-10">
<span class="z-10 font-semibold">
{{ article.title }}
</span>
</f7CardHeader>
Expand Down
14 changes: 14 additions & 0 deletions components/app/profile/page.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<script setup lang="ts">
import { f7BlockTitle, f7Link, f7List, f7ListButton, f7ListInput, f7ListItem, f7NavRight, f7NavTitle, f7NavTitleLarge, f7Navbar, f7Page, f7Popup, f7View } from 'framework7-vue'
import dayjs from 'dayjs'
import { devDependencies } from '~/package.json'
const appConfig = useAppConfig()
const { data: user } = useUser()
const graduationYear = computed(() => {
return `Class of ${user.value?.graduationYear}`
Expand Down Expand Up @@ -49,6 +52,17 @@ const { mutate: userSignOutMutate } = useUserSignOutMutation()
</f7ListButton>
</f7List>

<f7List>
<f7ListItem class="opacity-80 text-sm">
v{{ appConfig.buildInfo.version }}
<br>
<br>
Built on {{ dayjs(appConfig.buildInfo.time).format('DD/MM/YYYY HH:mm') }}
<br>
Commit: {{ appConfig.buildInfo.shortCommit }}
</f7ListItem>
</f7List>

<f7Popup id="acknowledgements" push>
<f7View>
<f7Page>
Expand Down
26 changes: 26 additions & 0 deletions modules/build-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Git from 'simple-git'
import { defineNuxtModule } from '@nuxt/kit'
import { version } from '../package.json'
import type { BuildInfo } from '~/shared/types'

export default defineNuxtModule({
meta: {
name: 'web:build-env',
},
async setup(_options, nuxt) {
const git = Git()

const commit = await git.revparse(['HEAD'])
const shortCommit = await git.revparse(['--short=7', 'HEAD'])

const buildInfo: BuildInfo = {
version,
time: +Date.now(),
commit,
shortCommit,
}

nuxt.options.appConfig = nuxt.options.appConfig || {}
nuxt.options.appConfig.buildInfo = buildInfo
},
})
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default defineNuxtConfig({
'@unocss/nuxt',
'@vite-pwa/nuxt',
'@vueuse/nuxt',
'~/modules/build-info',
],

routeRules: {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "nuxt-app",
"type": "module",
"private": true,
"version": "0.0.1-alpha.1",
"license": "MIT",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
Expand Down Expand Up @@ -38,6 +39,7 @@
"material-icons": "^1.13.11",
"nuxt": "^3.7.3",
"nuxt-vuefire": "^0.3.0",
"simple-git": "^3.20.0",
"vuefire": "^3.1.17",
"web-auth-library": "^1.0.3",
"zod": "^3.22.2"
Expand Down
21 changes: 12 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@ export type Event = InferSelectModel<typeof events>
export type EventWithAttendees = Event & { attendees: UserRestrictedWithAdmissionKey[] }

export type NewsArticle = InferSelectModel<typeof news>

export interface BuildInfo {
version: string
commit: string
shortCommit: string
time: number
}

declare module '@nuxt/schema' {
interface NuxtAppConfig {
buildInfo: BuildInfo
}
}

0 comments on commit 328aad4

Please # to comment.