cmvr-wms/mobile-app/scripts/export-update.mjs

19 lines
1.3 KiB
JavaScript
Raw Normal View History

import { execFileSync } from 'node:child_process';
import { writeFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
const require=createRequire(import.meta.url);
const cli=require.resolve('expo/bin/cli');
const updates=require.resolve('expo-updates/bin/cli.js');
const env={...process.env,EXPO_NO_TELEMETRY:'1',CI:'1'};
const runtime=JSON.parse(execFileSync(process.execPath,[updates,'runtimeversion:resolve','--platform','android'],{env,encoding:'utf8'})).runtimeVersion;
execFileSync(process.execPath,[cli,'export','--platform','android','--output-dir','dist'],{env,stdio:'inherit'});
const config=JSON.parse(execFileSync(process.execPath,[cli,'config','--type','public','--json'],{env,encoding:'utf8'}));
const after=JSON.parse(execFileSync(process.execPath,[updates,'runtimeversion:resolve','--platform','android'],{env,encoding:'utf8'})).runtimeVersion;
if(runtime!==after)throw Error('Native configuration changed during export; rebuild before publishing');
config.runtimeVersion=runtime;
// Never ship build-machine paths or private signing material in the manifest.
delete config._internal;
await writeFile('dist/resolved-config.json',JSON.stringify(config,null,2));
await writeFile('dist/runtime-version.txt',runtime);
console.log(`Exported Android update for native runtime ${runtime}`);