@prisma/cli-dev
Version:
Dev CLI for Prisma
10 lines (6 loc) • 1.57 kB
JavaScript
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
import{a as s,b as f}from"./chunk-D5MRRGDK.js";import{a as m,b as l,e}from"./chunk-ZKMEOIRF.js";import{a}from"./chunk-XOIFSEIB.js";import{deleteServer as u,isServerRunning as d,ServerState as C}from"@prisma/dev/internal/state";import{defineCommand as y}from"citty";import{consola as r}from"consola";import{process as c}from"std-env";var S={...a,force:{default:!1,description:"Stops any running servers before removing them. Default is `false`, which would fail the command if any server is running.",required:!1,type:"boolean"},name:{description:"Name(s)/pattern(s) of the server(s) to remove",required:!0,type:"positional",valueHint:"glob"}},h={description:"Remove servers",name:"rm"},P=y({args:S,meta:h,run:async n=>{let{debug:i,force:p,name:g}=n.args,v=g.split(","),o=await C.scan({debug:i,globs:v});if(o.length===0)return r.log(`\u26A0\uFE0F No ${e} servers found to remove.
`);if(!p&&o.some(d)){r.log(`\u{1F6AB} Some ${e} servers are currently running:
${s(o.filter(d))}
Use the ${l("--force")} flag to stop and remove them.`),c.exitCode||=1;return}if(r.log(`\u{1F5D1}\uFE0F Removing the following ${e} servers:
${s(o)}`),!await f({confirmationText:"i will lose local data",debug:n.args.debug}))return;(await Promise.allSettled(o.map(async t=>{await u(t,i),r.log(`\u{1F9F9} Removed ${e} server ${m(t.name)}.`)}))).some(t=>t.status==="rejected")&&(r.error(`Potentially failed to remove some ${e} servers.`),c.exitCode||=1),r.log("")}});export{P as RemoveCommand};