couplus-cli 1.0.5 → 1.0.6

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/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const e=require("http"),t=require("https"),{execSync:o}=require("child_process"),{executeCurl:r}=require("./core/curl-executor"),s=9876,n="1.0.5",i=864e5,c=process.argv[2];if("stop"===c||"status"===c)!function(){if("stop"===c){const t=e.request({hostname:"127.0.0.1",port:s,path:"/shutdown",method:"POST"},e=>{let t="";e.on("data",e=>t+=e),e.on("end",()=>{process.stdout.write(" ✔ couplus-cli 종료 완료\n"),process.exit(0)})});t.on("error",()=>{process.stdout.write(" ✘ couplus-cli가 실행 중이 아닙니다\n"),process.exit(1)}),t.end()}else e.get({hostname:"127.0.0.1",port:s,path:"/health"},e=>{let t="";e.on("data",e=>t+=e),e.on("end",()=>{try{const e=JSON.parse(t);process.stdout.write(` ✔ 실행 중 (v${e.version})\n`)}catch(e){process.stdout.write(" ✔ 실행 중\n")}process.exit(0)})}).on("error",()=>{process.stdout.write(" ✘ couplus-cli가 실행 중이 아닙니다\n"),process.exit(1)})}();else{const h=["http://localhost:8080","https://www.couplus.co.kr"],w=["chrome-extension://","https://www.couplus.co.kr","http://localhost:8080"];function a(e){return!e||w.some(t=>e.startsWith(t))}function p(e,t){t&&a(t)?e.setHeader("Access-Control-Allow-Origin",t):e.setHeader("Access-Control-Allow-Origin","*"),e.setHeader("Access-Control-Allow-Methods","POST, OPTIONS"),e.setHeader("Access-Control-Allow-Headers","Content-Type"),e.setHeader("Access-Control-Max-Age","86400")}function u(o,r,s,n){return new Promise((i,c)=>{const a=JSON.stringify(s),p=new URL(`${o}/api/recipe/${r}`),u={hostname:p.hostname,port:p.port||("https:"===p.protocol?443:80),path:p.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(a),Cookie:n||""}},d=("https:"===p.protocol?t:e).request(u,e=>{let t="";e.on("data",e=>t+=e),e.on("end",()=>{try{const e=JSON.parse(t);e.success&&e.recipe?i(e.recipe):c(new Error(e.error||"recipe 조회 실패"))}catch(e){c(new Error(`recipe 응답 파싱 실패: ${t.substring(0,200)}`))}})});d.on("error",c),d.write(a),d.end()})}async function d(e,t,o){for(const r of h)try{return await u(r,e,t,o)}catch(e){}throw new Error("모든 서버에서 recipe 조회 실패")}const y=e.createServer(async(e,t)=>{const o=e.headers.origin;if(p(t,o),"OPTIONS"===e.method)return t.writeHead(204),t.end();if("GET"===e.method&&"/health"===e.url)return t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({status:"ok",version:n}));if("POST"===e.method&&"/shutdown"===e.url&&(t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({status:"shutdown"})),process.exit(0)),"POST"===e.method&&"/execute"===e.url){let o="";return e.on("data",e=>o+=e),void e.on("end",async()=>{try{const{action:e,input:s,sessionCookie:n}=JSON.parse(o);if(!e||!s)return t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({success:!1,error:"action과 input이 필요합니다."}));const i=await d(e,s,n),c=await r(i);return t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({success:!0,data:c}))}catch(e){return t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({success:!1,error:e.message}))}})}t.writeHead(404,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Not Found"}))});function l(){t.get("https://registry.npmjs.org/couplus-cli/latest",e=>{let t="";e.on("data",e=>t+=e),e.on("end",()=>{try{const e=JSON.parse(t).version;if(e&&e!==n){process.stdout.write(` ↻ 업데이트 발견: ${n} → ${e}\n`),o("npm install -g couplus-cli",{stdio:"ignore",timeout:6e4}),process.stdout.write(" ✔ 업데이트 완료. 재시작합니다.\n");const{spawn:t}=require("child_process");t(process.argv[0],process.argv.slice(1),{detached:!0,stdio:"ignore",windowsHide:!0}).unref(),process.exit(0)}}catch(e){}})}).on("error",()=>{})}l(),setInterval(l,i),y.listen(s,"127.0.0.1",()=>{process.stdout.write(`\n ✔ couplus-cli v${n} 정상 실행 중\n\n`)})}
2
+ const e=require("http"),t=require("https"),{execSync:o}=require("child_process"),{executeCurl:r}=require("./core/curl-executor"),s=9876,n="1.0.6",i=864e5,c=process.argv[2];if("stop"===c||"status"===c)!function(){if("stop"===c){const t=e.request({hostname:"127.0.0.1",port:s,path:"/shutdown",method:"POST"},e=>{let t="";e.on("data",e=>t+=e),e.on("end",()=>{process.stdout.write(" ✔ couplus-cli 종료 완료\n"),process.exit(0)})});t.on("error",()=>{process.stdout.write(" ✘ couplus-cli가 실행 중이 아닙니다\n"),process.exit(1)}),t.end()}else e.get({hostname:"127.0.0.1",port:s,path:"/health"},e=>{let t="";e.on("data",e=>t+=e),e.on("end",()=>{try{const e=JSON.parse(t);process.stdout.write(` ✔ 실행 중 (v${e.version})\n`)}catch(e){process.stdout.write(" ✔ 실행 중\n")}process.exit(0)})}).on("error",()=>{process.stdout.write(" ✘ couplus-cli가 실행 중이 아닙니다\n"),process.exit(1)})}();else{const h=["http://localhost:8080","https://www.couplus.co.kr"],w=["chrome-extension://","https://www.couplus.co.kr","http://localhost:8080"];function a(e){return!e||w.some(t=>e.startsWith(t))}function p(e,t){t&&a(t)?e.setHeader("Access-Control-Allow-Origin",t):e.setHeader("Access-Control-Allow-Origin","*"),e.setHeader("Access-Control-Allow-Methods","POST, OPTIONS"),e.setHeader("Access-Control-Allow-Headers","Content-Type"),e.setHeader("Access-Control-Max-Age","86400")}function u(o,r,s,n){return new Promise((i,c)=>{const a=JSON.stringify(s),p=new URL(`${o}/api/recipe/${r}`),u={hostname:p.hostname,port:p.port||("https:"===p.protocol?443:80),path:p.pathname,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(a),Cookie:n||""}},d=("https:"===p.protocol?t:e).request(u,e=>{let t="";e.on("data",e=>t+=e),e.on("end",()=>{try{const e=JSON.parse(t);e.success&&e.recipe?i(e.recipe):c(new Error(e.error||"recipe 조회 실패"))}catch(e){c(new Error(`recipe 응답 파싱 실패: ${t.substring(0,200)}`))}})});d.on("error",c),d.write(a),d.end()})}async function d(e,t,o){for(const r of h)try{return await u(r,e,t,o)}catch(e){}throw new Error("모든 서버에서 recipe 조회 실패")}const y=e.createServer(async(e,t)=>{const o=e.headers.origin;if(p(t,o),"OPTIONS"===e.method)return t.writeHead(204),t.end();if("GET"===e.method&&"/health"===e.url)return t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({status:"ok",version:n}));if("POST"===e.method&&"/shutdown"===e.url&&(t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({status:"shutdown"})),process.exit(0)),"POST"===e.method&&"/execute"===e.url){let o="";return e.on("data",e=>o+=e),void e.on("end",async()=>{try{const{action:e,input:s,sessionCookie:n}=JSON.parse(o);if(!e||!s)return t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({success:!1,error:"action과 input이 필요합니다."}));const i=await d(e,s,n),c=await r(i);return t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({success:!0,data:c}))}catch(e){return t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({success:!1,error:e.message}))}})}t.writeHead(404,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Not Found"}))});function l(){t.get("https://registry.npmjs.org/couplus-cli/latest",e=>{let t="";e.on("data",e=>t+=e),e.on("end",()=>{try{const e=JSON.parse(t).version;if(e&&e!==n){process.stdout.write(` ↻ 업데이트 발견: ${n} → ${e}\n`),o("npm install -g couplus-cli",{stdio:"ignore",timeout:6e4}),process.stdout.write(" ✔ 업데이트 완료. 재시작합니다.\n");const{spawn:t}=require("child_process");t(process.argv[0],process.argv.slice(1),{detached:!0,stdio:"ignore",windowsHide:!0}).unref(),process.exit(0)}}catch(e){}})}).on("error",()=>{})}l(),setInterval(l,i),y.listen(s,"127.0.0.1",()=>{process.stdout.write(`\n ✔ couplus-cli v${n} 정상 실행 중\n\n`)})}
@@ -1 +1 @@
1
- const fs=require("fs"),path=require("path"),os=require("os"),{spawn:spawn,execSync:execSync}=require("child_process");"win32"!==process.platform&&process.exit(0);try{const e=path.join(os.homedir(),"AppData","Roaming","Microsoft","Windows","Start Menu","Programs","Startup"),s=path.join(e,"couplus-cli.vbs"),i=execSync("npm prefix -g",{encoding:"utf8"}).trim(),r=path.join(i,"couplus-cli.cmd"),t=`Set WshShell = CreateObject("WScript.Shell")\nWshShell.Run """${r}""", 0, False\n`;fs.writeFileSync(s,t);spawn(r,[],{detached:!0,stdio:"ignore",shell:!0,windowsHide:!0}).unref()}catch(e){}
1
+ const fs=require("fs"),path=require("path"),os=require("os"),{execSync:execSync}=require("child_process");"win32"!==process.platform&&process.exit(0);try{const e=path.join(os.homedir(),"AppData","Roaming","Microsoft","Windows","Start Menu","Programs","Startup"),c=path.join(e,"couplus-cli.vbs"),t=execSync("npm prefix -g",{encoding:"utf8"}).trim(),o=`Set WshShell = CreateObject("WScript.Shell")\nWshShell.Run """${path.join(t,"couplus-cli.cmd")}""", 0, False\n`;fs.writeFileSync(c,o),execSync(`cscript //nologo "${c}"`,{stdio:"ignore",timeout:1e4})}catch(e){}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "couplus-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "couplus local agent",
5
5
  "main": "dist/index.js",
6
6
  "bin": {