Platform detection utility for Prisma's internal use that detects operating system, architecture, and Linux distribution information to determine appropriate binary targets for Prisma engines.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Core platform detection functionality that identifies the current operating system, CPU architecture, and detailed Linux distribution information. This module provides comprehensive system analysis to determine appropriate binary targets for Prisma engines.
Gets the binary target string for the current platform, which determines which Prisma engine binary to use.
/**
* Get the binary target for the current platform
* @returns Promise resolving to the appropriate binary target string
* @example "linux-musl-arm64-openssl-3.0.x" for Linux Alpine on ARM64
*/
function getBinaryTargetForCurrentPlatform(): Promise<BinaryTarget>;Usage Examples:
import { getBinaryTargetForCurrentPlatform } from "@prisma/get-platform";
// Get binary target for current platform
const target = await getBinaryTargetForCurrentPlatform();
console.log(target);
// Possible outputs:
// "darwin-arm64" (macOS on Apple Silicon)
// "linux-musl-arm64-openssl-3.0.x" (Alpine Linux on ARM64)
// "debian-openssl-1.1.x" (Debian/Ubuntu with OpenSSL 1.1)
// "windows" (Windows)Gets comprehensive platform information including binary target and detailed system characteristics.
/**
* Get the binary target and other system information for the current platform
* @returns Promise resolving to complete platform information
*/
function getPlatformInfo(): Promise<PlatformInfo>;Usage Examples:
import { getPlatformInfo } from "@prisma/get-platform";
const info = await getPlatformInfo();
console.log(info);
// Example output on Linux:
// {
// platform: "linux",
// arch: "x64",
// binaryTarget: "debian-openssl-1.1.x",
// targetDistro: "debian",
// familyDistro: "debian",
// originalDistro: "ubuntu",
// archFromUname: "x86_64",
// libssl: "1.1.x"
// }For internal use. Gets detailed OS information without the binary target resolution.
/**
* Get detailed operating system information
* @returns Promise resolving to OS detection results
* @internal This function is for internal use and may change without notice
*/
function getos(): Promise<GetOSResult>;Usage Examples:
import { getos } from "@prisma/get-platform";
const osInfo = await getos();
console.log(osInfo);
// Example output on Linux:
// {
// platform: "linux",
// arch: "arm64",
// archFromUname: "aarch64",
// libssl: "3.0.x",
// targetDistro: "musl",
// familyDistro: "alpine",
// originalDistro: "alpine"
// }
// Example output on macOS:
// {
// platform: "darwin",
// arch: "arm64"
// }These functions are exported for testing purposes but are not part of the official public API:
/**
* Internal function for binary target resolution
* @internal Testing purposes only
*/
function getBinaryTargetForCurrentPlatformInternal(args: GetOSResult): BinaryTarget;
/**
* Memoized version of getPlatformInfo
* @internal Testing purposes only
*/
function getPlatformInfoMemoized(): Promise<PlatformInfo & { memoized: boolean }>;
/**
* Parse Linux distribution information from /etc/os-release content
* @internal Testing purposes only
*/
function parseDistro(osReleaseInput: string): DistroInfo;
/**
* Resolve current Linux distribution information
* @internal Testing purposes only
*/
function resolveDistro(): Promise<DistroInfo>;
/**
* Get system architecture from uname command
* @internal Testing purposes only
*/
function getArchFromUname(): Promise<string | undefined>;The platform detection system supports:
Operating Systems:
CPU Architectures:
Linux Distribution Families:
SSL Library Versions:
The platform detection functions handle various error conditions gracefully:
Platform detection never throws errors, but may emit warnings via the console for configuration issues that could affect Prisma engine selection.
Install with Tessl CLI
npx tessl i tessl/npm-prisma--get-platform