Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(mobile): show app version and commit metadata (#1489)

Corentin Thomassetff74b8020086
diff --git a/.changeset/beige-rings-feel.md b/.changeset/beige-rings-feel.md
new file mode 100644
index 00000000..ff42963f
--- /dev/null
+++ b/.changeset/beige-rings-feel.md
@@ -0,0 +1,5 @@
+---
+'@papra/mobile': patch
+---
+
+Added app version and commit short hash in the app settings screen.
diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts
index 0779e90c..2f7ade7a 100644
--- a/apps/mobile/app.config.ts
+++ b/apps/mobile/app.config.ts
@@ -1,6 +1,25 @@
import type { ExpoConfig } from 'expo/config';
+import { execFileSync } from 'node:child_process';
import { version } from './package.json';
+function getGitCommitSha() {
+ const commitSha = process.env.EAS_BUILD_GIT_COMMIT_HASH || process.env.GIT_COMMIT;
+
+ if (commitSha) {
+ return commitSha.trim();
+ }
+
+ try {
+ return execFileSync('git', ['rev-parse', 'HEAD'], {
+ cwd: __dirname,
+ encoding: 'utf8',
+ stdio: ['ignore', 'pipe', 'ignore'],
+ }).trim();
+ } catch {
+ return undefined;
+ }
+}
+
const isDevelopment = process.env.APP_VARIANT === 'development';
const profile = isDevelopment
@@ -91,6 +110,7 @@ const config: ExpoConfig = {
reactCompiler: true,
},
extra: {
+ gitCommitSha: getGitCommitSha(),
router: {},
eas: {
projectId: '8d127afd-9d57-415b-a108-3e7b85439cfd',
diff --git a/apps/mobile/src/modules/app-settings/screens/app-settings.screen.tsx b/apps/mobile/src/modules/app-settings/screens/app-settings.screen.tsx
index 102ee8f8..533a3602 100644
--- a/apps/mobile/src/modules/app-settings/screens/app-settings.screen.tsx
+++ b/apps/mobile/src/modules/app-settings/screens/app-settings.screen.tsx
@@ -11,6 +11,7 @@ import {
View,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
+import { APP_COMMIT_SHA, APP_VERSION } from '@/modules/app/app.constants';
import { useAppTranslations } from '@/modules/i18n/hooks/use-app-translations';
import { useLocale } from '@/modules/i18n/hooks/use-locale';
import { LOCALE_KEYS, locales } from '@/modules/i18n/locales';
@@ -119,6 +120,26 @@ export function AppSettingsScreen() {
);
})}
</View>
+
+ <View style={styles.about}>
+ <Text style={styles.sectionTitle} accessibilityRole="header">
+ {t.appSettings.about.title}
+ </Text>
+ <View style={styles.infoRow}>
+ <Text style={styles.infoLabel}>{t.appSettings.about.version}</Text>
+ <Text style={styles.infoValue} selectable>
+ {APP_VERSION ?? t.appSettings.about.unknown}
+ </Text>
+ </View>
+ {APP_COMMIT_SHA && (
+ <View style={styles.infoRow}>
+ <Text style={styles.infoLabel}>{t.appSettings.about.commit}</Text>
+ <Text style={styles.infoValue} selectable>
+ {APP_COMMIT_SHA.slice(0, 7)}
+ </Text>
+ </View>
+ )}
+ </View>
</ScrollView>
</SafeAreaView>
);
@@ -172,6 +193,27 @@ function createStyles({ themeColors }: { themeColors: ThemeColors }) {
color: themeColors.mutedForeground,
marginBottom: 20,
},
+ about: {
+ marginTop: 32,
+ gap: 12,
+ },
+ infoRow: {
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ gap: 16,
+ },
+ infoLabel: {
+ flexShrink: 1,
+ fontSize: 14,
+ color: themeColors.mutedForeground,
+ },
+ infoValue: {
+ flexShrink: 1,
+ textAlign: 'right',
+ fontSize: 14,
+ color: themeColors.foreground,
+ },
languageOptions: {
gap: 8,
},
diff --git a/apps/mobile/src/modules/app/app.constants.ts b/apps/mobile/src/modules/app/app.constants.ts
index 1f2f4efe..2378afd4 100644
--- a/apps/mobile/src/modules/app/app.constants.ts
+++ b/apps/mobile/src/modules/app/app.constants.ts
@@ -1,3 +1,7 @@
import Constants from 'expo-constants';
export const APP_SCHEME = String(Constants.expoConfig?.scheme ?? 'papra');
+export const APP_VERSION = Constants.expoConfig?.version;
+
+const gitCommitSha: unknown = Constants.expoConfig?.extra?.gitCommitSha;
+export const APP_COMMIT_SHA = typeof gitCommitSha === 'string' ? gitCommitSha : undefined;
diff --git a/apps/mobile/src/modules/i18n/translations/de.ts b/apps/mobile/src/modules/i18n/translations/de.ts
index 616e3b56..4110a36a 100644
--- a/apps/mobile/src/modules/i18n/translations/de.ts
+++ b/apps/mobile/src/modules/i18n/translations/de.ts
@@ -212,6 +212,12 @@ export const de = {
},
appSettings: {
title: 'App-Einstellungen',
+ about: {
+ title: 'Über die App',
+ version: 'Version',
+ commit: 'Commit',
+ unknown: 'Unbekannt',
+ },
language: {
title: 'Sprache',
description: 'Wählen Sie die Sprache, die die App auf diesem Gerät verwendet.',
diff --git a/apps/mobile/src/modules/i18n/translations/en.ts b/apps/mobile/src/modules/i18n/translations/en.ts
index a652f2f1..9b181791 100644
--- a/apps/mobile/src/modules/i18n/translations/en.ts
+++ b/apps/mobile/src/modules/i18n/translations/en.ts
@@ -205,6 +205,12 @@ export const en = {
},
appSettings: {
title: 'App settings',
+ about: {
+ title: 'About',
+ version: 'Version',
+ commit: 'Commit',
+ unknown: 'Unknown',
+ },
language: {
title: 'Language',
description: 'Choose the language used by the app on this device.',
diff --git a/apps/mobile/src/modules/i18n/translations/es.ts b/apps/mobile/src/modules/i18n/translations/es.ts
index 362d006a..19d6e1ae 100644
--- a/apps/mobile/src/modules/i18n/translations/es.ts
+++ b/apps/mobile/src/modules/i18n/translations/es.ts
@@ -209,6 +209,12 @@ export const es = {
},
appSettings: {
title: 'Ajustes de la aplicación',
+ about: {
+ title: 'Acerca de',
+ version: 'Versión',
+ commit: 'Commit',
+ unknown: 'Desconocida',
+ },
language: {
title: 'Idioma',
description: 'Elige el idioma de la aplicación en este dispositivo.',
diff --git a/apps/mobile/src/modules/i18n/translations/fr.ts b/apps/mobile/src/modules/i18n/translations/fr.ts
index d23f2596..263e40cb 100644
--- a/apps/mobile/src/modules/i18n/translations/fr.ts
+++ b/apps/mobile/src/modules/i18n/translations/fr.ts
@@ -210,6 +210,12 @@ export const fr = {
},
appSettings: {
title: "Paramètres de l'application",
+ about: {
+ title: 'À propos',
+ version: 'Version',
+ commit: 'Commit',
+ unknown: 'Inconnue',
+ },
language: {
title: 'Langue',
description: "Choisissez la langue utilisée par l'application sur cet appareil.",