Page MenuHomeSealhub

index.ts
No OneTemporary

index.ts

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

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)

Event Timeline