Skip to content

Commit 18088ab

Browse files
committed
fmt
1 parent f75111a commit 18088ab

18 files changed

Lines changed: 523 additions & 405 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ fmt: ## Format the code
4949
@cd $(SYNC_SERVER_DIR) && $(PACKAGE_MANAGER) run prettier:check
5050
@cd $(LIB_DIR) && $(PACKAGE_MANAGER) run prettier:fix
5151
@cd $(LIB_DIR) && $(PACKAGE_MANAGER) run prettier:check
52+
@cd $(CLI_DIR) && $(PACKAGE_MANAGER) run prettier:fix
53+
@cd $(CLI_DIR) && $(PACKAGE_MANAGER) run prettier:check
5254

5355
.PHONY: check
5456
check: ## Check the code

atw-cli/bun.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

atw-cli/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"type": "module",
55
"version": "1.2.0",
66
"private": true,
7+
"scripts": {
8+
"prettier:check": "prettier --check .",
9+
"prettier:fix": "prettier --write ."
10+
},
711
"devDependencies": {
812
"@types/bun": "latest",
913
"@types/qrcode-terminal": "^0.12.2",

atw-cli/src/actions/register.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
import { ATW_API_BASEURL } from "../config"
1+
import { ATW_API_BASEURL } from "../config";
22

33
export type Event = {
4-
id: string
5-
slug: string
6-
name: string
7-
startDate: number
8-
tagline: string
9-
shortLocation: string|null
10-
}
4+
id: string;
5+
slug: string;
6+
name: string;
7+
startDate: number;
8+
tagline: string;
9+
shortLocation: string | null;
10+
};
1111

12-
export const registerAction = async (email: string, eventId: Event['id']) => {
13-
const response = await fetch(`${ATW_API_BASEURL}/events/${eventId}/register`, {
14-
method: 'POST',
15-
body: JSON.stringify({ email })
16-
})
17-
return await response.json()
18-
}
12+
export const registerAction = async (email: string, eventId: Event["id"]) => {
13+
const response = await fetch(
14+
`${ATW_API_BASEURL}/events/${eventId}/register`,
15+
{
16+
method: "POST",
17+
body: JSON.stringify({ email }),
18+
},
19+
);
20+
return await response.json();
21+
};

atw-cli/src/commands/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@ import { createJarvis } from "../core/create-jarvis";
22
import { createRegisterCommand } from "./register";
33

44
const jarvis = createJarvis("Plopix");
5-
export const commands = [
6-
createRegisterCommand({ tBot:jarvis }),
7-
]
8-
5+
export const commands = [createRegisterCommand({ tBot: jarvis })];

atw-cli/src/commands/register.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
import { Command } from "commander";
2-
import { render } from 'ink';
2+
import { render } from "ink";
33
import { RegisterJourney } from "../ui/journeys/register";
44
import pc from "picocolors";
55
import { logo } from "..";
66
import { AppLayout } from "../ui/app-layout";
77
import type { TalkativeBot } from "../contracts/talkative-bot-interface";
88

99
type Deps = {
10-
tBot: TalkativeBot
11-
}
12-
export const createRegisterCommand = (deps:Deps): Command => {
13-
const command = new Command("register")
14-
.description("Register to an event.")
15-
.action(async () => {
16-
console.log(pc.dim(logo));
17-
deps.tBot.say("We can't wait to see you soon! Select one of the events below to register.");
18-
const { waitUntilExit, unmount } = render(
19-
<AppLayout title="Register to an event!">
20-
<RegisterJourney unmount={() => unmount()} deps={deps} />
21-
</AppLayout>,
22-
{
23-
exitOnCtrlC: true,
24-
}
25-
);
26-
await waitUntilExit();
27-
});
28-
return command;
29-
}
10+
tBot: TalkativeBot;
11+
};
12+
export const createRegisterCommand = (deps: Deps): Command => {
13+
const command = new Command("register")
14+
.description("Register to an event.")
15+
.action(async () => {
16+
console.log(pc.dim(logo));
17+
deps.tBot.say(
18+
"We can't wait to see you soon! Select one of the events below to register.",
19+
);
20+
const { waitUntilExit, unmount } = render(
21+
<AppLayout title="Register to an event!">
22+
<RegisterJourney unmount={() => unmount()} deps={deps} />
23+
</AppLayout>,
24+
{
25+
exitOnCtrlC: true,
26+
},
27+
);
28+
await waitUntilExit();
29+
});
30+
return command;
31+
};

atw-cli/src/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
export const ATW_BASEURL = process.env.AWT_BASEURL || "https://allthingsweb.dev";
2-
export const ATW_API_BASEURL = process.env.ATW_API_BASEURL || `${ATW_BASEURL}/api`;
1+
export const ATW_BASEURL =
2+
process.env.AWT_BASEURL || "https://allthingsweb.dev";
3+
export const ATW_API_BASEURL =
4+
process.env.ATW_API_BASEURL || `${ATW_BASEURL}/api`;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export type TalkativeBot = {
2-
say: (text: string) => Promise<void>;
3-
shutup: () => Promise<void>;
4-
isSpeaking: () => boolean;
5-
}
2+
say: (text: string) => Promise<void>;
3+
shutup: () => Promise<void>;
4+
isSpeaking: () => boolean;
5+
};

atw-cli/src/core/create-jarvis.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
import type { TalkativeBot } from "../contracts/talkative-bot-interface";
22

33
export const createJarvis = (voice: string): TalkativeBot => {
4-
let currentOuput: ReturnType<typeof Bun.spawn> | null = null;
4+
let currentOuput: ReturnType<typeof Bun.spawn> | null = null;
55

6-
const shutup = async () => {
7-
if (currentOuput) {
8-
currentOuput.kill('SIGKILL');
9-
await currentOuput.exited;
10-
}
11-
currentOuput = null;
12-
}
13-
return {
14-
say: async (text: string) => {
15-
try {
16-
await shutup();
17-
currentOuput = Bun.spawn(['say', '-v', voice, text]);
18-
await currentOuput.exited;
19-
} catch (e) {
20-
currentOuput = null;
21-
}
22-
},
23-
shutup,
24-
isSpeaking: () => {
25-
return currentOuput !== null;
26-
}
6+
const shutup = async () => {
7+
if (currentOuput) {
8+
currentOuput.kill("SIGKILL");
9+
await currentOuput.exited;
2710
}
28-
29-
}
11+
currentOuput = null;
12+
};
13+
return {
14+
say: async (text: string) => {
15+
try {
16+
await shutup();
17+
currentOuput = Bun.spawn(["say", "-v", voice, text]);
18+
await currentOuput.exited;
19+
} catch (e) {
20+
currentOuput = null;
21+
}
22+
},
23+
shutup,
24+
isSpeaking: () => {
25+
return currentOuput !== null;
26+
},
27+
};
28+
};
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import qrcode from 'qrcode-terminal';
1+
import qrcode from "qrcode-terminal";
22

3-
export const generateQrCode = async (input: string, small = true) => new Promise<string>((resolve, reject) => {
3+
export const generateQrCode = async (input: string, small = true) =>
4+
new Promise<string>((resolve, reject) => {
45
qrcode.generate(input, { small }, (qrcode) => {
5-
if (qrcode) {
6-
resolve(qrcode);
7-
} else {
8-
reject(new Error("Failed to generate QR code"));
9-
}
6+
if (qrcode) {
7+
resolve(qrcode);
8+
} else {
9+
reject(new Error("Failed to generate QR code"));
10+
}
1011
});
11-
});
12+
});

0 commit comments

Comments
 (0)