Skip to content

Commit 2e041ac

Browse files
committed
chore: better claude file, include json config information, remove biome
1 parent 7290814 commit 2e041ac

File tree

6 files changed

+241
-91
lines changed

6 files changed

+241
-91
lines changed

CLAUDE.md

Lines changed: 149 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,156 @@
1-
Default to using Bun instead of Node.js.
2-
3-
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
4-
- Use `bun test` instead of `jest` or `vitest`
5-
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
6-
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
7-
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
8-
- Use `bunx <package> <command>` instead of `npx <package> <command>`
9-
- Bun automatically loads .env, so don't use dotenv.
10-
11-
## APIs
12-
13-
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
14-
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
15-
- `Bun.redis` for Redis. Don't use `ioredis`.
16-
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
17-
- `WebSocket` is built-in. Don't use `ws`.
18-
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
19-
- Bun.$`ls` instead of execa.
1+
# BackItUp Development Guide
2+
3+
BackItUp is a secure backup utility with glob patterns, tar.gz archives, local + S3 storage, Docker volume support, and safe cleanup. It's built with Bun and compiled to standalone binaries for cross-platform distribution.
4+
5+
## Quick Reference
6+
7+
```bash
8+
bun install # Install dependencies
9+
bun run dev # Development with hot reload
10+
bun test # Run tests
11+
bun run lint # Lint with oxlint
12+
bun run format # Format code with oxfmt
13+
bunx tsc --noEmit # Type check
14+
bun run build # Build standalone binary
15+
```
16+
17+
## Bun Runtime
18+
19+
Use Bun instead of Node.js for everything:
20+
21+
- `bun <file>` instead of `node` or `ts-node`
22+
- `bun test` instead of jest/vitest
23+
- `bun install` instead of npm/yarn/pnpm
24+
- `bun run <script>` instead of npm run
25+
- `bunx <pkg>` instead of npx
26+
- Bun auto-loads `.env` files (no dotenv needed)
27+
28+
### Bun APIs
29+
30+
- `Bun.file()` for file I/O (not `node:fs` readFile/writeFile)
31+
- `Bun.$\`cmd\`` for shell commands (not execa)
32+
- `bun:sqlite` for SQLite (not better-sqlite3)
33+
- `Bun.serve()` for HTTP/WebSocket servers
34+
35+
## Project Structure
36+
37+
```
38+
src/
39+
├── index.ts # CLI entry point, command routing
40+
├── types/ # TypeScript type definitions
41+
│ ├── config.ts # BackitupConfig, SourceConfig, etc.
42+
│ ├── backup.ts # BackupResult, BackupRecord
43+
│ ├── storage.ts # Storage interfaces
44+
│ └── database.ts # DB record types
45+
├── cli/
46+
│ ├── commands/ # backup, cleanup, list, start, verify
47+
│ └── ui/ # prompts, formatters, output helpers
48+
├── core/
49+
│ ├── backup/ # orchestrator, file-collector, archive-creator
50+
│ ├── cleanup/ # retention, validator, orchestrator
51+
│ └── scheduler/ # daemon, cron-parser
52+
├── config/ # loader, validator, resolver, inline options
53+
├── db/ # SQLite connection, repositories, migrations
54+
├── docker/ # volume backup, compose integration
55+
├── storage/ # local and S3 storage backends
56+
└── utils/ # logger, crypto, path, naming, format
57+
tests/ # Mirror of src/ structure
58+
```
59+
60+
## Code Style
61+
62+
- **Linter:** oxlint (run with `bun run lint`)
63+
- **Formatter:** oxfmt with double quotes, space indentation
64+
- **TypeScript:** Strict mode, ESNext target, bundler module resolution
65+
66+
### Conventions
67+
68+
- Commands return `Promise<number>` (exit code)
69+
- Use `@clack/prompts` and `picocolors` for CLI UI
70+
- Types are defined in `src/types/` and exported via barrel files
71+
- Repositories follow pattern: `*-repository.ts`
72+
- Core logic is in orchestrator files
2073

2174
## Testing
2275

23-
Use `bun test` to run tests.
76+
Tests live in `tests/` mirroring `src/` structure.
2477

25-
```ts#index.test.ts
26-
import { test, expect } from "bun:test";
78+
```ts
79+
import { describe, expect, test } from "bun:test";
2780

28-
test("hello world", () => {
29-
expect(1).toBe(1);
81+
describe("module", () => {
82+
test("does something", () => {
83+
expect(result).toBe(expected);
84+
});
3085
});
3186
```
87+
88+
Run tests: `bun test`
89+
90+
## CI/CD
91+
92+
CI runs on push/PR to main (`.github/workflows/ci.yml`):
93+
1. Type check: `bunx tsc --noEmit`
94+
2. Lint: `bun run lint`
95+
3. Test: `bun test`
96+
97+
Release runs on version tags (`.github/workflows/release.yml`):
98+
1. Same checks as CI
99+
2. Build binaries for linux-x64, linux-arm64, darwin-x64, darwin-arm64, windows-x64
100+
3. Generate SHA256 checksums
101+
4. Create GitHub release
102+
5. Build and push Docker image to ghcr.io
103+
104+
## Build Targets
105+
106+
```bash
107+
bun run build # Current platform
108+
bun run build:linux-x64 # Linux x64
109+
bun run build:linux-arm64 # Linux ARM64
110+
bun run build:darwin-x64 # macOS Intel
111+
bun run build:darwin-arm64 # macOS Apple Silicon
112+
bun run build:windows-x64 # Windows x64
113+
```
114+
115+
## Key Dependencies
116+
117+
- `@clack/prompts` - Interactive CLI prompts
118+
- `picocolors` - Terminal colors (imported as `color`)
119+
- `cron-parser` - Cron expression parsing
120+
- `js-yaml` - YAML config parsing
121+
122+
Dev:
123+
- `oxlint` - Linting
124+
- `oxfmt` - Formatting
125+
126+
## Configuration Types
127+
128+
Main config interface is `BackitupConfig` in `src/types/config.ts`:
129+
130+
- `sources: Record<string, SourceConfig>` - Named backup sources
131+
- `local: LocalStorageConfig` - Local storage settings
132+
- `s3: S3StorageConfig` - S3/R2/MinIO settings
133+
- `schedules: Record<string, ScheduleConfig>` - Cron schedules with retention
134+
- `docker?: DockerConfig` - Docker volume backup settings
135+
136+
## Common Tasks
137+
138+
### Adding a new command
139+
140+
1. Create `src/cli/commands/<name>.ts`
141+
2. Export `<name>Command(args: string[]): Promise<number>`
142+
3. Add case to switch in `src/index.ts`
143+
4. Add help text to `printHelp()`
144+
145+
### Adding a new config option
146+
147+
1. Add type to `src/types/config.ts`
148+
2. Update `src/config/defaults.ts`
149+
3. Update `src/config/validator.ts`
150+
4. If inline option, update `src/config/inline.ts`
151+
152+
### Database changes
153+
154+
1. Add migration to `src/db/migrations/`
155+
2. Update `src/db/migrations/index.ts`
156+
3. Update repository and mapper files as needed

README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Glob patterns • tar.gz compression • Local + S3 storage • Docker volumes
1313
[![Linux](https://img.shields.io/badge/Linux-FCC624?style=flat-square&logo=linux&logoColor=black)](https://github.com/climactic/backitup/releases)
1414
[![macOS](https://img.shields.io/badge/macOS-000000?style=flat-square&logo=apple&logoColor=white)](https://github.com/climactic/backitup/releases)
1515
[![Windows](https://img.shields.io/badge/Windows-0078D6?style=flat-square&logo=windows&logoColor=white)](https://github.com/climactic/backitup/releases)
16+
[![Docker](https://img.shields.io/badge/Docker-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/climactic/backitup/pkgs/container/backitup)
1617

1718
[![GitHub Sponsors](https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?style=for-the-badge&logo=githubsponsors)](https://github.com/sponsors/Climactic)
1819
[![Ko-fi](https://img.shields.io/badge/Support-Ko--fi-ff5e5b?style=for-the-badge&logo=ko-fi)](https://ko-fi.com/ClimacticCo)
@@ -73,7 +74,10 @@ docker pull ghcr.io/climactic/backitup:latest
7374

7475
## ⚡ Quick Start
7576

76-
**1.** Create `backitup.config.yaml` ([configuration reference](docs/configuration.md)):
77+
**1.** Create a config file ([configuration reference](docs/configuration.md)):
78+
79+
<details>
80+
<summary><b>backitup.config.yaml</b> (click to expand)</summary>
7781

7882
```yaml
7983
version: "1.0"
@@ -109,6 +113,45 @@ schedules:
109113
maxDays: 14 # Delete after 14 days
110114
```
111115
116+
</details>
117+
118+
<details>
119+
<summary><b>backitup.config.json</b> (click to expand)</summary>
120+
121+
```json
122+
{
123+
"version": "1.0",
124+
"database": {
125+
"path": "./data/backitup.db"
126+
},
127+
"sources": {
128+
"app": {
129+
"path": "/var/www/myapp",
130+
"patterns": ["**/*.ts", "**/*.js", "!**/node_modules/**"]
131+
}
132+
},
133+
"local": {
134+
"enabled": true,
135+
"path": "./backups"
136+
},
137+
"s3": {
138+
"enabled": false,
139+
"bucket": "my-backups"
140+
},
141+
"schedules": {
142+
"daily": {
143+
"cron": "0 2 * * *",
144+
"retention": {
145+
"maxCount": 7,
146+
"maxDays": 14
147+
}
148+
}
149+
}
150+
}
151+
```
152+
153+
</details>
154+
112155
**2.** Run:
113156

114157
```bash

biome.json

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

bun.lock

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,22 @@
55
"": {
66
"name": "backitup",
77
"dependencies": {
8-
"@clack/prompts": "^0.11.0",
9-
"cron-parser": "^5.4.0",
10-
"js-yaml": "^4.1.1",
8+
"@clack/prompts": "latest",
9+
"cron-parser": "latest",
10+
"js-yaml": "latest",
1111
},
1212
"devDependencies": {
13-
"@biomejs/biome": "2.3.10",
1413
"@types/bun": "latest",
15-
"@types/js-yaml": "^4.0.9",
16-
"oxfmt": "^0.18.0",
17-
"oxlint": "^1.33.0",
14+
"@types/js-yaml": "latest",
15+
"oxfmt": "latest",
16+
"oxlint": "latest",
1817
},
1918
"peerDependencies": {
20-
"typescript": "^5",
19+
"typescript": "latest",
2120
},
2221
},
2322
},
2423
"packages": {
25-
"@biomejs/biome": ["@biomejs/biome@2.3.10", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.3.10", "@biomejs/cli-darwin-x64": "2.3.10", "@biomejs/cli-linux-arm64": "2.3.10", "@biomejs/cli-linux-arm64-musl": "2.3.10", "@biomejs/cli-linux-x64": "2.3.10", "@biomejs/cli-linux-x64-musl": "2.3.10", "@biomejs/cli-win32-arm64": "2.3.10", "@biomejs/cli-win32-x64": "2.3.10" }, "bin": { "biome": "bin/biome" } }, "sha512-/uWSUd1MHX2fjqNLHNL6zLYWBbrJeG412/8H7ESuK8ewoRoMPUgHDebqKrPTx/5n6f17Xzqc9hdg3MEqA5hXnQ=="],
26-
27-
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.3.10", "", { "os": "darwin", "cpu": "arm64" }, "sha512-M6xUjtCVnNGFfK7HMNKa593nb7fwNm43fq1Mt71kpLpb+4mE7odO8W/oWVDyBVO4ackhresy1ZYO7OJcVo/B7w=="],
28-
29-
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.3.10", "", { "os": "darwin", "cpu": "x64" }, "sha512-Vae7+V6t/Avr8tVbFNjnFSTKZogZHFYl7MMH62P/J1kZtr0tyRQ9Fe0onjqjS2Ek9lmNLmZc/VR5uSekh+p1fg=="],
30-
31-
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.3.10", "", { "os": "linux", "cpu": "arm64" }, "sha512-hhPw2V3/EpHKsileVOFynuWiKRgFEV48cLe0eA+G2wO4SzlwEhLEB9LhlSrVeu2mtSn205W283LkX7Fh48CaxA=="],
32-
33-
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.3.10", "", { "os": "linux", "cpu": "arm64" }, "sha512-B9DszIHkuKtOH2IFeeVkQmSMVUjss9KtHaNXquYYWCjH8IstNgXgx5B0aSBQNr6mn4RcKKRQZXn9Zu1rM3O0/A=="],
34-
35-
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.3.10", "", { "os": "linux", "cpu": "x64" }, "sha512-wwAkWD1MR95u+J4LkWP74/vGz+tRrIQvr8kfMMJY8KOQ8+HMVleREOcPYsQX82S7uueco60L58Wc6M1I9WA9Dw=="],
36-
37-
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.3.10", "", { "os": "linux", "cpu": "x64" }, "sha512-QTfHZQh62SDFdYc2nfmZFuTm5yYb4eO1zwfB+90YxUumRCR171tS1GoTX5OD0wrv4UsziMPmrePMtkTnNyYG3g=="],
38-
39-
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.3.10", "", { "os": "win32", "cpu": "arm64" }, "sha512-o7lYc9n+CfRbHvkjPhm8s9FgbKdYZu5HCcGVMItLjz93EhgJ8AM44W+QckDqLA9MKDNFrR8nPbO4b73VC5kGGQ=="],
40-
41-
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.3.10", "", { "os": "win32", "cpu": "x64" }, "sha512-pHEFgq7dUEsKnqG9mx9bXihxGI49X+ar+UBrEIj3Wqj3UCZp1rNgV+OoyjFgcXsjCWpuEAF4VJdkZr3TrWdCbQ=="],
42-
4324
"@clack/core": ["@clack/core@0.5.0", "", { "dependencies": { "picocolors": "^1.0.0", "sisteransi": "^1.0.5" } }, "sha512-p3y0FIOwaYRUPRcMO7+dlmLh8PSRcrjuTndsiA0WAFbWES0mLZlrjVoBRZ9DzkPFJZG6KGkJmoEAY0ZcVWTkow=="],
4425

4526
"@clack/prompts": ["@clack/prompts@0.11.0", "", { "dependencies": { "@clack/core": "0.5.0", "picocolors": "^1.0.0", "sisteransi": "^1.0.5" } }, "sha512-pMN5FcrEw9hUkZA4f+zLlzivQSeQf5dRGJjSUbvVYDLvpKCdQx5OaknvKzgbtXOizhP+SJJJjqEbOe55uKKfAw=="],
@@ -76,15 +57,15 @@
7657

7758
"@oxlint/win32-x64": ["@oxlint/win32-x64@1.33.0", "", { "os": "win32", "cpu": "x64" }, "sha512-ReyR8rNHjKNnO7dxGny9RCPELRAdhm3y780FNBcA07E1wvxSCkB+Mn5db0Pa5bRmxrsU/MTZ/aaBFa+ERXDdXw=="],
7859

79-
"@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="],
60+
"@types/bun": ["@types/bun@1.3.5", "", { "dependencies": { "bun-types": "1.3.5" } }, "sha512-RnygCqNrd3srIPEWBd5LFeUYG7plCoH2Yw9WaZGyNmdTEei+gWaHqydbaIRkIkcbXwhBT94q78QljxN0Sk838w=="],
8061

8162
"@types/js-yaml": ["@types/js-yaml@4.0.9", "", {}, "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg=="],
8263

8364
"@types/node": ["@types/node@25.0.3", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA=="],
8465

8566
"argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
8667

87-
"bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="],
68+
"bun-types": ["bun-types@1.3.5", "", { "dependencies": { "@types/node": "*" } }, "sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw=="],
8869

8970
"cron-parser": ["cron-parser@5.4.0", "", { "dependencies": { "luxon": "^3.7.1" } }, "sha512-HxYB8vTvnQFx4dLsZpGRa0uHp6X3qIzS3ZJgJ9v6l/5TJMgeWQbLkR5yiJ5hOxGbc9+jCADDnydIe15ReLZnJA=="],
9071

0 commit comments

Comments
 (0)