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

index.mddocs/

@prisma/get-platform

@prisma/get-platform is a TypeScript platform detection utility specifically designed for Prisma's internal infrastructure needs. It provides comprehensive system analysis including operating system identification, CPU architecture detection, and detailed Linux distribution classification with family grouping. The library maps detected platform characteristics to appropriate binary targets for Prisma engines and handles edge cases across diverse deployment environments.

Package Information

  • Package Name: @prisma/get-platform
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @prisma/get-platform

Core Imports

import { 
  getBinaryTargetForCurrentPlatform, 
  getPlatformInfo, 
  assertNodeAPISupported,
  getNodeAPIName,
  getos,
  link,
  type BinaryTarget,
  type PlatformInfo,
  binaryTargets
} from "@prisma/get-platform";

For CommonJS:

const { getBinaryTargetForCurrentPlatform, getPlatformInfo } = require("@prisma/get-platform");

Test utilities (Jest only - exported through main package):

import { 
  jestContext, 
  jestConsoleContext, 
  jestStdoutContext, 
  processExitContext,
  type BaseContext,
  type ProcessContextSettings
} from "@prisma/get-platform";

Basic Usage

import { getBinaryTargetForCurrentPlatform, getPlatformInfo } from "@prisma/get-platform";

// Get the binary target for current platform
const binaryTarget = await getBinaryTargetForCurrentPlatform();
console.log(binaryTarget); // e.g., "linux-musl-arm64-openssl-3.0.x"

// Get comprehensive platform information
const platformInfo = await getPlatformInfo();
console.log(platformInfo.platform); // e.g., "linux"
console.log(platformInfo.arch); // e.g., "arm64"
console.log(platformInfo.binaryTarget); // e.g., "linux-musl-arm64-openssl-3.0.x"

Architecture

@prisma/get-platform is built around several key components:

  • Platform Detection Engine: Core functionality for detecting OS, architecture, and distribution information
  • Binary Target Resolution: Mapping platform characteristics to Prisma engine binary targets
  • SSL Version Detection: Specialized Linux SSL library version detection for engine compatibility
  • Node API Compatibility: Validation utilities for Node.js API support
  • Test Utilities: Comprehensive testing framework utilities for platform-related testing

Capabilities

Platform Detection

Core platform detection functionality that identifies the current operating system, CPU architecture, and detailed Linux distribution information.

function getBinaryTargetForCurrentPlatform(): Promise<BinaryTarget>;

function getPlatformInfo(): Promise<PlatformInfo>;

function getos(): Promise<GetOSResult>;

Platform Detection

Binary Target Resolution

Binary target system that maps platform characteristics to appropriate Prisma engine targets, supporting 33+ different platform configurations.

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

const binaryTargets: BinaryTarget[];

Binary Targets

Node API Support

Node.js API compatibility validation for ensuring proper engine type selection based on platform capabilities.

function assertNodeAPISupported(): void;

function getNodeAPIName(binaryTarget: BinaryTarget, type: 'url' | 'fs'): string;

Node API Support

Test Utilities

Testing utilities for platform-related functionality. Jest utilities are officially exported through the main package.

// Jest utilities (exported through main package)
const jestContext: ContextFactory;
const jestConsoleContext: ContextContributor;
const jestStdoutContext: ContextContributor;
const processExitContext: ContextContributor;

// Base types
type BaseContext: TestContext;
type ProcessContextSettings: Settings;

// Utility function
function link(url: any): string;

Test Utilities

Types

interface PlatformInfo extends GetOSResult {
  binaryTarget: BinaryTarget;
}

interface GetOSResult {
  platform: NodeJS.Platform;
  arch: Arch;
  targetDistro?: 'rhel' | 'debian' | 'musl' | 'arm' | 'nixos' | 'freebsd11' | 'freebsd12' | 'freebsd13' | 'freebsd14' | 'freebsd15';
  familyDistro?: string;
  originalDistro?: string;
  archFromUname?: string;
  libssl?: '1.0.x' | '1.1.x' | '3.0.x';
}

type Arch = 'x32' | 'x64' | 'arm' | 'arm64' | 's390' | 's390x' | 'mipsel' | 'ia32' | 'mips' | 'ppc' | 'ppc64';

interface DistroInfo {
  originalDistro?: string;
  familyDistro?: string;
  targetDistro?: 'rhel' | 'debian' | 'musl' | 'arm' | 'nixos' | 'freebsd11' | 'freebsd12' | 'freebsd13' | 'freebsd14' | 'freebsd15';
}

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