@dataramen/cli 0.0.67-beta.1 → 0.0.67

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.
package/README.md CHANGED
@@ -1,75 +1,75 @@
1
- # 🍜 DataRamen CLI
2
-
3
- Your cozy corner for exploring and working with SQL databases - no query writing required.
4
-
5
- DataRamen CLI lets you launch a powerful, local database exploration app that connects effortlessly to MySQL and PostgreSQL databases. Browse schemas, follow relationships, and insert/update data - all from your browser.
6
-
7
- ## ✨ Features
8
-
9
- - 🔌 **Connect to PostgreSQL & MySQL**
10
- Securely plug in your credentials - you're ready to explore.
11
-
12
- - 🧭 **Visual Schema Explorer**
13
- Instantly browse tables, columns, types, primary/foreign keys, and relationships.
14
-
15
- - 🧙 **No-SQL Querying**
16
- Filter, sort, join, and summarize data using a beautiful, intuitive interface.
17
-
18
- - 🔗 **Follow Relationships Easily**
19
- Click to expand related records.
20
-
21
- - ✏️ **Insert & Update Visually**
22
- Add or modify rows with a visual editor - no SQL errors.
23
-
24
- - 💾 **Save Queries**
25
- Save your favorite views for quick access later.
26
-
27
- ## 🛠️ Installation
28
-
29
- ### 1. Install Node.js
30
-
31
- DataRamen requires Node.js **v22 or above**.
32
- 👉 [Download Node.js](https://nodejs.org/)
33
-
34
- ### 2. Install DataRamen CLI
35
-
36
- Open your terminal and run:
37
-
38
- ```bash
39
- npm i -g @dataramen/cli
40
- ```
41
-
42
- ## 🖥️ Usage
43
-
44
- ### Start the Local Server
45
-
46
- ```bash
47
- dataramen start
48
- ```
49
-
50
- ### Open the App
51
-
52
- Go to `localhost:4466` in your browser. Your local server will connect automatically.
53
-
54
- ### Update the App
55
-
56
- You can update DataRamen CLI using `NPM` install command:
57
-
58
- ```bash
59
- npm i -g @dataramen/cli
60
- ```
61
-
62
- The above command will install latest stable version.
63
-
64
- ## 🔧 Additional CLI Commands
65
-
66
- | Command | Description |
67
- |-------------------|----------------------------------|
68
- | `dataramen start` | Start the local DataRamen server |
69
- | `dataramen stop` | Stop the local server |
70
- | `dataramen open` | Open local webapp |
71
- | `dataramen logs` | Show logs from the running server|
72
-
73
- ## ❤️ Made with love by [Oleksandr Demian](https://github.com/OleksandrDemian)
74
-
75
- Visit [dataramen.xyz](https://dataramen.xyz) for more info.
1
+ # 🍜 DataRamen CLI
2
+
3
+ Your cozy corner for exploring and working with SQL databases - no query writing required.
4
+
5
+ DataRamen CLI lets you launch a powerful, local database exploration app that connects effortlessly to MySQL and PostgreSQL databases. Browse schemas, follow relationships, and insert/update data - all from your browser.
6
+
7
+ ## ✨ Features
8
+
9
+ - 🔌 **Connect to PostgreSQL & MySQL**
10
+ Securely plug in your credentials - you're ready to explore.
11
+
12
+ - 🧭 **Visual Schema Explorer**
13
+ Instantly browse tables, columns, types, primary/foreign keys, and relationships.
14
+
15
+ - 🧙 **No-SQL Querying**
16
+ Filter, sort, join, and summarize data using a beautiful, intuitive interface.
17
+
18
+ - 🔗 **Follow Relationships Easily**
19
+ Click to expand related records.
20
+
21
+ - ✏️ **Insert & Update Visually**
22
+ Add or modify rows with a visual editor - no SQL errors.
23
+
24
+ - 💾 **Save Queries**
25
+ Save your favorite views for quick access later.
26
+
27
+ ## 🛠️ Installation
28
+
29
+ ### 1. Install Node.js
30
+
31
+ DataRamen requires Node.js **v22 or above**.
32
+ 👉 [Download Node.js](https://nodejs.org/)
33
+
34
+ ### 2. Install DataRamen CLI
35
+
36
+ Open your terminal and run:
37
+
38
+ ```bash
39
+ npm i -g @dataramen/cli
40
+ ```
41
+
42
+ ## 🖥️ Usage
43
+
44
+ ### Start the Local Server
45
+
46
+ ```bash
47
+ dataramen start
48
+ ```
49
+
50
+ ### Open the App
51
+
52
+ Go to `localhost:4466` in your browser. Your local server will connect automatically.
53
+
54
+ ### Update the App
55
+
56
+ You can update DataRamen CLI using `NPM` install command:
57
+
58
+ ```bash
59
+ npm i -g @dataramen/cli
60
+ ```
61
+
62
+ The above command will install latest stable version.
63
+
64
+ ## 🔧 Additional CLI Commands
65
+
66
+ | Command | Description |
67
+ |-------------------|----------------------------------|
68
+ | `dataramen start` | Start the local DataRamen server |
69
+ | `dataramen stop` | Stop the local server |
70
+ | `dataramen open` | Open local webapp |
71
+ | `dataramen logs` | Show logs from the running server|
72
+
73
+ ## ❤️ Made with love by [Oleksandr Demian](https://github.com/OleksandrDemian)
74
+
75
+ Visit [dataramen.xyz](https://dataramen.xyz) for more info.
package/bin/app.js CHANGED
File without changes
package/dist/README.md CHANGED
@@ -1,75 +1,75 @@
1
- # 🍜 DataRamen CLI
2
-
3
- Your cozy corner for exploring and working with SQL databases - no query writing required.
4
-
5
- DataRamen CLI lets you launch a powerful, local database exploration app that connects effortlessly to MySQL and PostgreSQL databases. Browse schemas, follow relationships, and insert/update data - all from your browser.
6
-
7
- ## ✨ Features
8
-
9
- - 🔌 **Connect to PostgreSQL & MySQL**
10
- Securely plug in your credentials - you're ready to explore.
11
-
12
- - 🧭 **Visual Schema Explorer**
13
- Instantly browse tables, columns, types, primary/foreign keys, and relationships.
14
-
15
- - 🧙 **No-SQL Querying**
16
- Filter, sort, join, and summarize data using a beautiful, intuitive interface.
17
-
18
- - 🔗 **Follow Relationships Easily**
19
- Click to expand related records.
20
-
21
- - ✏️ **Insert & Update Visually**
22
- Add or modify rows with a visual editor - no SQL errors.
23
-
24
- - 💾 **Save Queries**
25
- Save your favorite views for quick access later.
26
-
27
- ## 🛠️ Installation
28
-
29
- ### 1. Install Node.js
30
-
31
- DataRamen requires Node.js **v22 or above**.
32
- 👉 [Download Node.js](https://nodejs.org/)
33
-
34
- ### 2. Install DataRamen CLI
35
-
36
- Open your terminal and run:
37
-
38
- ```bash
39
- npm i -g @dataramen/cli
40
- ```
41
-
42
- ## 🖥️ Usage
43
-
44
- ### Start the Local Server
45
-
46
- ```bash
47
- dataramen start
48
- ```
49
-
50
- ### Open the App
51
-
52
- Go to `localhost:4466` in your browser. Your local server will connect automatically.
53
-
54
- ### Update the App
55
-
56
- You can update DataRamen CLI using `NPM` install command:
57
-
58
- ```bash
59
- npm i -g @dataramen/cli
60
- ```
61
-
62
- The above command will install latest stable version.
63
-
64
- ## 🔧 Additional CLI Commands
65
-
66
- | Command | Description |
67
- |-------------------|----------------------------------|
68
- | `dataramen start` | Start the local DataRamen server |
69
- | `dataramen stop` | Stop the local server |
70
- | `dataramen open` | Open local webapp |
71
- | `dataramen logs` | Show logs from the running server|
72
-
73
- ## ❤️ Made with love by [Oleksandr Demian](https://github.com/OleksandrDemian)
74
-
75
- Visit [dataramen.xyz](https://dataramen.xyz) for more info.
1
+ # 🍜 DataRamen CLI
2
+
3
+ Your cozy corner for exploring and working with SQL databases - no query writing required.
4
+
5
+ DataRamen CLI lets you launch a powerful, local database exploration app that connects effortlessly to MySQL and PostgreSQL databases. Browse schemas, follow relationships, and insert/update data - all from your browser.
6
+
7
+ ## ✨ Features
8
+
9
+ - 🔌 **Connect to PostgreSQL & MySQL**
10
+ Securely plug in your credentials - you're ready to explore.
11
+
12
+ - 🧭 **Visual Schema Explorer**
13
+ Instantly browse tables, columns, types, primary/foreign keys, and relationships.
14
+
15
+ - 🧙 **No-SQL Querying**
16
+ Filter, sort, join, and summarize data using a beautiful, intuitive interface.
17
+
18
+ - 🔗 **Follow Relationships Easily**
19
+ Click to expand related records.
20
+
21
+ - ✏️ **Insert & Update Visually**
22
+ Add or modify rows with a visual editor - no SQL errors.
23
+
24
+ - 💾 **Save Queries**
25
+ Save your favorite views for quick access later.
26
+
27
+ ## 🛠️ Installation
28
+
29
+ ### 1. Install Node.js
30
+
31
+ DataRamen requires Node.js **v22 or above**.
32
+ 👉 [Download Node.js](https://nodejs.org/)
33
+
34
+ ### 2. Install DataRamen CLI
35
+
36
+ Open your terminal and run:
37
+
38
+ ```bash
39
+ npm i -g @dataramen/cli
40
+ ```
41
+
42
+ ## 🖥️ Usage
43
+
44
+ ### Start the Local Server
45
+
46
+ ```bash
47
+ dataramen start
48
+ ```
49
+
50
+ ### Open the App
51
+
52
+ Go to `localhost:4466` in your browser. Your local server will connect automatically.
53
+
54
+ ### Update the App
55
+
56
+ You can update DataRamen CLI using `NPM` install command:
57
+
58
+ ```bash
59
+ npm i -g @dataramen/cli
60
+ ```
61
+
62
+ The above command will install latest stable version.
63
+
64
+ ## 🔧 Additional CLI Commands
65
+
66
+ | Command | Description |
67
+ |-------------------|----------------------------------|
68
+ | `dataramen start` | Start the local DataRamen server |
69
+ | `dataramen stop` | Stop the local server |
70
+ | `dataramen open` | Open local webapp |
71
+ | `dataramen logs` | Show logs from the running server|
72
+
73
+ ## ❤️ Made with love by [Oleksandr Demian](https://github.com/OleksandrDemian)
74
+
75
+ Visit [dataramen.xyz](https://dataramen.xyz) for more info.
package/dist/code/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var G=Object.create;var V=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var X=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Q(t))!z.call(e,n)&&n!==r&&V(e,n,{get:()=>t[n],enumerable:!(a=U(t,n))||a.enumerable});return e};var u=(e,t,r)=>(r=e!=null?G(q(e)):{},X(t||!e||!e.__esModule?V(r,"default",{value:e,enumerable:!0}):r,e));var B=require("commander");var C=require("node:os"),N=require("node:path"),Z=(0,C.homedir)(),c="@dataramen/server",i=(0,N.join)(Z,".dataramen",".runtime","server");var Y=require("node:path"),D=u(require("fs-extra")),K=require("node:child_process");var k=u(require("fs-extra")),P=require("node:path");function A(e){let t;function r(){try{return t||(t=k.readJsonSync(e)),t}catch{return}}return r}var v=A((0,P.join)(__dirname,"..","package.json")),S=A((0,P.join)(i,"package.json"));var p=u(require("fs-extra")),f=require("node:path"),M=require("node:child_process"),$=require("node:util"),E=u(require("yocto-spinner")),g=(0,$.promisify)(M.exec);function I(){try{let e=S();if(!e)return!0;let t=p.readJsonSync((0,f.join)(__dirname,"..","dist","package.json"));return e.version!==t.version}catch{return!0}}async function W(){let e=(0,E.default)({text:"Checking if PM2 is installed"}).start();try{return await g("pm2 -v"),e.success("PM2 already installed"),!0}catch{return e.warning("PM2 not installed"),!1}}async function j(){let e=(0,E.default)({text:"Installing PM2"}).start();try{await g("npm i -g pm2"),e.success("Installed PM2")}catch{e.error("Failed to install PM2"),process.exit(1)}}async function b(){let e=(0,E.default)({text:"Stop running instances of "+c}).start();try{await g(`pm2 stop "${c}"`),e.warning("Stopped "+c)}catch{e.success("No running instances of "+c+" found")}}async function J(){let e=(0,E.default)({text:"Create local server"}).start();p.removeSync((0,f.join)(i,"code")),p.copySync((0,f.join)(__dirname,"..","dist","code"),(0,f.join)(i,"code")),p.copySync((0,f.join)(__dirname,"..","dist","package.json"),(0,f.join)(i,"package.json")),e.text="Install local server dependencies",await g("npm i",{cwd:i}),e.success("Local server installed")}var x=u(require("yocto-spinner")),T=u(require("open"));var H=require("node:net");async function O(e){return new Promise(t=>{let r=(0,H.createServer)().once("error",()=>{t(!1)}).once("listening",()=>{r.close()}).once("close",()=>t(!0)).listen(e,"127.0.0.1")})}var y=u(require("node:crypto"));var h=require("fs-extra"),_=require("node:path");function ee(e){try{return(0,h.readFileSync)((0,_.join)(i,e),"utf-8")}catch{return}}function te(e){let t={},r=ee(e);if(r){let a=r.split(`
3
- `);for(let n of a){let s=n.trim();if(!s||s.startsWith("#"))continue;let d=s.indexOf("=");if(d===-1)continue;let R=s.slice(0,d).trim(),m=s.slice(d+1).trim();(m.startsWith('"')&&m.endsWith('"')||m.startsWith("'")&&m.endsWith("'"))&&(m=m.slice(1,-1)),t[R]=m}}return t}function ne(){let e={customValues:{},fileName:".env"};function t(){e.customValues=te(e.fileName)}function r(){let s=Object.entries(e.customValues).map(([d,R])=>`${d}=${R}`).join(`
2
+ var se=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var le=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ae(t))!ce.call(e,r)&&r!==o&&R(e,r,{get:()=>t[r],enumerable:!(s=ie(t,r))||s.enumerable});return e};var c=(e,t,o)=>(o=e!=null?se(me(e)):{},le(t||!e||!e.__esModule?R(o,"default",{value:e,enumerable:!0}):o,e));var P=require("commander"),C=(e,t)=>{t.commands.forEach(o=>{e.command(o.command).description(o.description).action(o.handler)})};function _(){let e=new P.Command,t={id:"commander",setMetadata:o=>(e.name(o.name).description(o.description).version(o.version,"-v, --version","Show version"),t),setDefaultCommand:o=>(e.command("default",{hidden:!0,isDefault:!0}).action(o.handler),t),setModules:o=>(o.forEach(s=>{if(s.name==="root")C(e,s);else{let r=e.command(s.name).description(`(Module) ${s.description}`);C(r,s)}}),t),start:()=>(e.parse(),t),getHandler:()=>e};return t}var V=c(require("fs-extra")),y=require("node:path");var b=require("node:os"),M=require("node:path"),pe=(0,b.homedir)(),m="@dataramen/server",a=(0,M.join)(pe,".dataramen",".runtime","server");function A(e){let t;function o(){try{return t||(t=V.readJsonSync(e)),t}catch{return}}return o}var N=A((0,y.join)(__dirname,"..","package.json")),k=A((0,y.join)(a,"package.json"));var u=c(require("fs-extra")),p=require("node:path"),H=require("node:child_process"),O=require("node:util"),g=c(require("yocto-spinner")),f=(0,O.promisify)(H.exec);function W(){try{let e=k();if(!e)return!0;let t=u.readJsonSync((0,p.join)(__dirname,"..","dist","package.json"));return e.version!==t.version}catch{return!0}}async function $(){let e=(0,g.default)({text:"Checking if PM2 is installed"}).start();try{return await f("pm2 -v"),e.success("PM2 already installed"),!0}catch{return e.warning("PM2 not installed"),!1}}async function j(){let e=(0,g.default)({text:"Installing PM2"}).start();try{await f("npm i -g pm2"),e.success("Installed PM2")}catch{e.error("Failed to install PM2"),process.exit(1)}}async function v(){let e=(0,g.default)({text:"Stop running instances of "+m}).start();try{await f(`pm2 stop "${m}"`),e.warning("Stopped "+m)}catch{e.success("No running instances of "+m+" found")}}async function I(){let e=(0,g.default)({text:"Create local server"}).start();u.removeSync((0,p.join)(a,"code")),u.copySync((0,p.join)(__dirname,"..","dist","code"),(0,p.join)(a,"code")),u.copySync((0,p.join)(__dirname,"..","dist","package.json"),(0,p.join)(a,"package.json")),e.text="Install local server dependencies",await f("npm i",{cwd:a}),e.success("Local server installed")}var S=c(require("node:crypto"));var E=require("fs-extra"),w=require("node:path");function ue(e){try{return(0,E.readFileSync)((0,w.join)(a,e),"utf-8")}catch{return}}function de(e){let t={},o=ue(e);if(o){let s=o.split(`
3
+ `);for(let r of s){let i=r.trim();if(!i||i.startsWith("#"))continue;let d=i.indexOf("=");if(d===-1)continue;let T=i.slice(0,d).trim(),l=i.slice(d+1).trim();(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),t[T]=l}}return t}function fe(){let e={customValues:{},fileName:".env"};function t(){e.customValues=de(e.fileName)}function o(){let i=Object.entries(e.customValues).map(([d,T])=>`${d}=${T}`).join(`
4
4
  `)+`
5
- `;(0,h.writeFileSync)((0,_.join)(i,e.fileName),s,{encoding:"utf8"})}function a(n){if(e.customValues[n])return e.customValues[n]}return t(),{getNumber:n=>re(a(n)),getString:n=>oe(a(n)),getBoolean:n=>se(a(n)),flush:r,set:(n,s)=>{e.customValues[n]=s},unset:n=>{delete e.customValues[n]}}}function re(e){if(!e)return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;throw new Error("Wrong env value type")}function oe(e){if(e){if(typeof e=="string")return e;throw new Error("Wrong env value type")}}function se(e){if(!e)return;let t=e.toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1;throw new Error("Wrong env value type")}var o=ne();function F(){let e=!1;if(!o.getString("SYMM_ENCRYPTION_KEY")){let t=y.randomBytes(32).toString("hex");o.set("SYMM_ENCRYPTION_KEY",t),console.log("Generated random SYMM_ENCRYPTION_KEY"),e=!0}if(!o.getString("JWT_SECRET")){let t=y.randomBytes(32).toString("hex");o.set("JWT_SECRET",t),console.log("Generated random JWT_SECRET"),e=!0}if(!o.getString("JWT_REFRESH_SECRET")){let t=y.randomBytes(32).toString("hex");o.set("JWT_REFRESH_SECRET",t),console.log("Generated random JWT_REFRESH_SECRET"),e=!0}e&&o.flush()}var ie=async e=>{try{return(await fetch(e,{method:"GET",signal:AbortSignal.timeout(5e3)})).status===200}catch{return!1}},L=async(e,t,r)=>{let a=Date.now();for(;Date.now()-a<t;){if(await ie(e))return!0;await new Promise(s=>setTimeout(s,r))}return!1};async function le(){await W()||await j(),await b();try{I()&&await J(),F();let t=o.getNumber("PORT")||4466;if(!t)throw new Error("PORT env variable not found");if(!await O(t))throw new Error(`Port ${t} is occupied by another process`);let a=(0,x.default)({text:"Starting new instance of "+c}).start(),n=D.readJsonSync((0,Y.join)(i,"package.json"));await g(`pm2 start "${n.main}" --name "${c}" --no-autorestart -- "${i}/.env"`,{cwd:i}),a.success("Local server will be available in a couple of seconds");let s=(0,x.default)({text:"Waiting for the server to become available"}).start();await L(`http://localhost:${t}/api/status`,3e4,1e3)?(await(0,T.default)(`http://localhost:${t}`),s.success(`App is running at http://localhost:${t}`)):s.error("Server failed to become available in time")}catch(t){console.error("Failed to start local server",t)}}async function me(){(0,K.execSync)(`pm2 logs ${c}`,{stdio:"inherit"})}async function ue(){await b()}function fe(){console.log(`DataRamen CLI version: ${v().version}`),console.log(`DataRamen local server version: ${S().version}`)}async function pe(){let e=o.getNumber("PORT");await(0,T.default)(`http://localhost:${e}`)}function de(e,t){o.set(e,t),o.flush(),console.log(`Environment property set: ${e}`)}function ge(e){o.unset(e),o.flush(),console.log(`Environment property unset: ${e}`)}var l={start:le,logs:me,stop:ue,version:fe,open:pe,setEnvVariable:de,unsetEnvVariable:ge};var w=new B.Command,Ee=[{command:"start",description:"Start local server, restarts if already running",handler:l.start},{command:"logs",description:"Listen for logs",handler:l.logs},{command:"stop",description:"Stop the server",handler:l.stop},{command:"open",description:"Stop the server",handler:l.open},{command:"set <prop> <value>",description:"Set env value",handler:l.setEnvVariable},{command:"unset <prop>",description:"Remove env value",handler:l.unsetEnvVariable}];w.name("dataramen").description("A cozy web GUI for MySQL and PostgreSQL - built for developers who like to move fast and stay focused.").version(v().version,"-v, --version","Show version");w.command("default",{hidden:!0,isDefault:!0}).action(l.start);Ee.forEach(e=>{w.command(e.command).description(e.description).action(e.handler)});w.parse();
5
+ `;(0,E.writeFileSync)((0,w.join)(a,e.fileName),i,{encoding:"utf8"})}function s(r){if(e.customValues[r])return e.customValues[r]}return t(),{getNumber:r=>ge(s(r)),getString:r=>ve(s(r)),getBoolean:r=>Ee(s(r)),flush:o,set:(r,i)=>{e.customValues[r]=i.toString()},unset:r=>{delete e.customValues[r]},values:()=>({...e.customValues})}}function ge(e){if(!e)return;let t=Number(e);if(!isNaN(t)&&e.trim()!=="")return t;throw new Error("Wrong env value type")}function ve(e){if(e){if(typeof e=="string")return e;throw new Error("Wrong env value type")}}function Ee(e){if(!e)return;let t=e.toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1;throw new Error("Wrong env value type")}var n=fe();function J(){let e=!1;if(!n.getString("SYMM_ENCRYPTION_KEY")){let t=S.randomBytes(32).toString("hex");n.set("SYMM_ENCRYPTION_KEY",t),console.log("Generated random SYMM_ENCRYPTION_KEY"),e=!0}if(!n.getString("JWT_SECRET")){let t=S.randomBytes(32).toString("hex");n.set("JWT_SECRET",t),console.log("Generated random JWT_SECRET"),e=!0}if(!n.getString("JWT_REFRESH_SECRET")){let t=S.randomBytes(32).toString("hex");n.set("JWT_REFRESH_SECRET",t),console.log("Generated random JWT_REFRESH_SECRET"),e=!0}e&&n.flush()}var F=require("node:net");async function L(e){return new Promise(t=>{let o=(0,F.createServer)().once("error",()=>{t(!1)}).once("listening",()=>{o.close()}).once("close",()=>t(!0)).listen(e,"127.0.0.1")})}var x=c(require("yocto-spinner"));var D=c(require("fs-extra")),K=require("node:path");var Se=async e=>{try{return(await fetch(e,{method:"GET",signal:AbortSignal.timeout(5e3)})).status===200}catch{return!1}},Y=async(e,t,o)=>{let s=Date.now();for(;Date.now()-s<t;){if(await Se(e))return!0;await new Promise(i=>setTimeout(i,o))}return!1};var B=c(require("open")),ye={command:"start",description:"Start local server, restarts if already running",handler:async()=>{await $()||await j(),await v();try{W()&&await I(),J();let t=n.getNumber("PORT")||4466;if(!t)throw new Error("PORT env variable not found");if(!await L(t))throw new Error(`Port ${t} is occupied by another process`);let s=(0,x.default)({text:"Starting new instance of "+m}).start(),r=D.readJsonSync((0,K.join)(a,"package.json"));await f(`pm2 start "${r.main}" --name "${m}" --no-autorestart -- local "${a}/.env"`,{cwd:a}),s.success("Local server will be available in a couple of seconds");let i=(0,x.default)({text:"Waiting for the server to become available"}).start();await Y(`http://localhost:${t}/api/status`,3e4,1e3)?(await(0,B.default)(`http://localhost:${t}`),i.success(`App is running at http://localhost:${t}`)):i.error("Server failed to become available in time")}catch(t){console.error("Failed to start local server",t)}}},h=ye;var G=require("node:child_process");var we={command:"logs",description:"Listen for logs",handler:async()=>{(0,G.execSync)(`pm2 logs ${m}`,{stdio:"inherit"})}},U=we;var xe={command:"stop",description:"Stop the server",handler:v},Q=xe;var q=c(require("open")),Re={command:"open",description:"Open webapp",handler:async()=>{let e=n.getNumber("PORT");await(0,q.default)(`http://localhost:${e}`)}},z=Re;var X={name:"root",description:"Root module has no description",commands:[h,U,Q,z]};var Ce={command:"set <prop> <value>",description:"Set env value",module:"env",handler:async(e,t)=>{n.set(e,t),n.flush(),console.log(`Environment property set: ${e}`)}},Z=Ce;var Pe={command:"unset <prop>",description:"Remove env value",module:"env",handler:async e=>{n.unset(e),n.flush(),console.log(`Environment property unset: ${e}`)}},ee=Pe;var _e={command:"list",description:"List env values",module:"env",handler:async()=>{console.table(n.values())}},te=_e;var oe={name:"env",description:"Handle env variables",commands:[Z,ee,te]};var re=[X,oe],ne=h;var be=_();be.setMetadata({name:"dataramen",description:"A cozy web GUI for MySQL and PostgreSQL - built for developers who like to move fast and stay focused.",version:N().version}).setDefaultCommand(ne).setModules(re).start();