Skip to content

Commit

Permalink
chore: use tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng authored and 0x4007 committed Feb 20, 2024
1 parent 8af6d6d commit ffee41e
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 18 deletions.
13 changes: 5 additions & 8 deletions airdrop-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
"format:prettier": "prettier --write .",
"format:cspell": "cspell **/*",
"prepare": "husky install",
"cli:debug": "node dist/index.js debug",
"cli:start": "node dist/index.js",
"cli:tally": "node dist/index.js tally",
"cli:single": "node dist/index.js single",
"cli:unspent": "node dist/index.js unspent",
"cli:help": "node dist/index.js help",
"cli:build": "npx tsc",
"cli:tsx": "yarn tsx src/invoke/index.ts",
"cli:debug": "npx tsx src/debug/cli-entry.ts",
"cli:tally": "npx tsx src/tally/cli-entry.ts",
"cli:single": "npx tsx src/single/cli-entry.ts",
"cli:unspent": "npx tsx src/unspent/cli-entry.ts",
"cli:help": "npx tsx src/help/cli-entry.ts",
"test": "npx jest"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion airdrop-cli/src/commands/single.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, command, param } from "clime";
import { processRepo } from "../invoke/invoke";
import { processRepo } from "../tally/tally";
import { genKeySet, loadingBar } from "../utils";

@command({
Expand Down
2 changes: 1 addition & 1 deletion airdrop-cli/src/commands/tally.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, command, metadata } from "clime";
import { invoke } from "../invoke/invoke";
import { invoke } from "../tally/tally";

// Tally command
// Takes around 1 minute to complete using async/await (rate limited using promises)
Expand Down
10 changes: 10 additions & 0 deletions airdrop-cli/src/debug/cli-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { loadingBar } from "../utils";
import { parseDebugData } from "../utils/debug";

(async () => {
const loader = await loadingBar();

await parseDebugData();

clearInterval(loader);
})();
11 changes: 11 additions & 0 deletions airdrop-cli/src/help/cli-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { genKeySet } from "../utils";

(async () => {
const keySet = await genKeySet();

console.log("Key\tRepository");
console.log("===\t==========");
for (const key of keySet) {
console.log(`${key.key}\t${key.name}`);
}
})();
7 changes: 0 additions & 7 deletions airdrop-cli/src/invoke/index.ts

This file was deleted.

15 changes: 15 additions & 0 deletions airdrop-cli/src/single/cli-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { processRepo } from "../tally/tally";
import { genKeySet, loadingBar } from "../utils";

(async (key: string) => {
const keySet = await genKeySet();

const filtered = keySet.filter((k) => k.key === key || k.name === key);
const loader = await loadingBar();

for (const key of filtered) {
await processRepo("Ubiquity", key.repo, false);
}

clearInterval(loader);
})(process.argv[2]);
5 changes: 5 additions & 0 deletions airdrop-cli/src/tally/cli-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { invoke } from "./tally";

(async () => {
await invoke();
})();
File renamed without changes.
23 changes: 23 additions & 0 deletions airdrop-cli/src/unspent/cli-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Erc20Permit, processAllUnclaimedPermits } from "./index";
import fs from "fs";
import { loadingBar, writeToFile } from "../utils";

(async () => {
const loader = await loadingBar();

let permits: Erc20Permit[];

try {
const temp = fs.readFileSync("./debug/repos/decoded-permits.json", "utf8");
permits = JSON.parse(temp);
} catch (err) {
console.log(err);
throw new Error("ERROR: Have you run the 'cli:tally' command?");
}

const unspentPermits = await processAllUnclaimedPermits(permits);

await writeToFile("./src/unspent/unspentPermits.json", JSON.stringify(unspentPermits, null, 2));

clearInterval(loader);
})();
2 changes: 1 addition & 1 deletion airdrop-cli/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchPublicRepositories } from "../invoke/invoke";
import { fetchPublicRepositories } from "../tally/tally";
import { CSVData, Contributor, DebugData, NoPayments, PaymentInfo, Permits, Repositories } from "../types";
import { writeFile } from "fs";
import { decodePermits } from "./debug";
Expand Down

0 comments on commit ffee41e

Please sign in to comment.