UNPKG

@prisma/cli-dev

Version:

Dev CLI for Prisma

14 lines (10 loc) 1.65 kB
import { createRequire } from 'module'; const require = createRequire(import.meta.url); import{a as m,c as u,d,e as S}from"./chunk-FODIIZRP.js";import{a as i}from"./chunk-FON2L4R6.js";import{b as f,f as r,g as p,h as c}from"./chunk-SZYQ5TDI.js";import{d as t,f as g}from"./chunk-4QNO2WQL.js";import"./chunk-M6TFCQLD.js";import{setTimeout as C}from"timers/promises";import{isServerRunning as $,ServerState as y}from"@prisma/dev/internal/state";var A={...g,name:{description:"Name(s)/pattern(s) of the server(s) to start",required:!0,type:"positional",valueHint:"glob"}},b={description:"Start one or more stopped servers",name:"start"},U={args:A,meta:b,run:async v=>{let{debug:T,name:h}=v.args,R=h.split(","),w=await y.scan({debug:T,globs:R}),s=[],a=[];for(let e of w)($(e)?a:s).push(e);if(a.length>0&&t.log(`\u{1F45F} The following ${r} servers are already running and won't be affected: ${i(a)} `),s.length===0)return t.log(`\u26A0\uFE0F No ${r} servers found to start. `);t.log(`\u{1F56F}\uFE0F Starting the following ${r} servers: ${i(s)} `);let l=await Promise.allSettled(s.map(async e=>{let o=await m(e);return t.log(`\u{1F525} Started ${r} server ${f(o.name)}! Listening on ports ${S([new URL(o.http.url).port,new URL(o.database.connectionString).port,new URL(o.shadowDatabase.connectionString).port])}.`),o})),n=l.filter(e=>e.status==="fulfilled");if(n.length===1){let{value:e}=n[0];t.log(` `),t.log(u(e)),c&&await C(1e3),t.log(` `),t.log(d(e))}else n.length>1&&t.log(` \u{1F4DC} Run ${p("ls")} to see all running ${r} servers and their URLs.`);n.length!==l.length&&(process.exitCode||=1),t.log("")}};export{U as StartCommand};