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

binary-targets.mddocs/

Binary Targets

Binary target system that maps platform characteristics to appropriate Prisma engine targets. The system supports 33+ different platform configurations covering major operating systems, architectures, and SSL library versions.

Capabilities

Binary Target Type

Union type defining all supported binary target platform strings used by Prisma engines.

type BinaryTarget =
  | 'native'
  | 'darwin'
  | 'darwin-arm64'
  | 'debian-openssl-1.0.x'
  | 'debian-openssl-1.1.x'
  | 'debian-openssl-3.0.x'
  | 'rhel-openssl-1.0.x'
  | 'rhel-openssl-1.1.x'
  | 'rhel-openssl-3.0.x'
  | 'linux-arm64-openssl-1.1.x'
  | 'linux-arm64-openssl-1.0.x'
  | 'linux-arm64-openssl-3.0.x'
  | 'linux-arm-openssl-1.1.x'
  | 'linux-arm-openssl-1.0.x'
  | 'linux-arm-openssl-3.0.x'
  | 'linux-musl'
  | 'linux-musl-openssl-3.0.x'
  | 'linux-musl-arm64-openssl-1.1.x'
  | 'linux-musl-arm64-openssl-3.0.x'
  | 'linux-nixos'
  | 'linux-static-x64'
  | 'linux-static-arm64'
  | 'windows'
  | 'freebsd11'
  | 'freebsd12'
  | 'freebsd13'
  | 'freebsd14'
  | 'freebsd15'
  | 'openbsd'
  | 'netbsd'
  | 'arm';

Binary Targets Array

Array containing all supported binary target strings, excluding the 'native' placeholder.

/**
 * Array of all supported binary target platform strings
 * Used for validation and iteration over available targets
 */
const binaryTargets: BinaryTarget[];

Usage Examples:

import { binaryTargets, BinaryTarget } from "@prisma/get-platform";

// Check if a target is supported
function isValidTarget(target: string): target is BinaryTarget {
  return binaryTargets.includes(target as BinaryTarget) || target === 'native';
}

// List all Linux targets
const linuxTargets = binaryTargets.filter(target => target.startsWith('linux-'));
console.log(linuxTargets);
// [
//   'linux-arm64-openssl-1.1.x',
//   'linux-arm64-openssl-1.0.x', 
//   'linux-arm64-openssl-3.0.x',
//   'linux-arm-openssl-1.1.x',
//   'linux-arm-openssl-1.0.x',
//   'linux-arm-openssl-3.0.x',
//   'linux-musl',
//   'linux-musl-openssl-3.0.x',
//   'linux-musl-arm64-openssl-1.1.x',
//   'linux-musl-arm64-openssl-3.0.x',
//   'linux-nixos',
//   'linux-static-x64',
//   'linux-static-arm64'
// ]

// Get all OpenSSL 3.0.x targets
const openssl3Targets = binaryTargets.filter(target => target.includes('openssl-3.0.x'));
console.log(openssl3Targets);

Binary Target Categories

macOS Targets

  • darwin: Intel-based macOS (x64)
  • darwin-arm64: Apple Silicon macOS (M1/M2/etc.)

Windows Targets

  • windows: All Windows platforms (x64, x86)

Linux glibc Targets

Debian-based distributions (Ubuntu, Debian, Mint, etc.):

  • debian-openssl-1.0.x
  • debian-openssl-1.1.x
  • debian-openssl-3.0.x

RHEL-based distributions (CentOS, Fedora, AlmaLinux, etc.):

  • rhel-openssl-1.0.x
  • rhel-openssl-1.1.x
  • rhel-openssl-3.0.x

ARM64 Linux (glibc-based):

  • linux-arm64-openssl-1.0.x
  • linux-arm64-openssl-1.1.x
  • linux-arm64-openssl-3.0.x

ARM 32-bit Linux (glibc-based):

  • linux-arm-openssl-1.0.x
  • linux-arm-openssl-1.1.x
  • linux-arm-openssl-3.0.x

Linux musl Targets

Alpine Linux and musl-based distributions:

  • linux-musl: Base musl target (OpenSSL 1.1.x or no SSL)
  • linux-musl-openssl-3.0.x: Alpine 3.17+ with OpenSSL 3.0
  • linux-musl-arm64-openssl-1.1.x: ARM64 Alpine with OpenSSL 1.1
  • linux-musl-arm64-openssl-3.0.x: ARM64 Alpine with OpenSSL 3.0

Specialized Linux Targets

  • linux-nixos: NixOS distribution
  • linux-static-x64: Statically linked x64 binaries
  • linux-static-arm64: Statically linked ARM64 binaries
  • arm: Generic ARM target (Raspbian fallback)

BSD Targets

FreeBSD versions:

  • freebsd11, freebsd12, freebsd13, freebsd14, freebsd15

Other BSD:

  • openbsd: OpenBSD
  • netbsd: NetBSD

Special Targets

  • native: Placeholder indicating platform-native compilation (not in binaryTargets array)

Target Selection Logic

The binary target selection follows this priority order:

  1. Platform identification: macOS, Windows, Linux, BSD
  2. Architecture detection: x64, arm64, arm, etc.
  3. Distribution family: For Linux - Debian, RHEL, Alpine/musl, NixOS
  4. SSL library version: 1.0.x, 1.1.x, 3.0.x (normalized)
  5. Fallback strategy: Default to Debian + OpenSSL 1.1.x if detection fails

Examples of target resolution:

// macOS on Apple Silicon
{ platform: 'darwin', arch: 'arm64' } → 'darwin-arm64'

// Ubuntu 20.04 on x64 with OpenSSL 1.1
{ platform: 'linux', targetDistro: 'debian', libssl: '1.1.x' } → 'debian-openssl-1.1.x'

// Alpine Linux on ARM64 with OpenSSL 3.0
{ platform: 'linux', targetDistro: 'musl', arch: 'arm64', libssl: '3.0.x' } → 'linux-musl-arm64-openssl-3.0.x'

// CentOS 8 on x64 with OpenSSL 1.1
{ platform: 'linux', targetDistro: 'rhel', libssl: '1.1.x' } → 'rhel-openssl-1.1.x'

// FreeBSD 13
{ platform: 'freebsd', targetDistro: 'freebsd13' } → 'freebsd13'

SSL Version Handling

OpenSSL version detection and normalization:

  • Version normalization: OpenSSL 3.1.x, 3.2.x → 3.0.x (API compatible)
  • Detection methods:
    1. libssl.so file inspection (preferred)
    2. ldconfig cache lookup
    3. openssl binary version (fallback)
  • Default fallback: 1.1.x if detection fails
  • Excluded versions: libssl 0.x automatically filtered out

Platform Warnings

The system emits warnings for:

  • Unsupported architectures: Non-x64/arm64 on Linux
  • SSL detection failure: Falls back to default with installation instructions
  • Unknown platforms: Falls back to Linux target
  • Unknown distributions: Falls back to Debian family

These warnings help users understand potential compatibility issues while maintaining functionality.

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