mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2025-07-13 06:04:26 +02:00
enable downlevelIteration build option in typescript
This commit is contained in:
70
libantosdk/build/debug/core/linux.worker.js
Normal file
70
libantosdk/build/debug/core/linux.worker.js
Normal file
@ -0,0 +1,70 @@
|
||||
class LinuxJob extends AntOSDKBaseJob {
|
||||
constructor(data)
|
||||
{
|
||||
super(data);
|
||||
}
|
||||
execute()
|
||||
{
|
||||
switch (this.job.cmd) {
|
||||
case 'linux-exec':
|
||||
/**
|
||||
* Execute a linux command with the
|
||||
* help of a server side lua API
|
||||
* script
|
||||
*/
|
||||
this.exec();
|
||||
break;
|
||||
default:
|
||||
const err_msg = `Unkown job ${this.job.cmd}`;
|
||||
this.log_error(err_msg);
|
||||
return this.error(err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
exec()
|
||||
{
|
||||
const path = "pkg://libantosdk/core/lua/api.lua".abspath(this.job.root);
|
||||
const url = API.REST.replace("http","ws") + "/system/apigateway?ws=1";
|
||||
try{
|
||||
const socket = new WebSocket(url);
|
||||
socket.onerror = (e)=> {
|
||||
this.log_error(e.toString());
|
||||
this.error(e);
|
||||
socket.close();
|
||||
};
|
||||
socket.onclose = (e) => {
|
||||
this.log_info("Connection closed");
|
||||
this.result("Done");
|
||||
};
|
||||
socket.onopen = (e) => {
|
||||
// send the command
|
||||
const cmd = {
|
||||
path: path,
|
||||
parameters: {
|
||||
action: "exec",
|
||||
args: this.job.data
|
||||
}
|
||||
};
|
||||
socket.send(JSON.stringify(cmd));
|
||||
};
|
||||
socket.onmessage = (e) => {
|
||||
const json = JSON.parse(e.data);
|
||||
if(json.error)
|
||||
{
|
||||
this.log_error(json.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.log_print(json.result);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
this.log_error(error.toString());
|
||||
return this.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
API.jobhandle["linux-exec"] = LinuxJob;
|
31
libantosdk/build/debug/core/lua/api.lua
Normal file
31
libantosdk/build/debug/core/lua/api.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local args=...
|
||||
|
||||
local result = function(data)
|
||||
return { error = false, result = data }
|
||||
end
|
||||
|
||||
local error = function(msg)
|
||||
return {error = msg, result = false}
|
||||
end
|
||||
|
||||
local handle = {}
|
||||
|
||||
handle.exec = function(data)
|
||||
local cmd = data.cmd
|
||||
if data.pwd then
|
||||
cmd = "cd "..require("vfs").ospath(data.pwd).. " && "..cmd
|
||||
end
|
||||
cmd = cmd.." 2>&1"
|
||||
local pipe = io.popen(cmd)
|
||||
for line in pipe:lines() do
|
||||
echo(JSON.encode(result(line)))
|
||||
end
|
||||
pipe:close()
|
||||
return result("Done: ["..cmd.."]")
|
||||
end
|
||||
|
||||
if args.action and handle[args.action] then
|
||||
return handle[args.action](args.args)
|
||||
else
|
||||
return error("Invalid action parameter")
|
||||
end
|
@ -92,6 +92,7 @@ class TSJob extends AntOSDKBaseJob {
|
||||
const program = ts.createProgram(files, {
|
||||
"target": "es6",
|
||||
"skipLibCheck": true,
|
||||
"downlevelIteration": true
|
||||
}, host);
|
||||
const result = program.emit();
|
||||
const diagnostics = result.diagnostics.concat((ts.getPreEmitDiagnostics(program)));
|
||||
|
Reference in New Issue
Block a user