UNPKG

@visulima/cerebro

Version:

A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.

2 lines (1 loc) 1.59 kB
var a=Object.defineProperty;var p=(r,t)=>a(r,"name",{value:t,configurable:!0});import{d as v,e as d,g as y}from"../packem_shared/runtime-process-G-n-wOub.js";var g=Object.defineProperty,n=p((r,t)=>g(r,"name",{value:t,configurable:!0}),"o");const s=n(r=>{if(!r||typeof r!="string")return 0;const t=r.split(".");if(t.length===0||!t[0])return 0;const e=Number.parseInt(t[0],10);return Number.isNaN(e)?0:e},"parseMajorVersion"),h=n(r=>!r||typeof r!="string"?"":r.replace("v",""),"extractNodeVersion"),l=n(()=>{if(typeof Bun<"u"){const e=Bun.version||"";return{major:s(e),type:"bun",version:e}}if(typeof Deno<"u"){const e=Deno.version?.deno||"";return{major:s(e),type:"deno",version:e}}const r=y().node??"",t=h(r);return{major:s(t),type:"node",version:t}},"detectRuntime"),b=n((r={})=>({description:"Checks if the current runtime version meets the minimum requirement",init:n(async t=>{const e=l(),c={bun:1,deno:1,node:18};let o;try{const u=v().CEREBRO_MIN_NODE_VERSION,m=u===void 0?void 0:Number.parseInt(u,10);o=Number.isNaN(m)?void 0:m}catch{o=void 0}let i;r.runtimes?.[e.type]?.minVersion!==void 0?i=r.runtimes[e.type].minVersion:e.type==="node"&&o!==void 0?i=o:i=c[e.type],e.major<i&&(t.logger.error(`cerebro requires ${e.type} version ${i} or higher. You have ${e.type} ${e.version}. Read our version support policy: https://github.com/visulima/visulima#supported-runtimes`),d(1)),t.logger.debug(`Runtime version check passed: ${e.type} ${e.version} >= ${i}`)},"init"),name:"runtime-version-check",version:"1.0.0"}),"runtimeVersionCheckPlugin");export{b as runtimeVersionCheckPlugin};