Skip to content

Commit efd78dc

Browse files
committed
feat: cli 1.20 and CS
1 parent 1afc7a8 commit efd78dc

File tree

20 files changed

+198
-169
lines changed

20 files changed

+198
-169
lines changed

Makefile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,15 @@ serve: website/.env ## Serve the application
7575

7676
.PHONY: build-cli
7777
build-cli: ## Build CLI
78-
@cd $(CLI_DIR) && bun build --bundle src/index.ts --outfile atw-cli.js --target=bun
79-
@cd $(CLI_DIR) && bun shim.ts
80-
@cd $(CLI_DIR) && bun build --compile --minify atw-cli.js --outfile atw-cli
81-
@cd $(CLI_DIR) && rm atw-cli.js
78+
@cd $(CLI_DIR) && bun build --compile --minify src/index --outfile atw-cli
79+
@cd $(CLI_DIR) && rm -f .*.bun-build
8280

8381
.PHONY: build-all-cli
8482
build-all-cli:
85-
@cd $(CLI_DIR) && bun build --bundle src/index.ts --outfile atw-cli.js --target=bun
86-
@cd $(CLI_DIR) && bun shim.ts
8783
@cd $(CLI_DIR) && for target in bun-linux-x64 bun-linux-arm64 bun-windows-x64 bun-darwin-x64 bun-darwin-arm64; do \
88-
bun build --compile --minify atw-cli.js --outfile atw-cli-$$target --target=$$target; \
84+
bun build --compile --minify src/index --outfile atw-cli-$$target --target=$$target; \
8985
done
90-
@cd $(CLI_DIR) && rm atw-cli.js
86+
@cd $(CLI_DIR) && rm -f .*.bun-build
9187

9288
.PHONY: deploy-sync-permissions
9389
deploy-sync-permissions:

atw-cli/bun.lock

Lines changed: 11 additions & 5 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: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22
"name": "atw-cli",
33
"module": "index.ts",
44
"type": "module",
5-
"version": "1.1.0",
5+
"version": "1.2.0",
66
"private": true,
77
"devDependencies": {
88
"@types/bun": "latest",
9-
"@types/react": "^19.0.10"
9+
"@types/qrcode-terminal": "^0.12.2",
10+
"@types/react": "^19.0.11"
1011
},
1112
"peerDependencies": {
12-
"typescript": "^5"
13+
"typescript": "^5.8.2"
1314
},
1415
"dependencies": {
1516
"@inkjs/ui": "^2.0.0",
17+
"@rocicorp/zero": "^0.16.2025031000",
1618
"commander": "^13.1.0",
17-
"ink": "^5.1.1",
19+
"ink": "^5.2.0",
1820
"ink-link": "^4.1.0",
19-
"@rocicorp/zero": "^0.16.2025022602",
2021
"picocolors": "^1.1.1",
21-
"react": "^18",
22+
"qrcode-terminal": "^0.12.0",
23+
"react": "^18.3.1",
2224
"react-devtools-core": "^6.1.1"
2325
}
2426
}

atw-cli/shim.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

atw-cli/src/actions/register.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type Event = {
55
slug: string
66
name: string
77
startDate: number
8+
tagline: string
89
shortLocation: string|null
910
}
1011

atw-cli/src/commands/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { createJarvis } from "../core/create-jarvis";
12
import { createRegisterCommand } from "./register";
23

4+
const jarvis = createJarvis("Plopix");
35
export const commands = [
4-
createRegisterCommand()
6+
createRegisterCommand({ tBot:jarvis }),
57
]
68

atw-cli/src/commands/register.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ import { RegisterJourney } from "../ui/journeys/register";
44
import pc from "picocolors";
55
import { logo } from "..";
66
import { AppLayout } from "../ui/app-layout";
7+
import type { TalkativeBot } from "../contracts/talkative-bot-interface";
78

8-
export const createRegisterCommand = (): Command => {
9+
type Deps = {
10+
tBot: TalkativeBot
11+
}
12+
export const createRegisterCommand = (deps:Deps): Command => {
913
const command = new Command("register")
1014
.description("Register to an event.")
1115
.action(async () => {
1216
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.");
1318
const { waitUntilExit, unmount } = render(
1419
<AppLayout title="Register to an event!">
15-
<RegisterJourney unmount={() => unmount()} />
20+
<RegisterJourney unmount={() => unmount()} deps={deps} />
1621
</AppLayout>,
1722
{
1823
exitOnCtrlC: true,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export type TalkativeBot = {
2+
say: (text: string) => Promise<void>;
3+
shutup: () => Promise<void>;
4+
isSpeaking: () => boolean;
5+
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type { TalkativeBot } from "../contracts/talkative-bot-interface";
2+
3+
export const createJarvis = (voice: string): TalkativeBot => {
4+
let currentOuput: ReturnType<typeof Bun.spawn> | null = null;
5+
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+
}
27+
}
28+
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import qrcode from 'qrcode-terminal';
2+
3+
export const generateQrCode = async (input: string, small = true) => new Promise<string>((resolve, reject) => {
4+
qrcode.generate(input, { small }, (qrcode) => {
5+
if (qrcode) {
6+
resolve(qrcode);
7+
} else {
8+
reject(new Error("Failed to generate QR code"));
9+
}
10+
});
11+
});

0 commit comments

Comments
 (0)