@dataramen/cli 0.0.19 → 0.0.20
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/bin/run.js +1 -1
- package/dist/code/cli.js +1 -1
- package/dist/package.json +1 -1
- package/package.json +2 -1
- package/dist/code/register.windows.js +0 -44
package/bin/run.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var J=Object.create;var P=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var N=(r,t,o,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of B(t))!H.call(r,m)&&m!==o&&P(r,m,{get:()=>t[m],enumerable:!(p=T(t,m))||p.enumerable});return r};var a=(r,t,o)=>(o=r!=null?J(D(r)):{},N(t||!r||!r.__esModule?P(o,"default",{value:r,enumerable:!0}):o,r));var F=a(require("yargs")),I=require("yargs/helpers");var v=require("node:os"),y=require("node:path"),V=(0,v.homedir)();var e="@dataramen/local-server",n=(0,y.join)(V,".dataramen",".runtime","server");var O=require("node:path"),L=a(require("fs-extra")),$=require("node:child_process");var x=a(require("fs-extra")),u=require("node:path");function S(r){let t;function o(){try{return t||(t=x.readJsonSync(r)),t}catch{return}}return o}var h=S((0,u.join)(__dirname,"..","package.json")),d=S((0,u.join)(n,"package.json"));var c=a(require("fs-extra")),s=require("node:path"),w=require("node:child_process"),E=require("node:util"),l=a(require("yocto-spinner")),i=(0,E.promisify)(w.exec);function _(){try{let r=d();if(!r)return!0;let t=c.readJsonSync((0,s.join)(__dirname,"..","dist","package.json"));return r.version!==t.version}catch{return!0}}async function k(){let r=(0,l.default)({text:"Checking if PM2 is installed"}).start();try{return await i("pm2 -v"),r.success("PM2 already installed"),!0}catch{return r.warning("PM2 not installed"),!1}}async function R(){let r=(0,l.default)({text:"Installing PM2"}).start();try{await i("npm i -g pm2"),r.success("Installed PM2")}catch{r.error("Failed to install PM2"),process.exit(1)}}async function j(){let r=(0,l.default)({text:"Stop running instances of "+e}).start();try{await i(`pm2 stop "${e}"`),r.warning("Stopped "+e)}catch{r.success("No running instances of "+e+" found")}}async function A(){let r=(0,l.default)({text:"Create local server"}).start();c.copySync((0,s.join)(__dirname,"..","dist","code"),(0,s.join)(n,"code")),c.copySync((0,s.join)(__dirname,"..","dist","env",".env.default"),(0,s.join)(n,"env",".env.default")),c.copySync((0,s.join)(__dirname,"..","dist","package.json"),(0,s.join)(n,"package.json")),r.text="Install local server dependencies",await i("npm i",{cwd:n}),r.success("Local server installed")}var g=a(require("yocto-spinner")),b=a(require("open"));var C=require("node:net");async function M(r){return new Promise(t=>{let o=(0,C.createServer)().once("error",()=>{t(!1)}).once("listening",()=>{o.close()}).once("close",()=>t(!0)).listen(r,"0.0.0.0")})}async function z(){await k()||await R(),await j();try{if(_()&&await A(),!await M(4466))throw new Error("Port 4466 is occupied by another process");let o=(0,g.default)({text:"Starting new instance of "+e}).start(),p=L.readJsonSync((0,O.join)(n,"package.json"));await i(`pm2 start "${p.main}" --name "${e}" --no-autorestart`,{cwd:n}),o.success("Local server will be available in a couple of seconds"),console.log("You can close this window"),await(0,b.default)("https://app.dataramen.xyz"),console.log("App is running at https://app.dataramen.xyz")}catch(t){console.error("Failed to start local server",t)}}async function W(){(0,$.execSync)(`pm2 logs ${e}`,{stdio:"inherit"})}async function Y(){let r=(0,g.default)({text:"Stopping local server"}).start();await i(`pm2 stop ${e}`),r.success("Local server stopped")}function q(){console.log(`Dataramen CLI version: ${h().version}`),console.log(`Dataramen local server version: ${d().version}`)}var f={start:z,logs:W,stop:Y,version:q};(0,F.default)((0,I.hideBin)(process.argv)).command("start","Default command, start/restart the server",f.start).command(["logs"],"Listen for logs",f.logs).command("stop","Stop the server",f.stop).command(["version"],"Show version",f.version).parse();
|
package/dist/code/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var J=Object.create;var P=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var N=(r,t,o,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of B(t))!H.call(r,m)&&m!==o&&P(r,m,{get:()=>t[m],enumerable:!(p=T(t,m))||p.enumerable});return r};var a=(r,t,o)=>(o=r!=null?J(D(r)):{},N(t||!r||!r.__esModule?P(o,"default",{value:r,enumerable:!0}):o,r));var F=a(require("yargs")),I=require("yargs/helpers");var v=require("node:os"),y=require("node:path"),V=(0,v.homedir)();var e="@dataramen/local-server",n=(0,y.join)(V,".dataramen",".runtime","server");var O=require("node:path"),L=a(require("fs-extra")),$=require("node:child_process");var x=a(require("fs-extra")),u=require("node:path");function S(r){let t;function o(){try{return t||(t=x.readJsonSync(r)),t}catch{return}}return o}var h=S((0,u.join)(__dirname,"..","package.json")),d=S((0,u.join)(n,"package.json"));var c=a(require("fs-extra")),s=require("node:path"),w=require("node:child_process"),E=require("node:util"),l=a(require("yocto-spinner")),i=(0,E.promisify)(w.exec);function _(){try{let r=d();if(!r)return!0;let t=c.readJsonSync((0,s.join)(__dirname,"..","dist","package.json"));return r.version!==t.version}catch{return!0}}async function k(){let r=(0,l.default)({text:"Checking if PM2 is installed"}).start();try{return await i("pm2 -v"),r.success("PM2 already installed"),!0}catch{return r.warning("PM2 not installed"),!1}}async function R(){let r=(0,l.default)({text:"Installing PM2"}).start();try{await i("npm i -g pm2"),r.success("Installed PM2")}catch{r.error("Failed to install PM2"),process.exit(1)}}async function j(){let r=(0,l.default)({text:"Stop running instances of "+e}).start();try{await i(`pm2 stop "${e}"`),r.warning("Stopped "+e)}catch{r.success("No running instances of "+e+" found")}}async function A(){let r=(0,l.default)({text:"Create local server"}).start();c.copySync((0,s.join)(__dirname,"..","dist","code"),(0,s.join)(n,"code")),c.copySync((0,s.join)(__dirname,"..","dist","env",".env.default"),(0,s.join)(n,"env",".env.default")),c.copySync((0,s.join)(__dirname,"..","dist","package.json"),(0,s.join)(n,"package.json")),r.text="Install local server dependencies",await i("npm i",{cwd:n}),r.success("Local server installed")}var g=a(require("yocto-spinner")),b=a(require("open"));var C=require("node:net");async function M(r){return new Promise(t=>{let o=(0,C.createServer)().once("error",()=>{t(!1)}).once("listening",()=>{o.close()}).once("close",()=>t(!0)).listen(r,"0.0.0.0")})}async function z(){await k()||await R(),await j();try{if(_()&&await A(),!await M(4466))throw new Error("Port 4466 is occupied by another process");let o=(0,g.default)({text:"Starting new instance of "+e}).start(),p=L.readJsonSync((0,O.join)(n,"package.json"));await i(`pm2 start "${p.main}" --name "${e}" --no-autorestart`,{cwd:n}),o.success("Local server will be available in a couple of seconds"),console.log("You can close this window"),await(0,b.default)("https://app.dataramen.xyz"),console.log("App is running at https://app.dataramen.xyz")}catch(t){console.error("Failed to start local server",t)}}async function W(){(0,$.execSync)(`pm2 logs ${e}`,{stdio:"inherit"})}async function Y(){let r=(0,g.default)({text:"Stopping local server"}).start();await i(`pm2 stop ${e}`),r.success("Local server stopped")}function q(){console.log(`Dataramen CLI version: ${h().version}`),console.log(`Dataramen local server version: ${d().version}`)}var f={start:z,logs:W,stop:Y,version:q};(0,F.default)((0,I.hideBin)(process.argv)).command("start","Default command, start/restart the server",f.start).command(["logs"],"Listen for logs",f.logs).command("stop","Stop the server",f.stop).command(["version"],"Show version",f.version).parse();
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@dataramen/local-server","version":"0.0.
|
|
1
|
+
{"name":"@dataramen/local-server","version":"0.0.42","license":"MIT","main":"code/proxy.js","dependencies":{"@fastify/cors":"^11.0.1","dotenv":"^16.5.0","fast-glob":"^3.3.3","fastify":"^5.3.2","mysql2":"^3.14.1","pg":"^8.15.6","sqlite3":"^5.1.7","typeorm":"^0.3.23"},"devDependencies":{"fs-extra":"^11.3.0","open":"^10.2.0","yargs":"^18.0.0","yocto-spinner":"^1.0.0"}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dataramen/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dataramen": "bin/run.js"
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"fs-extra": "^11.3.0",
|
|
14
|
+
"open": "^10.2.0",
|
|
14
15
|
"yargs": "^18.0.0",
|
|
15
16
|
"yocto-spinner": "^1.0.0"
|
|
16
17
|
},
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const os = require("node:os");
|
|
2
|
-
const path = require("node:path");
|
|
3
|
-
const { execSync } = require("node:child_process");
|
|
4
|
-
|
|
5
|
-
const homeDir = os.homedir();
|
|
6
|
-
const filesPath = path.join(homeDir, ".dataramen", ".runtime", "server");
|
|
7
|
-
const scriptPath = path.join(filesPath, "code", "cli.js");
|
|
8
|
-
|
|
9
|
-
const protocol = "dataramen";
|
|
10
|
-
|
|
11
|
-
function register () {
|
|
12
|
-
// Registry command (uses reg.exe)
|
|
13
|
-
const regCommands = [
|
|
14
|
-
`reg add "HKCU\\Software\\Classes\\${protocol}" /ve /d "DataRamen" /f`,
|
|
15
|
-
`reg add "HKCU\\Software\\Classes\\${protocol}" /v "URL Protocol" /d "" /f`,
|
|
16
|
-
`reg add "HKCU\\Software\\Classes\\${protocol}\\shell\\open\\command" /ve /d "\\"C:\\\\Windows\\\\System32\\\\cmd.exe\\" /c node \\"${scriptPath}\\" \\"%1\\"" /f`
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
for (const cmd of regCommands) {
|
|
21
|
-
execSync(cmd, { stdio: "inherit" });
|
|
22
|
-
}
|
|
23
|
-
console.log(`Custom protocol '${protocol}://' registered to run: node ${scriptPath}`);
|
|
24
|
-
} catch (err) {
|
|
25
|
-
console.error("Failed to register protocol. Try running this script as Administrator.");
|
|
26
|
-
console.error(err.message);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function unregister () {
|
|
31
|
-
try {
|
|
32
|
-
// Delete the custom protocol registry key
|
|
33
|
-
execSync(`reg delete "HKCU\\Software\\Classes\\${protocol}" /f`, { stdio: "inherit" });
|
|
34
|
-
console.log(`Protocol '${protocol}://' successfully unregistered.`);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
console.error(`Failed to unregister protocol '${protocol}://'. Try running as Administrator if needed.`);
|
|
37
|
-
console.error(err.message);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
module.exports = {
|
|
42
|
-
register,
|
|
43
|
-
unregister,
|
|
44
|
-
};
|