Skip to main content
This package has been archived, and as such it is read-only.
This release is 1 version behind 0.0.9 — the latest version of @apompolo/mr-cli. Jump to latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
58%
Published
4 weeks ago (0.0.8)
Package root>getAppInfo.ts
import { join } from "jsr:@std/path@^1.0.8"; interface AppInfo { name: string; version: string; buildNumber: number; projectDir: string; } export async function getAppInfo(projectDir: string): Promise<AppInfo> { const packageJsonPath = join(projectDir, "package.json"); try { await Deno.lstat(packageJsonPath); } catch { console.error(`package.json was not found inside ${projectDir} You must run mr-cli inside mApp's project folder! `); Deno.exit(1); } const { version, name } = await Deno.readTextFile(packageJsonPath).then( JSON.parse ); const appBuildGradle = await Deno.readTextFile( join(projectDir, "android", "app", "build.gradle") ); const versionCodeRegex = new RegExp(/versionCode .+/gm); const buildNumber = Number(appBuildGradle.search(versionCodeRegex)); if (Number.isNaN(buildNumber)) { throw new Error( "The build number was not found! (Search in android/app/build.gradle for 'versionCode'" ); } return { version, name, buildNumber, projectDir }; }