Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1374896
index.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
index.ts
View Options
import
*
as
os
from
"os"
;
import
*
as
fs
from
"fs"
;
import
*
as
path
from
"path"
;
import
*
as
util
from
"util"
;
import
axios
from
"axios"
;
import
*
as
childProcess
from
"child_process"
;
// TODO(itsromek): Move this to some config file
const
API
=
"https://hub.sealcode.org/api/"
;
const
queryKey
=
"dTaNeNuwKB7l"
;
const
readFile
=
util
.
promisify
(
fs
.
readFile
);
const
writeFile
=
util
.
promisify
(
fs
.
writeFile
);
const
exec
=
util
.
promisify
(
childProcess
.
exec
);
interface
Task
{
description
:
any
;
cmd
:
string
;
}
interface
responseItem
{
id
:
number
;
fields
:
{
name
:
string
;
};
}
async
function
resolveAPIToken
()
:
Promise
<
string
>
{
const
config
=
await
readFile
(
path
.
resolve
(
os
.
homedir
(),
".arcrc"
));
const
parsedConfig
=
JSON
.
parse
(
config
.
toString
());
return
parsedConfig
.
hosts
[
API
].
token
;
}
async
function
getData
()
:
Promise
<
{
[
key
:
string
]
:
Task
}
>
{
const
results
:
{
[
key
:
string
]
:
Task
}
=
{};
const
apiToken
=
await
resolveAPIToken
();
const
res
=
await
axios
.
get
(
API
+
"maniphest.search"
,
{
data
:
`api.token=
${
apiToken
}
`
,
});
res
.
data
.
result
.
data
.
forEach
((
item
:
responseItem
)
=>
{
const
taskID
=
"T"
+
item
.
id
;
results
[
taskID
]
=
{
description
:
item
.
fields
.
name
,
cmd
:
`xdg-open https://hub.sealcode.org/
${
taskID
}
`
,
};
});
return
results
;
}
async
function
main
()
{
const
data
=
await
getData
();
await
writeFile
(
path
.
resolve
(
os
.
homedir
(),
".config/rofi-json-menu"
),
JSON
.
stringify
(
data
)
);
exec
(
"rofi -modi json-menu -show json-menu"
);
}
main
();
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Tue, Feb 25, 19:07 (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
610606
Default Alt Text
index.ts (1 KB)
Attached To
Mode
rROFI Roficator
Attached
Detach File
Event Timeline
Log In to Comment