feat(app): show app version on welcome screen
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import Constants from "expo-constants";
|
||||
import appPackage from "../../package.json";
|
||||
|
||||
function toVersionOrNull(value: unknown): string | null {
|
||||
if (typeof value !== "string") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const trimmed = value.trim();
|
||||
if (trimmed.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
export function resolveAppVersion(): string | null {
|
||||
const packageVersion = toVersionOrNull(appPackage?.version);
|
||||
if (packageVersion) {
|
||||
return packageVersion;
|
||||
}
|
||||
|
||||
const expoVersion = toVersionOrNull(Constants.expoConfig?.version);
|
||||
if (expoVersion) {
|
||||
return expoVersion;
|
||||
}
|
||||
|
||||
const manifestVersion = toVersionOrNull((Constants as any).manifest?.version);
|
||||
if (manifestVersion) {
|
||||
return manifestVersion;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user