pulse-coder-cli 0.0.1-alpha.6 → 0.0.1-alpha.7
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/LICENSE +21 -0
- package/dist/index.cjs +166 -157
- package/dist/runner.cjs +20 -0
- package/package.json +11 -7
package/dist/runner.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';var m=require('vm'),util=require('util');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var m__default=/*#__PURE__*/_interopDefault(m);var w=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var p=w(()=>{function d(e){return e instanceof Error?e.stack??e.message:String(e)}function f(e,n,t){let s=e+n;return s.length<=t?{value:s,truncated:false}:{value:s.slice(0,t),truncated:true}}function r(e){return e.map(n=>typeof n=="string"?n:util.inspect(n,{depth:4,breakLength:120,compact:true,maxArrayLength:100})).join(" ")}function k(e){return {log:(...n)=>e("stdout",`${r(n)}
|
|
3
|
+
`),info:(...n)=>e("stdout",`${r(n)}
|
|
4
|
+
`),warn:(...n)=>e("stderr",`${r(n)}
|
|
5
|
+
`),error:(...n)=>e("stderr",`${r(n)}
|
|
6
|
+
`),debug:(...n)=>e("stdout",`${r(n)}
|
|
7
|
+
`),trace:(...n)=>e("stderr",`${r(n)}
|
|
8
|
+
`),dir:n=>e("stdout",`${util.inspect(n)}
|
|
9
|
+
`),dirxml:n=>e("stdout",`${util.inspect(n)}
|
|
10
|
+
`),assert:(n,...t)=>{n||e("stderr",`${r(t.length?t:["Assertion failed"])}
|
|
11
|
+
`);},clear:()=>{},count:()=>{},countReset:()=>{},group:(...n)=>e("stdout",`${r(n)}
|
|
12
|
+
`),groupCollapsed:(...n)=>e("stdout",`${r(n)}
|
|
13
|
+
`),groupEnd:()=>{},table:n=>e("stdout",`${util.inspect(n,{depth:3})}
|
|
14
|
+
`),time:()=>{},timeLog:(...n)=>e("stdout",`${r(n)}
|
|
15
|
+
`),timeEnd:(...n)=>e("stdout",`${r(n)}
|
|
16
|
+
`),timeStamp:()=>{},profile:()=>{},profileEnd:()=>{}}}function R(e,n){let t={input:e,console:n,fetch:void 0,WebSocket:void 0,EventSource:void 0,require:void 0,process:void 0,module:void 0,exports:void 0,Buffer:void 0,setTimeout,clearTimeout,setInterval,clearInterval};return t.globalThis=t,t.global=t,m__default.default.createContext(t,{codeGeneration:{strings:false,wasm:false}})}async function x(e){let n="",t="",s=false,l=(o,u)=>{if(o==="stdout"){let a=f(n,u,e.maxOutputChars);n=a.value,a.truncated&&(s=true);return}let i=f(t,u,e.maxOutputChars);t=i.value,i.truncated&&(s=true);};try{let o=k(l),u=R(e.input,o),i=`'use strict';
|
|
17
|
+
(async () => {
|
|
18
|
+
${e.code}
|
|
19
|
+
})()`;return {type:"success",result:await new m__default.default.Script(i,{filename:"pulse-sandbox-user-code.js"}).runInContext(u),stdout:n,stderr:t,outputTruncated:s}}catch(o){return l("stderr",`${d(o)}
|
|
20
|
+
`),{type:"error",errorCode:"RUNTIME_ERROR",errorMessage:d(o),stdout:n,stderr:t,outputTruncated:s}}}function g(e,n){if(!process.send){process.exit(n);return}process.send(e,t=>{if(t){process.exit(1);return}process.exit(n);});}process.once("message",async e=>{try{let n=await x(e);g(n,0);}catch(n){let t={type:"error",errorCode:"INTERNAL",errorMessage:d(n),stdout:"",stderr:d(n),outputTruncated:false};g(t,1);}});});var runner = p();module.exports=runner;
|
package/package.json
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pulse-coder-cli",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.7",
|
|
4
4
|
"description": "CLI interface for Pulse Coder",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"bin": {
|
|
8
8
|
"pulse-coder": "./dist/index.cjs"
|
|
9
9
|
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsup",
|
|
12
|
-
"dev": "tsup --watch",
|
|
13
|
-
"test": "vitest",
|
|
14
|
-
"start": "node dist/index.cjs"
|
|
15
|
-
},
|
|
16
10
|
"files": [
|
|
17
11
|
"dist"
|
|
18
12
|
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"pulse-coder-engine": "0.0.1-alpha.6",
|
|
15
|
+
"pulse-sandbox": "0.0.1-alpha.0"
|
|
16
|
+
},
|
|
19
17
|
"devDependencies": {
|
|
20
18
|
"typescript": "^5.0.0",
|
|
21
19
|
"tsup": "^8.0.0",
|
|
22
20
|
"vitest": "^1.0.0",
|
|
23
21
|
"@types/node": "^25.0.10"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsup",
|
|
25
|
+
"dev": "tsup --watch",
|
|
26
|
+
"test": "vitest",
|
|
27
|
+
"start": "node dist/index.cjs"
|
|
24
28
|
}
|
|
25
29
|
}
|