okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
31030b170
main
1/** 2* The app's version, from one place. The desktop shell reports its own (apps/desktop/src-tauri/Cargo.toml, which Tauri also uses for 3* the installer and file names) in STRATA_APP_VERSION. Outside the app, in a source checkout, the same file is read; otherwise 'dev'. 4*/ 5import { readFileSync } from 'node:fs' ; 6import { join } from 'node:path' ; 7 8const VERSION = / ^\d + \.\d + \.\d + (?:[ -+ ][ 0 - 9A - Za - z.+- ] + ) ? $ / ; 9 10export function appVersionFrom ({ env= process . env , here}) { 11const given = String ( env . STRATA_APP_VERSION ?? '' ). trim (); 12if ( VERSION . test ( given )) return given ; 13try { 14const toml = readFileSync ( join ( here , '..' , '..' , 'desktop' , 'src-tauri' , 'Cargo.toml' ), 'utf8' ); 15const found = / ^version\s * =\s * " ([ ^ " ] + ) " / m . exec ( toml ); 16if ( found && VERSION . test ( found [ 1 ])) return found [ 1 ]; 17} catch { /* not a checkout */ } 18return 'dev' ; 19} 20 21/** The version "Strata" means on screen and in the update check: the app's own, not Strata Control's (see src/lib/app-version.ts). */ 22export function appVersionToShow ( app , control ) { 23const real = value => ( typeof value === 'string' && value . trim () && value . trim (). toLowerCase () !== 'dev' ?value . trim () :null ); 24return real ( app ) ?? real ( control ) ?? ( typeof app === 'string' && app . trim () ?app . trim () :null ); 25}