Skip to content

Commit d86c519

Browse files
committed
feat: ATW CLI
1 parent 10493b6 commit d86c519

17 files changed

Lines changed: 734 additions & 0 deletions

File tree

.github/workflows/cli-release.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
on:
2+
push:
3+
tags:
4+
- '*'
5+
6+
name: Release a New Version of the CLI
7+
8+
jobs:
9+
releaseandpublish:
10+
name: Release on Github
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: ⬇️ Checkout repo
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
fetch-tags: false
18+
19+
- name: ⎔ Setup bun
20+
uses: oven-sh/setup-bun@v2
21+
22+
- name: 📥 Download deps
23+
run: bun install --frozen-lockfile
24+
25+
- name: 🔨 Compiling the different versions
26+
run: make build-all-cli
27+
28+
- name: 🏷 Create GitHub Release
29+
run: |
30+
TAG_NAME=${GITHUB_REF_NAME}
31+
TAG_MESSAGE=$(git tag -l --format='%(contents)' "$TAG_NAME")
32+
gh release create "${TAG_NAME}" --title "Release ${TAG_NAME}" --notes "${TAG_MESSAGE}"
33+
env:
34+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: 🚀 Upload Assets
37+
run: |
38+
ASSET_PLATFORMS=("bun-linux-x64" "bun-linux-arm64" "bun-windows-x64.exe" "bun-darwin-x64" "bun-darwin-arm64")
39+
for platform in "${ASSET_PLATFORMS[@]}"; do
40+
if [ -f "atw-cli/atw-cli-$platform" ]; then
41+
gh release upload "${GITHUB_REF_NAME}" "atw-cli/atw-cli-$platform" --clobber
42+
echo "✅ Uploaded file for platform $platform"
43+
else
44+
echo "❌ File for platform $platform not found, skipping."
45+
fi
46+
done
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pages.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy to Pages
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: 'pages'
15+
cancel-in-progress: false
16+
17+
jobs:
18+
deploy:
19+
environment:
20+
name: github-pages
21+
url: ${{ steps.deployment.outputs.page_url }}
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: ⬇️ Checkout repo
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
fetch-tags: false
29+
30+
- name: 📦 Setup Pages
31+
uses: actions/configure-pages@v5
32+
33+
- name: 🦾 Upload artifact
34+
uses: actions/upload-pages-artifact@v3
35+
with:
36+
path: 'pages/'
37+
38+
- name: 🚢 Deploy to GitHub Pages
39+
id: deployment
40+
uses: actions/deploy-pages@v4

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PACKAGE_MANAGER := bun
99
CURRENT_DIR := $(shell pwd)
1010
DEPENDENCIES := bun git
1111
WEBSITE_DIR := $(CURRENT_DIR)/website
12+
CLI_DIR := $(CURRENT_DIR)/atw-cli
1213

1314
.PHONY: list
1415
list:
@@ -56,3 +57,19 @@ test: ## Run Playwright tests (requires dev server to be running)
5657
.PHONY: serve
5758
serve: website/.env ## Serve the application
5859
@cd $(WEBSITE_DIR) && $(PACKAGE_MANAGER) run dev
60+
61+
.PHONY: build-cli
62+
build-cli: ## Build CLI
63+
@cd $(CLI_DIR) && bun build --bundle src/index.ts --outfile atw-cli.js --target=bun
64+
@cd $(CLI_DIR) && bun shim.ts
65+
@cd $(CLI_DIR) && bun build --compile --minify atw-cli.js --outfile atw-cli
66+
@cd $(CLI_DIR) && rm atw-cli.js
67+
68+
.PHONY: build-all-cli
69+
build-all-cli:
70+
@cd $(CLI_DIR) && bun build --bundle src/index.ts --outfile atw-cli.js --target=bun
71+
@cd $(CLI_DIR) && bun shim.ts
72+
@cd $(CLI_DIR) && for target in bun-linux-x64 bun-linux-arm64 bun-windows-x64 bun-darwin-x64 bun-darwin-arm64; do \
73+
bun build --compile --minify atw-cli.js --outfile atw-cli-$$target --target=$$target; \
74+
done
75+
@rm atw-cli.js

atw-cli/.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store

atw-cli/bun.lock

Lines changed: 163 additions & 0 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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "atw-cli",
3+
"module": "index.ts",
4+
"type": "module",
5+
"version": "1.0.0",
6+
"private": true,
7+
"devDependencies": {
8+
"@types/bun": "latest",
9+
"@types/react": "^19.0.10"
10+
},
11+
"peerDependencies": {
12+
"typescript": "^5"
13+
},
14+
"dependencies": {
15+
"@inkjs/ui": "^2.0.0",
16+
"commander": "^13.1.0",
17+
"ink": "^5.1.1",
18+
"ink-link": "^4.1.0",
19+
"picocolors": "^1.1.1",
20+
"react": "18",
21+
"react-devtools-core": "^6.1.1"
22+
}
23+
}

atw-cli/shim.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Workaround to compile properly the yoga.wasm...
2+
const bin = Bun.file('atw-cli.js');
3+
let content = await new Response(bin).text();
4+
const pattern = /var Yoga = await initYoga\(await E\(_\(import\.meta\.url\)\.resolve\("\.\/yoga\.wasm"\)\)\);/g;
5+
const replacement = `import initYogaAsm from 'yoga-wasm-web/asm'; const Yoga = initYogaAsm();`;
6+
content = content.replace(pattern, replacement);
7+
await Bun.write('atw-cli.js', content);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
export type Event = {
3+
id: string
4+
slug: string
5+
name: string
6+
startDate: string
7+
location: string
8+
}
9+
10+
export const registerAction = async (email: string, eventId: Event['id']) => {
11+
const response = await fetch(`https://allthingsweb.dev/api/events/${eventId}/register`, {
12+
method: 'POST',
13+
body: JSON.stringify({ email })
14+
})
15+
if (!response.ok) {
16+
throw new Error('Failed to register')
17+
}
18+
const { success } = await response.json()
19+
return success
20+
}

atw-cli/src/commands/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { createRegisterCommand } from "./register";
2+
3+
export const commands = [
4+
createRegisterCommand()
5+
]
6+

0 commit comments

Comments
 (0)