Something went wrong. Try again.
A fully featured CLI used as an alternative to AppView applications (Bsky.app/mu.social)
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324252627282930313233import * as FS from 'node:fs';
// This package's package.json — beside the sources on disk, and beside them// inside the archive too: the version, and where its OAuth client lives.
interface PackageInfo { version: string; /** * The hosted OAuth client documents to try, in order, with `{version}` * standing for the version: this release's own first, then fallbacks. */ oauthClients: string[];}
let cached: PackageInfo | undefined;
export function packageInfo(): PackageInfo { if (!cached) { try { const json = JSON.parse(FS.readFileSync(new URL('../package.json', import.meta.url), 'utf-8')) as { version?: string; atcli?: { oauthClients?: string[] } }; const version = String(json.version ?? '0.0.0'); cached = { version, oauthClients: (json.atcli?.oauthClients ?? []).map((template) => template.replaceAll('{version}', version)) }; } catch { cached = { version: '0.0.0', oauthClients: [] }; } } return cached;}
export function version(): string { return packageInfo().version;}