From b13673c2eff9a8d0bac868adfa33d04b639bebec Mon Sep 17 00:00:00 2001 From: Andres Pirela <60560109+andreespirela@users.noreply.github.com> Date: Sat, 3 Oct 2026 23:30:36 -0400 Subject: [PATCH 1/3] [feat] Landing page + docs --- .github/workflows/check.yml | 24 + .github/workflows/deploy-site.yml | 53 ++ .github/workflows/release.yml | 47 ++ .gitignore | 5 +- Cargo.toml | 12 +- README.md | 130 ++-- apps/.gitignore | 1 + apps/Cargo.lock | 790 +++++++++++++++++++++ apps/Cargo.toml | 58 ++ apps/README.md | 76 ++ apps/docs/.gitignore | 6 + apps/docs/Cargo.toml | 29 + apps/docs/build.rs | 32 + apps/docs/navigation.json | 27 + apps/docs/public/brand.css | 31 + apps/docs/src/app.rs | 75 ++ apps/docs/src/lib.rs | 1 + apps/docs/web/index.html | 39 + apps/landing/.gitignore | 4 + apps/landing/Cargo.toml | 28 + apps/landing/build.rs | 15 + apps/landing/public/copy.svg | 5 + apps/landing/public/landing.css | 488 +++++++++++++ apps/landing/public/terminal/inspector.svg | 308 ++++++++ apps/landing/public/terminal/library.svg | 566 +++++++++++++++ apps/landing/public/terminal/menu.svg | 444 ++++++++++++ apps/landing/public/terminal/results.svg | 347 +++++++++ apps/landing/public/terminal/welcome.svg | 347 +++++++++ apps/landing/src/app.rs | 146 ++++ apps/landing/src/lib.rs | 1 + apps/landing/web/index.html | 148 ++++ crates/completion/Cargo.toml | 2 + docs/architecture.md | 35 + docs/flight-sql.md | 58 ++ docs/get-started.md | 80 +++ docs/index.md | 20 + docs/status.md | 18 + docs/workspace.md | 124 ++++ examples/site-preview/sample.sql | 13 + examples/site-preview/server.rs | 142 ++++ examples/site-preview/snapshot.rs | 135 ++++ justfile | 49 ++ package-lock.json | 60 ++ package.json | 8 + scripts/browser-app.mjs | 62 ++ scripts/capture-preview.py | 118 +++ scripts/site.mjs | 141 ++++ src/site_preview.rs | 35 + vercel.json | 34 + 49 files changed, 5375 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/deploy-site.yml create mode 100644 apps/.gitignore create mode 100644 apps/Cargo.lock create mode 100644 apps/Cargo.toml create mode 100644 apps/README.md create mode 100644 apps/docs/.gitignore create mode 100644 apps/docs/Cargo.toml create mode 100644 apps/docs/build.rs create mode 100644 apps/docs/navigation.json create mode 100644 apps/docs/public/brand.css create mode 100644 apps/docs/src/app.rs create mode 100644 apps/docs/src/lib.rs create mode 100644 apps/docs/web/index.html create mode 100644 apps/landing/.gitignore create mode 100644 apps/landing/Cargo.toml create mode 100644 apps/landing/build.rs create mode 100644 apps/landing/public/copy.svg create mode 100644 apps/landing/public/landing.css create mode 100644 apps/landing/public/terminal/inspector.svg create mode 100644 apps/landing/public/terminal/library.svg create mode 100644 apps/landing/public/terminal/menu.svg create mode 100644 apps/landing/public/terminal/results.svg create mode 100644 apps/landing/public/terminal/welcome.svg create mode 100644 apps/landing/src/app.rs create mode 100644 apps/landing/src/lib.rs create mode 100644 apps/landing/web/index.html create mode 100644 docs/architecture.md create mode 100644 docs/flight-sql.md create mode 100644 docs/get-started.md create mode 100644 docs/index.md create mode 100644 docs/status.md create mode 100644 docs/workspace.md create mode 100644 examples/site-preview/sample.sql create mode 100644 examples/site-preview/server.rs create mode 100644 examples/site-preview/snapshot.rs create mode 100644 justfile create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 scripts/browser-app.mjs create mode 100644 scripts/capture-preview.py create mode 100644 scripts/site.mjs create mode 100644 src/site_preview.rs create mode 100644 vercel.json diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 9b6d930..a4d7a04 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -6,6 +6,30 @@ permissions: contents: read jobs: + site: + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + with: + workspaces: apps -> target + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + - uses: taiki-e/install-action@v2 + with: + tool: just + - run: just setup-browser + - run: npx playwright install-deps chromium + - run: just site-check + - run: just site-browser + check: strategy: fail-fast: false diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml new file mode 100644 index 0000000..bc0b260 --- /dev/null +++ b/.github/workflows/deploy-site.yml @@ -0,0 +1,53 @@ +name: Deploy site + +on: + workflow_dispatch: + inputs: + environment: + description: Deploy to production or a preview URL + type: choice + options: [production, preview] + default: production + +permissions: + contents: read + +concurrency: + group: deploy-site + cancel-in-progress: false + +jobs: + deploy: + runs-on: ubuntu-latest + timeout-minutes: 45 + environment: vercel + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ vars.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ vars.VERCEL_PROJECT_ID }} + steps: + - name: Verify Vercel configuration + run: | + : "${VERCEL_TOKEN:?Set the VERCEL_TOKEN secret in the vercel environment}" + : "${VERCEL_ORG_ID:?Set the VERCEL_ORG_ID variable in the vercel environment}" + : "${VERCEL_PROJECT_ID:?Set the VERCEL_PROJECT_ID variable in the vercel environment}" + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + with: + workspaces: apps -> target + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + - uses: taiki-e/install-action@v2 + with: + tool: just + - run: just setup-browser + - run: just site-check + - run: npm install --global vercel@59.23.2 + - run: vercel pull --yes --environment=${{ inputs.environment }} + - run: just deploy ${{ inputs.environment }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f53a3d..83621b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -111,3 +111,50 @@ jobs: RELEASE_TAG: ${{ github.event.release.tag_name }} run: | gh release upload "$RELEASE_TAG" artifacts/* --clobber --repo "$GITHUB_REPOSITORY" + + crates-io: + if: github.event_name == 'release' + needs: binaries + runs-on: ubuntu-24.04 + environment: crates-io + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - run: cargo publish --workspace --locked --dry-run + - name: Publish unreleased crates + shell: bash + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: | + packages=$(cargo metadata --locked --no-deps --format-version 1 | + jq -r '.packages[] | select(.publish != []) | [.name, .version] | @tsv') + skip=() + remaining=0 + while IFS=$'\t' read -r name version; do + index="$RUNNER_TEMP/$name-index.json" + status=$(curl --silent --show-error --output "$index" --write-out '%{http_code}' \ + "https://index.crates.io/${name:0:2}/${name:2:2}/$name") + case "$status" in + 200) + published=$(jq --slurp --arg version "$version" \ + 'any(.[]; .vers == $version)' "$index") + if [ "$published" = true ]; then + skip+=(--exclude "$name") + continue + fi + ;; + 404) ;; + *) + echo "::error::Registry lookup for $name failed with HTTP $status" + exit 1 + ;; + esac + remaining=$((remaining + 1)) + done <<< "$packages" + if [ "$remaining" -eq 0 ]; then + echo "Every workspace crate version is already published." + else + cargo publish --workspace --locked "${skip[@]}" + fi diff --git a/.gitignore b/.gitignore index a2263a1..04f543b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,7 @@ rustc-ice-*.txt # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ -.idea \ No newline at end of file +.idea +/node_modules/ +/.vercel/ +.env* diff --git a/Cargo.toml b/Cargo.toml index acf4242..0f65dae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = [".", "crates/completion"] +exclude = ["apps"] resolver = "3" [workspace.dependencies] @@ -12,11 +13,18 @@ version = "0.1.0" edition = "2024" license = "MIT" description = "A terminal workspace for SQL queries and streaming results" +repository = "https://github.com/fusor-rs/sql-bomb" +include = ["src/**", "ui/**", "tests/**", "assets/brand/**", "examples/site-preview/**", + "build.rs", "Cargo.toml", "Cargo.lock", "LICENSE", "README.md"] [[bin]] name = "boom" path = "src/main.rs" +[[example]] +name = "site-preview" +path = "src/site_preview.rs" + [package.metadata.hypercmd] entry = "ui/app.html" templates = ["ui"] @@ -35,7 +43,7 @@ keyring = { version = "=3.6.3", features = [ "apple-native", "sync-secret-service", "crypto-rust", "vendored", ] } rusqlite = { version = "=0.33.0", features = ["bundled"] } -sql-bomb-completion = { path = "crates/completion" } +sql-bomb-completion = { path = "crates/completion", version = "=0.1.0" } thiserror.workspace = true tokio.workspace = true tonic = { version = "=0.14.6", features = ["tls-ring", "tls-native-roots"] } @@ -47,10 +55,12 @@ default-features = false features = ["derive"] [dependencies.hypercmd] +version = "=0.1.0" git = "https://github.com/fusor-rs/hypercmd" rev = "a910ab9e084df3e352e620b422d177fd0f6d75da" [build-dependencies.hypercmd-build] +version = "=0.1.0" git = "https://github.com/fusor-rs/hypercmd" rev = "a910ab9e084df3e352e620b422d177fd0f6d75da" diff --git a/README.md b/README.md index e6da8a3..2825646 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,17 @@ # Query SQL. Watch the rows arrive. -Write a query, stream the results, and keep the SQL worth running again. +sql-bomb is a terminal application for running SQL and streaming results into a +table. You can inspect complete cell values and return to queries from your local +history or starred library. The installed executable is named `boom`. -sql-bomb is a database-agnostic SQL terminal built in Rust, with pluggable clients -and an interface powered by -[hypercmd](https://github.com/fusor-rs/hypercmd) and -[fusor](https://github.com/fusor-rs/fusor). Browse results as they arrive, inspect -complete values, and return to queries from your local history or starred library. +Flight SQL is currently the only supported connection type. It connects to +servers that implement Arrow Flight SQL, a protocol for running SQL over gRPC. +Direct PostgreSQL and MySQL connections are not implemented. -Install sql-bomb, then launch it with `boom`. +The terminal interface is built with +[Hypercmd](https://github.com/fusor-rs/hypercmd) and +[Fusor](https://github.com/fusor-rs/fusor). **In development · v0.1** — See [available clients](#clients) and [status and known limitations](#status-and-known-limitations). @@ -27,54 +29,84 @@ Install sql-bomb, then launch it with `boom`. ## Get started -You need an interactive terminal on macOS or Linux and a connection supported by -an [available client](#clients). -The shell installer downloads the latest published release for x86-64 or ARM64, -verifies its SHA-256 checksum, and installs it in `~/.sqlbomb/bin` without sudo -or a Rust toolchain: +sql-bomb runs in a terminal on macOS or Linux. To run queries, you need the address +of a server that supports [Arrow Flight SQL](#clients). sql-bomb connects to +that server; it does not start a database for you. + +### Install with Cargo + +Cargo is Rust's package manager, included when you install Rust through +[rustup](https://rustup.rs). After a sql-bomb release is published to crates.io, +you can install the `boom` executable with: ```sh -curl -fsSL https://raw.githubusercontent.com/fusor-rs/sql-bomb/main/install.sh | sh -export PATH="$HOME/.sqlbomb/bin:$PATH" +cargo install sql-bomb --locked boom ``` -Add that PATH export to your shell profile to keep it across sessions. Run the -installer again to upgrade. To select a release, append `-s -- v0.1.0` to `sh`. -Set `SQL_BOMB_INSTALL` on the `sh` command to choose a different install directory; -the executable goes in its `bin/`. The installer leaves saved connections, query -history, and stars untouched. - -Installation requires a published release with completed binary uploads. To build -from this checkout instead, install Rust and Cargo, then run: +`--locked` uses the dependency versions recorded in the release. Cargo installs +`boom` in `~/.cargo/bin` by default; that directory needs to be in your shell's PATH. -```sh -cargo run --locked -``` +### Install a binary release -To install the executable from this checkout: +The shell installer downloads the latest published GitHub release for x86-64 or +ARM64 on Linux or macOS. It verifies the download's SHA-256 checksum and installs +`boom` in `~/.sqlbomb/bin`, without sudo or a Rust toolchain: ```sh -cargo install --path . --locked +curl -fsSL https://boom.fusor.build/install.sh | sh +export PATH="$HOME/.sqlbomb/bin:$PATH" boom ``` -Choose a client from the centered cards with a click or Enter, fill in its -connection details, and select **Open workspace**. The editor is ready for input. -The logo and wordmark reveal over half a second in the empty results pane and -remain until you run a query. -The small logo stays visible in short or narrow terminals as the tagline wraps. +Add the `export` line to your shell profile, such as `~/.zshrc` or `~/.bashrc`, so +new terminals can find `boom`. Run the installer again to upgrade. To select a +release, append `-s -- v0.1.0` to `sh`. Set `SQL_BOMB_INSTALL` on the `sh` command +to choose a different install directory; the executable goes in its `bin/`. +Saved connections, query history, and stars are left untouched. -Write SQL in the editor and click **Run**, or press Ctrl+R: +This method requires a GitHub release with completed binary uploads. + +### Connect to a server + +1. Run `boom` and choose **Flight SQL**, the only client currently available. +2. Enter your server URL, including its scheme and port, such as + `http://localhost:50051`. This example requires a server already running at that + address. Use `https://` for a server with TLS encryption. +3. If the server requires authentication, enter its request headers, such as + `authorization: Bearer YOUR_TOKEN`. Otherwise, leave the headers empty. +4. Select **Open workspace**. + +Type a query in the editor and press Ctrl+R, or click **Run**: ```sql SELECT 1 AS value; ``` -**Connection** opens your saved connections, or the client chooser if you have -none. Opening the workspace loads available table metadata in the background; -running a query opens its query connection. For direct launches, see -the [client-specific flags and connection settings](#clients). +Rows appear below the editor as the server sends them. Press Ctrl+C to quit. + +For a connection without headers, you can skip the chooser and form: + +```sh +boom --flightsql http://localhost:50051 +``` + +Once you save a connection, `boom` opens your saved connections instead. See +[Using sql-bomb](#using-sql-bomb) for saving connections and browsing results, or +[Flight SQL](#clients) for supported URLs and authentication. + +### Build from source + +With Rust and Cargo installed, clone the repository and install from the checkout: + +```sh +git clone https://github.com/fusor-rs/sql-bomb +cd sql-bomb +cargo install --path . --locked +boom +``` + +For development, `cargo run --locked` builds and launches the app from the checkout. ## Using sql-bomb @@ -324,7 +356,7 @@ tests check that profiles exclude secrets and failed saves preserve credentials. The [Check workflow](.github/workflows/check.yml) runs these checks on Linux and macOS for pushes and pull requests, then installs and launches the executable. -### Release binaries +### Releases Publish a GitHub release with a tag matching the package version in `Cargo.toml`, such as `v0.1.0`. The [Release workflow](.github/workflows/release.yml) runs Check, @@ -337,13 +369,31 @@ release. It also checks that a corrupt download leaves the installed executable unchanged. `SQL_BOMB_DOWNLOAD_BASE` points the installer at these local archives during CI. +The same release publishes `sql-bomb-completion` and `sql-bomb` to crates.io after +all binary builds pass. Configure a GitHub environment named `crates-io` with a +`CARGO_REGISTRY_TOKEN` secret authorized to publish both crates. The workflow +verifies the packaged workspace before uploading and skips versions already +published when a release is rerun. + +Crates.io publication requires a Hypercmd release containing the selection events +and `Node::replace_range` API used here. Published Hypercmd 0.1.0 lacks those APIs; +update both Hypercmd dependency versions and their Git revision to a compatible +release before publishing sql-bomb. The package verification step rejects the +current registry dependencies. + Running Release manually produces workflow artifacts without publishing them. -It does not publish to crates.io. Windows binaries and a PowerShell installer -require Windows support in Hypercmd's native runtime and the query library's +Windows binaries and a PowerShell installer require Windows support in Hypercmd's +native runtime and the query library's filesystem handling. Logo assets and palette guidance are in [the brand guide](assets/brand/BRANDING.md). +### Website + +The landing page and documentation are Fusor apps in a separate `apps/` workspace, +following Hypercmd's site setup. See [website development and Vercel deployment](apps/README.md) +for local previews, browser checks, and the manual **Deploy site** workflow. + ## License Licensed under the [MIT License](LICENSE). diff --git a/apps/.gitignore b/apps/.gitignore new file mode 100644 index 0000000..178135c --- /dev/null +++ b/apps/.gitignore @@ -0,0 +1 @@ +/dist/ diff --git a/apps/Cargo.lock b/apps/Cargo.lock new file mode 100644 index 0000000..1485ce2 --- /dev/null +++ b/apps/Cargo.lock @@ -0,0 +1,790 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "docs-base" +version = "0.1.0" +source = "git+https://github.com/fusor-rs/docs-base?rev=e2c7b3939721002ea2aa7556d8e4409aa131472b#e2c7b3939721002ea2aa7556d8e4409aa131472b" +dependencies = [ + "fusor-build", + "fusor-components", + "fusor-core", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "docs-base-build" +version = "0.1.0" +source = "git+https://github.com/fusor-rs/docs-base?rev=e2c7b3939721002ea2aa7556d8e4409aa131472b#e2c7b3939721002ea2aa7556d8e4409aa131472b" +dependencies = [ + "proc-macro2", + "pulldown-cmark", + "quote", + "serde", + "serde_json", + "syntect", + "two-face", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "fancy-regex" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f" +dependencies = [ + "bit-set", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "flate2" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" +dependencies = [ + "crc32fast", + "miniz_oxide", + "zlib-rs", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fusor-build" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e853f1efe0a7a43a69c1b0ba429a65e3fb2b059a9839522bea725452a325d5" +dependencies = [ + "fusor-core", + "fusor-islands", + "fusor-router", + "html5gum", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "syn 2.0.119", + "toml", +] + +[[package]] +name = "fusor-components" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ff376904a2eadb6a540744719429734482d2e736a0773377d9853fe170613f5" +dependencies = [ + "fusor-core", +] + +[[package]] +name = "fusor-core" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36cc8392e17b5eea5f45606a51bb8736042bd19175f20fb63ee82fc1787561eb" +dependencies = [ + "fusor-macros", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "fusor-islands" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09040f3dfaa95e41e54a4ba1005a88e017910b0eceee4e700c5f04be3c47ce22" +dependencies = [ + "fusor-core", + "serde", + "serde_json", +] + +[[package]] +name = "fusor-macros" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebdbd0919aeab94a1589b0952a9711e7d46aab3123a0c2c02ba3b0683d814490" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "fusor-router" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cbb73da8ceba9583442a661d65d9d1256ee2863a55ee1ec95f8e5d4b4507070" +dependencies = [ + "form_urlencoded", + "fusor-core", + "js-sys", + "percent-encoding", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "html5gum" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "428502d3ec1742c35e015871aef742bc4722a9acfcb616b8ff79b519922e1c36" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e04e2ef80ce82e13552136fabeef8a5ed1f985a96805761cbb9a2c34e7664d9" +dependencies = [ + "cfg-if", + "futures-util", + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.190" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pulldown-cmark" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e8bbe1a966bd2f362681a44f6edce3c2310ac21e4d5067a6e7ec396297a6ea0" +dependencies = [ + "bitflags", + "memchr", + "pulldown-cmark-escape", + "unicase", +] + +[[package]] +name = "pulldown-cmark-escape" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae" + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "serde_json" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "sql-bomb-docs" +version = "0.1.0" +dependencies = [ + "docs-base", + "docs-base-build", + "fusor-build", + "fusor-components", + "fusor-core", + "fusor-router", + "wasm-bindgen", +] + +[[package]] +name = "sql-bomb-landing" +version = "0.1.0" +dependencies = [ + "fusor-build", + "fusor-components", + "fusor-core", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syntect" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "656b45c05d95a5704399aeef6bd0ddec7b2b3531b7c9e900abbf7c4d2190c925" +dependencies = [ + "bincode", + "fancy-regex", + "flate2", + "fnv", + "once_cell", + "regex-syntax", + "serde", + "serde_derive", + "thiserror", + "walkdir", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + +[[package]] +name = "two-face" +version = "0.5.2+bat-0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915be7adc2ff6f4338acbf71f3eda0a146f46003b992a1669c674308610efdac" +dependencies = [ + "serde", + "serde_derive", + "syntect", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicase" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" + +[[package]] +name = "unicode-ident" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0551fc1bb415591e3372d0bc4780db7e587d84e2a7e79da121051c5c4b89d0b0" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03623de6905b7206edd0a75f69f747f134b7f0a2323392d664448bf2d3c5d87e" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fbdf9a35adf44786aecd5ff89b4563a90325f9da0923236f6104e603c7e86be" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dca9693ef2bab6d4e6707234500350d8dad079eb508dca05530c85dc3a529ff2" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 2.0.119", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39129a682a6d2d841b6c429d0c51e5cb0ed1a03829d8b3d1e69a011e62cb3d3b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd70027e39b12f0849461e08ffc50b9cd7688d942c1c8e3c7b22273236b4dd0a" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "winnow" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" +dependencies = [ + "memchr", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/apps/Cargo.toml b/apps/Cargo.toml new file mode 100644 index 0000000..f0ec576 --- /dev/null +++ b/apps/Cargo.toml @@ -0,0 +1,58 @@ +[workspace] +members = ["landing", "docs"] +resolver = "2" + +[workspace.metadata.fusor.site] +output = "dist" + +[workspace.metadata.fusor.site.mounts] +"/" = "sql-bomb-landing" +"/docs/" = "sql-bomb-docs" + +[workspace.dependencies] +fusor = { package = "fusor-core", version = "=0.1.4", features = ["dom", "derive"] } +fusor-components = { version = "=0.1.4", features = ["browser"] } +fusor-build = "=0.1.4" +wasm-bindgen = "=0.2.117" + +[workspace.dependencies.docs-base] +git = "https://github.com/fusor-rs/docs-base" +rev = "e2c7b3939721002ea2aa7556d8e4409aa131472b" + +[workspace.dependencies.docs-base-build] +git = "https://github.com/fusor-rs/docs-base" +rev = "e2c7b3939721002ea2aa7556d8e4409aa131472b" + +[profile.dev] +debug = 0 + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 +panic = "abort" +strip = "debuginfo" + +[workspace.lints.rust] +unsafe_code = "forbid" +unused = { level = "deny", priority = -1 } + +[workspace.lints.clippy] +all = { level = "deny", priority = -1 } +allow_attributes = "deny" +allow_attributes_without_reason = "deny" +dbg_macro = "deny" +todo = "deny" +unimplemented = "deny" +unwrap_used = "deny" +redundant_clone = "deny" +needless_pass_by_value = "deny" +too_many_lines = "deny" +cognitive_complexity = "deny" +wildcard_imports = "deny" +min_ident_chars = "deny" +match_same_arms = "deny" +branches_sharing_code = "deny" +fn_params_excessive_bools = "deny" +struct_excessive_bools = "deny" +excessive_nesting = "deny" diff --git a/apps/README.md b/apps/README.md new file mode 100644 index 0000000..f43771f --- /dev/null +++ b/apps/README.md @@ -0,0 +1,76 @@ +# sql-bomb website + +The landing page at `/` and documentation at `/docs/` are Fusor browser apps in +this Cargo workspace, separate from the native terminal. They follow Hypercmd's +`apps/` setup and share its pinned `docs-base` components. Documentation in +`../docs/` describes the behavior in the repository README. Brand assets come +from `../assets/brand/`; the builds copy them into ignored public directories. +The landing build also copies the root `install.sh` to serve at `/install.sh` on +`https://boom.fusor.build`. Edit the root script; the public copy is generated. + +## Build and preview + +Install Rust, Node.js 22 and [just](https://just.systems/), then run from the +repository root: + +```sh +just setup-browser +just site +just preview +``` + +Open `http://127.0.0.1:4187`. The combined static output is `apps/dist/`. +`just landing-dev` and `just docs-dev` serve individual apps. Restart the docs +server after changing `docs/`, which is outside its watched app directory. +`FUSOR_BIN` selects an alternate Fusor CLI. `just site-check` runs formatting, +Clippy and tests for both apps; `just site-browser` builds and exercises the +combined site in Chromium. The Check workflow runs both alongside native checks. + +The landing walkthrough displays SVG captures of the native application: its +workspace, results, cell inspector, query library and action menu. Stages rotate +automatically, pause while hovered, and respect reduced-motion preferences. +Regenerate captures on macOS or Linux with Python 3 and `just capture-preview` after UI +changes. The tool compiles the same native modules and templates as `boom`, +executes the sample SQL through a local Flight SQL server backed by SQLite, +and records terminal colors and glyphs. Its query library lives in a temporary +directory; it does not use your saved connections or history. The captures are +committed assets, so website builds do not start a server or require Python. + +Docs use the same navigation, search, theme, Markdown downloads and history +routing as Hypercmd. Add guides to `../docs/` and register their slugs in +`docs/navigation.json`. Both apps require JavaScript and WebAssembly; the docs +do not prerender a separate HTML document for each route. + +## Vercel deployment + +Create a Vercel project for sql-bomb with the repository root as its root +directory. Create a GitHub environment named `vercel` with: + +| Kind | Name | Value | +| --- | --- | --- | +| Secret | `VERCEL_TOKEN` | A Vercel token with access to the project | +| Variable | `VERCEL_ORG_ID` | The project's Vercel team/account ID | +| Variable | `VERCEL_PROJECT_ID` | The sql-bomb Vercel project ID | + +Run **Deploy site** from GitHub Actions and choose production or preview. +Like Hypercmd, deployment is manual: pushes run checks and Vercel Git deployments +are disabled. Rust builds run in GitHub Actions; Vercel receives prebuilt files. +`vercel.json` redirects `/docs` to `/docs/`, serves documentation deep links, +and caches versioned Fusor assets. The deploy recipe removes Fusor build +manifests containing local paths from the upload. + +For a local deployment, run the setup above, install the Vercel CLI version +pinned in `../.github/workflows/deploy-site.yml`, then authenticate and link +this directory to the sql-bomb project: + +```sh +vercel login +vercel link +vercel pull --yes --environment=production +just deploy production +``` + +For a preview, use `preview` in both commands. Vercel's +[prebuilt deployment documentation](https://vercel.com/docs/cli/deploy#prebuilt) +describes the build/upload flow. Project credentials and generated output stay +outside version control. diff --git a/apps/docs/.gitignore b/apps/docs/.gitignore new file mode 100644 index 0000000..ed3cec2 --- /dev/null +++ b/apps/docs/.gitignore @@ -0,0 +1,6 @@ +/target/ +/dist/ +/public/content/ +/public/docs-base.css +/public/favicon.svg +/.fusor/ diff --git a/apps/docs/Cargo.toml b/apps/docs/Cargo.toml new file mode 100644 index 0000000..b654395 --- /dev/null +++ b/apps/docs/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "sql-bomb-docs" +version = "0.1.0" +edition = "2024" +rust-version = "1.85" +publish = false + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +docs-base.workspace = true +fusor.workspace = true +fusor-components.workspace = true +fusor-router = { version = "=0.1.4", features = ["browser"] } +wasm-bindgen.workspace = true + +[build-dependencies] +docs-base-build.workspace = true +fusor-build.workspace = true + +[package.metadata.fusor] +entry = "web/index.html" +assets = "public" +base-path = "/docs/" +history-fallback = ["/"] + +[lints] +workspace = true diff --git a/apps/docs/build.rs b/apps/docs/build.rs new file mode 100644 index 0000000..b0f372d --- /dev/null +++ b/apps/docs/build.rs @@ -0,0 +1,32 @@ +use docs_base_build::{Config, Highlighter}; +use std::{ + env, fs, + path::{Path, PathBuf}, +}; + +fn main() -> Result<(), Box> { + let directory = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?); + let root = directory + .parent() + .and_then(Path::parent) + .ok_or("the docs app must live in apps/docs inside the sql-bomb repository")?; + let guides = docs_base_build::compile( + &Config { + root, + content: Path::new("docs"), + navigation: Path::new("apps/docs/navigation.json"), + references: None, + base_path: "/docs/", + repository: Some("https://github.com/fusor-rs/sql-bomb/blob/main/"), + }, + &Highlighter::default(), + )?; + guides.write_assets(Path::new("public"))?; + fs::write( + PathBuf::from(env::var("OUT_DIR")?).join("guides.rs"), + guides.source.to_string(), + )?; + println!("cargo:rerun-if-changed=../../assets/brand/sql-bomb.svg"); + fs::copy(root.join("assets/brand/sql-bomb.svg"), "public/favicon.svg")?; + fusor_build::compile_app() +} diff --git a/apps/docs/navigation.json b/apps/docs/navigation.json new file mode 100644 index 0000000..5dba5b2 --- /dev/null +++ b/apps/docs/navigation.json @@ -0,0 +1,27 @@ +[ + { + "slug": "", + "group": "Learn" + }, + { + "slug": "get-started", + "group": "Learn" + }, + { + "slug": "workspace", + "group": "Learn" + }, + { + "slug": "flight-sql", + "group": "Reference", + "reference": true + }, + { + "slug": "architecture", + "group": "Reference" + }, + { + "slug": "status", + "group": "Reference" + } +] diff --git a/apps/docs/public/brand.css b/apps/docs/public/brand.css new file mode 100644 index 0000000..9dbcf73 --- /dev/null +++ b/apps/docs/public/brand.css @@ -0,0 +1,31 @@ +.site { + --bg: #faf9f6; + --panel: #f4f1ed; + --text: #272a2c; + --accent: #a83228; + --wash: #f8eae5; +} +.site.dark { + --bg: #211c1b; + --panel: #292220; + --text: #faf9f6; + --accent: #ff9983; + --wash: #442924; +} + +.article .lead, +.article .markdown { + font-size: 16px; + line-height: 1.75; +} +.article .inline-code { + font-size: 0.95em; +} +.article pre { + font-size: 13px; + line-height: 1.75; +} + +.markdown td:first-child code { + white-space: nowrap; +} diff --git a/apps/docs/src/app.rs b/apps/docs/src/app.rs new file mode 100644 index 0000000..b4bffb4 --- /dev/null +++ b/apps/docs/src/app.rs @@ -0,0 +1,75 @@ +use docs_base::{Location, Navigation, Site}; +use fusor::{ + OwnerHandle, + dom::{Content, FromInputs, JsValue}, +}; +use fusor_router::browser::declarative::Navigation as RouterNavigation; + +include!(concat!(env!("OUT_DIR"), "/guides.rs")); + +static SITE: Site = Site { + name: "sql-bomb", + base_path: "/docs/", + logo: "/docs/favicon.svg", + version: "v0.1 dev", + pages: PAGES, +}; + +struct App { + navigation: Navigation, + header: Content, +} + +impl App { + fn new() -> Self { + Self { + navigation: Navigation::new(&SITE), + header: Content::new(|_| Header), + } + } +} + +struct Header; + +struct DocRoute { + index: Option, +} + +struct DocRouteInputs { + navigation: Navigation, +} + +impl FromInputs for DocRoute { + type Inputs = DocRouteInputs; + type Error = JsValue; + + fn from_inputs(inputs: Self::Inputs, owner: OwnerHandle) -> Result { + let router = RouterNavigation::from_owner(&owner) + .ok_or_else(|| JsValue::from_str("missing documentation navigation"))?; + let index = match router.location().get().segments() { + Ok(segments) => { + let slug = segments.join("/"); + PAGES.iter().position(|page| page.slug == slug) + } + // Malformed route encodings use the same missing-page view as unknown paths. + Err(_) => None, + }; + inputs + .navigation + .active + .set(index.map_or(Location::Missing, Location::Guide)); + Ok(Self { index }) + } +} + +#[expect( + clippy::too_many_lines, + clippy::excessive_nesting, + clippy::redundant_clone, + reason = "Fusor 0.1.4 DOM codegen: https://github.com/fusor-rs/fusor/issues/17" +)] +mod dom { + use super::{App, DocRoute, Header, SITE}; + use docs_base::{Article, ArticleExtras, Shell}; + fusor::template!("web/index.html"); +} diff --git a/apps/docs/src/lib.rs b/apps/docs/src/lib.rs new file mode 100644 index 0000000..c0de390 --- /dev/null +++ b/apps/docs/src/lib.rs @@ -0,0 +1 @@ +mod app; diff --git a/apps/docs/web/index.html b/apps/docs/web/index.html new file mode 100644 index 0000000..4b4aa97 --- /dev/null +++ b/apps/docs/web/index.html @@ -0,0 +1,39 @@ + + + + + + + sql-bomb documentation + + + + + + +
+ + + + + +
+
+ + + + + diff --git a/apps/landing/.gitignore b/apps/landing/.gitignore new file mode 100644 index 0000000..6d5027e --- /dev/null +++ b/apps/landing/.gitignore @@ -0,0 +1,4 @@ +/dist/ +/.fusor/ +/public/brand/ +/public/install.sh diff --git a/apps/landing/Cargo.toml b/apps/landing/Cargo.toml new file mode 100644 index 0000000..d02d815 --- /dev/null +++ b/apps/landing/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "sql-bomb-landing" +version = "0.1.0" +edition = "2024" +rust-version = "1.85" +publish = false + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +fusor.workspace = true +fusor-components.workspace = true +wasm-bindgen.workspace = true +wasm-bindgen-futures = "=0.4.67" +web-sys = { version = "=0.3.94", features = ["Window", "Navigator", "Clipboard", "MediaQueryList"] } + +[build-dependencies] +fusor-build.workspace = true + +[package.metadata.fusor] +entry = "web/index.html" +templates = [] +assets = "public" +base-path = "/" + +[lints] +workspace = true diff --git a/apps/landing/build.rs b/apps/landing/build.rs new file mode 100644 index 0000000..a9a617a --- /dev/null +++ b/apps/landing/build.rs @@ -0,0 +1,15 @@ +use std::fs; + +fn main() -> Result<(), Box> { + let source = "../../assets/brand"; + let destination = "public/brand"; + fs::create_dir_all(destination)?; + for name in ["sql-bomb.svg", "sql-bomb-horizontal.svg"] { + println!("cargo:rerun-if-changed={source}/{name}"); + fs::copy(format!("{source}/{name}"), format!("{destination}/{name}"))?; + } + let installer = "../../install.sh"; + println!("cargo:rerun-if-changed={installer}"); + fs::copy(installer, "public/install.sh")?; + fusor_build::compile_app() +} diff --git a/apps/landing/public/copy.svg b/apps/landing/public/copy.svg new file mode 100644 index 0000000..6d1fc98 --- /dev/null +++ b/apps/landing/public/copy.svg @@ -0,0 +1,5 @@ + + + + diff --git a/apps/landing/public/landing.css b/apps/landing/public/landing.css new file mode 100644 index 0000000..8be1d23 --- /dev/null +++ b/apps/landing/public/landing.css @@ -0,0 +1,488 @@ +:root { + color-scheme: light; + --paper: #faf9f6; + --ink: #272a2c; + --oxide: #a83228; + --vermilion: #df5036; + --muted: #76736f; + --line: #e5e1da; + --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace; + background: var(--paper); + color: var(--ink); + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; + font-synthesis: none; + -webkit-font-smoothing: antialiased; +} +* { + box-sizing: border-box; +} +body, h1, h2, p, pre { + margin: 0; +} +button, a { + -webkit-tap-highlight-color: transparent; +} +button { + font: inherit; + cursor: pointer; +} +a { + color: inherit; + text-decoration: none; +} +a:hover { + color: var(--oxide); +} +::selection { + background: #efd0c5; + color: var(--ink); +} +.page { + width: min(1120px, calc(100% - 80px)); + margin-inline: auto; +} +.skip-link { + position: absolute; + top: -60px; + left: 20px; + padding: 12px; + background: var(--paper); + z-index: 2; +} +.skip-link:focus { + top: 12px; +} +.site-header { + height: 102px; + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1px solid var(--line); +} +.brand img { + display: block; + height: auto; +} +.family { + font-size: 12px; + color: var(--muted); +} +.hero { + text-align: center; + padding: 65px 0 48px; +} +.eyebrow { + display: flex; + justify-content: center; + align-items: center; + gap: 10px; + color: var(--oxide); + font-family: var(--mono); + font-size: 11px; + margin-bottom: 22px; +} +h1 { + font-size: clamp(40px, 5.6vw, 76px); + font-weight: 630; + line-height: 1.09; + letter-spacing: -0.055em; +} +h1 span { + color: var(--oxide); +} +.description { + max-width: 730px; + margin: 25px auto 0; + color: #77736e; + font-size: 15px; + line-height: 1.7; +} +.example { + animation: show-example 240ms ease-out both; +} +.window-controls { + display: flex; + gap: 6px; + margin-right: 14px; +} +.window-controls i { + width: 8px; + height: 8px; + border-radius: 50%; + background: #615551; +} +.window-controls i:nth-child(2) { + background: #686149; +} +.window-controls i:nth-child(3) { + background: #495d50; +} +.pane-label { + margin-left: auto; + font-size: 10px; + color: #81867f; +} +.pane-footer { + height: 34px; + padding: 0 20px; + display: flex; + align-items: center; + justify-content: flex-end; + border-top: 1px solid #ffffff0b; + color: #8c9289; + font-size: 10px; +} +.terminal-capture { + display: block; + width: 100%; + min-width: 740px; + height: auto; +} +.walkthrough { + display: flex; + justify-content: center; + flex-wrap: wrap; + gap: 8px; + margin-top: 20px; +} +.walkthrough button { + padding: 9px 16px; + border: 1px solid var(--line); + border-radius: 5px; + color: var(--muted); + background: transparent; + font: 12px var(--mono); +} +.walkthrough button:hover, +.walkthrough button[aria-pressed="true"] { + border-color: var(--oxide); + color: var(--oxide); + background: #a8322809; +} +.walkthrough-description { + margin-top: 16px; + text-align: center; + color: var(--ink); + font-size: 13px; + line-height: 1.7; +} +.example-caption { + margin-top: 17px; + color: var(--muted); + font-size: 11px; +} +.installation { + padding: 49px 0 43px; + text-align: center; +} +h2 { + font-size: 17px; + font-weight: 500; + letter-spacing: -0.025em; + margin-bottom: 17px; +} +.install-box { + width: min(660px, 100%); + margin: 0 auto; + border: 1px solid #ddd9d0; + border-radius: 6px; + background: #f2f0eb; +} +.install-methods { + display: flex; + gap: 24px; + padding: 0 18px; + border-bottom: 1px solid #ddd9d0; +} +.install-methods button { + padding: 12px 0; + border: 0; + border-bottom: 2px solid transparent; + background: transparent; + color: var(--muted); + font: 12px var(--mono); +} +.install-methods button:hover { + color: var(--oxide); +} +.install-methods button[aria-pressed="true"] { + color: var(--oxide); + border-bottom-color: var(--oxide); +} +.install-command { + display: flex; + align-items: center; + gap: 8px; + padding: 16px 18px; +} +.install-command > .shell-prompt { + margin: 0 8px 0 0; + font: 14px var(--mono); +} +.install-command code { + min-width: 0; + font: 12px var(--mono); + user-select: all; + text-align: left; + overflow-wrap: anywhere; +} +.copy-button { + display: grid; + grid-template-columns: 17px auto; + min-height: 24px; + gap: 7px; + align-items: center; + padding: 0 0 0 19px; + margin-left: auto; + border: 0; + border-left: 1px solid #dcd8cf; + background: transparent; + color: #6c6b62; + font-size: 11px; + white-space: nowrap; +} +.copy-button:hover { + color: var(--oxide); +} +.copy-button img { + grid-area: 1 / 1; +} +.copy-button.copied img { + visibility: hidden; +} +.copy-button.copied::after { + content: "✓"; + grid-area: 1 / 1; + color: var(--oxide); + font-size: 17px; +} +.install-note { + margin-top: 13px; + font-size: 10px; + color: #79756d; +} +.quick-start { + margin-top: 28px; + font-size: 12px; +} +.quick-start pre { + width: fit-content; + margin: 14px auto; + padding-left: 16px; + border-left: 2px solid var(--line); + text-align: left; + font: 12px/1.9 var(--mono); +} +.quick-start a { + color: var(--oxide); +} +footer { + display: flex; + justify-content: space-between; + align-items: center; + padding: 27px 0 31px; + border-top: 1px solid var(--line); + font-size: 12px; +} +footer nav { + display: flex; + align-items: center; + gap: 22px; +} +footer a { + display: flex; + gap: 8px; + align-items: center; +} +.handle { + color: var(--muted); +} +footer p { + color: #8b877d; + font-size: 11px; +} +button:focus-visible, textarea:focus-visible, a:focus-visible { + outline: 2px solid var(--vermilion); + outline-offset: 5px; +} +.eyebrow > span { + color: var(--vermilion); + font-size: 16px; + font-weight: bold; +} +.description a, .example-caption a { + color: var(--oxide); + text-decoration: underline; + text-underline-offset: 3px; +} +.hero-links { + display: flex; + align-items: center; + justify-content: center; + gap: 26px; + margin-top: 27px; + font-size: 13px; +} +.primary-link { + padding: 13px 20px; + background: var(--oxide); + border: 1px solid var(--oxide); + border-radius: 5px; + color: var(--paper); +} +.primary-link:hover { + background: var(--paper); +} +.example-heading { + display: flex; + justify-content: space-between; + margin-bottom: 14px; + color: var(--muted); + font: 11px var(--mono); +} +.live-dot { + display: inline-block; + width: 6px; + height: 6px; + margin-right: 7px; + border-radius: 50%; + background: var(--vermilion); +} +.studio { + overflow: hidden; + border: 1px solid #393a38; + border-radius: 10px; + background: #272a2c; + color: #d8d8d0; + box-shadow: 0 20px 55px -28px #30261970; + font: 12px var(--mono); +} +.pane-heading { + height: 48px; + padding: 0 22px; + display: flex; + align-items: center; + gap: 12px; + border-bottom: 1px solid #ffffff12; +} +.terminal-body { + padding: 16px 12px; + overflow-x: auto; +} +.example-caption { + text-align: center; + line-height: 1.9; +} +.features { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 38px; + padding: 44px 0; + margin-top: 24px; + border-block: 1px solid var(--line); +} +.feature-number { + color: var(--oxide); + font: 10px var(--mono); +} +.features h2 { + margin: 15px 0 10px; +} +.features p { + color: var(--muted); + font-size: 13px; + line-height: 1.8; +} +@keyframes show-example { + from { + opacity: 0; + transform: translateY(6px); + } + to { + opacity: 1; + transform: none; + } +} +@media (max-width: 1000px) { + .page { + width: calc(100% - 48px); + } + .install-command { + flex-wrap: wrap; + } +} +@media (max-width: 720px) { + .page { + width: calc(100% - 36px); + } + .site-header { + height: 80px; + } + .brand img { + width: 140px; + } + .family { + max-width: 110px; + font-size: 10px; + text-align: right; + } + .hero { + padding: 45px 0 36px; + } + h1 { + font-size: clamp(34px, 6.4vw, 46px); + } + .description { + font-size: 13px; + } + .example-heading { + font-size: 10px; + } + .example-heading > span { + display: none; + } + .terminal-body { + padding: 14px 8px; + } + .pane-footer { + padding-inline: 12px; + font-size: 9px; + } + .features { + grid-template-columns: 1fr; + gap: 26px; + padding: 30px 0; + } + .copy-button { + margin: 8px 0 0; + padding: 0; + border: 0; + } + .install-command { + gap: 5px; + padding: 14px; + } + .install-command > .shell-prompt { + display: none; + } + .install-command code { + width: 100%; + line-height: 1.8; + font-size: 11px; + } + footer { + align-items: flex-start; + flex-direction: column; + gap: 22px; + } + footer nav { + flex-wrap: wrap; + gap: 18px; + font-size: 11px; + } +} +@media (prefers-reduced-motion: reduce) { + .example { + animation: none; + } +} diff --git a/apps/landing/public/terminal/inspector.svg b/apps/landing/public/terminal/inspector.svg new file mode 100644 index 0000000..4f80972 --- /dev/null +++ b/apps/landing/public/terminal/inspector.svg @@ -0,0 +1,308 @@ + + + + + +›_ + + sql-bomb + + Flight SQL · http://127.0.0.1:51201 + + Menu ^K + + Library ^P Connection + + Row 1 · city · Utf8 + +╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ + +│ + + Montréal + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + Scroll to read · Esc back · / menu · Ctrl+C quit + + diff --git a/apps/landing/public/terminal/library.svg b/apps/landing/public/terminal/library.svg new file mode 100644 index 0000000..f9e64ac --- /dev/null +++ b/apps/landing/public/terminal/library.svg @@ -0,0 +1,566 @@ + + + + + +›_ + + sql-bomb + + Flight SQL · http://127.0.0.1:51201 + + Menu ^K + + Library ^P Connection + + + +Query library + + Back Esc + + + + History + + ★ Starred + +Saved on this device + + + + +┌──────────────────────────────────────────────────────────────────────────────────────────────────────────┐ + + + +│ + + +S + +earch SQL or connection… + +│ + + + +└──────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + + +╭──────────────────────────────────────────────╮ + + +╭─────────────────────────────────────────────────────────╮ + + + +│ + + QUERIES · newest first + +│ + + +│ + + + SQL PREVIEW + + +│ + + + +│ + + ›★ SELECT city, country, distance_km FROM d… + +│ + + +│ + + +2026-10-03 22:59:13 · http://127.0.0.1:51201 + + +│ + + + +│ + + +2026-10-03 22:59:13 · http://127.0.0.1:51201 + + +│ + + +│ + + SELECT city, country, distance_km + +│ + + + +│ + + +│ + + +│ + + FROM destinations + +│ + + + +│ + + +│ + + +│ + + ORDER BY distance_km; + +│ + + + +│ + + +│ + + +│ + + +│ + + + +│ + + +│ + + +│ + + +│ + + + +│ + + +│ + + +│ + + +│ + + + +│ + + +│ + + +│ + + +│ + + + +│ + + +│ + + +│ + + +│ + + + +│ + + +│ + + +│ + + +│ + + + +│ + + +│ + + +│ + + +│ + + + +│ + + +│ + + +│ + + +│ + + + +│ + + +│ + + +│ + + +Loads into your current connection. + + +│ + + + +│ + + 1 query + +│ + + +│ + + + Use query ↵ + + ★ Unstar ^S + +│ + + + +╰──────────────────────────────────────────────╯ + + +╰─────────────────────────────────────────────────────────╯ + + + + ↑↓ choose · Enter load · Esc back · Menu for more actions + + + + diff --git a/apps/landing/public/terminal/menu.svg b/apps/landing/public/terminal/menu.svg new file mode 100644 index 0000000..fdd7864 --- /dev/null +++ b/apps/landing/public/terminal/menu.svg @@ -0,0 +1,444 @@ + + + + + +›_ + + sql-bomb + + Flight SQL · http://127.0.0.1:51201 + + Menu ^K + + Library ^P Connection + + + +╭──────────────────────────────────────────────────────────────────────────╮ + + + +│ + + +Menu + + Close Esc + +│ + + + +│ + + +╭──────────────────────────────────────────────────────────────────────╮ + + +│ + + + +│ + + +│ + + Find an action… + +│ + + +│ + + + +│ + + +╰──────────────────────────────────────────────────────────────────────╯ + + +│ + + + +│ + + +│ + + + +│ + + + +› + +Query editor + +Ctrl+E + + + +│ + + + +│ + + + +Query history + + + +│ + + + +│ + + + +Starred queries + + + +│ + + + +│ + + + + +Run query Ctrl+R + + +│ + + + +│ + + + +Star / unstar query + +Ctrl+S + + +│ + + + +│ + + + +Browse results + +Ctrl+L + + +│ + + + +│ + + + +Inspect result value + + + +│ + + + +│ + + + + +Cancel query + + +│ + + + +│ + + + +Change connection + + + +│ + + + +│ + + + +Save connection… + + + +│ + + + +│ + + +│ + + + +│ + + Return to your SQL draft. + +│ + + + +│ + + +│ + + + +│ + + +↑↓ choose · Enter open · Esc close · Ctrl+C quit + + +│ + + + +╰──────────────────────────────────────────────────────────────────────────╯ + + + + + + + + diff --git a/apps/landing/public/terminal/results.svg b/apps/landing/public/terminal/results.svg new file mode 100644 index 0000000..fc62698 --- /dev/null +++ b/apps/landing/public/terminal/results.svg @@ -0,0 +1,347 @@ + + + + + +›_ + + sql-bomb + + Flight SQL · http://127.0.0.1:51201 + + Menu ^K + + Library ^P + + Connection + + +╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ + +│ + + SELECT city, country, distance_km + +│ + +│ + + FROM destinations + +│ + +│ + + ORDER BY distance_km; + +│ + +╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + +1 tables available + + Refresh schema + + Run ⌘↵ / ^R + + + Cancel Esc + + ☆ Star ^S + + Complete · 0.02s + +╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ + +│ + + city + + country distance_km + +│ + +│ + + Montréal + + Canada 534 + +│ + +│ + + Reykjavík Iceland 4208 + +│ + +│ + + Lisbon Portugal 5420 + +│ + +│ + + Copenhagen Denmark 6198 + +│ + +│ + + Buenos Aires Argentina 8523 + +│ + +│ + + Tokyo Japan 10838 + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + Row 1 / 6 · Column 1 / 3 · city + + Arrows select · Enter inspect · / menu · Ctrl+C quit + + diff --git a/apps/landing/public/terminal/welcome.svg b/apps/landing/public/terminal/welcome.svg new file mode 100644 index 0000000..82d663b --- /dev/null +++ b/apps/landing/public/terminal/welcome.svg @@ -0,0 +1,347 @@ + + + + + +›_ + + sql-bomb + + Flight SQL · http://127.0.0.1:51201 + + Menu ^K + + Library ^P Connection + +╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ + +│ + + SELECT * FROM your_table LIMIT 100; + +│ + +│ + + +│ + +│ + + +│ + +╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + + + Refresh schema + + Run ⌘↵ / ^R + + + Cancel Esc + + + ☆ Star ^S + + + Ready · Write SQL and choose Run + +╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + + ▄█▀ ▀ + + +│ + +│ + + + ▄█████ + + +sql-bomb + + +│ + +│ + + + ▀███████ + + +│ + +│ + + + ▀██▄▄▄▄██▀ + + +Query SQL. + + +│ + +│ + + + ▀██████▀ + + +Watch the rows arrive. + + +│ + +│ + + + ▀▀▀▀ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +│ + + +│ + +╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + 0 rows · 0 columns + + Arrows select · Enter inspect · / menu · Ctrl+C quit + + diff --git a/apps/landing/src/app.rs b/apps/landing/src/app.rs new file mode 100644 index 0000000..54eeb74 --- /dev/null +++ b/apps/landing/src/app.rs @@ -0,0 +1,146 @@ +use fusor::{Signal, signal}; +use wasm_bindgen::{JsCast, JsValue, closure::Closure}; + +#[derive(PartialEq)] +struct InstallMethod { + name: &'static str, + command: &'static str, +} + +const INSTALL_METHODS: &[InstallMethod] = &[ + InstallMethod { + name: "Cargo", + command: "cargo install sql-bomb --locked", + }, + InstallMethod { + name: "Linux", + command: "curl -fsSL https://boom.fusor.build/install.sh | sh", + }, +]; +const COPY_PROMPT: &str = "Copy command"; +const COPY_SUCCESS: &str = "Copied!"; +const ROTATION_INTERVAL_MS: i32 = 3_000; + +#[derive(PartialEq)] +struct Scene { + name: &'static str, + image: &'static str, + description: &'static str, +} + +const SCENES: &[Scene] = &[ + Scene { + name: "Workspace", + image: "/terminal/welcome.svg", + description: "Start with a SQL editor, schema suggestions, and the sql-bomb welcome screen.", + }, + Scene { + name: "Query", + image: "/terminal/results.svg", + description: "Six destinations, sorted by distance. Arrow keys select a row and column.", + }, + Scene { + name: "Inspect", + image: "/terminal/inspector.svg", + description: "Press Enter on a cell to read its complete value and Arrow type.", + }, + Scene { + name: "Library", + image: "/terminal/library.svg", + description: "Search your local query history, preview the SQL, and star a query to keep it.", + }, + Scene { + name: "Menu", + image: "/terminal/menu.svg", + description: "Open the searchable action menu with Ctrl+K, or / outside the SQL editor.", + }, +]; + +struct App { + scene: Signal<&'static Scene>, + install_method: Signal<&'static InstallMethod>, + hovering: Signal, + window: web_sys::Window, + rotation_interval: i32, + _rotation: Closure, + clipboard: web_sys::Clipboard, + copy_label: Signal<&'static str>, +} + +impl App { + fn new() -> Result { + let window = web_sys::window().ok_or_else(|| JsValue::from_str("window is unavailable"))?; + let scene = signal(&SCENES[1]); + let hovering = signal(false); + let reduced_motion = window.match_media("(prefers-reduced-motion: reduce)")?; + let rotating_scene = scene.clone(); + let hovered = hovering.clone(); + let rotation = Closure::::new(move || { + if hovered.get() + || reduced_motion + .as_ref() + .is_some_and(web_sys::MediaQueryList::matches) + { + return; + } + let current = SCENES + .iter() + .position(|scene| scene == rotating_scene.get()) + .expect("the selected scene belongs to SCENES"); + rotating_scene.set(&SCENES[(current + 1) % SCENES.len()]); + }); + let rotation_interval = window.set_interval_with_callback_and_timeout_and_arguments_0( + rotation.as_ref().unchecked_ref(), + ROTATION_INTERVAL_MS, + )?; + Ok(Self { + scene, + install_method: signal(&INSTALL_METHODS[0]), + hovering, + rotation_interval, + _rotation: rotation, + clipboard: window.navigator().clipboard(), + copy_label: signal(COPY_PROMPT), + window, + }) + } + + fn select_install(&self, method: &'static InstallMethod) { + self.install_method.set(method); + self.copy_label.set(COPY_PROMPT); + } + + fn copy_install(&self) { + let method = self.install_method.get(); + let promise = self.clipboard.write_text(method.command); + let selected = self.install_method.clone(); + let label = self.copy_label.clone(); + wasm_bindgen_futures::spawn_local(async move { + let outcome = match wasm_bindgen_futures::JsFuture::from(promise).await { + Ok(_) => COPY_SUCCESS, + Err(_) => "Select command to copy", + }; + if selected.get() == method { + label.set(outcome); + } + }); + } +} + +impl Drop for App { + fn drop(&mut self) { + self.window + .clear_interval_with_handle(self.rotation_interval); + } +} + +#[expect( + clippy::too_many_lines, + clippy::excessive_nesting, + clippy::redundant_clone, + reason = "Fusor 0.1.4 DOM codegen: https://github.com/fusor-rs/fusor/issues/17" +)] +mod dom { + use super::{App, COPY_SUCCESS, INSTALL_METHODS, SCENES}; + fusor::template!("web/index.html"); +} diff --git a/apps/landing/src/lib.rs b/apps/landing/src/lib.rs new file mode 100644 index 0000000..c0de390 --- /dev/null +++ b/apps/landing/src/lib.rs @@ -0,0 +1 @@ +mod app; diff --git a/apps/landing/web/index.html b/apps/landing/web/index.html new file mode 100644 index 0000000..3262bfa --- /dev/null +++ b/apps/landing/web/index.html @@ -0,0 +1,148 @@ + + + + + + + + + + + sql-bomb — Ultrafast SQL Client in your Terminal + + + + + + +
+ +
+
+

+ Less waiting. More querying. +

+

Ultrafast SQL Client
in your Terminal

+

+ sql-bomb is a fast SQL client for querying databases and streaming results + in a beautiful terminal interface, powered by + Hypercmd + and Fusor. +

+ +
+
+
+

+ The real terminal. Take a look around.

+ Explore the app ↓ +
+
+
+ + ~ / sql-bombboom +
+
+ {{ state.scene.get().description }} +
+ +
+
+ + + +
+

+ {{ state.scene.get().description }} +

+

+ A recorded walkthrough of sql-bomb, running against a local + Flight SQL server with sample data. + Hover to pause, or choose a view above to explore. +

+
+
+
+ 01 / QUERY +

Stay in your flow.

+

Multiline SQL, table and column suggestions, and a searchable action menu.

+
+
+ 02 / EXPLORE +

Follow the rows.

+

Browse results as they arrive. + Open a cell to see the complete value and its type.

+
+
+ 03 / KEEP +

Good SQL deserves an encore.

+

Return to local history, star a useful query, and reopen saved connections.

+
+
+
+

Your next query starts with boom.

+
+
+ + + +
+
+ + {{ state.install_method.get().command }} + +
+
+

+ macOS & Linux · x86-64 & ARM64 · v0.1, in development +

+
+

After installation, open your SQL workspace:

+
boom
+ Installation & first connection ↗ +

Install commands require a published release. + Build from source + to run this checkout.

+
+
+
+ +
+
+ + + diff --git a/crates/completion/Cargo.toml b/crates/completion/Cargo.toml index 0cfab25..41fcd97 100644 --- a/crates/completion/Cargo.toml +++ b/crates/completion/Cargo.toml @@ -3,6 +3,8 @@ name = "sql-bomb-completion" version = "0.1.0" edition = "2024" license = "MIT" +description = "SQL table and column completion from cursor position and catalog metadata" +repository = "https://github.com/fusor-rs/sql-bomb" [dependencies] thiserror.workspace = true diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..11219f4 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,35 @@ +# How it works + +This page describes the implementation for contributors. The +[workspace guide](workspace.md) covers using the app. + +## Clients and results + +Each client implements the public [QueryClient trait](../src/lib.rs), the shared +Rust interface for running queries. It returns the columns and their types, +followed by a stream of Arrow record batches: chunks of rows stored by column. +Errors can arrive with the stream. The terminal displays a window of those rows +and columns while keeping received rows in memory. + +The [client registry](../src/client.rs) supplies the chooser, CLI flags, and +connection setup. Network operations run in Tokio, Rust's asynchronous runtime, +so the interface can respond while results arrive. + +Each Flight SQL query opens a gRPC connection, executes a statement, and reads all +returned endpoints in order. When an endpoint advertises multiple locations, +sql-bomb uses the first. The optional `QueryClient::tables()` method uses the +Flight SQL `CommandGetTables` operation with schemas included. It returns each +table's catalog, database schema, name, type, and Arrow column schema. + +## Terminal interface + +Fusor connects the [HTML template](../ui/app.html) to +[Rust state](../src/terminal.rs), updating the view when that state changes. +Hypercmd handles terminal layout, focus, and input. + +## SQL suggestions + +The independent [completion crate](../crates/completion) uses Tree-sitter, a +parser library, to read SQL around the cursor. It combines that syntax with table +and column information from the client and returns text edits to the editor. +It runs inside sql-bomb; it does not start a language server or execute SQL. diff --git a/docs/flight-sql.md b/docs/flight-sql.md new file mode 100644 index 0000000..3fa8ceb --- /dev/null +++ b/docs/flight-sql.md @@ -0,0 +1,58 @@ +# Clients and Flight SQL + +A client is the part of sql-bomb that connects to a server and runs queries. +Flight SQL is currently the only client; PostgreSQL and MySQL clients are not +implemented. Arrow Flight SQL sends SQL over gRPC and receives results in Apache +Arrow format, which preserves each column's data type. + +## Connection address + +Choose **Flight SQL** in the client chooser, or pass its flag: + +```sh +boom --flightsql +boom --flightsql http://localhost:50051 +``` + +The first command opens the connection form. The second also skips the form, so +use it for connections without headers. An address without the flag, such as +`boom http://localhost:50051`, fills in the form after you choose a client. + +The server URL contains a scheme, host, and port, such as +`http://localhost:50051` or `https://sql.example.com:443`. Credentials, paths, and +query parameters do not belong in the URL. Use `http://` or `grpc+tcp://` for an +unencrypted connection. Use `https://` or `grpc+tls://` for TLS encryption with +certificates trusted by your operating system. + +## Authentication + +Headers are extra name/value pairs sent with a request, often to carry a token. +Leave the field empty if your server needs none. Otherwise, enter one header per +line as `name: value`: + +```text +authorization: Bearer YOUR_TOKEN +x-tenant: YOUR_TENANT +``` + +Header names and values must be ASCII; binary metadata is not supported. +Authentication uses these headers. Flight handshake authentication and client +certificates (mutual TLS) are not implemented. + +A Flight SQL server can direct sql-bomb to another address to fetch results. +Headers are sent only to addresses with the same scheme, host, and port as the +configured server. See the +[Arrow Flight protocol](https://arrow.apache.org/docs/format/Flight.html) for the +protocol's endpoint and authentication conventions. + +## Remembering headers + +Headers stay in memory unless you check **Remember headers securely** when saving +a connection. This option is off by default. It stores headers in macOS Keychain +or Linux Secret Service. On Linux, the Secret Service keyring must be unlocked +and available on your session D-Bus. + +Without that option, reopening a saved connection that used headers asks for +them again. Renaming the connection without entering headers keeps that prompt. +Credential-store failures appear in the form. Headers are never saved in query +history or written to a plaintext fallback file. diff --git a/docs/get-started.md b/docs/get-started.md new file mode 100644 index 0000000..d54471a --- /dev/null +++ b/docs/get-started.md @@ -0,0 +1,80 @@ +# Get started + +sql-bomb runs in a terminal on macOS or Linux. To run queries, you need the address +of a server that supports [Arrow Flight SQL](flight-sql.md). sql-bomb connects to +that server; it does not start a database for you. + +## Install with Cargo + +Cargo is Rust's package manager, included when you install Rust through +[rustup](https://rustup.rs). After a sql-bomb release is published to crates.io, +you can install the `boom` executable with: + +```sh +cargo install sql-bomb --locked +boom +``` + +`--locked` uses the dependency versions recorded in the release. Cargo installs +`boom` in `~/.cargo/bin` by default; that directory needs to be in your shell's PATH. + +## Install a binary release + +The shell installer downloads the latest published GitHub release for x86-64 or +ARM64 on Linux or macOS. It verifies the download's SHA-256 checksum and installs +`boom` in `~/.sqlbomb/bin`, without sudo or a Rust toolchain: + +```sh +curl -fsSL https://boom.fusor.build/install.sh | sh +export PATH="$HOME/.sqlbomb/bin:$PATH" +boom +``` + +Add the `export` line to your shell profile, such as `~/.zshrc` or `~/.bashrc`, so +new terminals can find `boom`. Run the installer again to upgrade. To select a +release, append `-s -- v0.1.0` to `sh`. Set `SQL_BOMB_INSTALL` on the `sh` command +to choose a different install directory; the executable goes in its `bin/`. +Saved connections, query history, and stars are left untouched. + +This method requires a GitHub release with completed binary uploads. + +## Connect to a server + +1. Run `boom` and choose **Flight SQL**, the only client currently available. +2. Enter your server URL, including its scheme and port, such as + `http://localhost:50051`. This example requires a server already running at that + address. Use `https://` for a server with TLS encryption. +3. If the server requires authentication, enter its request headers, such as + `authorization: Bearer YOUR_TOKEN`. Otherwise, leave the headers empty. +4. Select **Open workspace**. + +Type a query in the editor and press Ctrl+R, or click **Run**: + +```sql +SELECT 1 AS value; +``` + +Rows appear below the editor as the server sends them. Press Ctrl+C to quit. + +For a connection without headers, you can skip the chooser and form: + +```sh +boom --flightsql http://localhost:50051 +``` + +Once you save a connection, `boom` opens your saved connections instead. See +[Using sql-bomb](workspace.md) for saving connections and browsing results, or +[Flight SQL](flight-sql.md) for supported URLs and authentication. + +## Build from source + +With Rust and Cargo installed, clone the repository and install from the checkout: + +```sh +git clone https://github.com/fusor-rs/sql-bomb +cd sql-bomb +cargo install --path . --locked +boom +``` + +For development, `cargo run --locked` builds and launches the app from the checkout. diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..ee7fe65 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,20 @@ +# sql-bomb + +sql-bomb is a terminal application for running SQL and streaming results into a +table. You can inspect complete cell values and return to queries from your local +history or starred library. The installed executable is named `boom`. + +Flight SQL is currently the only supported connection type. It connects to +servers that implement Arrow Flight SQL, a protocol for running SQL over gRPC. +Direct PostgreSQL and MySQL connections are not implemented. + +The terminal interface is built with +[Hypercmd](https://github.com/fusor-rs/hypercmd) and +[Fusor](https://github.com/fusor-rs/fusor). + +**In development · v0.1** — See [available clients](flight-sql.md) and +[status and known limitations](status.md). + +[Get started](get-started.md) · [Using sql-bomb](workspace.md) · +[Clients](flight-sql.md) · [How it works](architecture.md) · [Status](status.md) · +[Contributing](../README.md#contributing) diff --git a/docs/status.md b/docs/status.md new file mode 100644 index 0000000..d8903c2 --- /dev/null +++ b/docs/status.md @@ -0,0 +1,18 @@ +# Status and known limitations + +sql-bomb is in early development. Queries currently target statements that return +rows, such as `SELECT`. Client availability and protocol-specific limits are +listed under [Clients](flight-sql.md). + +| Area | Included | +| --- | --- | +| Query workspace | Multiline SQL editor, searchable action menu, keyboard and mouse controls | +| SQL suggestions | Qualified tables and columns from referenced tables and aliases | +| Results | Streaming table, cancellation, and full cell inspection | +| Query library | Local history and starred queries in SQLite | +| Saved connections | Searchable saved connections; optional OS credential storage | +| Terminal platforms | macOS and Linux | + +All received rows stay in memory until another query starts or the connection +changes. **Cancel** stops receiving results. It does not send a server-side SQL +cancellation command, so the server decides whether to keep running the query. diff --git a/docs/workspace.md b/docs/workspace.md new file mode 100644 index 0000000..f721dbd --- /dev/null +++ b/docs/workspace.md @@ -0,0 +1,124 @@ +# Using sql-bomb + +## Saved connections + +Check **Save on this device** in the connection form. Give it a name +(the hostname is suggested), then choose **Save & open**. Leave the checkbox +unchecked for a session-only connection. A direct CLI launch remains unsaved; +**Menu → Save connection…** saves it without clearing SQL or results. + +When saved connections exist, launching `boom` opens **Connections**. Search +by name, client, or address; recently opened connections appear first. Click a row, +or use Up/Down and Enter, to open it. **New connection**, **Edit**, and **Remove** +are visible actions. Editing requires **Save changes**; Escape discards the edit. +Removal asks for confirmation and keeps query history, stars, and the active workspace. + +Saved connections live in `~/.sqlbomb/queries.sqlite3`. Authentication and credential +storage options are described in the [client settings](flight-sql.md). + +## The menu + +**Menu** is always visible in the header. Click it or press Ctrl+K, then search +for an action. Click a result to open it, or use Up/Down and Enter. Unavailable +actions explain what is needed when selected. + +Press `/` in results, previews, or other non-editing controls to open the same +menu. In text fields, `/` remains ordinary text. Search for an action by name, such as +`history`; a leading `/` is optional. Escape restores the previous pane, including the editor's +cursor and selection. Queries continue streaming while the menu is open. + +## SQL suggestions + +Clients that implement table discovery provide suggestions as you type. After +`FROM` or `JOIN`, the editor suggests tables from the active connection, including +catalog and schema qualifiers. In column positions, it suggests columns from +referenced tables and aliases, with their data types and source tables. + +Use Up/Down to choose a suggestion, then Tab or a click to insert it. Insertion +replaces the identifier at the caret and preserves the rest of the query. Escape +closes suggestions; Enter inserts a newline. Suggestions stay out of comments +and string literals. Quoted identifiers preserve their quoting style. +The list shows a bounded set of matches; keep typing to narrow it. + +Table and column information is loaded when you open the workspace and kept in +memory. **Refresh schema** reloads it after database changes or a discovery +failure. Loading and failures appear beneath the editor; typing and executing SQL +remain available. Clients without discovery work without suggestions. + +Completion resolves catalog tables and aliases within the current statement or +subquery. Columns derived from `WITH` queries (CTEs), subquery select lists, and +set operations such as `UNION` are not resolved. Ambiguous table references do not +produce guessed column lists. + +## Results + +The multiline editor preserves pasted SQL, including comments and string +literals. Results appear as rows arrive. Column headers stay visible, +the selected cell is highlighted, and the footer shows your row and column. +Use the arrow keys to browse or the mouse wheel to scroll. + +Long values end with an ellipsis. Enter opens the complete selected value and its +data type in a scrollable inspector. Large values are split into bounded parts +with Previous/Next controls. **Error details** opens the complete query error. +HTTP(S) cells show **Open link ↗**; a normal left click opens the full destination +in your browser. + +**Cancel** stops receiving rows and keeps the results already received. While a +query streams, your selection stays put; End jumps to the latest row. + +## History and starred queries + +**Library** opens searchable **History** and **Starred** tabs. Filter by SQL or +connection address, browse the list, and preview the selected query. Each entry +includes its original server address and local timestamp. The panes stack in narrow +terminals. + +**Use query** or Enter loads the full SQL into your current connection's editor +without executing it. Escape returns to your unchanged draft. **Star** or Ctrl+S +saves the editor's query, including SQL you have not run. In the library, it +stars or unstars the selected query. A star belongs to the exact SQL and server address; +editing that SQL creates a different query to star. + +History and stars live in `~/.sqlbomb/queries.sqlite3`, outside the project. +Every run attempt is recorded before contacting the server, including failed and +cancelled queries. Repeated executions remain separate history entries. The +library survives restarts and supports multiple sql-bomb sessions. + +New directories and database files are private to your account. The database +stores full SQL and server addresses in plaintext, with no automatic history expiry. +Storage errors are displayed rather than silently dropping the record. + +## Keyboard and mouse + +The Menu lists actions and their shortcuts. The full reference is below. + +| Key | Action | +| --- | --- | +| Ctrl+K or Menu | Open or close the searchable action menu | +| / outside text fields | Open the menu | +| Command+Enter in SQL or Ctrl+R | Run the SQL in the editor | +| Ctrl+E / Ctrl+L | Focus SQL / results | +| Ctrl+P | Open the query library / focus its search | +| Ctrl+S | Star or unstar the editor's query / selected library query | +| Enter in library search or list | Load the selected query into the editor | +| Up / Down, then Enter in Connections | Choose and open a saved connection | +| Space on a checkbox | Toggle saving or remembering headers | +| Enter in SQL | Insert a newline | +| Ctrl+A in SQL | Select the entire query | +| Tab or Shift+Tab | Move between controls and panes | +| Arrows in results | Select a cell and reveal it when outside the window | +| PageUp / PageDown | Move one page through results or the inspector | +| Up / Down in library | Select the previous / next query | +| PageUp / PageDown in library | Browse one page of queries | +| Home / End in results | Select the first / last received row | +| Enter in results | Inspect the selected cell | +| Mouse wheel | Scroll the pane under the pointer | +| Shift+wheel or horizontal wheel | Move through result columns | +| Escape | Go back from connection setup, library, or inspector; otherwise cancel a running query | +| Ctrl+C | Quit and restore the terminal | + +Command+Enter works only if your terminal forwards the Command key through +[enhanced keyboard reporting](https://sw.kovidgoyal.net/kitty/keyboard-protocol/). +If your terminal reserves that shortcut, map it to `ESC [ 13 ; 9 u` (without +spaces), or use Ctrl+R. Link clicks use `open` on macOS or `xdg-open` on Linux. +Modifier-click gestures belong to the terminal emulator. diff --git a/examples/site-preview/sample.sql b/examples/site-preview/sample.sql new file mode 100644 index 0000000..c69a2e6 --- /dev/null +++ b/examples/site-preview/sample.sql @@ -0,0 +1,13 @@ +CREATE TABLE destinations ( + city TEXT, + country TEXT, + distance_km INTEGER +); + +INSERT INTO destinations VALUES + ('Lisbon', 'Portugal', 5420), + ('Montréal', 'Canada', 534), + ('Tokyo', 'Japan', 10838), + ('Copenhagen', 'Denmark', 6198), + ('Buenos Aires', 'Argentina', 8523), + ('Reykjavík', 'Iceland', 4208); diff --git a/examples/site-preview/server.rs b/examples/site-preview/server.rs new file mode 100644 index 0000000..9ce5e45 --- /dev/null +++ b/examples/site-preview/server.rs @@ -0,0 +1,142 @@ +use arrow_array::{ArrayRef, Int64Array, RecordBatch, StringArray}; +use arrow_flight::{ + FlightDescriptor, FlightEndpoint, FlightInfo, Ticket, + encode::FlightDataEncoderBuilder, + error::FlightError, + flight_service_server::{FlightService, FlightServiceServer}, + sql::{ + CommandGetTables, CommandStatementQuery, ProstMessageExt, SqlInfo, TicketStatementQuery, + server::FlightSqlService, + }, +}; +use futures_util::{TryStreamExt, stream}; +use prost::Message; +use std::sync::Arc; +use tokio::net::TcpListener; +use tokio_stream::wrappers::TcpListenerStream; +use tonic::{Request, Response, Status, transport::Server}; + +const SAMPLE_QUERY: &str = "SELECT city, country, distance_km FROM destinations"; + +struct Destinations; + +pub(super) async fn start() -> Result> { + let listener = TcpListener::bind("127.0.0.1:0").await?; + let address = format!("http://{}", listener.local_addr()?); + tokio::spawn(async move { + if let Err(error) = Server::builder() + .add_service(FlightServiceServer::new(Destinations)) + .serve_with_incoming(TcpListenerStream::new(listener)) + .await + { + eprintln!("Preview Flight SQL server failed: {error}"); + } + }); + Ok(address) +} + +fn query(sql: &str) -> Result> { + let database = rusqlite::Connection::open_in_memory()?; + database.execute_batch(include_str!("sample.sql"))?; + let mut statement = database.prepare(sql)?; + let mut cities = Vec::new(); + let mut countries = Vec::new(); + let mut distances = Vec::new(); + let mut rows = statement.query([])?; + while let Some(row) = rows.next()? { + cities.push(row.get::<_, String>(0)?); + countries.push(row.get::<_, String>(1)?); + distances.push(row.get::<_, i64>(2)?); + } + Ok(RecordBatch::try_from_iter([ + ("city", Arc::new(StringArray::from(cities)) as ArrayRef), + ( + "country", + Arc::new(StringArray::from(countries)) as ArrayRef, + ), + ( + "distance_km", + Arc::new(Int64Array::from(distances)) as ArrayRef, + ), + ])?) +} + +#[tonic::async_trait] +impl FlightSqlService for Destinations { + type FlightService = Self; + + async fn get_flight_info_statement( + &self, + command: CommandStatementQuery, + _request: Request, + ) -> Result, Status> { + let batch = + query(&command.query).map_err(|error| Status::invalid_argument(error.to_string()))?; + flight_info( + &batch, + Ticket::new( + TicketStatementQuery { + statement_handle: command.query.into(), + } + .as_any() + .encode_to_vec(), + ), + ) + } + + async fn do_get_statement( + &self, + ticket: TicketStatementQuery, + _request: Request, + ) -> Result::DoGetStream>, Status> { + let sql = std::str::from_utf8(&ticket.statement_handle) + .map_err(|error| Status::invalid_argument(error.to_string()))?; + let batch = query(sql).map_err(|error| Status::invalid_argument(error.to_string()))?; + Ok(encode(batch)) + } + + async fn get_flight_info_tables( + &self, + command: CommandGetTables, + _request: Request, + ) -> Result, Status> { + let ticket = Ticket::new(command.as_any().encode_to_vec()); + flight_info(&tables(command)?, ticket) + } + + async fn do_get_tables( + &self, + command: CommandGetTables, + _request: Request, + ) -> Result::DoGetStream>, Status> { + Ok(encode(tables(command)?)) + } + + async fn register_sql_info(&self, _identifier: i32, _result: &SqlInfo) {} +} + +fn tables(command: CommandGetTables) -> Result { + let batch = query(SAMPLE_QUERY).map_err(|error| Status::internal(error.to_string()))?; + let mut tables = command.into_builder(); + tables.append("", "", "destinations", "TABLE", &batch.schema())?; + tables + .build() + .map_err(|error| Status::internal(error.to_string())) +} + +fn flight_info(batch: &RecordBatch, ticket: Ticket) -> Result, Status> { + Ok(Response::new( + FlightInfo::new() + .try_with_schema(&batch.schema()) + .map_err(FlightError::from)? + .with_endpoint(FlightEndpoint::new().with_ticket(ticket)), + )) +} + +fn encode(batch: RecordBatch) -> Response<::DoGetStream> { + let encoded = FlightDataEncoderBuilder::new() + .with_schema(batch.schema()) + .build(stream::iter([Ok(batch)])) + .map_err(Status::from); + Response::new(Box::pin(encoded)) +} diff --git a/examples/site-preview/snapshot.rs b/examples/site-preview/snapshot.rs new file mode 100644 index 0000000..5d93cfb --- /dev/null +++ b/examples/site-preview/snapshot.rs @@ -0,0 +1,135 @@ +use std::io::{self, Read}; +use vt100::{Cell, Color, Screen}; + +const CELL_WIDTH: u16 = 8; +const CELL_HEIGHT: u16 = 17; +const BASELINE: u16 = 13; + +#[derive(Clone, Copy)] +pub(super) enum Format { + Svg, + Text, +} + +struct TextRun<'screen> { + cell: &'screen Cell, + column: u16, + row: u16, + columns: u16, + text: String, +} + +pub(super) fn write(format: Format) -> Result<(), Box> { + let mut dimensions = std::env::args().skip(2); + let columns = dimensions.next().ok_or("Pass columns")?.parse()?; + let rows = dimensions.next().ok_or("Pass rows")?.parse()?; + let mut bytes = Vec::new(); + io::stdin().read_to_end(&mut bytes)?; + let mut parser = vt100::Parser::new(rows, columns, 0); + parser.process(&bytes); + match format { + Format::Text => println!("{}", parser.screen().contents()), + Format::Svg => svg(parser.screen())?, + } + Ok(()) +} + +fn svg(screen: &Screen) -> Result<(), Box> { + let (rows, columns) = screen.size(); + println!( + r##" + +"##, + columns * CELL_WIDTH, + rows * CELL_HEIGHT, + ); + for row in 0..rows { + paint_row(screen, row)?; + } + println!("\n"); + Ok(()) +} + +fn paint_row(screen: &Screen, row: u16) -> Result<(), Box> { + let mut column = 0; + while column < screen.size().1 { + let start = column; + let cell = screen.cell(row, column).expect("cell is inside the screen"); + let mut text = String::new(); + while let Some(next) = screen + .cell(row, column) + .filter(|next| same_style(cell, next)) + { + if next.has_contents() { + text.push_str(&next.contents()); + } else if !next.is_wide_continuation() { + text.push(' '); + } + column += 1; + } + paint(&TextRun { + cell, + column: start, + row, + columns: column - start, + text, + })?; + } + Ok(()) +} + +fn same_style(first: &Cell, second: &Cell) -> bool { + first.fgcolor() == second.fgcolor() + && first.bgcolor() == second.bgcolor() + && first.bold() == second.bold() + && first.italic() == second.italic() + && first.underline() == second.underline() + && first.inverse() == second.inverse() +} + +fn paint(run: &TextRun<'_>) -> Result<(), Box> { + let cell = run.cell; + let left = run.column * CELL_WIDTH; + let top = run.row * CELL_HEIGHT; + let width = run.columns * CELL_WIDTH; + let mut foreground = color(cell.fgcolor(), "#faf9f6")?; + let mut background = color(cell.bgcolor(), "#272a2c")?; + if cell.inverse() { + std::mem::swap(&mut foreground, &mut background); + } + println!( + r#""#, + ); + if !run.text.trim().is_empty() { + let weight = if cell.bold() { "bold" } else { "normal" }; + let style = if cell.italic() { "italic" } else { "normal" }; + let decoration = if cell.underline() { + "underline" + } else { + "none" + }; + let baseline = top + BASELINE; + let escaped = run + .text + .replace('&', "&") + .replace('<', "<") + .replace('>', ">"); + println!( + r#"{escaped}"#, + ); + } + Ok(()) +} + +fn color(color: Color, default: &str) -> Result> { + match color { + Color::Default => Ok(default.into()), + Color::Rgb(red, green, blue) => Ok(format!("#{red:02x}{green:02x}{blue:02x}")), + Color::Idx(index) => { + Err(format!("Expected native RGB colors, found palette index {index}").into()) + } + } +} diff --git a/justfile b/justfile new file mode 100644 index 0000000..7ac3398 --- /dev/null +++ b/justfile @@ -0,0 +1,49 @@ +fusor := env_var_or_default("FUSOR_BIN", "fusor") + +default: + @just --list + +check: + cargo fmt --all -- --check + cargo clippy --workspace --all-targets --locked -- -D warnings + cargo test --workspace --locked + +site-check: + cargo fmt --manifest-path apps/Cargo.toml --all -- --check + cargo clippy --manifest-path apps/Cargo.toml --workspace --all-targets --locked -- -D warnings + cargo test --manifest-path apps/Cargo.toml --workspace --locked + +[working-directory: "apps"] +site: + {{fusor}} build --site --locked + +preview port="4187": + {{fusor}} preview apps/dist --port {{port}} + +landing-dev: + {{fusor}} dev --manifest-path apps/landing/Cargo.toml + +docs-dev: + {{fusor}} dev --manifest-path apps/docs/Cargo.toml + +capture-preview: + python3 scripts/capture-preview.py + +site-browser: + node scripts/site.mjs + +setup-browser: + cargo install fusor-cli --version 0.1.4 --locked + {{fusor}} install --manifest-path apps/Cargo.toml -p sql-bomb-docs --locked + npm ci + npx playwright install chromium + +[unix] +deploy environment="production": + @case "{{environment}}" in \ + production|preview) ;; \ + *) echo "deploy: expected production or preview" >&2; exit 2 ;; \ + esac + vercel build {{ if environment == "production" { "--prod" } else { "" } }} --yes + find .vercel/output/static -name '.fusor-*.json' -delete + vercel deploy --prebuilt {{ if environment == "production" { "--prod" } else { "" } }} --yes diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..31e78a8 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,60 @@ +{ + "name": "sql-bomb-site", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "sql-bomb-site", + "devDependencies": { + "playwright": "1.62.1" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/playwright": { + "version": "1.62.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.62.1.tgz", + "integrity": "sha512-0M+L3LAD8/nm554LOla9Ayx0j0tmFZ0FBcoQ7F1VuVHpM/XpiC8RcDzBQB8W5+hA8L22THxELzeF+2WcUzvcLg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.62.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.62.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.62.1.tgz", + "integrity": "sha512-wPYSwEBJY9GHraISXqyqtx0na0LpO3XEX7jNDhntbex7tzUS7kLnZsOlFruFJB4Hi/rhDMjXGqHewDZ68nYZVw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..9d40703 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "sql-bomb-site", + "private": true, + "type": "module", + "devDependencies": { + "playwright": "1.62.1" + } +} diff --git a/scripts/browser-app.mjs b/scripts/browser-app.mjs new file mode 100644 index 0000000..8032ffc --- /dev/null +++ b/scripts/browser-app.mjs @@ -0,0 +1,62 @@ +import assert from "node:assert/strict"; +import { execFileSync, spawn } from "node:child_process"; +import { createServer } from "node:net"; +import { join, resolve } from "node:path"; +import { chromium } from "playwright"; + +export async function checkBrowser(directory, verify, buildArguments = []) { + const app = resolve(import.meta.dirname, "..", directory); + const fusor = process.env.FUSOR_BIN ?? "fusor"; + execFileSync(fusor, [ + "build", ...buildArguments, "--manifest-path", join(app, "Cargo.toml"), + "--debug", "--locked", "--offline", + ], { cwd: app, stdio: "inherit", timeout: 180_000 }); + const { server, ready, origin } = await preview(fusor, app); + let browser; + try { + await ready; + browser = await chromium.launch(); + const page = await browser.newPage(); + page.setDefaultTimeout(15_000); + const errors = []; + page.on("console", message => { + if (message.type() === "error") errors.push(message.text()); + }); + page.on("pageerror", error => errors.push(error.message)); + try { + await verify(page, origin); + } finally { + assert.deepEqual(errors, []); + } + } finally { + await browser?.close(); + server.kill(); + if (server.exitCode === null) await new Promise(resolve => server.once("exit", resolve)); + } +} + +async function preview(fusor, app) { + const portPicker = createServer(); + await new Promise((resolve, reject) => { + portPicker.once("error", reject); + portPicker.listen(0, "127.0.0.1", resolve); + }); + const port = portPicker.address().port; + await new Promise(resolve => portPicker.close(resolve)); + const server = spawn(fusor, ["preview", join(app, "dist"), "--port", String(port)], { cwd: app }); + const ready = new Promise((resolve, reject) => { + const timeout = setTimeout(() => { + reject(new Error("fusor preview did not become ready")); + }, 10_000); + server.once("error", error => { clearTimeout(timeout); reject(error); }); + server.once("exit", code => { + clearTimeout(timeout); + reject(new Error(`fusor preview exited: ${code}`)); + }); + server.stderr.on("data", bytes => { + if (bytes.toString().includes("Ready.")) { clearTimeout(timeout); resolve(); } + }); + server.stderr.pipe(process.stderr); + }); + return { server, ready, origin: `http://127.0.0.1:${port}/` }; +} diff --git a/scripts/capture-preview.py b/scripts/capture-preview.py new file mode 100644 index 0000000..c2e1d08 --- /dev/null +++ b/scripts/capture-preview.py @@ -0,0 +1,118 @@ +import errno +import fcntl +import os +from pathlib import Path +import select +import signal +import struct +import subprocess +import tempfile +import termios +import time + + +ROOT = Path(__file__).resolve().parent.parent +BINARY = ROOT / "target/debug/examples/site-preview" +OUTPUT = ROOT / "apps/landing/public/terminal" +COLUMNS = 110 +ROWS = 28 +TIMEOUT = 20 +# Ratatui ends each draw with these resets; the sample has no hyperlink draw groups. +FRAME_END = b"\x1b[39m\x1b[49m\x1b[0m" +QUERY = """SELECT city, country, distance_km +FROM destinations +ORDER BY distance_km;""" + + +def render(output, output_format): + return subprocess.run( + [BINARY, output_format, str(COLUMNS), str(ROWS)], + input=output, + capture_output=True, + check=True, + ).stdout + + +def capture(terminal, output, name, expected): + deadline = time.monotonic() + TIMEOUT + while True: + ready, _, _ = select.select([terminal], [], [], max(0, deadline - time.monotonic())) + if not ready: + raise TimeoutError(f"Waiting for {name}:\n{render(output, '--text').decode()}") + chunk = os.read(terminal, 65536) + if not chunk: + raise RuntimeError(f"Native app exited while capturing {name}") + output.extend(chunk) + boundary = output.rfind(FRAME_END) + if boundary < 0: + continue + frame = output[:boundary + len(FRAME_END)] + text = render(frame, "--text").decode() + if all(value in text for value in expected): + (OUTPUT / f"{name}.svg").write_bytes(render(frame, "--svg")) + print(f"Captured {name}") + return + + +def walkthrough(terminal): + output = bytearray() + capture(terminal, output, "welcome", ["Ready", "Ctrl+C quit"]) + os.write(terminal, f"\x1b[200~{QUERY}\x1b[201~\x12".encode()) + capture(terminal, output, "results", ["Complete", "Row 1 / 6", "Tokyo"]) + os.write(terminal, b"\x0c\r") + capture(terminal, output, "inspector", ["Row 1", "Utf8", "Scroll to read"]) + os.write(terminal, b"\x1b") + capture(terminal, output, "results", ["Complete", "Row 1 / 6", "Arrows select"]) + os.write(terminal, b"\x13\x10") + capture(terminal, output, "library", ["Query library", "›★ SELECT", "Menu for more actions"]) + os.write(terminal, b"\x0b") + capture(terminal, output, "menu", ["Find an action", "Browse results", "Enter open"]) + os.write(terminal, b"\x03") + + +def main(): + subprocess.run( + ["cargo", "build", "--example", "site-preview", "--locked", "--offline"], + cwd=ROOT, + check=True, + ) + OUTPUT.mkdir(parents=True, exist_ok=True) + with tempfile.TemporaryDirectory(prefix="sql-bomb-preview-") as directory: + child, terminal = os.forkpty() + if child == 0: + fcntl.ioctl(0, termios.TIOCSWINSZ, struct.pack("HHHH", ROWS, COLUMNS, 0, 0)) + environment = {name: value for name, value in os.environ.items() if name != "NO_COLOR"} + environment.update(TERM="xterm-256color", COLORTERM="truecolor") + os.execve(BINARY, [str(BINARY), directory], environment) + try: + walkthrough(terminal) + drain(terminal) + except BaseException: + os.kill(child, signal.SIGTERM) + os.waitpid(child, 0) + raise + finally: + os.close(terminal) + _, status = os.waitpid(child, 0) + if status != 0: + raise RuntimeError(f"Native app exited with status {status}") + + +def drain(terminal): + deadline = time.monotonic() + TIMEOUT + while True: + ready, _, _ = select.select([terminal], [], [], max(0, deadline - time.monotonic())) + if not ready: + raise TimeoutError("Native app did not close after Ctrl+C") + try: + if not os.read(terminal, 65536): + return + except OSError as error: + if error.errno != errno.EIO: + raise + # Linux PTYs report EIO when the slave closes. + return + + +if __name__ == "__main__": + main() diff --git a/scripts/site.mjs b/scripts/site.mjs new file mode 100644 index 0000000..67da13c --- /dev/null +++ b/scripts/site.mjs @@ -0,0 +1,141 @@ +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { checkBrowser } from "./browser-app.mjs"; + +const root = resolve(import.meta.dirname, ".."); +const navigation = JSON.parse(await readFile(resolve(root, "apps/docs/navigation.json"), "utf8")); + +await checkBrowser("apps", async (page, origin) => { + await page.setViewportSize({ width: 1440, height: 1100 }); + await page.clock.install({ time: "2026-01-01T00:00:00Z" }); + await page.goto(origin); + await page.getByRole("heading", { name: "Ultrafast SQL Client in your Terminal" }).waitFor(); + const installer = await page.request.get(origin + "install.sh"); + assert.equal(installer.status(), 200); + assert.equal(await installer.text(), await readFile(resolve(root, "install.sh"), "utf8")); + await page.locator(".example").hover(); + await checkWalkthrough(page); + await page.context().grantPermissions(["clipboard-read", "clipboard-write"]); + const methods = page.getByRole("group", { name: "Installation method" }); + assert.equal(await methods.getByRole("button", { name: "Cargo" }).getAttribute("aria-pressed"), + "true"); + for (const [name, command] of [ + ["Cargo", "cargo install sql-bomb --locked"], + ["Linux", "curl -fsSL https://boom.fusor.build/install.sh | sh"], + ]) { + const button = methods.getByRole("button", { name, exact: true }); + await button.click(); + assert.equal(await button.getAttribute("aria-pressed"), "true"); + assert.equal(await page.locator("#install-command code").textContent(), command); + await page.getByRole("button", { name: "Copy command", exact: true }).click(); + await page.getByRole("button", { name: "Copied!", exact: true }).waitFor(); + assert.equal(await page.evaluate(() => navigator.clipboard.readText()), command); + } + await methods.getByRole("button", { name: "Cargo" }).click(); + await page.screenshot({ path: resolve(root, "apps/target/landing-desktop.png"), fullPage: true }); + for (const width of [320, 390, 768]) { + await page.setViewportSize({ width, height: 844 }); + assert.equal(await page.evaluate(() => document.documentElement.scrollWidth), width); + } + await page.emulateMedia({ reducedMotion: "reduce" }); + assert.equal(await page.locator(".example").evaluate(node => + getComputedStyle(node).animationName), "none"); + await page.setViewportSize({ width: 390, height: 844 }); + await page.screenshot({ path: resolve(root, "apps/target/landing-mobile.png"), fullPage: true }); + await page.getByRole("link", { name: "Documentation", exact: false }).click(); + assert.equal(new URL(page.url()).pathname, "/docs/"); + await checkDocs(page, origin); +}, ["--site"]); +console.log("PASS: native walkthrough, clipboard, responsive layout, docs, routing and themes"); + +async function checkWalkthrough(page) { + const controls = page.getByRole("group", { name: "Explore sql-bomb", exact: true }); + const capture = page.locator(".terminal-capture"); + for (const [name, filename, expected] of [ + ["Workspace", "welcome", "Ready"], + ["Query", "results", "Montréal"], + ["Inspect", "inspector", "Utf8"], + ["Library", "library", "SQL PREVIEW"], + ["Menu", "menu", "Find an action"], + ]) { + const button = controls.getByRole("button", { name, exact: true }); + await button.focus(); + await page.keyboard.press("Enter"); + assert.equal(await button.getAttribute("aria-pressed"), "true"); + assert.equal(await controls.locator('[aria-pressed="true"]').count(), 1); + assert.equal(await capture.getAttribute("src"), `/terminal/${filename}.svg`); + await capture.evaluate(image => image.decode()); + const response = await page.request.get(new URL(await capture.getAttribute("src"), page.url()).href); + assert.equal(response.status(), 200); + assert.ok((await response.text()).includes(expected)); + } + await controls.getByRole("button", { name: "Query", exact: true }).click(); + const outside = page.getByRole("heading", { name: "Ultrafast SQL Client in your Terminal" }); + const clockStep = "00:03"; + await page.clock.pauseAt("2026-01-01T00:01:00Z"); + await page.clock.fastForward(clockStep); + assert.equal(await capture.getAttribute("src"), "/terminal/results.svg"); + await outside.hover(); + for (const filename of ["inspector", "library", "menu", "welcome", "results"]) { + await page.clock.fastForward(clockStep); + assert.equal(await capture.getAttribute("src"), `/terminal/${filename}.svg`); + } + await capture.hover(); + await page.clock.fastForward(clockStep); + assert.equal(await capture.getAttribute("src"), "/terminal/results.svg"); + await controls.getByRole("button", { name: "Menu", exact: true }).click(); + await page.clock.fastForward(clockStep); + assert.equal(await capture.getAttribute("src"), "/terminal/menu.svg"); + await outside.hover(); + await page.clock.fastForward(clockStep); + assert.equal(await capture.getAttribute("src"), "/terminal/welcome.svg"); + await page.emulateMedia({ reducedMotion: "reduce" }); + await page.clock.fastForward(clockStep); + assert.equal(await capture.getAttribute("src"), "/terminal/welcome.svg"); + await controls.getByRole("button", { name: "Query", exact: true }).click(); + assert.equal(await capture.getAttribute("src"), "/terminal/results.svg"); + await page.emulateMedia({ reducedMotion: "no-preference" }); + await page.clock.resume(); +} + +async function checkDocs(page, origin) { + for (const { slug } of navigation) { + const filename = `${slug || "index"}.md`; + const markdown = await readFile(resolve(root, "docs", filename), "utf8"); + const title = markdown.split("\n")[0].slice(2); + await page.goto(origin + "docs/" + slug); + await page.getByRole("heading", { name: title, exact: true }).waitFor(); + assert.equal(await page.title(), `${title} · sql-bomb`); + await page.reload(); + await page.getByRole("heading", { name: title, exact: true }).waitFor(); + const bodySizes = await page.locator(".article .lead, .article .markdown").evaluateAll(nodes => + [...new Set(nodes.map(node => getComputedStyle(node).fontSize))]); + assert.deepEqual(bodySizes, ["16px"]); + const response = await page.request.get(origin + "docs/content/" + filename); + assert.equal(response.status(), 200); + assert.equal(await response.text(), markdown); + await page.setViewportSize({ width: 390, height: 844 }); + assert.equal(await page.evaluate(() => document.documentElement.scrollWidth), 390); + } + await page.setViewportSize({ width: 1440, height: 1000 }); + await page.goto(origin + "docs/"); + await page.getByRole("searchbox").fill("no-matching-topic"); + await page.locator(".search-empty").waitFor(); + await page.getByRole("searchbox").press("Escape"); + await page.getByRole("button", { name: "Toggle color theme" }).click(); + await page.reload(); + await page.locator(".site.dark").waitFor(); + await page.setViewportSize({ width: 390, height: 844 }); + await page.getByRole("button", { name: "Toggle navigation" }).click(); + await page.locator(".sidebar").getByRole("link", { name: "Get started", exact: true }).click(); + await page.getByRole("heading", { name: "Get started", exact: true }).waitFor(); + await page.locator(".sidebar").waitFor({ state: "hidden" }); + await page.screenshot({ path: resolve(root, "apps/target/docs-mobile.png"), fullPage: true }); + await page.setViewportSize({ width: 1440, height: 1000 }); + await page.screenshot({ path: resolve(root, "apps/target/docs-desktop.png"), fullPage: true }); + await page.goto(origin + "docs/missing"); + await page.getByRole("heading", { name: "Page not found", exact: true }).waitFor(); + await page.getByRole("link", { name: "Home", exact: true }).click(); + await page.getByRole("heading", { name: "Ultrafast SQL Client in your Terminal" }).waitFor(); +} diff --git a/src/site_preview.rs b/src/site_preview.rs new file mode 100644 index 0000000..48d13e9 --- /dev/null +++ b/src/site_preview.rs @@ -0,0 +1,35 @@ +mod cli; +mod client; +mod library; +mod results; +#[path = "../examples/site-preview/server.rs"] +mod server; +#[path = "../examples/site-preview/snapshot.rs"] +mod snapshot; +mod terminal; + +fn main() -> Result<(), Box> { + let directory = std::env::args() + .nth(1) + .ok_or("Pass a temporary library directory or --svg/--text")?; + match directory.as_str() { + "--svg" => return snapshot::write(snapshot::Format::Svg), + "--text" => return snapshot::write(snapshot::Format::Text), + _ => {} + } + let runtime = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build()?; + let _runtime = runtime.enter(); + let address = runtime.block_on(server::start())?; + let cli::Command::Start(startup) = + cli::parse([client::Client::FlightSql.profile().flag.to_owned(), address].into_iter())? + else { + cli::help(); + return Ok(()); + }; + let library = + library::Library::open(&std::path::Path::new(&directory).join(library::DIRECTORY))?; + hypercmd::native::run(hypercmd::mount::((startup, library))?)?; + Ok(()) +} diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..e64ed3b --- /dev/null +++ b/vercel.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://openapi.vercel.sh/vercel.json", + "framework": null, + "git": { + "deploymentEnabled": false + }, + "installCommand": "", + "buildCommand": "just site", + "outputDirectory": "apps/dist", + "redirects": [ + { + "source": "/docs", + "destination": "/docs/", + "permanent": true + } + ], + "rewrites": [ + { + "source": "/docs/:path*", + "destination": "/docs/index.html" + } + ], + "headers": [ + { + "source": "/(.*)__fusor/(.*)", + "headers": [ + { + "key": "Cache-Control", + "value": "public, max-age=31536000, immutable" + } + ] + } + ] +} From 1bc7edf1df2ed7864e8d85f5f6ae96f885f286a9 Mon Sep 17 00:00:00 2001 From: Andres Pirela <60560109+andreespirela@users.noreply.github.com> Date: Sat, 3 Oct 2026 23:39:13 -0400 Subject: [PATCH 2/3] chore: Feedback --- README.md | 36 ++++++++++++++++-------------------- apps/docs/public/brand.css | 2 +- apps/docs/web/index.html | 2 +- apps/landing/web/index.html | 9 ++++----- docs/architecture.md | 6 ------ docs/flight-sql.md | 20 ++++++++++++-------- docs/get-started.md | 20 ++++++++------------ docs/index.md | 13 +++++++------ scripts/site.mjs | 2 +- 9 files changed, 50 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 2825646..3dd5f87 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,14 @@ # Query SQL. Watch the rows arrive. -sql-bomb is a terminal application for running SQL and streaming results into a -table. You can inspect complete cell values and return to queries from your local -history or starred library. The installed executable is named `boom`. +sql-bomb is a database-agnostic terminal application for running SQL and streaming +results into a table. You can inspect complete cell values, reopen saved +connections, and return to queries from your local history or starred library. +The installed executable is named `boom`. -Flight SQL is currently the only supported connection type. It connects to -servers that implement Arrow Flight SQL, a protocol for running SQL over gRPC. -Direct PostgreSQL and MySQL connections are not implemented. +A client connects sql-bomb to a database server, and every client shares the same +editor, results table, saved connections, and query library. The +[client reference](#clients) lists the available clients and their settings. The terminal interface is built with [Hypercmd](https://github.com/fusor-rs/hypercmd) and @@ -29,9 +30,10 @@ The terminal interface is built with ## Get started -sql-bomb runs in a terminal on macOS or Linux. To run queries, you need the address -of a server that supports [Arrow Flight SQL](#clients). sql-bomb connects to -that server; it does not start a database for you. +sql-bomb runs in a terminal on macOS or Linux. To run queries, you need a running +database server and its address; the [client reference](#clients) lists the +connection types sql-bomb supports. sql-bomb connects to that server; it does not +start a database for you. ### Install with Cargo @@ -69,7 +71,7 @@ This method requires a GitHub release with completed binary uploads. ### Connect to a server -1. Run `boom` and choose **Flight SQL**, the only client currently available. +1. Run `boom` and choose a client from the chooser. 2. Enter your server URL, including its scheme and port, such as `http://localhost:50051`. This example requires a server already running at that address. Use `https://` for a server with TLS encryption. @@ -85,15 +87,10 @@ SELECT 1 AS value; Rows appear below the editor as the server sends them. Press Ctrl+C to quit. -For a connection without headers, you can skip the chooser and form: - -```sh -boom --flightsql http://localhost:50051 -``` - Once you save a connection, `boom` opens your saved connections instead. See -[Using sql-bomb](#using-sql-bomb) for saving connections and browsing results, or -[Flight SQL](#clients) for supported URLs and authentication. +[Using sql-bomb](#using-sql-bomb) for saving connections and browsing results, or the +[client reference](#clients) for supported URLs, authentication, and +command-line shortcuts that skip the chooser and form. ### Build from source @@ -243,8 +240,7 @@ Clients provide connection settings and query execution. The editor, result browser, saved connections, and query library share the same workspace regardless of the selected client. -Flight SQL is currently the only implemented client. PostgreSQL and MySQL clients -are not implemented. +Available clients are listed below. ### Flight SQL diff --git a/apps/docs/public/brand.css b/apps/docs/public/brand.css index 9dbcf73..2f86a39 100644 --- a/apps/docs/public/brand.css +++ b/apps/docs/public/brand.css @@ -15,7 +15,7 @@ .article .lead, .article .markdown { - font-size: 16px; + font-size: 14px; line-height: 1.75; } .article .inline-code { diff --git a/apps/docs/web/index.html b/apps/docs/web/index.html index 4b4aa97..0d5220e 100644 --- a/apps/docs/web/index.html +++ b/apps/docs/web/index.html @@ -4,7 +4,7 @@ + content="Install sql-bomb, connect to a database, and explore streaming query results." /> sql-bomb documentation diff --git a/apps/landing/web/index.html b/apps/landing/web/index.html index 3262bfa..f276787 100644 --- a/apps/landing/web/index.html +++ b/apps/landing/web/index.html @@ -5,7 +5,7 @@ + content="A database-agnostic SQL terminal powered by Hypercmd and Fusor." /> @@ -31,8 +31,8 @@

Ultrafast SQL Client
in your Terminal

- sql-bomb is a fast SQL client for querying databases and streaming results - in a beautiful terminal interface, powered by + sql-bomb is a fast, database-agnostic SQL workspace for querying databases + and streaming results in a beautiful terminal interface, powered by Hypercmd and Fusor.

@@ -74,8 +74,7 @@

Ultrafast SQL Client
in your Terminal

{{ state.scene.get().description }}

- A recorded walkthrough of sql-bomb, running against a local - Flight SQL server with sample data. + A recorded walkthrough of sql-bomb, running against a local server with sample data. Hover to pause, or choose a view above to explore.

diff --git a/docs/architecture.md b/docs/architecture.md index 11219f4..26f3147 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -15,12 +15,6 @@ The [client registry](../src/client.rs) supplies the chooser, CLI flags, and connection setup. Network operations run in Tokio, Rust's asynchronous runtime, so the interface can respond while results arrive. -Each Flight SQL query opens a gRPC connection, executes a statement, and reads all -returned endpoints in order. When an endpoint advertises multiple locations, -sql-bomb uses the first. The optional `QueryClient::tables()` method uses the -Flight SQL `CommandGetTables` operation with schemas included. It returns each -table's catalog, database schema, name, type, and Arrow column schema. - ## Terminal interface Fusor connects the [HTML template](../ui/app.html) to diff --git a/docs/flight-sql.md b/docs/flight-sql.md index 3fa8ceb..76b0033 100644 --- a/docs/flight-sql.md +++ b/docs/flight-sql.md @@ -1,11 +1,15 @@ -# Clients and Flight SQL +# Clients -A client is the part of sql-bomb that connects to a server and runs queries. -Flight SQL is currently the only client; PostgreSQL and MySQL clients are not -implemented. Arrow Flight SQL sends SQL over gRPC and receives results in Apache -Arrow format, which preserves each column's data type. +A client is the part of sql-bomb that connects to a server and runs queries. The +editor, results, saved connections, and query library work the same way with every +client. Available clients are listed below. -## Connection address +## Flight SQL + +Arrow Flight SQL sends SQL over gRPC and receives results in Apache Arrow format, +which preserves each column's data type. + +### Connection address Choose **Flight SQL** in the client chooser, or pass its flag: @@ -24,7 +28,7 @@ query parameters do not belong in the URL. Use `http://` or `grpc+tcp://` for an unencrypted connection. Use `https://` or `grpc+tls://` for TLS encryption with certificates trusted by your operating system. -## Authentication +### Authentication Headers are extra name/value pairs sent with a request, often to carry a token. Leave the field empty if your server needs none. Otherwise, enter one header per @@ -45,7 +49,7 @@ configured server. See the [Arrow Flight protocol](https://arrow.apache.org/docs/format/Flight.html) for the protocol's endpoint and authentication conventions. -## Remembering headers +### Remembering headers Headers stay in memory unless you check **Remember headers securely** when saving a connection. This option is off by default. It stores headers in macOS Keychain diff --git a/docs/get-started.md b/docs/get-started.md index d54471a..65d0fe6 100644 --- a/docs/get-started.md +++ b/docs/get-started.md @@ -1,8 +1,9 @@ # Get started -sql-bomb runs in a terminal on macOS or Linux. To run queries, you need the address -of a server that supports [Arrow Flight SQL](flight-sql.md). sql-bomb connects to -that server; it does not start a database for you. +sql-bomb runs in a terminal on macOS or Linux. To run queries, you need a running +database server and its address; the [client reference](flight-sql.md) lists the +connection types sql-bomb supports. sql-bomb connects to that server; it does not +start a database for you. ## Install with Cargo @@ -40,7 +41,7 @@ This method requires a GitHub release with completed binary uploads. ## Connect to a server -1. Run `boom` and choose **Flight SQL**, the only client currently available. +1. Run `boom` and choose a client from the chooser. 2. Enter your server URL, including its scheme and port, such as `http://localhost:50051`. This example requires a server already running at that address. Use `https://` for a server with TLS encryption. @@ -56,15 +57,10 @@ SELECT 1 AS value; Rows appear below the editor as the server sends them. Press Ctrl+C to quit. -For a connection without headers, you can skip the chooser and form: - -```sh -boom --flightsql http://localhost:50051 -``` - Once you save a connection, `boom` opens your saved connections instead. See -[Using sql-bomb](workspace.md) for saving connections and browsing results, or -[Flight SQL](flight-sql.md) for supported URLs and authentication. +[Using sql-bomb](workspace.md) for saving connections and browsing results, or the +[client reference](flight-sql.md) for supported URLs, authentication, and +command-line shortcuts that skip the chooser and form. ## Build from source diff --git a/docs/index.md b/docs/index.md index ee7fe65..8594d7e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,12 +1,13 @@ # sql-bomb -sql-bomb is a terminal application for running SQL and streaming results into a -table. You can inspect complete cell values and return to queries from your local -history or starred library. The installed executable is named `boom`. +sql-bomb is a database-agnostic terminal application for running SQL and streaming +results into a table. You can inspect complete cell values, reopen saved +connections, and return to queries from your local history or starred library. +The installed executable is named `boom`. -Flight SQL is currently the only supported connection type. It connects to -servers that implement Arrow Flight SQL, a protocol for running SQL over gRPC. -Direct PostgreSQL and MySQL connections are not implemented. +A client connects sql-bomb to a database server, and every client shares the same +editor, results table, saved connections, and query library. The +[client reference](flight-sql.md) lists the available clients and their settings. The terminal interface is built with [Hypercmd](https://github.com/fusor-rs/hypercmd) and diff --git a/scripts/site.mjs b/scripts/site.mjs index 67da13c..2950b9e 100644 --- a/scripts/site.mjs +++ b/scripts/site.mjs @@ -111,7 +111,7 @@ async function checkDocs(page, origin) { await page.getByRole("heading", { name: title, exact: true }).waitFor(); const bodySizes = await page.locator(".article .lead, .article .markdown").evaluateAll(nodes => [...new Set(nodes.map(node => getComputedStyle(node).fontSize))]); - assert.deepEqual(bodySizes, ["16px"]); + assert.deepEqual(bodySizes, ["14px"]); const response = await page.request.get(origin + "docs/content/" + filename); assert.equal(response.status(), 200); assert.equal(await response.text(), markdown); From 5e610eb1d891962b0b93a9523f63b6b659390317 Mon Sep 17 00:00:00 2001 From: Andres Pirela <60560109+andreespirela@users.noreply.github.com> Date: Sat, 3 Oct 2026 23:45:56 -0400 Subject: [PATCH 3/3] chore: fixes --- .github/workflows/check.yml | 1 + .github/workflows/deploy-site.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a4d7a04..7d21184 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -18,6 +18,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: workspaces: apps -> target + cache-targets: false - uses: actions/setup-node@v4 with: node-version: 22 diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml index bc0b260..8e3616e 100644 --- a/.github/workflows/deploy-site.yml +++ b/.github/workflows/deploy-site.yml @@ -39,6 +39,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: workspaces: apps -> target + cache-targets: false - uses: actions/setup-node@v4 with: node-version: 22