CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-prisma--get-platform

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.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

platform-detection.mddocs/

Platform Detection

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.

Capabilities

Get Binary Target for Current Platform

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)

Get Platform Information

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"
// }

Get OS Information

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"
// }

Internal Platform Detection Functions

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>;

Platform Support

The platform detection system supports:

Operating Systems:

  • Linux (various distributions)
  • macOS (Intel and Apple Silicon)
  • Windows
  • FreeBSD (versions 11-15)
  • OpenBSD
  • NetBSD

CPU Architectures:

  • x64 (x86_64, amd64)
  • arm64 (aarch64)
  • arm (32-bit ARM)
  • x32, ia32, s390, s390x, mipsel, mips, ppc, ppc64

Linux Distribution Families:

  • Debian-based (Ubuntu, Debian, etc.)
  • RHEL-based (CentOS, Fedora, AlmaLinux, etc.)
  • Alpine/musl-based
  • Arch-based
  • NixOS
  • Raspbian (ARM-specific handling)

SSL Library Versions:

  • OpenSSL 1.0.x
  • OpenSSL 1.1.x
  • OpenSSL 3.0.x (and 3.x normalized to 3.0.x)

Error Handling

The platform detection functions handle various error conditions gracefully:

  • Unsupported architectures: Warns but continues with best-effort detection
  • SSL detection failure: Falls back to default OpenSSL 1.1.x with warning
  • Distribution detection failure: Falls back to Debian target with debug logging
  • Command execution failure: Returns undefined for optional information
  • File system errors: Handles missing files and permission issues silently

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

docs

binary-targets.md

index.md

node-api-support.md

platform-detection.md

test-utilities.md

tile.json