From 12c55d1735ddfb6d9aeb222591e1f0415a4002b1 Mon Sep 17 00:00:00 2001 From: lxsang Date: Thu, 6 May 2021 14:25:50 +0200 Subject: [PATCH] AntosSDK support server side command executing --- libantosdk/README.md | 1 + libantosdk/build.json | 12 ++++++++++++ libantosdk/build/debug/README.md | 1 + libantosdk/build/debug/core/worker.js | 16 ++++++++++++++-- libantosdk/build/debug/main.js | 2 +- libantosdk/build/debug/package.json | 2 +- libantosdk/build/release/libantosdk.zip | Bin 1269645 -> 1271052 bytes libantosdk/core/worker.js | 16 ++++++++++++++-- libantosdk/package.json | 2 +- libantosdk/ts/main.ts | 10 ++++++++-- packages.json | 2 +- 11 files changed, 54 insertions(+), 10 deletions(-) diff --git a/libantosdk/README.md b/libantosdk/README.md index 6806f4b..336aef9 100644 --- a/libantosdk/README.md +++ b/libantosdk/README.md @@ -2,4 +2,5 @@ AntOSDK: development API for AntOS based applications/projects ## Change logs +- 0.0.5: add API that supports running Linux commands on server - 0.0.4: support automatic locale generation \ No newline at end of file diff --git a/libantosdk/build.json b/libantosdk/build.json index 3c1881b..3a00aab 100644 --- a/libantosdk/build.json +++ b/libantosdk/build.json @@ -78,6 +78,18 @@ } } ] + }, + "list": { + "require": ["linux"], + "jobs": [ + { + "name": "linux-exec", + "data": { + "cmd": "ls -al .", + "pwd": "home://" + } + } + ] } } } \ No newline at end of file diff --git a/libantosdk/build/debug/README.md b/libantosdk/build/debug/README.md index 6806f4b..336aef9 100644 --- a/libantosdk/build/debug/README.md +++ b/libantosdk/build/debug/README.md @@ -2,4 +2,5 @@ AntOSDK: development API for AntOS based applications/projects ## Change logs +- 0.0.5: add API that supports running Linux commands on server - 0.0.4: support automatic locale generation \ No newline at end of file diff --git a/libantosdk/build/debug/core/worker.js b/libantosdk/build/debug/core/worker.js index 3322d7f..6ee2f5b 100644 --- a/libantosdk/build/debug/core/worker.js +++ b/libantosdk/build/debug/core/worker.js @@ -72,7 +72,18 @@ class AntOSDKBaseJob { id: this.job.id, type: "log", error: false, - result: data + result: data, + show_time: true + }); + } + + log_print(data) { + postMessage({ + id: this.job.id, + type: "log", + error: false, + result: data, + show_time: false }); } @@ -81,7 +92,8 @@ class AntOSDKBaseJob { id: this.job.id, type: "log", error: true, - result: data + result: data, + show_time: true }); } diff --git a/libantosdk/build/debug/main.js b/libantosdk/build/debug/main.js index 966a176..d23a2cc 100644 --- a/libantosdk/build/debug/main.js +++ b/libantosdk/build/debug/main.js @@ -1 +1 @@ -var OS;!function(e){let t;!function(t){class r{constructor(t){this.worker=new Worker(t.asFileHandle().getlink()),this.jobs={},this.worker.onmessage=e=>{let t=e.data,r=this.jobs[t.id];r?"log"===t.type?r.logger&&(t.error?r.logger.error(t.result):r.logger.info(t.result)):(r.callback(t),delete this.jobs[t.id]):console.log("Unable to identify result of job",t.id,t)};const r={};for(const t in e.setting.system.packages){const o=e.setting.system.packages[t];r[t]={path:o.path,name:o.pkgname}}this.submit("sdk-setup",{REST:e.API.REST,pkgs:r})}newJobID(){return"job_"+Math.random().toString(36).replace(".","")}exectue_job(e,t,r,o,s){const n=this.newJobID(),i={id:n,cmd:e,data:t,root:r};this.jobs[n]={callback:o,logger:s},this.worker.postMessage(i)}submit(e,t,r,o){return new Promise((s,n)=>{this.exectue_job(e,t,r,e=>{if(e.error)return n(e.error);s(e.result)},o)})}terminate(){this.worker.terminate()}}class o{constructor(e,t){this.root=t,this.logger=e,o.worker||(o.worker=new r("pkg://libantosdk/core/worker.js"))}require(e){return this.run("sdk-import",e.map(e=>e+".worker.js"))}compile(e,t){return new Promise(async(r,o)=>{try{await this.require([e]),r(await this.run(e+"-compile",t))}catch(e){o(__e(e))}})}run(t,r){return"sdk-run-app"===t?new Promise(async(t,o)=>{try{let o=r;1==o.split("://").length&&(o=`${this.root}/${r}`);const s=await(o+"/package.json").asFileHandle().read("json");return s.text=s.name,s.path=o,s.filename=s.pkgname,s.type="app",s.mime="antos/app",s.icon&&(s.icon=`${s.path}/${s.icon}`),s.iconclass||s.icon||(s.iconclass="fa fa-adn"),this.logger.info(__("Installing...")),e.setting.system.packages[s.pkgname]=s,s.app?(this.logger.info(__("Running {0}...",s.app)),e.GUI.forceLaunch(s.app,[])):this.logger.error(__("{0} is not an application",s.pkgname)),t(void 0)}catch(e){o(e)}}):o.worker.submit(t,r,this.root,this.logger)}batch(e,t){return t.root&&(this.root=t.root),new Promise(async(r,o)=>{try{t.targets||o("No target found");for(const r of e){const e=t.targets[r];if(!e)return o(__("No target: {0}",r));if(e.depend&&await this.batch(e.depend,t),e.require&&await this.require(e.require),this.logger&&this.logger.info(__("### RUNNING STAGE: {0}###",r).__()),e.jobs)for(const t of e.jobs)await this.run(t.name,t.data)}r(void 0)}catch(e){o(e)}})}}let s;t.AntOSDKBuilder=o,function(e){class t extends e.RemoteFileHandle{constructor(e){super(e);const t="pkg://libantosdk/"+this.genealogy.join("/");this.setPath(t.asFileHandle().path)}}e.SDKFileHandle=t,e.register("^sdk$",t)}(s=t.VFS||(t.VFS={}))}(t=e.API||(e.API={}))}(OS||(OS={})); \ No newline at end of file +var OS;!function(e){let t;!function(t){class r{constructor(t){this.worker=new Worker(t.asFileHandle().getlink()),this.jobs={},this.worker.onmessage=e=>{let t=e.data,r=this.jobs[t.id];r?"log"===t.type?r.logger&&(t.error?r.logger.error(t.result):!1===t.show_time&&r.logger.print?r.logger.print(t.result):r.logger.info(t.result)):(r.callback(t),delete this.jobs[t.id]):console.log("Unable to identify result of job",t.id,t)};const r={};for(const t in e.setting.system.packages){const o=e.setting.system.packages[t];r[t]={path:o.path,name:o.pkgname}}this.submit("sdk-setup",{REST:e.API.REST,pkgs:r})}newJobID(){return"job_"+Math.random().toString(36).replace(".","")}exectue_job(e,t,r,o,s){const i=this.newJobID(),n={id:i,cmd:e,data:t,root:r};this.jobs[i]={callback:o,logger:s},this.worker.postMessage(n)}submit(e,t,r,o){return new Promise((s,i)=>{this.exectue_job(e,t,r,e=>{if(e.error)return i(e.error);s(e.result)},o)})}terminate(){this.worker.terminate()}}class o{constructor(e,t){this.root=t,this.logger=e,o.worker||(o.worker=new r("pkg://libantosdk/core/worker.js"))}require(e){return this.run("sdk-import",e.map(e=>e+".worker.js"))}compile(e,t){return new Promise(async(r,o)=>{try{await this.require([e]),r(await this.run(e+"-compile",t))}catch(e){o(__e(e))}})}run(t,r){return"sdk-run-app"===t?new Promise(async(t,o)=>{try{let o=r;1==o.split("://").length&&(o=`${this.root}/${r}`);const s=await(o+"/package.json").asFileHandle().read("json");return s.text=s.name,s.path=o,s.filename=s.pkgname,s.type="app",s.mime="antos/app",s.icon&&(s.icon=`${s.path}/${s.icon}`),s.iconclass||s.icon||(s.iconclass="fa fa-adn"),this.logger.info(__("Installing...")),e.setting.system.packages[s.pkgname]=s,s.app?(this.logger.info(__("Running {0}...",s.app)),e.GUI.forceLaunch(s.app,[])):this.logger.error(__("{0} is not an application",s.pkgname)),t(void 0)}catch(e){o(e)}}):o.worker.submit(t,r,this.root,this.logger)}batch(e,t){return t.root&&(this.root=t.root),new Promise(async(r,o)=>{try{t.targets||o("No target found");for(const r of e){const e=t.targets[r];if(!e)return o(__("No target: {0}",r));if(e.depend&&await this.batch(e.depend,t),e.require&&await this.require(e.require),this.logger&&this.logger.info(__("### RUNNING STAGE: {0}###",r).__()),e.jobs)for(const t of e.jobs)await this.run(t.name,t.data)}r(void 0)}catch(e){o(e)}})}}let s;t.AntOSDKBuilder=o,function(e){class t extends e.RemoteFileHandle{constructor(e){super(e);const t="pkg://libantosdk/"+this.genealogy.join("/");this.setPath(t.asFileHandle().path)}}e.SDKFileHandle=t,e.register("^sdk$",t)}(s=t.VFS||(t.VFS={}))}(t=e.API||(e.API={}))}(OS||(OS={})); \ No newline at end of file diff --git a/libantosdk/build/debug/package.json b/libantosdk/build/debug/package.json index 8f9ce9d..280dfee 100644 --- a/libantosdk/build/debug/package.json +++ b/libantosdk/build/debug/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "mrsang@iohub.dev" }, - "version": "0.0.4-a", + "version": "0.0.5-a", "category": "Other", "iconclass": "fa fa-cog", "mimes": [ diff --git a/libantosdk/build/release/libantosdk.zip b/libantosdk/build/release/libantosdk.zip index 1e2d7b8242b5711c3b7e40ed52b527fcbc7e3ed9..f07892ab8eb28f0cfe65356fcbac006e92dfc3d4 100644 GIT binary patch delta 6616 zcmZ`;1z1#Dv>qCUW{|D{q#FdJmG15?0j0YK0Yyr>8-^5+MhQV+2+bhm>c89buNL$Ri9RQNj@_4FvwHu}FaK3c>^c+64dr z9QZ;kom{Osy_{U1S-WyPb(F0wU)IcNL$J@stZC}95;qh|%IAiu}VO`0+U#^p&UqoW!F**A+vrjUje2Ei#)Lo@j z`g}8xMHC<)0aZ;gp*c!?l7}1fB48UQQ{Thv;bqVXoeRTl0C!G%Q+SB!g>{z*1jdtN z`l&D`CZfQHJZ3oX8)?9)nxxbMew>~&vR#MZ=M1bTBlL2Tm!B8=i?8*zY>{*a zLbZKe>Qx2xk)W1T24eK>M5X&T#)e$Tk1(wtD#%6%VW-ew$AWudAsd$aNjYCOBDZVk zr5GWS6)3>Wy`2s_%{)9KV*p{$Ms>gKps_Lpfam~xQibwEe#xC8HP&4sD z_54w7UOkd6tIyhDDlaxE+Cx&;Y&RH1UW6yC86yR{Eb$+cMFxYdjVR=&o;#Zv(?0G= z!|x%DbjlfVnpe^7x0zlAboc6aEDz*dqXleDyB7kc zf&GmLs%`?O@0XvbrxMVhxE|H3yr<1^u;fVbp9`WJ3vkYLbVq(<4lVf~0Mq~~k#U&iw6A=>;hDB>OU2|ihRL5sM^|G$q zZxtEl>or&MJt%75@vAr6QB2b#uDt1WcKQ#m)QOdOquWNfTYg9(z3!{o5GphcKrQYl zy!E@@As(vrI{lhlBU7FtDCTD;15UqzTwVCtDA9u@T%MU|Mm*CUne(23=7(aRKF(|3 z@=J}m0Np%5Aok=7ZlG7WRvRANkD|w*t?b$i6L33lW6|iBJh?tc1ct~OGGt$$t~|#G z?qams-EnX18Yv_}n`EElz@_N;{)X<$~{#UM!gR4n0bS{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!kd zm?L=5%2V*eZ1wTT_6Ks#F@cZteX=c8)rG2bD5AgK)n~3pX%sCN$=OTVnoF1HY*5Ka zakdh+Ja7)bJaE1vn&fxr##I;4uZW;39()xKurG|{>}igzwgI#MS`VAH0pq7_E*#YS zCg3~Y(cUki`Y(?q%$I|j02;h62d(C_Gfq?yFf6KwhyY>&Km?EwKuQ1^0ptWw5I{)) z6+WuyoDPQtkcbZO|GPGSHwkBhzdamn^*?F9>=a2L0Puzg066ytCk3lx0b%~12FpKj zrv&PM?3RBr|F1^nFA6nb@Qw68ZOK2B-_Dcu%#5!3*pvu2=g-btdz=Z(; z-v~Au-9MrTBkc;{Z(UYSwzf7lu2x8UXE#DK_K&*X|4$-eA7(CD;@`n;u7dvroShH0 z_m>b2Sz_#_4VaGL+WmQzB^N7-B}xb`9*hJ)`-cGaL(tzj;g8*%Tw&HQxBuGy_vtqj zb_-m6Mg$0srUB6W!7q77@;Cq20iV$Y{=I*-u~7~W2NhtBl^?+H2cJlS9Gg}IWMt4* WCm~!dfRLUBz(jED%uOML+5Z8osX0Ob diff --git a/libantosdk/core/worker.js b/libantosdk/core/worker.js index 3322d7f..6ee2f5b 100644 --- a/libantosdk/core/worker.js +++ b/libantosdk/core/worker.js @@ -72,7 +72,18 @@ class AntOSDKBaseJob { id: this.job.id, type: "log", error: false, - result: data + result: data, + show_time: true + }); + } + + log_print(data) { + postMessage({ + id: this.job.id, + type: "log", + error: false, + result: data, + show_time: false }); } @@ -81,7 +92,8 @@ class AntOSDKBaseJob { id: this.job.id, type: "log", error: true, - result: data + result: data, + show_time: true }); } diff --git a/libantosdk/package.json b/libantosdk/package.json index 8f9ce9d..280dfee 100644 --- a/libantosdk/package.json +++ b/libantosdk/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "mrsang@iohub.dev" }, - "version": "0.0.4-a", + "version": "0.0.5-a", "category": "Other", "iconclass": "fa fa-cog", "mimes": [ diff --git a/libantosdk/ts/main.ts b/libantosdk/ts/main.ts index 99243fc..f69ba03 100644 --- a/libantosdk/ts/main.ts +++ b/libantosdk/ts/main.ts @@ -13,6 +13,7 @@ namespace OS { type: "result"|"log"; error?: any; result?: any; + show_time?:boolean; } interface AntOSDKWorkerJob { @@ -44,7 +45,12 @@ namespace OS { if(ret.error) job.logger.error(ret.result); else - job.logger.info(ret.result); + { + if(ret.show_time === false && job.logger.print) + job.logger.print(ret.result); + else + job.logger.info(ret.result); + } } } else @@ -77,7 +83,7 @@ namespace OS { return `job_${Math.random().toString(36).replace(".","")}`; } - private exectue_job(cmd: string, data: any, root:string, callback: (AntOSDKWorkerResult) => void, logger?: AntOSDKLogger): void + private exectue_job(cmd: string, data: any, root:string, callback: (arg: AntOSDKWorkerResult) => void, logger?: AntOSDKLogger): void { const id = this.newJobID(); const job: AntOSDKWorkerJob = { diff --git a/packages.json b/packages.json index ee79712..65c734f 100644 --- a/packages.json +++ b/packages.json @@ -195,7 +195,7 @@ "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/README.md", "category": "Other", "author": "Xuan Sang LE", - "version": "0.0.4-a", + "version": "0.0.5-a", "dependencies": [], "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/build/release/libantosdk.zip" },