Skip to content

Commit acb1979

Browse files
init commit
0 parents  commit acb1979

20 files changed

+7025
-0
lines changed

.claude/settings.local.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(npm run build:*)",
5+
"WebSearch",
6+
"WebFetch(domain:developers.cloudflare.com)",
7+
"Bash(node test-connection.js:*)",
8+
"Bash(timeout 3 npm start)",
9+
"WebFetch(domain:github.com)",
10+
"WebFetch(domain:raw.githubusercontent.com)",
11+
"Bash(node test-commands.js:*)",
12+
"Bash(npm install:*)",
13+
"Bash(node -e:*)",
14+
"Bash(timeout 2 npm start:*)",
15+
"Bash(npm run package:macos:*)",
16+
"Bash(node dist/index.js:*)",
17+
"Bash(npm run bundle:*)",
18+
"Bash(node dist/bundle.cjs:*)",
19+
"Bash(chmod:*)",
20+
"Bash(bin/r2sql-shell-macos:*)",
21+
"Bash(npm start -- --help)",
22+
"Bash(./r2sql-shell-macos:*)",
23+
"Bash(timeout 3 bin/r2sql-shell-macos:*)",
24+
"Bash(timeout 2 /Users/mselwan/Documents/r2sql-shell/bin/r2sql-shell-macos:*)",
25+
"Bash(timeout 2 bin/r2sql-shell-macos:*)",
26+
"Bash(timeout 2 ./bin/r2sql-shell-macos:*)"
27+
],
28+
"deny": [],
29+
"ask": []
30+
}
31+
}

.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Cloudflare Configuration
2+
# Get your Account ID from the Cloudflare dashboard
3+
CLOUDFLARE_ACCOUNT_ID=your_account_id_here
4+
5+
# The R2 bucket name that contains your data catalog
6+
R2_BUCKET_NAME=your_bucket_name_here
7+
8+
# API Token with the following permissions:
9+
# - R2 Data Catalog: Edit
10+
# - R2 Object Storage: Edit
11+
# - R2 SQL: Read
12+
CLOUDFLARE_API_TOKEN=your_api_token_here

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
bin/
7+
8+
# Environment variables
9+
.env
10+
11+
# IDE
12+
.vscode/
13+
.idea/
14+
*.swp
15+
*.swo
16+
*~
17+
18+
# OS
19+
.DS_Store
20+
Thumbs.db
21+
22+
# Logs
23+
*.log
24+
npm-debug.log*
25+
26+
# History
27+
.r2sql_history
28+
r2-sql-history.txt
29+
r2sql-debug.log
30+
31+
#Testing/debugging
32+
test*
33+
34+
#Stuff you also don't need
35+
PUBLUSH*
36+
HOMEBREW*
37+
get-sha256.sh

CLAUDE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Building with Claude Code
2+
3+
This project was built using [Claude Code](https://claude.com/claude-code), Anthropic's agentic coding tool. This document serves as both guidance for Claude Code when working on this codebase and as a guide for developers who want to build similar applications.
4+
5+
## What is r2 sql shell?
6+
7+
r2 sql shell is an interactive repl users can use as a colorful interactive shell to query tables in R2 Data Catalog using R2 SQL. Currently, R2 SQL can only be accessed via an HTTP REST API or Cloudflare Wrangler so this acts as a convenient way to view, format, and explore their data!
8+
9+
### Key Features
10+
- colorful, syntax highlighted UI
11+
- Auto complete
12+
- Integration with R2 Data Catalog to list namespaces, tables, and schemas
13+
- some very light automatic charting capabilities (time series, bar charts, etc) rendered in a fun bash-style colorful way
14+
- Errors are nicely formatted with helpful suggestions
15+
- Store history locally
16+
17+
### Reference for Claude
18+
- R2 SQL has a limited SQL feature set, see: https://developers.cloudflare.com/r2-sql/reference/limitations-best-practices/
19+
- R2 SQL itself can't list namespaces or tables yet so a user will need to provide an API token that has R2 Data Catalog edit, R2 object storage edit, and R2 SQL read capabilities
20+
- It should use Apache Iceberg REST API calls to list namespaces, tables, schemas, etc
21+
- R2 SQL returns some metadata about the request and it should format tht nicely as well
22+
- Reference for HTTP API for R2 SQL: https://developers.cloudflare.com/r2-sql/query-data/
23+
- You built an app that does the Iceberg REST API calls for me here https://github.com/Marcinthecloud/iceberg.rest use this as reference - we should be able to construct the Iceberg REST catalog endpoint of R2 Data Catalog as it's always: https://catalog.cloudflarestorage.com/{cloudflaire account ID}/{bucket name} - a user needs to provide the warehouse for querying which is always {cloudflare account id}_{bucket name}
24+
- So when a user starts the shell, it should look for a .env file with those parameters or a user can specify them when starting the repl/shell including the API key which can be used for all calls
25+
- I really like how this sql repl looks - we should replicate this: https://github.com/achristmascarl/rainfrog
26+
- here is the R2 SQL reference: https://developers.cloudflare.com/r2-sql/sql-reference/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 R2 SQL Shell Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

PUBLISH_CHECKLIST.md

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
# Publishing Checklist for r2sql
2+
3+
Follow these steps to publish r2sql to Homebrew.
4+
5+
## Pre-publishing
6+
7+
- [ ] Update version in `package.json` if needed
8+
- [ ] Run `npm run build` to ensure code compiles
9+
- [ ] Test the CLI locally: `npm start -- --help`
10+
11+
## Step 1: Build Executables
12+
13+
```bash
14+
cd /Users/mselwan/Documents/r2sql-shell
15+
npm run package:all
16+
```
17+
18+
- [ ] Verify `bin/r2sql-shell-macos` exists
19+
- [ ] Verify `bin/r2sql-shell-linux` exists
20+
- [ ] Verify `bin/r2sql-shell-win.exe` exists
21+
22+
## Step 2: Test macOS Binary
23+
24+
```bash
25+
chmod +x bin/r2sql-shell-macos
26+
./bin/r2sql-shell-macos --version
27+
./bin/r2sql-shell-macos --help
28+
```
29+
30+
- [ ] Version displays correctly
31+
- [ ] Help displays correctly
32+
33+
## Step 3: Calculate SHA256 Hash
34+
35+
```bash
36+
shasum -a 256 bin/r2sql-shell-macos
37+
```
38+
39+
- [ ] Copy and save this hash - you'll need it later!
40+
41+
**Your SHA256 hash:**
42+
```
43+
_______________________________________________________________
44+
```
45+
46+
## Step 4: Create GitHub Repository
47+
48+
1. Go to: https://github.com/new
49+
2. Repository name: `r2sql`
50+
3. Description: `Interactive shell for querying R2 Data Catalog with R2 SQL`
51+
4. Public repository
52+
5. Do NOT initialize with README
53+
54+
- [ ] Repository created
55+
56+
**Your repository URL:**
57+
```
58+
https://github.com/_____________/r2sql
59+
```
60+
61+
## Step 5: Push Code to GitHub
62+
63+
```bash
64+
cd /Users/mselwan/Documents/r2sql-shell
65+
66+
# If not already initialized
67+
git init
68+
git add .
69+
git commit -m "Initial release: R2 SQL Shell v1.0.0"
70+
71+
# Replace YOUR_USERNAME with your GitHub username
72+
git remote add origin https://github.com/YOUR_USERNAME/r2sql.git
73+
git branch -M main
74+
git push -u origin main
75+
```
76+
77+
- [ ] Code pushed to GitHub
78+
- [ ] Verify code is visible on GitHub
79+
80+
## Step 6: Create GitHub Release
81+
82+
1. Go to: `https://github.com/YOUR_USERNAME/r2sql/releases/new`
83+
2. Tag version: `v1.0.0`
84+
3. Release title: `v1.0.0 - Initial Release`
85+
4. Upload these files as release assets:
86+
- `bin/r2sql-shell-macos` → rename to `r2sql-macos`
87+
- `bin/r2sql-shell-linux` → rename to `r2sql-linux`
88+
- `bin/r2sql-shell-win.exe` → rename to `r2sql-win.exe`
89+
5. Click "Publish release"
90+
91+
- [ ] Release created
92+
- [ ] Assets uploaded and renamed correctly
93+
94+
**Your release URL:**
95+
```
96+
https://github.com/_____________/r2sql/releases/tag/v1.0.0
97+
```
98+
99+
## Step 7: Create Homebrew Tap Repository
100+
101+
1. Go to: https://github.com/new
102+
2. Repository name: `homebrew-r2sql`
103+
3. Description: `Homebrew tap for r2sql`
104+
4. Public repository
105+
5. Initialize with README
106+
107+
- [ ] Tap repository created
108+
109+
**Your tap URL:**
110+
```
111+
https://github.com/_____________/homebrew-r2sql
112+
```
113+
114+
## Step 8: Create Homebrew Formula
115+
116+
```bash
117+
cd ~/
118+
git clone https://github.com/YOUR_USERNAME/homebrew-r2sql.git
119+
cd homebrew-r2sql
120+
mkdir -p Formula
121+
```
122+
123+
Create `Formula/r2sql.rb` with this content (use the template from `homebrew-formula-template.rb`):
124+
125+
```ruby
126+
class R2sql < Formula
127+
desc "Interactive shell for querying R2 Data Catalog with R2 SQL"
128+
homepage "https://github.com/YOUR_USERNAME/r2sql"
129+
url "https://github.com/YOUR_USERNAME/r2sql/releases/download/v1.0.0/r2sql-macos"
130+
sha256 "PASTE_YOUR_SHA256_FROM_STEP_3"
131+
version "1.0.0"
132+
license "MIT"
133+
134+
def install
135+
bin.install "r2sql-macos" => "r2sql"
136+
end
137+
138+
test do
139+
assert_match "1.0.0", shell_output("#{bin}/r2sql --version")
140+
end
141+
end
142+
```
143+
144+
**Important replacements:**
145+
- Replace `YOUR_USERNAME` with your GitHub username (2 places)
146+
- Replace `PASTE_YOUR_SHA256_FROM_STEP_3` with the hash from Step 3
147+
148+
```bash
149+
# Commit and push
150+
git add Formula/r2sql.rb
151+
git commit -m "Add r2sql formula v1.0.0"
152+
git push origin main
153+
```
154+
155+
- [ ] Formula file created and pushed
156+
157+
## Step 9: Test Installation
158+
159+
```bash
160+
# Add your tap
161+
brew tap YOUR_USERNAME/r2sql
162+
163+
# Install
164+
brew install r2sql
165+
166+
# Test
167+
r2sql --version
168+
r2sql --help
169+
```
170+
171+
- [ ] Tap added successfully
172+
- [ ] Package installed successfully
173+
- [ ] `r2sql --version` works
174+
- [ ] `r2sql --help` works
175+
176+
## Step 10: Update README
177+
178+
Update the README.md in your main repository to replace `YOUR_USERNAME` with your actual GitHub username:
179+
180+
```bash
181+
cd /Users/mselwan/Documents/r2sql-shell
182+
# Edit README.md and replace YOUR_USERNAME
183+
git add README.md
184+
git commit -m "Update README with actual GitHub username"
185+
git push origin main
186+
```
187+
188+
- [ ] README updated with correct installation instructions
189+
190+
## 🎉 Done!
191+
192+
Users can now install with:
193+
194+
```bash
195+
brew tap YOUR_USERNAME/r2sql
196+
brew install r2sql
197+
```
198+
199+
## For Future Releases
200+
201+
When releasing v1.1.0, v1.2.0, etc.:
202+
203+
1. Update version in `package.json`
204+
2. Run `npm run package:all`
205+
3. Calculate new SHA256: `shasum -a 256 bin/r2sql-shell-macos`
206+
4. Create new GitHub release with new tag and binaries
207+
5. Update `Formula/r2sql.rb` with new version, URL, and SHA256
208+
6. Commit and push the formula update
209+
210+
Users will update with:
211+
```bash
212+
brew update
213+
brew upgrade r2sql
214+
```
215+
216+
## Troubleshooting
217+
218+
**"SHA256 mismatch"**
219+
- Recalculate the hash of your binary
220+
- Make sure you're using the exact file from the release
221+
222+
**"Cannot download"**
223+
- Verify the release URL is correct
224+
- Make sure binaries were uploaded as release assets
225+
226+
**Need help?**
227+
See [HOMEBREW_SETUP.md](HOMEBREW_SETUP.md) for detailed instructions.

0 commit comments

Comments
 (0)