devcon-cli 0.1.1 → 0.1.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.
- package/dist/agent-bun.js +6 -6
- package/dist/agent-node.js +6 -6
- package/package.json +1 -1
package/dist/agent-bun.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import*as
|
|
4
|
-
`);for(let
|
|
5
|
-
`)}
|
|
6
|
-
`);
|
|
7
|
-
`),process.exit(1)}),
|
|
8
|
-
`),process.exit(1);
|
|
3
|
+
import*as R from"fs";import*as _ from"net";function B(F){let z=[],J=new Set,K=F.split(`
|
|
4
|
+
`);for(let C=1;C<K.length;C++){let j=K[C].trim();if(!j)continue;let G=j.split(/\s+/),Q=G[1],N=G[3];if(!Q||!N)continue;if(N!=="0A")continue;let W=Q.split(":")[1];if(!W)continue;let U=parseInt(W,16);if(U<=0||J.has(U))continue;let V=G[9];if(!V)continue;let X=parseInt(V,10);if(isNaN(X))continue;J.add(U),z.push({port:U,inode:X})}return z.sort((C,j)=>C.port-j.port)}function L(){let F=new Map,z;try{z=R.readdirSync("/proc").filter((J)=>/^\d+$/.test(J))}catch{return F}for(let J of z){let K=parseInt(J,10),C=`/proc/${K}/fd`,j;try{j=R.readdirSync(C)}catch{continue}for(let G of j)try{let N=R.readlinkSync(`${C}/${G}`).match(/^socket:\[(\d+)\]$/);if(N)F.set(parseInt(N[1],10),K)}catch{continue}}return F}function O(){let F=new Map,z;try{z=R.readdirSync("/proc").filter((J)=>/^\d+$/.test(J))}catch{return F}for(let J of z){let K=parseInt(J,10);try{let C=R.readFileSync(`/proc/${K}/stat`,"utf-8"),j=C.lastIndexOf(")");if(j===-1)continue;let Q=C.slice(j+2).split(" "),N=parseInt(Q[1],10);if(!isNaN(N))F.set(K,N)}catch{continue}}return F}function v(F){let z=new Map;for(let[C,j]of F){let G=z.get(j);if(!G)G=[],z.set(j,G);G.push(C)}let J=new Set,K=[];for(let[C,j]of F)if(j===0&&C!==1)J.add(C),K.push(C);while(K.length>0){let C=K.shift(),j=z.get(C);if(j){for(let G of j)if(!J.has(G))J.add(G),K.push(G)}}return J}function w(){function F(j){process.stdout.write(JSON.stringify(j)+`
|
|
5
|
+
`)}F({type:"ready",pid:process.pid});let z="";function J(){let j="";try{j+=R.readFileSync("/proc/net/tcp","utf-8")}catch{}try{j+=R.readFileSync("/proc/net/tcp6","utf-8")}catch{}let G=B(j);if(G.length===0){if(z!=="")z="",F({type:"ports",ports:[]});return}let Q=L(),N=O(),W=v(N),U=[];for(let{port:X,inode:$}of G){let Y=Q.get($);if(Y!==void 0&&W.has(Y))U.push(X)}let V=U.join(",");if(V!==z)z=V,F({type:"ports",ports:U})}J();let K=setInterval(J,1000),C="";process.stdin.setEncoding("utf-8"),process.stdin.on("data",(j)=>{C+=j;let G=C.split(`
|
|
6
|
+
`);C=G.pop();for(let Q of G){if(!Q.trim())continue;try{let N=JSON.parse(Q);if(N.type==="stop")clearInterval(K),process.exit(0);if(N.type==="ping")F({type:"ready",pid:process.pid})}catch{}}}),process.stdin.on("end",()=>{clearInterval(K),process.exit(0)})}function A(F){let z=_.createConnection({host:"localhost",port:F},()=>{process.stdin.pipe(z),z.pipe(process.stdout)});z.on("error",(J)=>{process.stderr.write(`bridge error: ${J.message}
|
|
7
|
+
`),process.exit(1)}),z.on("close",()=>{process.exit(0)}),process.stdin.on("end",()=>{z.end()})}var Z=process.argv[2];if(Z==="monitor")w();else if(Z==="bridge"){let F=parseInt(process.argv[3],10);if(isNaN(F))process.stderr.write(`Usage: agent bridge <port>
|
|
8
|
+
`),process.exit(1);A(F)}else process.stderr.write(`Usage: agent <monitor|bridge> [port]
|
|
9
9
|
`),process.exit(1);
|
package/dist/agent-node.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import*as
|
|
3
|
-
`);for(let
|
|
4
|
-
`)}
|
|
5
|
-
`);
|
|
6
|
-
`),process.exit(1)}),
|
|
7
|
-
`),process.exit(1);
|
|
2
|
+
import*as R from"node:fs";import*as _ from"node:net";function B(F){let z=[],J=new Set,K=F.split(`
|
|
3
|
+
`);for(let C=1;C<K.length;C++){let j=K[C].trim();if(!j)continue;let G=j.split(/\s+/),Q=G[1],N=G[3];if(!Q||!N)continue;if(N!=="0A")continue;let W=Q.split(":")[1];if(!W)continue;let U=parseInt(W,16);if(U<=0||J.has(U))continue;let V=G[9];if(!V)continue;let X=parseInt(V,10);if(isNaN(X))continue;J.add(U),z.push({port:U,inode:X})}return z.sort((C,j)=>C.port-j.port)}function L(){let F=new Map,z;try{z=R.readdirSync("/proc").filter((J)=>/^\d+$/.test(J))}catch{return F}for(let J of z){let K=parseInt(J,10),C=`/proc/${K}/fd`,j;try{j=R.readdirSync(C)}catch{continue}for(let G of j)try{let N=R.readlinkSync(`${C}/${G}`).match(/^socket:\[(\d+)\]$/);if(N)F.set(parseInt(N[1],10),K)}catch{continue}}return F}function O(){let F=new Map,z;try{z=R.readdirSync("/proc").filter((J)=>/^\d+$/.test(J))}catch{return F}for(let J of z){let K=parseInt(J,10);try{let C=R.readFileSync(`/proc/${K}/stat`,"utf-8"),j=C.lastIndexOf(")");if(j===-1)continue;let Q=C.slice(j+2).split(" "),N=parseInt(Q[1],10);if(!isNaN(N))F.set(K,N)}catch{continue}}return F}function v(F){let z=new Map;for(let[C,j]of F){let G=z.get(j);if(!G)G=[],z.set(j,G);G.push(C)}let J=new Set,K=[];for(let[C,j]of F)if(j===0&&C!==1)J.add(C),K.push(C);while(K.length>0){let C=K.shift(),j=z.get(C);if(j){for(let G of j)if(!J.has(G))J.add(G),K.push(G)}}return J}function w(){function F(j){process.stdout.write(JSON.stringify(j)+`
|
|
4
|
+
`)}F({type:"ready",pid:process.pid});let z="";function J(){let j="";try{j+=R.readFileSync("/proc/net/tcp","utf-8")}catch{}try{j+=R.readFileSync("/proc/net/tcp6","utf-8")}catch{}let G=B(j);if(G.length===0){if(z!=="")z="",F({type:"ports",ports:[]});return}let Q=L(),N=O(),W=v(N),U=[];for(let{port:X,inode:$}of G){let Y=Q.get($);if(Y!==void 0&&W.has(Y))U.push(X)}let V=U.join(",");if(V!==z)z=V,F({type:"ports",ports:U})}J();let K=setInterval(J,1000),C="";process.stdin.setEncoding("utf-8"),process.stdin.on("data",(j)=>{C+=j;let G=C.split(`
|
|
5
|
+
`);C=G.pop();for(let Q of G){if(!Q.trim())continue;try{let N=JSON.parse(Q);if(N.type==="stop")clearInterval(K),process.exit(0);if(N.type==="ping")F({type:"ready",pid:process.pid})}catch{}}}),process.stdin.on("end",()=>{clearInterval(K),process.exit(0)})}function A(F){let z=_.createConnection({host:"localhost",port:F},()=>{process.stdin.pipe(z),z.pipe(process.stdout)});z.on("error",(J)=>{process.stderr.write(`bridge error: ${J.message}
|
|
6
|
+
`),process.exit(1)}),z.on("close",()=>{process.exit(0)}),process.stdin.on("end",()=>{z.end()})}var Z=process.argv[2];if(Z==="monitor")w();else if(Z==="bridge"){let F=parseInt(process.argv[3],10);if(isNaN(F))process.stderr.write(`Usage: agent bridge <port>
|
|
7
|
+
`),process.exit(1);A(F)}else process.stderr.write(`Usage: agent <monitor|bridge> [port]
|
|
8
8
|
`),process.exit(1);
|