fix(types): add global declarations for build-time defines and fix eslint issues

This commit is contained in:
Gigi
2025-10-16 19:58:57 +02:00
parent a92b14e877
commit f6c562e9be
3 changed files with 18 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
/* global __APP_VERSION__, __GIT_COMMIT__, __GIT_COMMIT_URL__ */
import React, { useState, useEffect, useRef } from 'react' import React, { useState, useEffect, useRef } from 'react'
import { faTimes, faUndo } from '@fortawesome/free-solid-svg-icons' import { faTimes, faUndo } from '@fortawesome/free-solid-svg-icons'
import { RelayPool } from 'applesauce-relay' import { RelayPool } from 'applesauce-relay'

7
src/vite-env.d.ts vendored
View File

@@ -8,3 +8,10 @@ declare module '*.svg?raw' {
const content: string const content: string
export default content export default content
} }
// Build-time defines injected by Vite in vite.config.ts
declare const __APP_VERSION__: string
declare const __GIT_COMMIT__: string
declare const __GIT_BRANCH__: string
declare const __BUILD_TIME__: string
declare const __GIT_COMMIT_URL__: string

View File

@@ -1,3 +1,4 @@
/* eslint-env node */
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import { VitePWA } from 'vite-plugin-pwa' import { VitePWA } from 'vite-plugin-pwa'
@@ -11,10 +12,14 @@ function getGitMetadata() {
let branch = envRef let branch = envRef
try { try {
if (!commit) commit = execSync('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim() if (!commit) commit = execSync('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim()
} catch {} } catch {
// ignore
}
try { try {
if (!branch) branch = execSync('git rev-parse --abbrev-ref HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim() if (!branch) branch = execSync('git rev-parse --abbrev-ref HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim()
} catch {} } catch {
// ignore
}
return { commit, branch } return { commit, branch }
} }
@@ -49,7 +54,9 @@ function getCommitUrl(commit: string): string {
const cleaned = https.replace(/\.git$/, '') const cleaned = https.replace(/\.git$/, '')
return `${cleaned}/commit/${commit}` return `${cleaned}/commit/${commit}`
} }
} catch {} } catch {
// ignore
}
return '' return ''
} }