okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221storage and version: one Downloaded models list from the real files, Check folder unloads nothing, app version shown as Strata31030b170

main
1.2 KiB25 linesraw
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 }) {
11  const given = String(env.STRATA_APP_VERSION ?? '').trim();
12  if (VERSION.test(given)) return given;
13  try {
14    const toml = readFileSync(join(here, '..', '..', 'desktop', 'src-tauri', 'Cargo.toml'), 'utf8');
15    const found = /^version\s*=\s*"([^"]+)"/m.exec(toml);
16    if (found && VERSION.test(found[1])) return found[1];
17  } catch { /* not a checkout */ }
18  return '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) {
23  const real = value => (typeof value === 'string' && value.trim() && value.trim().toLowerCase() !== 'dev' ? value.trim() : null);
24  return real(app) ?? real(control) ?? (typeof app === 'string' && app.trim() ? app.trim() : null);
25}