@prisma/cli-dev 0.16.0 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as v,b as s,c as y,e as h,f as S,h as b,i as B,j as O}from"./chunk-P5JORAQS.js";import{b as f,c as d}from"./chunk-GZHQT2TW.js";import{b as M}from"./chunk-M6TFCQLD.js";import{fork as A}from"child_process";import{createRequire as _}from"module";import{ServerState as D}from"@prisma/dev/internal/state";var G=_(import.meta.url).resolve("@prisma/dev/internal/daemon");function N(){let e={[Symbol.asyncIterator]:()=>e,next:()=>Promise.resolve({done:!0,value:void 0}),return:()=>Promise.resolve({done:!0,value:void 0}),throw:t=>Promise.reject(t instanceof Error?t:new Error(String(t)))};return e}function L(){return{wal:{stream:()=>N(),subscribe:()=>()=>{}}}}function P(e){return{...e,experimental:e.experimental??L()}}async function Xe(e){let t,o,a=new Promise((n,p)=>{t=n,o=p}),i=typeof e=="string"?e:e.name,c=A(G,[i],{detached:!0,stdio:"ignore"});c.once("error",n=>{d.error(n)}),c.once("message",n=>{let{type:p}=n;if(p==="error")return o(n.error);if(p==="started")return t(P(n.server));o(`Unknown message type: "${p}"`)});try{return await a}catch(n){if(typeof n=="string"&&n.includes("is already running")){if(typeof e!="string")return P({...e.exports,name:i});let p=await D.fromServerDump({name:i});if(!p)throw new Error(`Failed to retrieve the status of the running server "${i}".`);return P({...p.exports,name:i})}throw n}finally{c.disconnect(),c.unref(),c.removeAllListeners()}}import{setTimeout as Le}from"timers/promises";import l from"process";import{stripVTControlCharacters as Be}from"util";var m={};M(m,{bgBlack:()=>ie,bgBlue:()=>pe,bgBlueBright:()=>Te,bgCyan:()=>me,bgCyanBright:()=>$e,bgGray:()=>ue,bgGreen:()=>ae,bgGreenBright:()=>Pe,bgMagenta:()=>le,bgMagentaBright:()=>we,bgRed:()=>se,bgRedBright:()=>be,bgWhite:()=>he,bgWhiteBright:()=>Ce,bgYellow:()=>ce,bgYellowBright:()=>Re,black:()=>X,blue:()=>ee,blueBright:()=>ve,bold:()=>W,cyan:()=>re,cyanBright:()=>ye,dim:()=>q,gray:()=>ne,green:()=>J,greenBright:()=>ge,hidden:()=>Q,inverse:()=>j,italic:()=>F,magenta:()=>te,magentaBright:()=>xe,overline:()=>Y,red:()=>z,redBright:()=>de,reset:()=>H,strikethrough:()=>K,underline:()=>V,white:()=>oe,whiteBright:()=>Se,yellow:()=>Z,yellowBright:()=>fe});import U from"tty";var k=U?.WriteStream?.prototype?.hasColors?.()??!1,r=(e,t)=>{if(!k)return i=>i;let o=`\x1B[${e}m`,a=`\x1B[${t}m`;return i=>{let c=i+"",n=c.indexOf(a);if(n===-1)return o+c+a;let p=o,u=0,x=(t===22?a:"")+o;for(;n!==-1;)p+=c.slice(u,n)+x,u=n+a.length,n=c.indexOf(a,u);return p+=c.slice(u)+a,p}},H=r(0,0),W=r(1,22),q=r(2,22),F=r(3,23),V=r(4,24),Y=r(53,55),j=r(7,27),Q=r(8,28),K=r(9,29),X=r(30,39),z=r(31,39),J=r(32,39),Z=r(33,39),ee=r(34,39),te=r(35,39),re=r(36,39),oe=r(37,39),ne=r(90,39),ie=r(40,49),se=r(41,49),ae=r(42,49),ce=r(43,49),pe=r(44,49),le=r(45,49),me=r(46,49),he=r(47,49),ue=r(100,49),de=r(91,39),ge=r(92,39),fe=r(93,39),ve=r(94,39),xe=r(95,39),ye=r(96,39),Se=r(97,39),be=r(101,49),Pe=r(102,49),Re=r(103,49),Te=r(104,49),we=r(105,49),$e=r(106,49),Ce=r(107,49);var g=l.platform!=="win32"||!!l.env.WT_SESSION||l.env.TERM_PROGRAM==="vscode",Oe=e=>!!(e.isTTY&&l.env.TERM!=="dumb"&&!("CI"in l.env)),Ie=m.blue(g?"\u2139":"i"),Ee=m.green(g?"\u2714":"\u221A"),Me=m.yellow(g?"\u26A0":"\u203C"),Ae=m.red(g?"\u2716":"\xD7"),_e={frames:g?["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]:["-","\\","|","/"],interval:80},R=class{#p;#l;#n=-1;#i;#r;#e;#s;#m=0;#o;#t;#d=0;#h=!1;constructor(t={}){let o=t.spinner??_e;this.#p=o.frames,this.#l=o.interval,this.#r=t.text??"",this.#e=t.stream??l.stderr,this.#s=t.color??"cyan",this.#t=Oe(this.#e),this.#o=this.#S.bind(this)}start(t){return t&&(this.#r=t),this.isSpinning?this:(this.#h=!0,this.#f(),this.#c(),this.#x(),this.#t&&(this.#i=setInterval(()=>{this.#c()},this.#l)),this)}stop(t){return this.isSpinning?(this.#h=!1,this.#i&&(clearInterval(this.#i),this.#i=void 0),this.#v(),this.clear(),this.#y(),t&&this.#e.write(`${t}
|
|
3
|
+
`),this):this}#a(t,o){return this.stop(`${t} ${o??this.#r}`)}success(t){return this.#a(Ee,t)}error(t){return this.#a(Ae,t)}warning(t){return this.#a(Me,t)}info(t){return this.#a(Ie,t)}get isSpinning(){return this.#h}get text(){return this.#r}set text(t){this.#r=t??"",this.#c()}get color(){return this.#s}set color(t){this.#s=t,this.#c()}clear(){if(!this.#t)return this;this.#e.cursorTo(0);for(let t=0;t<this.#m;t++)t>0&&this.#e.moveCursor(0,-1),this.#e.clearLine(1);return this.#m=0,this}#c(){let t=Date.now();(this.#n===-1||t-this.#d>=this.#l)&&(this.#n=++this.#n%this.#p.length,this.#d=t);let o=m[this.#s]??m.cyan,a=this.#p[this.#n],i=`${o(a)} ${this.#r}`;this.#t||(i+=`
|
|
4
|
+
`),this.clear(),this.#u(i),this.#t&&(this.#m=this.#g(i))}#u(t){this.#e.write(t)}#g(t){let o=this.#e.columns??80,a=Be(t).split(`
|
|
5
|
+
`),i=0;for(let c of a)i+=Math.max(1,Math.ceil(c.length/o));return i}#f(){this.#t&&this.#u("\x1B[?25l")}#v(){this.#t&&this.#u("\x1B[?25h")}#x(){l.once("SIGINT",this.#o),l.once("SIGTERM",this.#o)}#y(){l.off("SIGINT",this.#o),l.off("SIGTERM",this.#o)}#S(t){this.isSpinning&&this.stop();let o=t==="SIGINT"?130:t==="SIGTERM"?143:1;l.exit(o)}};function T(e){return new R(e)}var De=[{value:"q",label:"quit"}],w=3;function I(e){let t=new O({debug:e?.debug,options:De,render:Ge,signal:e?.abortSignal});return{clearPrompt(){v.stdout.moveCursor(0,-w),v.stdout.cursorTo(0),v.stdout.clearScreenDown()},prompt:t,respond:async o=>{if(B(o)||o==="q")return await e?.onQuit?.();await e?.onOption?.[o]?.()}}}function Ge(){return Ne()}function Ne(){let e="Press q to quit",t=`\u250C${"\u2500".repeat(e.length+2)}\u2510`,o=`\u2514${"\u2500".repeat(e.length+2)}\u2518`;return["",t,`\u2502 ${e} \u2502`,o].join(`
|
|
6
|
+
`)}function ft(e){let t=T();return{renderContent:Ue,renderIntro:()=>He(e,t),renderOutro:()=>Promise.resolve(We(e)),spinner:t}}async function Ue(e){let{abortSignal:t,debug:o,isClosed:a,onQuit:i,server:c,spinner:n}=e;if(n.success(ke(c)),d.log(qe(c)),!!b)for(;!a();){let{clearPrompt:p,prompt:u,respond:C}=I({abortSignal:t,debug:o,onQuit:i}),x=await u.prompt();p(),t.aborted||await C(x)}}function ke(e){return` Your local Prisma Postgres server ${s(e.name)} is now running \u{1F44D}`}async function He(e,t){t.start(` Starting ${S} server ${s(e)}...${`
|
|
7
|
+
`.repeat(w+3)}`),b&&await Le(250)}function We(e){d.log(`\u{1F44B} Buh Bye!
|
|
8
|
+
|
|
9
|
+
Your ${S} server ${s(e)} has been closed successfully.
|
|
10
|
+
`)}function vt(e){return`\u{1F50C} To connect to your local Prisma Postgres database via HTTP + Prisma ORM
|
|
11
|
+
use the following connection string:
|
|
12
|
+
|
|
13
|
+
${Ve("\u{1F4C4} .env:")}
|
|
14
|
+
|
|
15
|
+
${$("DATABASE_URL",Fe(e.ppg.url))}
|
|
16
|
+
|
|
17
|
+
\u2728 The ${s("api_key")} above does not contain any sensitive information.`}function qe(e){return`
|
|
18
|
+
\u{1F50C} To connect with Prisma ORM use the following connection strings:
|
|
19
|
+
|
|
20
|
+
${$("DATABASE_URL",E(e.database.prismaORMConnectionString))}
|
|
21
|
+
${$("SHADOW_DATABASE_URL",E(e.shadowDatabase.prismaORMConnectionString))}
|
|
22
|
+
|
|
23
|
+
\u{1F418} You can also use the ${s("DATABASE_URL")} with the ${s("pg")} or ${s("postgres.js")} JavaScript drivers as well as your favorite DB gui.
|
|
24
|
+
|
|
25
|
+
For the best experience, set the maximum number of connections to ${s(10)}, connect timeout to ${s(0)} and
|
|
26
|
+
idle timeout to the smallest positive value supported.`}function xt(e){if(e.length===0)return"";let t=[...e].map(Number).sort();return t.length>1&&t.every((o,a)=>a===0||o===t[a-1]+1)?`${s(t[0])}-${s(t.at(-1))}`:e.map(s).join(", ")}function $(e,t){return`${s(e)}="${t}"`}function Fe(e){return e=new URL(e),`${y(e.protocol)}//${s(e.hostname)}:${s(e.port)}${h(e.pathname)}${h(e.search)}`}function E(e){return e=new URL(e),`${y(e.protocol)}${h(`//${e.username}:${e.password}@`)}${s(e.hostname)}${h(":")}${s(e.port)}${h(e.pathname)}${h(e.search)}`}function Ve(e){return f("italic",f("dim",f("green",`# ${e}`)))}export{Xe as a,ft as b,vt as c,qe as d,xt as e};
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as x,b as N,e as I}from"./chunk-
|
|
2
|
+
import{a as x,b as N,e as I}from"./chunk-X6T3XKLI.js";import{a as l,b as f,f as E}from"./chunk-P5JORAQS.js";import{a as C,c as d,d as P,e as R}from"./chunk-GZHQT2TW.js";import"./chunk-M6TFCQLD.js";import{startPrismaDevServer as B}from"@prisma/dev";function A(e){let t,r,o=new Promise((s,p)=>{t=s,r=p}),n=s=>{n=i=null,r(s),e?.onRejected?.(s),e?.onFulfilled?.()},i=s=>{i=n=null,t(s),e?.onResolved?.(s),e?.onFulfilled?.()};return{isFulfilled:()=>i===n,promise:o,reject:s=>n?.(s),resolve:s=>i?.(s)}}var T="0.16.2";var a={database:"db-port",server:"port",shadow_database:"shadow-db-port"},O={...R,[a.database]:{alias:"P",description:"Port number the database server will listen on.",required:!1,type:"string"},detach:{alias:"d",description:"Run the server in the background.",required:!1,type:"boolean"},name:{alias:"n",default:"default",description:"Name of the server. Helps keep state isolated between different projects. Defaults to `default`.",required:!1,type:"string"},[a.server]:{alias:"p",description:"Main port number the Prisma Dev server will listen on.",required:!1,type:"string"},[a.shadow_database]:{description:"Port number the shadow database server will listen on.",required:!1,type:"string"}},L=/^[a-zA-Z0-9-_]+$/;function k(e){let{[a.server]:t,[a.database]:r,[a.shadow_database]:o,debug:n,detach:i,name:s}=e.args,p=r?Number(r):void 0,c=t?Number(t):void 0,u=o?Number(o):void 0;return t&&Number.isNaN(c)?(console.error(`Invalid server port number provided. Please provide a valid port number in \`--${a.server}\`.`),process.exit(1)):r&&Number.isNaN(p)?(console.error(`Invalid database port number provided. Please provide a valid port number in \`--${a.database}\`.`),process.exit(1)):o&&Number.isNaN(u)?(console.error(`Invalid shadow database port number provided. Please provide a valid port number in \`--${a.shadow_database}\`.`),process.exit(1)):c!=null&&c===p?(console.error(`The server port and database port cannot be the same. Please provide different port numbers in \`--${a.server}\` and/or \`--${a.database}\`.`),process.exit(1)):p!=null&&p===u?(console.error(`The database port and shadow database port cannot be the same. Please provide different port numbers in \`--${a.database}\` and/or \`--${a.shadow_database}\`.`),process.exit(1)):c!=null&&c===u?(console.error(`The server port and shadow database port cannot be the same. Please provide different port numbers in \`--${a.server}\` and/or \`--${a.shadow_database}\`.`),process.exit(1)):L.test(s)?{databasePort:p,debug:n,detach:i,name:s,serverPort:c,shadowDatabasePort:u}:(console.error("Invalid name provided. The name can only contain letters, numbers, dashes, and underscores. Please provide a valid name in `--name`."),process.exit(1))}import{PortNotAvailableError as q,ServerAlreadyRunningError as H}from"@prisma/dev";async function v(e,t,r){if(e instanceof H)try{let n=await e.server;if(!n)return await v("Something went wrong, try again!",t,r);t.warning(` Skipped! \u{1F60C}
|
|
3
3
|
|
|
4
4
|
Your ${E} server ${f(n.name)} is already running and listening on ports ${I([n.port,n.databasePort,n.shadowDatabasePort])}.
|
|
5
5
|
|
|
6
6
|
To start a different server, use the ${`${f("-n")}/${f("--name")}`} flag with another name.
|
|
7
7
|
`);return}catch(n){return await v(n,t,r)}let{args:o}=r;throw d.error(e instanceof q?`Prisma Dev Error: port number \`${e.port}\` is already in use. Please pass a different port number in the \`--${o.port===String(e.port)?"port":o.databasePort===String(e.port)?"database":"shadow_database"}\` option.`:e),l.exitCode||=1,e}function _(e){l.on?.("uncaughtException",t=>{if("code"in t&&t.code==="ECONNRESET"){e?.debug&&d.error("uncaught ECONNRESET");return}e?.onError?.(t)})}function M(e){let t={shutdownAlreadyStarted:!1};l.once?.("SIGINT",$("SIGINT",e,t)),l.once?.("SIGTERM",$("SIGTERM",e,t))}function $(e,t,r){let{debug:o,onFailure:n,onSuccess:i,server:s}=t;return()=>{if(r.shutdownAlreadyStarted){o&&d.debug(`Received ${e} signal, ignoring.`);return}r.shutdownAlreadyStarted=!0,o&&d.debug(`${e} signal receieved.`),o&&d.log(`
|
|
8
8
|
Closing Prisma Dev...
|
|
9
|
-
`),l.exitCode=e==="SIGINT"?130:143,s.close().then(()=>{o&&d.debug("Prisma Dev server closed."),e==="SIGINT"&&(l.exitCode=0),i()}).catch(n)}}var U={description:"Create and run a new server",name:"prisma dev",version:T},b="\v",h={args:O,meta:U,run:async e=>{let{subCommands:t}=e.cmd,r=t?e.rawArgs.find(m=>!m.startsWith("-")):void 0;if(r&&r!==b&&r in t)return;let{debug:o,detach:n,name:i,serverPort:s,...p}=k(e);if(n){let m=await x(i);return d.log(m.database.connectionString)}let{renderContent:c,renderIntro:u,renderOutro:G,spinner:g}=N(i);try{let m=await V({...p,debug:o,name:i,port:s,renderIntro:u}),w=new AbortController,{isFulfilled:D,promise:j,reject:S,resolve:y}=A({onFulfilled:()=>w.abort()});M({debug:o,onFailure:S,onSuccess:y,server:m}),_({debug:o,onError:S}),await c({abortSignal:w.signal,debug:o,isClosed:D,onQuit:async()=>{await m.close(),y()},server:m,spinner:g}),await j,await G(),l.exitCode||=0}catch(m){await v(m,g,e)}},setup(e){e.args.debug&&(d.level=C.debug),d.options.formatOptions.date=!1},subCommands:{[b]:{},ls:()=>import("./list-K27C36FV.js").then(e=>e.ListCommand),rm:()=>import("./remove-3XULX44O.js").then(e=>e.RemoveCommand),start:()=>import("./start-
|
|
9
|
+
`),l.exitCode=e==="SIGINT"?130:143,s.close().then(()=>{o&&d.debug("Prisma Dev server closed."),e==="SIGINT"&&(l.exitCode=0),i()}).catch(n)}}var U={description:"Create and run a new server",name:"prisma dev",version:T},b="\v",h={args:O,meta:U,run:async e=>{let{subCommands:t}=e.cmd,r=t?e.rawArgs.find(m=>!m.startsWith("-")):void 0;if(r&&r!==b&&r in t)return;let{debug:o,detach:n,name:i,serverPort:s,...p}=k(e);if(n){let m=await x(i);return d.log(m.database.connectionString)}let{renderContent:c,renderIntro:u,renderOutro:G,spinner:g}=N(i);try{let m=await V({...p,debug:o,name:i,port:s,renderIntro:u}),w=new AbortController,{isFulfilled:D,promise:j,reject:S,resolve:y}=A({onFulfilled:()=>w.abort()});M({debug:o,onFailure:S,onSuccess:y,server:m}),_({debug:o,onError:S}),await c({abortSignal:w.signal,debug:o,isClosed:D,onQuit:async()=>{await m.close(),y()},server:m,spinner:g}),await j,await G(),l.exitCode||=0}catch(m){await v(m,g,e)}},setup(e){e.args.debug&&(d.level=C.debug),d.options.formatOptions.date=!1},subCommands:{[b]:{},ls:()=>import("./list-K27C36FV.js").then(e=>e.ListCommand),rm:()=>import("./remove-3XULX44O.js").then(e=>e.RemoveCommand),start:()=>import("./start-6AU37PKI.js").then(e=>e.StartCommand),stop:()=>import("./stop-D7RWEVES.js").then(e=>e.StopCommand)}};async function V(e){let{renderIntro:t,...r}=e,[,o]=await Promise.allSettled([e.renderIntro(),B({...r,persistenceMode:"stateful"})]);if(o.status==="rejected")throw o.reason;return o.value}async function we(e,t){let[r]=e;r==="-v"&&(e[0]="--version"),r&&!(r in h.subCommands)&&r!=="--help"&&r!=="-h"&&r!=="--version"&&r!=="-v"&&e.unshift(b),await P(h,{rawArgs:e})}export{we as run};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as m,c as u,d,e as S}from"./chunk-
|
|
2
|
+
import{a as m,c as u,d,e as S}from"./chunk-X6T3XKLI.js";import{a as i}from"./chunk-2HCX64E4.js";import{b as f,f as r,g as p,h as c}from"./chunk-P5JORAQS.js";import{c as t,e as g}from"./chunk-GZHQT2TW.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:
|
|
3
3
|
|
|
4
4
|
${i(a)}
|
|
5
5
|
`),s.length===0)return t.log(`\u26A0\uFE0F No ${r} servers found to start.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/cli-dev",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "Dev CLI for Prisma",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"common-stuff": "^0.0.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@prisma/dev": "0.
|
|
50
|
+
"@prisma/dev": "0.22.1"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "tsup",
|
package/dist/chunk-RJHC3PIO.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as v,b as s,c as S,e as m,f as b,h as y,i as O,j as C}from"./chunk-P5JORAQS.js";import{b as f,c as d}from"./chunk-GZHQT2TW.js";import{b as M}from"./chunk-M6TFCQLD.js";import{fork as E}from"child_process";import{createRequire as _}from"module";import{ServerState as A}from"@prisma/dev/internal/state";var D=_(import.meta.url).resolve("@prisma/dev/internal/daemon");async function Qt(e){let t,o,a=new Promise((n,p)=>{t=n,o=p}),i=typeof e=="string"?e:e.name,c=E(D,[i],{detached:!0,stdio:"ignore"});c.once("error",n=>{d.error(n)}),c.once("message",n=>{let{type:p}=n;if(p==="error")return o(n.error);if(p==="started")return t(n.server);o(`Unknown message type: "${p}"`)});try{return await a}catch(n){if(typeof n=="string"&&n.includes("is already running")){if(typeof e!="string")return{...e.exports,name:i};let p=await A.fromServerDump({name:i});if(!p)throw new Error(`Failed to retrieve the status of the running server "${i}".`);return{...p.exports,name:i}}throw n}finally{c.disconnect(),c.unref(),c.removeAllListeners()}}import{setTimeout as Dt}from"timers/promises";import h from"process";import{stripVTControlCharacters as wt}from"util";var l={};M(l,{bgBlack:()=>rt,bgBlue:()=>st,bgBlueBright:()=>yt,bgCyan:()=>ct,bgCyanBright:()=>Tt,bgGray:()=>ht,bgGreen:()=>nt,bgGreenBright:()=>St,bgMagenta:()=>at,bgMagentaBright:()=>Pt,bgRed:()=>ot,bgRedBright:()=>xt,bgWhite:()=>pt,bgWhiteBright:()=>$t,bgYellow:()=>it,bgYellowBright:()=>bt,black:()=>Q,blue:()=>z,blueBright:()=>dt,bold:()=>U,cyan:()=>Z,cyanBright:()=>ft,dim:()=>H,gray:()=>et,green:()=>K,greenBright:()=>mt,hidden:()=>W,inverse:()=>V,italic:()=>k,magenta:()=>J,magentaBright:()=>gt,overline:()=>F,red:()=>j,redBright:()=>lt,reset:()=>L,strikethrough:()=>Y,underline:()=>q,white:()=>tt,whiteBright:()=>vt,yellow:()=>X,yellowBright:()=>ut});import G from"tty";var N=G?.WriteStream?.prototype?.hasColors?.()??!1,r=(e,t)=>{if(!N)return i=>i;let o=`\x1B[${e}m`,a=`\x1B[${t}m`;return i=>{let c=i+"",n=c.indexOf(a);if(n===-1)return o+c+a;let p=o,u=0,x=(t===22?a:"")+o;for(;n!==-1;)p+=c.slice(u,n)+x,u=n+a.length,n=c.indexOf(a,u);return p+=c.slice(u)+a,p}},L=r(0,0),U=r(1,22),H=r(2,22),k=r(3,23),q=r(4,24),F=r(53,55),V=r(7,27),W=r(8,28),Y=r(9,29),Q=r(30,39),j=r(31,39),K=r(32,39),X=r(33,39),z=r(34,39),J=r(35,39),Z=r(36,39),tt=r(37,39),et=r(90,39),rt=r(40,49),ot=r(41,49),nt=r(42,49),it=r(43,49),st=r(44,49),at=r(45,49),ct=r(46,49),pt=r(47,49),ht=r(100,49),lt=r(91,39),mt=r(92,39),ut=r(93,39),dt=r(94,39),gt=r(95,39),ft=r(96,39),vt=r(97,39),xt=r(101,49),St=r(102,49),bt=r(103,49),yt=r(104,49),Pt=r(105,49),Tt=r(106,49),$t=r(107,49);var g=h.platform!=="win32"||!!h.env.WT_SESSION||h.env.TERM_PROGRAM==="vscode",Rt=e=>!!(e.isTTY&&h.env.TERM!=="dumb"&&!("CI"in h.env)),Ot=l.blue(g?"\u2139":"i"),Ct=l.green(g?"\u2714":"\u221A"),Bt=l.yellow(g?"\u26A0":"\u203C"),It=l.red(g?"\u2716":"\xD7"),Mt={frames:g?["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]:["-","\\","|","/"],interval:80},P=class{#p;#h;#n=-1;#i;#r;#t;#s;#l=0;#o;#e;#d=0;#m=!1;constructor(t={}){let o=t.spinner??Mt;this.#p=o.frames,this.#h=o.interval,this.#r=t.text??"",this.#t=t.stream??h.stderr,this.#s=t.color??"cyan",this.#e=Rt(this.#t),this.#o=this.#b.bind(this)}start(t){return t&&(this.#r=t),this.isSpinning?this:(this.#m=!0,this.#f(),this.#c(),this.#x(),this.#e&&(this.#i=setInterval(()=>{this.#c()},this.#h)),this)}stop(t){return this.isSpinning?(this.#m=!1,this.#i&&(clearInterval(this.#i),this.#i=void 0),this.#v(),this.clear(),this.#S(),t&&this.#t.write(`${t}
|
|
3
|
-
`),this):this}#a(t,o){return this.stop(`${t} ${o??this.#r}`)}success(t){return this.#a(Ct,t)}error(t){return this.#a(It,t)}warning(t){return this.#a(Bt,t)}info(t){return this.#a(Ot,t)}get isSpinning(){return this.#m}get text(){return this.#r}set text(t){this.#r=t??"",this.#c()}get color(){return this.#s}set color(t){this.#s=t,this.#c()}clear(){if(!this.#e)return this;this.#t.cursorTo(0);for(let t=0;t<this.#l;t++)t>0&&this.#t.moveCursor(0,-1),this.#t.clearLine(1);return this.#l=0,this}#c(){let t=Date.now();(this.#n===-1||t-this.#d>=this.#h)&&(this.#n=++this.#n%this.#p.length,this.#d=t);let o=l[this.#s]??l.cyan,a=this.#p[this.#n],i=`${o(a)} ${this.#r}`;this.#e||(i+=`
|
|
4
|
-
`),this.clear(),this.#u(i),this.#e&&(this.#l=this.#g(i))}#u(t){this.#t.write(t)}#g(t){let o=this.#t.columns??80,a=wt(t).split(`
|
|
5
|
-
`),i=0;for(let c of a)i+=Math.max(1,Math.ceil(c.length/o));return i}#f(){this.#e&&this.#u("\x1B[?25l")}#v(){this.#e&&this.#u("\x1B[?25h")}#x(){h.once("SIGINT",this.#o),h.once("SIGTERM",this.#o)}#S(){h.off("SIGINT",this.#o),h.off("SIGTERM",this.#o)}#b(t){this.isSpinning&&this.stop();let o=t==="SIGINT"?130:t==="SIGTERM"?143:1;h.exit(o)}};function T(e){return new P(e)}var Et=[{value:"q",label:"quit"}],$=3;function B(e){let t=new C({debug:e?.debug,options:Et,render:_t,signal:e?.abortSignal});return{clearPrompt(){v.stdout.moveCursor(0,-$),v.stdout.cursorTo(0),v.stdout.clearScreenDown()},prompt:t,respond:async o=>{if(O(o)||o==="q")return await e?.onQuit?.();await e?.onOption?.[o]?.()}}}function _t(){return At()}function At(){let e="Press q to quit",t=`\u250C${"\u2500".repeat(e.length+2)}\u2510`,o=`\u2514${"\u2500".repeat(e.length+2)}\u2518`;return["",t,`\u2502 ${e} \u2502`,o].join(`
|
|
6
|
-
`)}function ue(e){let t=T();return{renderContent:Gt,renderIntro:()=>Lt(e,t),renderOutro:()=>Promise.resolve(Ut(e)),spinner:t}}async function Gt(e){let{abortSignal:t,debug:o,isClosed:a,onQuit:i,server:c,spinner:n}=e;if(n.success(Nt(c)),d.log(Ht(c)),!!y)for(;!a();){let{clearPrompt:p,prompt:u,respond:R}=B({abortSignal:t,debug:o,onQuit:i}),x=await u.prompt();p(),t.aborted||await R(x)}}function Nt(e){return` Your local Prisma Postgres server ${s(e.name)} is now running \u{1F44D}`}async function Lt(e,t){t.start(` Starting ${b} server ${s(e)}...${`
|
|
7
|
-
`.repeat($+3)}`),y&&await Dt(250)}function Ut(e){d.log(`\u{1F44B} Buh Bye!
|
|
8
|
-
|
|
9
|
-
Your ${b} server ${s(e)} has been closed successfully.
|
|
10
|
-
`)}function de(e){return`\u{1F50C} To connect to your local Prisma Postgres database via HTTP + Prisma ORM
|
|
11
|
-
use the following connection string:
|
|
12
|
-
|
|
13
|
-
${qt("\u{1F4C4} .env:")}
|
|
14
|
-
|
|
15
|
-
${w("DATABASE_URL",kt(e.ppg.url))}
|
|
16
|
-
|
|
17
|
-
\u2728 The ${s("api_key")} above does not contain any sensitive information.`}function Ht(e){return`
|
|
18
|
-
\u{1F50C} To connect with Prisma ORM use the following connection strings:
|
|
19
|
-
|
|
20
|
-
${w("DATABASE_URL",I(e.database.prismaORMConnectionString))}
|
|
21
|
-
${w("SHADOW_DATABASE_URL",I(e.shadowDatabase.prismaORMConnectionString))}
|
|
22
|
-
|
|
23
|
-
\u{1F418} You can also use the ${s("DATABASE_URL")} with the ${s("pg")} or ${s("postgres.js")} JavaScript drivers as well as your favorite DB gui.
|
|
24
|
-
|
|
25
|
-
For the best experience, set the maximum number of connections to ${s(10)}, connect timeout to ${s(0)} and
|
|
26
|
-
idle timeout to the smallest positive value supported.`}function ge(e){if(e.length===0)return"";let t=[...e].map(Number).sort();return t.length>1&&t.every((o,a)=>a===0||o===t[a-1]+1)?`${s(t[0])}-${s(t.at(-1))}`:e.map(s).join(", ")}function w(e,t){return`${s(e)}="${t}"`}function kt(e){return e=new URL(e),`${S(e.protocol)}//${s(e.hostname)}:${s(e.port)}${m(e.pathname)}${m(e.search)}`}function I(e){return e=new URL(e),`${S(e.protocol)}${m(`//${e.username}:${e.password}@`)}${s(e.hostname)}${m(":")}${s(e.port)}${m(e.pathname)}${m(e.search)}`}function qt(e){return f("italic",f("dim",f("green",`# ${e}`)))}export{Qt as a,ue as b,de as c,Ht as d,ge as e};
|