Skip to content

Commit

Permalink
Use latest commit hash instead of package.json version
Browse files Browse the repository at this point in the history
  • Loading branch information
annavik committed Jan 31, 2024
1 parent c5a322a commit bc2bae1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
1 change: 0 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"react-router-dom": "^6.8.2",
"typescript": "^4.4.2",
"vite": "^4.5.0",
"vite-plugin-package-version": "^1.1.0",
"vite-tsconfig-paths": "^4.2.1"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/header/beta-info/beta-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styles from './beta-info.module.scss'
const COPY = {
LABEL: 'Beta',
INFO: 'More info about beta status goes here?',
VERSION: import.meta.env.PACKAGE_VERSION, // Read version from package.json
VERSION: `Build ${__COMMIT_HASH__}`,
}

export const BetaInfo = () => {
Expand All @@ -13,7 +13,7 @@ export const BetaInfo = () => {
<Tooltip content={COPY.INFO}>
<div className={styles.badge}>{COPY.LABEL}</div>
</Tooltip>
<span className={styles.version}>Version {COPY.VERSION}</span>
<span className={styles.version}>{COPY.VERSION}</span>
</div>
)
}
2 changes: 1 addition & 1 deletion ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"baseUrl": "src",
"types": ["vite/client", "vite-plugin-svgr/client"]
},
"include": ["src"]
"include": ["src", "vite-env.d.ts"]
}
2 changes: 2 additions & 0 deletions ui/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/// <reference types="vite/client" />

declare const __COMMIT_HASH__: string
10 changes: 8 additions & 2 deletions ui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import react from '@vitejs/plugin-react'
import childProcees from 'child_process'
import { defineConfig } from 'vite'
import eslint from 'vite-plugin-eslint'
import version from 'vite-plugin-package-version'
import svgr from 'vite-plugin-svgr'
import viteTsconfigPaths from 'vite-tsconfig-paths'

const commitHash = childProcees
.execSync('git rev-parse --short HEAD')
.toString()

export default defineConfig({
base: '/',
build: {
Expand All @@ -15,8 +19,10 @@ export default defineConfig({
viteTsconfigPaths(),
svgr({ include: '**/*.svg?react' }),
eslint({ exclude: ['/virtual:/**', 'node_modules/**'] }),
version(),
],
define: {
__COMMIT_HASH__: JSON.stringify(commitHash),
},
server: {
open: true,
port: 3000,
Expand Down
10 changes: 0 additions & 10 deletions ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6583,7 +6583,6 @@ __metadata:
typescript: "npm:^4.4.2"
vite: "npm:^4.5.0"
vite-plugin-eslint: "npm:^1.8.1"
vite-plugin-package-version: "npm:^1.1.0"
vite-plugin-svgr: "npm:^4.1.0"
vite-tsconfig-paths: "npm:^4.2.1"
languageName: unknown
Expand Down Expand Up @@ -15895,15 +15894,6 @@ __metadata:
languageName: node
linkType: hard

"vite-plugin-package-version@npm:^1.1.0":
version: 1.1.0
resolution: "vite-plugin-package-version@npm:1.1.0"
peerDependencies:
vite: ">=2.0.0-beta.69"
checksum: fb646bcc666746579cdb96dd81bc91c989f99176071d43b66588ed554f3d3c492b10a3b27ef715a2d6a5a2a52d2f776dd7365ccc6034dc65f2c65208236af38a
languageName: node
linkType: hard

"vite-plugin-svgr@npm:^4.1.0":
version: 4.1.0
resolution: "vite-plugin-svgr@npm:4.1.0"
Expand Down

0 comments on commit bc2bae1

Please sign in to comment.