Skip to content

Commit

Permalink
chore: start refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
molecula451 committed Mar 1, 2024
1 parent c0f6a42 commit 31c9d70
Show file tree
Hide file tree
Showing 72 changed files with 14,315 additions and 16 deletions.
28 changes: 21 additions & 7 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import esbuild from "esbuild";
const typescriptEntries = ["static/main.ts"];
// const cssEntries = ["static/style.css"];
const entries = [
...typescriptEntries,
// ...cssEntries
];
import * as dotenv from "dotenv";

const typescriptEntries = ["static/scripts/rewards/index.ts", "static/scripts/audit-report/audit.ts"];
const cssEntries = ["static/styles/rewards/rewards.css", "static/styles/audit-report/audit.css"];
export const entries = [...typescriptEntries, ...cssEntries];

export const esBuildContext: esbuild.BuildOptions = {
sourcemap: true,
Expand All @@ -19,7 +18,8 @@ export const esBuildContext: esbuild.BuildOptions = {
".ttf": "dataurl",
".svg": "dataurl",
},
outdir: "static/dist",
outdir: "static/out",
define: createEnvDefines(["SUPABASE_URL", "SUPABASE_ANON_KEY"]),
};

esbuild
Expand All @@ -31,3 +31,17 @@ esbuild
console.error(err);
process.exit(1);
});

function createEnvDefines(envVarNames: string[]): Record<string, string> {
const defines: Record<string, string> = {};
dotenv.config();
for (const name of envVarNames) {
const envVar = process.env[name];
if (envVar !== undefined) {
defines[name] = JSON.stringify(envVar);
} else {
throw new Error(`Missing environment variable: ${name}`);
}
}
return defines;
}
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ts-template",
"version": "1.0.0",
"description": "Template repository with TypeScript support.",
"description": "audit.ubq.fi",
"main": "build/index.ts",
"author": "Ubiquity DAO",
"license": "MIT",
Expand All @@ -27,7 +27,14 @@
"open-source"
],
"dependencies": {
"dotenv": "^16.4.4"
"@octokit/plugin-throttling": "^8.1.3",
"@octokit/rest": "^20.0.2",
"@sinclair/typebox": "^0.32.14",
"@supabase/supabase-js": "2.39.7",
"axios": "^1.6.7",
"dotenv": "^16.4.4",
"ethers": "^5.7.2",
"godb": "^0.6.2"
},
"devDependencies": {
"@commitlint/cli": "^18.6.1",
Expand Down
74 changes: 67 additions & 7 deletions static/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,73 @@
<!doctype html>
<html lang="en">
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ubiquity TypeScript Template</title>
<link rel="stylesheet" href="style.css" />
<title>Audit report</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="out/styles/audit-report/audit.css" rel="stylesheet" />
</head>

<body>
<h1>Ubiquity TypeScript Template</h1>
<script type="module" src="dist/main.js"></script>
<div class="container">
<h1 class="audit-tag">Audit report</h1>
<!-- params -->
<div class="mb-3">
<label for="botWalletAddress" class="form-label">Bot wallet address</label>
<input type="text" class="form-control" id="botWalletAddress" />
</div>
<div class="mb-3">
<label for="repoURLs" class="form-label">Repository URLs</label>
<input type="text" class="form-control" id="repoURLs" />
</div>
<div class="mb-3">
<label for="githubPAT" class="form-label">Github Personal Access Token</label>
<input type="text" class="form-control" id="githubPAT" />
</div>
<div class="mb-3">
<label for="quickName" class="form-label">Quick Import</label>
<textarea
type="text"
class="form-control"
id="quickName"
placeholder='
{
"WALLET": "",
"REPO": "",
"PAT": ""
}'
></textarea>
</div>
<div class="btn-container">
<button type="button" class="btn btn-primary mb-3" id="getReport">
<span class="btn-loader" id="report-loader"></span>
<span>Get report</span>
</button>
<div class="tg-list-item">
<input class="tgl tgl-flat" id="cb4" type="checkbox" />
<label class="tgl-btn" for="cb4"></label>
<div class="cache-title">⚡Cache</div>
</div>
</div>
<!-- result table -->
<div class="resultContainer">
<input type="text" id="searchInput" placeholder="Filter Result" />
<table id="resultTable" class="table" style="display: none">
<thead>
<tr>
<th scope="col">Organization/Repo Name</th>
<th scope="col">Issue URL</th>
<th scope="col">Bounty Hunter</th>
<th scope="col" id="amountHeader">Amount <span id="sortArrow">&#8595;</span></th>
<th scope="col">TX URL</th>
</tr>
</thead>
<tbody>
<!-- table content -->
</tbody>
</table>
</div>
</div>
<ul class="notifications"></ul>
<script src="out/scripts/audit-report/audit.js" type="application/javascript"></script>
</body>
</html>
Loading

0 comments on commit 31c9d70

Please sign in to comment.