Comparing version 0.20.0-dev.3 to 0.20.0
@@ -9,4 +9,4 @@ #!/usr/bin/env node | ||
var i=require("../library/node/data/Stream") | ||
var n=require("../library/node/file/File") | ||
var c=require("../library/node/file/Modify") | ||
var c=require("../library/node/file/File") | ||
var n=require("../library/node/file/Modify") | ||
var u=require("../library/node/server/function") | ||
@@ -26,5 +26,5 @@ var l=require("../library/node/server/TCPProxyServer") | ||
const O=(e,r)=>e(r).then(()=>T(`[${g}] done: ${r}`),e=>T(`[${g}] error: ${r}\n${e.stack||e}`)) | ||
const k=Boolean(b("help")) | ||
const x=b(g)||[] | ||
const N=$("input-file") | ||
const N=Boolean(b("help")) | ||
const k=b(g)||[] | ||
const x=$("input-file") | ||
const P=$("output-file") | ||
@@ -34,7 +34,7 @@ const A=async()=>{const e=($("host")||"").split(":") | ||
return{hostname:r,port:Number(e[1]||await(0,u.autoTestServerPort)([80,8080,8888,8800,8e3],r))}} | ||
switch(g){case"eval":case"eval-readline":{let t=await(0,S.evalScript)(N?(0,r.readFileSync)(N).toString():x[0],N?x:x.slice(1),N?(0,e.dirname)(N):process.cwd(),w) | ||
switch(g){case"eval":case"eval-readline":{let t=await(0,S.evalScript)(x?(0,r.readFileSync)(x).toString():k[0],x?k:k.slice(1),x?(0,e.dirname)(x):process.cwd(),w) | ||
"eval-readline"===g&&(t=await(0,S.evalReadlineExtend)(t,q("root"),T)) | ||
return void 0!==t&&(e=>P?(0,r.writeFileSync)(P,e):(0,i.pipeStreamAsync)(process.stdout,(0,i.bufferToStream)(e)))(t instanceof Buffer?t:Buffer.from(String(t)))}case"repl":return(0,t.start)({prompt:"> ",input:process.stdin,output:process.stdout,useGlobal:!0}).context.require=require | ||
case"echo":return h(x) | ||
case"cat":if(x.length)for(const e of x)await(0,i.pipeStreamAsync)(process.stdout,(0,r.createReadStream)(e)) | ||
case"echo":return h(k) | ||
case"cat":if(k.length)for(const e of k)await(0,i.pipeStreamAsync)(process.stdout,(0,r.createReadStream)(e)) | ||
else process.stdin.isTTY||await(0,i.pipeStreamAsync)(process.stdout,process.stdin) | ||
@@ -44,23 +44,23 @@ return | ||
const u="write"===g?"w":"a" | ||
return(0,i.pipeStreamAsync)((0,r.createWriteStream)(x[0],{flags:u}),process.stdin) | ||
case"open":{const r=x[0]||"." | ||
return(0,m.runSync)({command:(0,p.getDefaultOpen)(),argList:[r.includes("://")?r:(0,e.normalize)(r)]})}case"status":return h(k?(0,d.describeSystemStatus)():{system:(0,d.getSystemStatus)(),process:(0,d.getProcessStatus)()}) | ||
case"file-list":case"file-list-all":case"file-tree":return h(await(0,S.collectFile)(g,x[0]||process.cwd())) | ||
case"file-create-directory":for(const e of x)await O(n.createDirectory,e) | ||
return(0,i.pipeStreamAsync)((0,r.createWriteStream)(k[0],{flags:u}),process.stdin) | ||
case"open":{const r=k[0]||"." | ||
return(0,m.runSync)({command:(0,p.getDefaultOpen)(),argList:[r.includes("://")?r:(0,e.normalize)(r)]})}case"status":return h(N?(0,d.describeSystemStatus)():{system:(0,d.getSystemStatus)(),process:(0,d.getProcessStatus)()}) | ||
case"file-list":case"file-list-all":case"file-tree":return h(await(0,S.collectFile)(g,k[0]||process.cwd())) | ||
case"file-create-directory":for(const e of k)await O(c.createDirectory,e) | ||
return | ||
case"file-modify-copy":return c.modify.copy(x[0],x[1]) | ||
case"file-modify-move":return c.modify.move(x[0],x[1]) | ||
case"file-modify-delete":for(const e of x)await O(c.modify.delete,e) | ||
case"file-modify-copy":return n.modify.copy(k[0],k[1]) | ||
case"file-modify-move":return n.modify.move(k[0],k[1]) | ||
case"file-modify-delete":for(const e of k)await O(n.modify.delete,e) | ||
return | ||
case"file-merge":{const[e,...t]=x | ||
case"file-merge":{const[e,...t]=k | ||
for(const s of t)await(0,i.pipeStreamAsync)((0,r.createWriteStream)(e,{flags:"a"}),(0,r.createReadStream)(s)) | ||
return}case"fetch":{let[e,t=4,a=0]=x | ||
return}case"fetch":{let[e,t=4,a=0]=k | ||
t=Number(t)||0 | ||
a=Number(a)||0 | ||
const o=await(0,S.fetchWithJump)(e,{headers:{accept:"*/*","user-agent":`${S.packageName}/${S.packageVersion}`},timeout:a},t,(e,r,o)=>T(`[fetch] url: ${e}, jump: ${r}/${t}, timeout: ${a?(0,s.time)(a):"none"}, cookie: ${o.length}`)) | ||
const n=Number(o.headers["content-length"]) | ||
T(`[fetch] get status: ${o.status}, fetch response content${n?` (${(0,s.binary)(n)}B)`:""}...`) | ||
const c=Number(o.headers["content-length"]) | ||
T(`[fetch] get status: ${o.status}, fetch response content${c?` (${(0,s.binary)(c)}B)`:""}...`) | ||
await(e=>(0,i.pipeStreamAsync)(P?(0,r.createWriteStream)(P):process.stdout,e))(o.stream()) | ||
return T("\n[fetch] done")}case"process-status":{const[e="pid--"]=x | ||
return h(await(0,S.collectAllProcessStatus)(e,k))}case"server-serve-static":case"server-serve-static-simple":{const[e=3e5]=x | ||
return T("\n[fetch] done")}case"process-status":{const[e="pid--"]=k | ||
return h(await(0,S.collectAllProcessStatus)(e,N))}case"server-serve-static":case"server-serve-static-simple":{const[e=3e5]=k | ||
const r="server-serve-static-simple"===g | ||
@@ -72,4 +72,4 @@ const t=$("root")||process.cwd() | ||
let r | ||
if((0,o.isBasicFunction)(x[0])){e=[{hostname:"custom-hostname",port:"custom-port"}] | ||
r=x[0]}else{e=x.map(e=>{const[r,t]=e.split(":") | ||
if((0,o.isBasicFunction)(k[0])){e=[{hostname:"custom-hostname",port:"custom-port"}] | ||
r=k[0]}else{e=k.map(e=>{const[r,t]=e.split(":") | ||
return{hostname:r||"localhost",port:Number(t)}}) | ||
@@ -83,3 +83,3 @@ let t=0 | ||
return T((0,a.indentList)("[TCPProxy]",[`pid: ${process.pid}`,`at: ${t.hostname}:${t.port}`,...e.map(e=>`proxy to: ${e.hostname}:${e.port}`)]))}}};(async()=>{const e=await(0,g.parseOption)() | ||
const{name:r}=g.MODE_FORMAT_LIST.find(({name:r})=>e.tryGet(r))||{} | ||
const r=g.MODE_NAME_LIST.find(r=>e.tryGet(r)) | ||
if(!r)return h(e.tryGet("version")?(0,S.getVersion)():(0,g.formatUsage)(null,e.tryGet("help")?null:"simple")) | ||
@@ -86,0 +86,0 @@ await w(r,e).catch(e=>{console.warn(`[Error] in mode: ${r}:`,e.stack||e) |
@@ -5,6 +5,7 @@ var e=require("../library/node/module/Option/preset") | ||
const s=t("eval,e/A|eval file or string: -O=outputFile, -I/$0=scriptFile/scriptString, $@=...evalArgv","eval-readline,erl/A|eval with readline: -R=readlineFile, ...eval","repl,i/T|start node REPL","echo/A|show args: $@=...args","cat/AP/0-|with 0 args pipe stdin to stdout, else read $@ as file and pipe to stdout",'write/SP|for use like ">": `dr-js --cat sourceFile | dr-js --write outputFile`','append/SP|for use like ">>": `dr-js --cat sourceFile | dr-js --append outputFile`',"open,o//0-1|use system default app to open uri or path: $0=uriOrPath/cwd","status,s/T|basic system status: -h=isHumanReadableOutput","file-list,ls/AP/0-1|list file: $0=path/cwd","file-list-all,ls-R,lla/AP/0-1|list all file: $0=path/cwd","file-tree,tree/AP/0-1|list all file in tree: $0=path/cwd","file-create-directory,mkdir/AP/0-|create directory: $@=...pathList","file-modify-copy,cp/AP/2|copy path: $@=pathFrom,pathTo","file-modify-move,mv/AP/2|move path: $@=pathFrom,pathTo","file-modify-delete,rm/AP/0-|delete path: $@=...pathList","file-merge,merge/AP/2-|merge to one file: $@=mergedFile,...inputFileList","fetch,f//1-3|fetch uri: -O=outputFile/stdout, $@=initialUrl,jumpMax/4,timeout/0",'process-status,ps//0-1|show system process status: -h=isHumanReadableOutput, $0=outputMode/"pid--"',"server-serve-static,sss//0-1|static file server: -H=hostname:port, -R=staticRoot/cwd, $0=expireTime/5*60*1000","server-serve-static-simple,ssss//0-1|static file server, no HTML: -H=hostname:port, -R=staticRoot/cwd, $0=expireTime/5*60*1000","server-websocket-group,swg|websocket chat server: -H=hostname:port","server-test-connection,stc|connection test server: -H=hostname:port","server-tcp-proxy,stp//1-|tcp proxy server: -H=hostname:port, $@=toHostname:toPort,toHostname:toPort,...") | ||
exports.MODE_FORMAT_LIST=s | ||
const r={prefixENV:"dr-js",prefixCONFIG:"dr-js",formatList:[e.Preset.Config,...o,...s]} | ||
const{parseOption:i,formatUsage:a}=(0,e.prepareOption)(r) | ||
exports.formatUsage=a | ||
exports.parseOption=i | ||
const r=s.map(({name:e})=>e) | ||
exports.MODE_NAME_LIST=r | ||
const i={prefixENV:"dr-js",prefixCONFIG:"dr-js",formatList:[e.Preset.Config,...o,...s]} | ||
const{parseOption:a,formatUsage:p}=(0,e.prepareOption)(i) | ||
exports.formatUsage=p | ||
exports.parseOption=a |
@@ -19,4 +19,8 @@ var e=require("../env/global") | ||
e()}} | ||
return{start:()=>{s||(s=r(a,t))},stop:()=>{if(s){o(s) | ||
s=null}},isActive:()=>Boolean(s)}}) | ||
const c=()=>{s||(s=r(a,t))} | ||
const n=()=>{if(s){o(s) | ||
s=null}} | ||
return{start:c,stop:n,isActive:()=>Boolean(s),getDelay:()=>t,setDelay:e=>{if(e!==t){t=e | ||
n() | ||
c()}}}}) | ||
exports.createStepper=((e=t())=>()=>{const r=t() | ||
@@ -23,0 +27,0 @@ const o=r-e |
@@ -31,13 +31,23 @@ import { global } from "../env/global"; | ||
}; | ||
const start = () => { | ||
token || (token = queueTask(update, delay)); | ||
}; | ||
const stop = () => { | ||
if (token) { | ||
cancelTask(token); | ||
token = null; | ||
} | ||
}; | ||
return { | ||
start: () => { | ||
token || (token = queueTask(update, delay)); | ||
}, | ||
stop: () => { | ||
if (token) { | ||
cancelTask(token); | ||
token = null; | ||
start, | ||
stop, | ||
isActive: () => Boolean(token), | ||
getDelay: () => delay, | ||
setDelay: nextDelay => { | ||
if (nextDelay !== delay) { | ||
delay = nextDelay; | ||
stop(); | ||
start(); | ||
} | ||
}, | ||
isActive: () => Boolean(token) | ||
} | ||
}; | ||
@@ -44,0 +54,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
{"name":"dr-js","version":"0.20.0-dev.3","description":"A collection of strange functions","author":"dr-js","license":"MIT","keywords":["Dr","Dr-js","JavaScript"],"repository":"github:dr-js/dr-js","bin":"bin/index.js","browser":"library/Dr.browser.js","engines":{"node":">=8.12","npm":">=6"},"sideEffects":false} | ||
{"name":"dr-js","version":"0.20.0","description":"A collection of strange functions","author":"dr-js","license":"MIT","keywords":["Dr","Dr-js","JavaScript"],"repository":"github:dr-js/dr-js","bin":"bin/index.js","browser":"library/Dr.browser.js","engines":{"node":">=8.12","npm":">=6"},"sideEffects":false} |
Sorry, the diff of this file is too big to display
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
452046
10493