feat: add git commit hash
This commit is contained in:
		
							parent
							
								
									daaa819e6c
								
							
						
					
					
						commit
						1d4b121ea5
					
				
					 2 changed files with 9 additions and 2 deletions
				
			
		|  | @ -28,6 +28,7 @@ | |||
|     import FollowersIcon from '@cf/icons/followers.svg'; | ||||
| 
 | ||||
|     const VERSION = APP_VERSION; | ||||
|     const COMMIT = APP_COMMIT; | ||||
|     const lang = Lang(); | ||||
| 
 | ||||
|     const dispatch = createEventDispatcher(); | ||||
|  | @ -184,7 +185,7 @@ | |||
|     {/if} | ||||
| 
 | ||||
|     <span class="version"> | ||||
|         campfire v{VERSION} | ||||
|         campfire v{VERSION} ({COMMIT}) | ||||
|         <br> | ||||
|         <ul> | ||||
|             <li><a href="https://git.arimelody.me/blisstown/campfire">{lang.string('source')}</a></li> | ||||
|  |  | |||
|  | @ -3,11 +3,16 @@ import { defineConfig } from 'vite'; | |||
| import { readFileSync } from 'fs'; | ||||
| import { fileURLToPath } from 'url'; | ||||
| import svg from '@poppanator/sveltekit-svg' | ||||
| import { execSync } from 'child_process'; | ||||
| 
 | ||||
| // get ver from package.json
 | ||||
| const packageFile = fileURLToPath(new URL('package.json', import.meta.url)); | ||||
| const packageData = readFileSync(packageFile, 'utf8'); | ||||
| const packageJSON = JSON.parse(packageData); | ||||
| 
 | ||||
| // get git commit hash
 | ||||
| const commitHash = execSync("git rev-parse HEAD") | ||||
|     .toString().trim().slice(0, 10) | ||||
| 
 | ||||
| export default defineConfig({ | ||||
| 	plugins: [ | ||||
|  | @ -15,7 +20,8 @@ export default defineConfig({ | |||
|         svg() | ||||
|     ], | ||||
|     define: { | ||||
|         APP_VERSION: JSON.stringify(packageJSON.version) | ||||
|         APP_VERSION: JSON.stringify(packageJSON.version), | ||||
|         APP_COMMIT: `"${commitHash}"` | ||||
|     } | ||||
| }); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue