Update libantosdk

This commit is contained in:
lxsang 2022-07-04 21:40:46 +02:00
parent 54fd3b09f9
commit 92025918e0
11 changed files with 14 additions and 355 deletions

View File

@ -1,17 +0,0 @@
# LibGitGraph
Git grapth visualization API for AntOS application.
The visualization can be easily integrated to an AntOS application, example:
```typescript
const graph = new API.LibGitGraph({
target: this.find("git-graph")
});
graph.on_open_diff = (files) => {
console.log(files);
}
graph.base_dir = "home://workspace/repo-git";
```
## Change logs:
- v0.1.0-b: Initial version

View File

@ -1,86 +0,0 @@
-- nothing todo for now
local args=...
local vfs = require("vfs")
local result = function(data)
return { error = false, result = data }
end
local error = function(msg)
return {error = msg, result = false}
end
local handle = {}
handle.log = function(data)
-- convert VFS to OS path
local os_path = vfs.ospath(data.base_dir)
if(not os_path) then
return error("Base dir "..data.base_dir.." is not found")
end
local cmd = "cd "..os_path.." && "
cmd = cmd.."git --no-pager log -n "..data.n_commits.." --all --format='{ \"hashes\":{ \"commit\":\"%H\", \"tree\":\"%T\", \"parents\":\"%P\" }, \"author\":{ \"date\": \"%ai\", \"name\": \"%an\", \"email\":\"%ae\" }, \"committer\":{ \"date\": \"%ci\", \"name\": \"%cn\", \"email\":\"%ce\" }, \"extra\":\"%D\"} ====:RAW:====%B====:RAW:========:COMMITEND:===='"
if(data.before) then
cmd = cmd.." --before='"..data.before.."'"
end
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
local ret = {}
for line in s:gmatch("(.-)====:COMMITEND:====\n") do
local arr = {}
for el in line:gmatch("(.-)====:RAW:====") do
table.insert(arr, el)
end
local commit = JSON.decodeString(arr[1])
commit.message = arr[2]
table.insert(ret, commit)
end
return result(ret)
end
handle.list_file = function(data)
local os_path = vfs.ospath(data.base_dir)
if(not os_path) then
return error("Base dir "..data.base_dir.." is not found")
end
local cmd = "cd "..os_path..' && git --no-pager log -m -1 --name-status --pretty="format:" '..data.commit
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
local ret = {}
for line in s:gmatch("(.-)\n") do
table.insert(ret, line)
end
return result(ret)
end
handle.get_changes = function(data)
local os_path = vfs.ospath(data.base_dir)
if(not os_path) then
return error("Base dir "..data.base_dir.." is not found")
end
local cmd = "cd "..os_path.." && git --no-pager diff --no-prefix -U1000 "..data.commit.."^:"..data.file.." "..data.commit..":"..data.file
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
return result(s)
end
handle.get_file = function(data)
local os_path = vfs.ospath(data.base_dir)
if(not os_path) then
return error("Base dir "..data.base_dir.." is not found")
end
local cmd = "cd "..os_path.." && git --no-pager show "..data.commit..":"..data.file
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
return result(s)
end
if args.action and handle[args.action] then
return handle[args.action](args.args)
else
return error("Invalid action parameter")
end

File diff suppressed because one or more lines are too long

View File

@ -1,208 +0,0 @@
afx-app-window[data-id="GitGraph"] div[data-id="git-graph"]
{
overflow-y: auto;
background-color: bisque;
}
afx-app-window[data-id="GitGraph"] afx-label[data-id="txt-repo"] i.label-text
{
display: block;
text-align: center;
font-weight: bold;
}
p.git_graph_commit_message:hover
{
background-color:rgba(39, 39, 39,0.5);
}
p.git_graph_commit_current_head
{
font-weight: bold;
}
p.git_graph_commit_message i.git_graph_commit_hash
{
font-weight: bold;
margin-right: 5px;
font-style: normal;
margin: 0;
padding: 0;
display: inline-block;
}
p.git_graph_commit_message i.git_graph_commit_tag,
p.git_graph_commit_message i.git_graph_commit_branch
{
border: 1px solid;
font-style: normal;
border-radius: 5px;
line-height: 20px;
padding: 0;
padding-left: 2px;
padding-right: 2px;
font-weight: bold;
margin: 0;
display: inline-block;
}
p.git_graph_commit_message i.git_graph_commit_tag::before
{
font-family: 'bootstrap-icons';
content: "\F5AF";
font-style: normal;
font-weight: normal;
position: relative;
top: 2px;
padding-right: 3px;
}
p.git_graph_commit_message i.git_graph_commit_branch::before
{
font-family: 'FontAwesome';
content: "\f126";
font-style: normal;
font-weight: normal;
position: relative;
top: 1px;
padding-right: 3px;
}
div.git_grapth_commit_detail
{
border-radius: 5px;
background-color: whitesmoke;
box-shadow: 0px 3px 6px 0px rgb(0,0,0,0.5);
}
div.git_grapth_commit_detail_right,
div.git_grapth_commit_detail_left {
background-color: transparent !important;
padding: 10px;
}
div.git_grapth_commit_detail_left {
padding-top: 20px;
}
div.git_grapth_commit_detail_left p{
margin: 0;
padding: 0;
word-wrap:break-word;
margin-bottom: 5px;
}
div.git_grapth_commit_detail_left pre
{
margin: 0;
padding-top: 10px;
display: block;
border-top: 1px solid #9c9c9c;
}
div.git_grapth_commit_detail_right a{
white-space:nowrap;
}
div.git_grapth_commit_detail_right a.git_graph_file_m::before
{
font-family: 'bootstrap-icons';
content: "\F364";
font-style: normal;
font-weight: normal;
color: blue !important;
padding-right: 5px;
}
div.git_grapth_commit_detail_right a.git_graph_file_a::before
{
font-family: 'bootstrap-icons';
content: "\F37D";
font-style: normal;
font-weight: normal;
color: green !important;
padding-right: 5px;
}
div.git_grapth_commit_detail_right a.git_graph_file_d::before
{
font-family: 'bootstrap-icons';
content: "\F368";
font-style: normal;
font-weight: normal;
color: red !important;
padding-right: 5px;
}
div.git_grapth_commit_detail_ctrl i::before{
display: block;
font-family: 'bootstrap-icons';
content: "\F622";
font-style: normal;
font-weight: normal;
margin-left: 5px;
margin-top: 5px;
}
div.git_grapth_commit_detail_ctrl i {
width: 20px;
height: 20px;
display: block;
overflow: hidden;
}
div.git_grapth_commit_detail_right ul{
margin: 0;
padding: 0;
list-style: none;
}
p.git_graph_commit_message i.git_graph_commit_text
{
font-style: normal;
display: inline-block;
}
p.git_graph_commit_message i.git_graph_commit_author::before
{
font-family: 'bootstrap-icons';
content: "\F4DC";
font-style: normal;
font-weight: normal;
padding-left: 5px;
padding-right: 3px;
position: relative;
top: 3px;
line-height: 20px;
}
p.git_graph_commit_message i.git_graph_commit_date::before
{
font-family: 'bootstrap-icons';
content: "\F205";
font-style: normal;
font-weight: normal;
padding-right: 3px;
padding-left: 5px;
position: relative;
top: 2px;
line-height: 20px;
}
p.git_grapth_load_more
{
font-weight: normal ;
text-align: left;
color:#131313;
display: inline-block !important;
padding-left: 5px !important;
padding-right: 5px !important;
}
p.git_grapth_load_more::before
{
font-family: 'bootstrap-icons';
content: "\F118";
font-style: normal;
font-weight: normal;
display: inline-block;
padding-right: 5px;
}
p.git_grapth_load_more:hover
{
cursor: pointer;
}

View File

@ -1 +0,0 @@
var OS;!function(t){let i,e;i=t.API||(t.API={}),function(t){class e extends t.BaseApplication{constructor(t){super("GitGraph",t)}main(){const t=new i.LibGitGraph({target:this.find("git-graph")});t.on_open_diff=t=>{this._gui.launch("Antedit",[]).then(i=>{i.observable.one("launched",()=>i.openDiff(t))}).catch(t=>this.error(__("Unable to open diff with Antedit: {0}",t.toString()),t))},this.find("btn-open").onbtclick=i=>{this.openDialog("FileDialog",{title:__("Select a repository"),type:"dir"}).then(i=>{this.find("txt-repo").text=i.file.path,t.base_dir=i.file})}}}t.GitGraph=e,e.dependencies=["pkg://GitGraph/libgitgraph.js"]}(e=t.application||(t.application={}))}(OS||(OS={}));

View File

@ -1,16 +0,0 @@
{
"pkgname": "GitGraph",
"app":"GitGraph",
"name":"GIT Visualization",
"description":"Git Grapth",
"info":{
"author": "Dany LE",
"email": "contact@iohub.dev"
},
"version":"0.0.1-a",
"category":"Development",
"iconclass":"bi bi-git",
"mimes":["dir"],
"dependencies":[],
"locale": {}
}

View File

@ -1,12 +0,0 @@
<afx-app-window apptitle="LibGitGraph" width="600" height="400" data-id="GitGraph">
<afx-vbox>
<afx-hbox data-height="25">
<afx-button data-width="24" iconclass = "bi bi-folder2-open" data-id="btn-open"></afx-button>
<afx-label data-id="txt-repo"></afx-label>
</afx-hbox>
<afx-hbox >
<div data-id="git-graph">
</div>
</afx-hbox>
</afx-vbox>
</afx-app-window>

Binary file not shown.

View File

@ -446,13 +446,12 @@ class VFSJob extends AntOSDKBaseJob {
case 'rm':
this.delete(this.job.data)
.then(d => this.result(d))
.catch((e) => {
if(this.job.ignore_error)
{
return this.result(false);
}
this.error(e);
});
.catch((e) =>this.error(e));
break;
case 'rm-no-error':
this.delete(this.job.data)
.then(d => this.result(d))
.catch((e) =>this.result(false));
break;
case 'mkdir':
this.mkdir(this.job.data)
@ -479,6 +478,7 @@ API.jobhandle["sdk-import"] = LoadScritpJob;
API.jobhandle["sdk-setup"] = SDKSetup;
API.jobhandle["vfs-cat"] = VFSJob;
API.jobhandle["vfs-rm"] = VFSJob;
API.jobhandle["vfs-rm-no-error"] = VFSJob;
API.jobhandle["vfs-mkdir"] = VFSJob;
API.jobhandle["vfs-cp"] = VFSJob;

View File

@ -446,13 +446,12 @@ class VFSJob extends AntOSDKBaseJob {
case 'rm':
this.delete(this.job.data)
.then(d => this.result(d))
.catch((e) => {
if(this.job.ignore_error)
{
return this.result(false);
}
this.error(e);
});
.catch((e) =>this.error(e));
break;
case 'rm-no-error':
this.delete(this.job.data)
.then(d => this.result(d))
.catch((e) =>this.result(false));
break;
case 'mkdir':
this.mkdir(this.job.data)
@ -479,6 +478,7 @@ API.jobhandle["sdk-import"] = LoadScritpJob;
API.jobhandle["sdk-setup"] = SDKSetup;
API.jobhandle["vfs-cat"] = VFSJob;
API.jobhandle["vfs-rm"] = VFSJob;
API.jobhandle["vfs-rm-no-error"] = VFSJob;
API.jobhandle["vfs-mkdir"] = VFSJob;
API.jobhandle["vfs-cp"] = VFSJob;