// rnx version — one overview of both halves you're running. // // the rnx CLI and the engine runtime (versioned tarball // rendered in the browser/electron shell) are versioned independently, which // is a frequent "I upgraded but the version didn't change" trap. the terse // `rnx --version` flag prints both for scripts; this command adds the // channel, a "newer runtime available" hint, and a what's-new pointer. import fs from 'node:fs' import path from 'node:path' import { getCliVersion } from '../../src/cli-version' import { runtimeDir } from '../../src/home-paths' import { RNX_CHANGELOG_URL, rnxRuntime } from '../../src/runtime-delivery' import { resolveRNXAppConfig } from '../app-config' import { readCachedCliUpdate, refreshCliUpdateCache } from '../cli-update' import { getRuntimeSummary } from '../runtime-summary' import { IS_STANDALONE } from '../standalone' export async function runVersion(_args: string[]): Promise { const cliUpdatePromise = IS_STANDALONE ? refreshCliUpdateCache().catch(() => readCachedCliUpdate()) : Promise.resolve(null) const { IS_BETA, BETA_LABEL } = await import('../../src/beta') const suffix = IS_BETA ? ` · ${BETA_LABEL}` : '' console.log(`rnx v${getCliVersion()}${suffix}`) const runtime = getRuntimeSummary() const channel = rnxRuntime.resolveChannel() if (runtime.isDevBridge) { console.log(runtime.primary) if (runtime.installedRuntime) console.log(`${runtime.installedRuntime} · ${channel}`) } else if (runtime.primary === 'runtime not installed') { console.log(`runtime not installed — run \`rnx runtime install\``) } else { console.log(`${runtime.primary} · ${channel}`) } const { config } = await resolveRNXAppConfig() if (config?.runtimeVersion) { const installed = fs.existsSync( path.join(runtimeDir(config.runtimeVersion), 'index.html'), ) console.log( `project runtime v${config.runtimeVersion} · configured · ${ installed ? 'installed' : 'installs on open' }`, ) } // best-effort network check; never fail the command on a flaky network. const [check, cliUpdate] = await Promise.all([ rnxRuntime.checkUpToDate({ channel }), cliUpdatePromise, ]) if (cliUpdate?.outdated) { console.log(`\n ↑ CLI v${cliUpdate.latestVersion} available; run \`rnx upgrade\``) } if (check.outdated && check.latest) { console.log(`\n ↑ default runtime v${check.latest} available; run \`rnx upgrade\``) } console.log(`\n what's new: ${RNX_CHANGELOG_URL}`) }