From c6b20f371f50d1ff49fd9a7338278c106c3c11bb Mon Sep 17 00:00:00 2001 From: Thomas Lin Pedersen Date: Sun, 26 Apr 2026 00:14:17 +0200 Subject: [PATCH 1/2] move cli to module --- .github/workflows/release-packages.yml | 28 ++++++---- Cargo.lock | 16 ++++-- Cargo.toml | 2 + doc/index.qmd | 2 +- ggsql-cli/Cargo.toml | 74 ++++++++++++++++++++++++++ {src => ggsql-cli}/build.rs | 0 {src => ggsql-cli}/entitlements.plist | 0 src/cli.rs => ggsql-cli/src/main.rs | 0 src/Cargo.toml | 42 +-------------- 9 files changed, 109 insertions(+), 55 deletions(-) create mode 100644 ggsql-cli/Cargo.toml rename {src => ggsql-cli}/build.rs (100%) rename {src => ggsql-cli}/entitlements.plist (100%) rename src/cli.rs => ggsql-cli/src/main.rs (100%) diff --git a/.github/workflows/release-packages.yml b/.github/workflows/release-packages.yml index fe1ffbae..58346eb3 100644 --- a/.github/workflows/release-packages.yml +++ b/.github/workflows/release-packages.yml @@ -62,8 +62,8 @@ jobs: uses: ./.github/workflows/actions/sign-files with: paths: | - ./src/target/release/packager/*.exe - ./src/target/release/packager/*.msi + ./ggsql-cli/target/release/packager/*.exe + ./ggsql-cli/target/release/packager/*.msi env: # environment variables required to sign with signtool SM_HOST: ${{ secrets.SM_HOST }} @@ -76,14 +76,14 @@ jobs: uses: actions/upload-artifact@v4 with: name: ggsql-windows-nsis - path: src/target/release/packager/*.exe + path: ggsql-cli/target/release/packager/*.exe retention-days: 30 - name: Upload MSI installer uses: actions/upload-artifact@v4 with: name: ggsql-windows-msi - path: src/target/release/packager/*.msi + path: ggsql-cli/target/release/packager/*.msi retention-days: 30 build-macos-x86_64: @@ -162,10 +162,10 @@ jobs: xargs -0 -I{} codesign --force --options runtime --timestamp --sign "$SIGN_ID" "{}" # Then sign the executables with hardened runtime + entitlements codesign --force --options runtime --timestamp \ - --entitlements src/entitlements.plist \ + --entitlements ggsql-cli/entitlements.plist \ --sign "$SIGN_ID" target/release/ggsql codesign --force --options runtime --timestamp \ - --entitlements src/entitlements.plist \ + --entitlements ggsql-cli/entitlements.plist \ --sign "$SIGN_ID" target/release/ggsql-jupyter - name: Build and notarize PKG installer (x86_64) @@ -285,10 +285,10 @@ jobs: xargs -0 -I{} codesign --force --options runtime --timestamp --sign "$SIGN_ID" "{}" # Then sign the executables with hardened runtime + entitlements codesign --force --options runtime --timestamp \ - --entitlements src/entitlements.plist \ + --entitlements ggsql-cli/entitlements.plist \ --sign "$SIGN_ID" target/release/ggsql codesign --force --options runtime --timestamp \ - --entitlements src/entitlements.plist \ + --entitlements ggsql-cli/entitlements.plist \ --sign "$SIGN_ID" target/release/ggsql-jupyter - name: Build and notarize PKG installer (aarch64) @@ -377,7 +377,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: ggsql-linux-deb-x86_64 - path: src/target/release/packager/*.deb + path: ggsql-cli/target/release/packager/*.deb retention-days: 30 build-linux-aarch64: @@ -428,7 +428,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: ggsql-linux-deb-aarch64 - path: src/target/release/packager/*.deb + path: ggsql-cli/target/release/packager/*.deb retention-days: 30 build-cargo: @@ -485,6 +485,14 @@ jobs: env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + - name: Wait for crates.io index update + run: sleep 30 + + - name: Publish ggsql-cli + run: cargo publish --package ggsql-cli + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + build-wasm: name: Build Wasm Package (wasm32) runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index 76519327..1bd15e58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1601,11 +1601,9 @@ dependencies = [ name = "ggsql" version = "0.2.7" dependencies = [ - "anyhow", "arrow", "bytes", "chrono", - "clap", "const_format", "csscolorparser", "duckdb", @@ -1623,7 +1621,6 @@ dependencies = [ "serde_json", "sprintf", "tempfile", - "termimad", "thiserror 1.0.69", "toml_edit 0.22.27", "tree-sitter", @@ -1632,6 +1629,19 @@ dependencies = [ "uuid", ] +[[package]] +name = "ggsql-cli" +version = "0.2.7" +dependencies = [ + "anyhow", + "clap", + "ggsql", + "regex", + "serde_json", + "termimad", + "ureq", +] + [[package]] name = "ggsql-jupyter" version = "0.2.7" diff --git a/Cargo.toml b/Cargo.toml index 55e9f6f4..a808b7c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,12 +2,14 @@ members = [ "tree-sitter-ggsql", "src", + "ggsql-cli", "ggsql-jupyter", "ggsql-wasm" ] default-members = [ "tree-sitter-ggsql", "src", + "ggsql-cli", "ggsql-jupyter" ] resolver = "2" diff --git a/doc/index.qmd b/doc/index.qmd index 76190856..789aef19 100644 --- a/doc/index.qmd +++ b/doc/index.qmd @@ -88,7 +88,7 @@ uv tool install ggsql-jupyter ggsql-jupyter --install # CLI (crates.io) -cargo install ggsql +cargo install ggsql-cli ``` ::: ::: diff --git a/ggsql-cli/Cargo.toml b/ggsql-cli/Cargo.toml new file mode 100644 index 00000000..bc8b1d43 --- /dev/null +++ b/ggsql-cli/Cargo.toml @@ -0,0 +1,74 @@ +[package] +name = "ggsql-cli" +version.workspace = true +edition.workspace = true +authors.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true +description = "Command-line interface for ggsql" +build = "build.rs" + +[[bin]] +name = "ggsql" +path = "src/main.rs" + +[dependencies] +ggsql = { workspace = true } + +# CLI and error handling +clap.workspace = true +anyhow.workspace = true + +# Serialization (used by `parse --format json`) +serde_json.workspace = true + +# Regex (used by `docs` markdown post-processing) +regex.workspace = true + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +# Terminal markdown rendering for `ggsql docs` (native targets only; +# crossterm 0.29 doesn't compile on wasm32) +termimad = "0.31" + +[build-dependencies] +regex.workspace = true +ureq = "3" + +[features] +default = ["duckdb", "sqlite", "vegalite", "ipc", "parquet", "builtin-data", "odbc"] +ipc = ["ggsql/ipc"] +duckdb = ["ggsql/duckdb"] +parquet = ["ggsql/parquet"] +postgres = ["ggsql/postgres"] +sqlite = ["ggsql/sqlite"] +odbc = ["ggsql/odbc"] +vegalite = ["ggsql/vegalite"] +ggplot2 = ["ggsql/ggplot2"] +builtin-data = ["ggsql/builtin-data"] +all-readers = ["duckdb", "postgres", "sqlite", "odbc"] +all-writers = ["vegalite", "ggplot2"] + +# cargo-packager configuration for cross-platform installers +[package.metadata.packager] +product-name = "ggsql" +identifier = "com.ggsql.app" +category = "DeveloperTool" +publisher = "ggsql Team" +authors = ["ggsql Team"] +icons = ["../doc/assets/logo.png"] +license-file = "../LICENSE.md" +out-dir = "target/release/packager" +homepage = "https://ggsql.org/" +description = "SQL extension for declarative data visualization" +long-description = "ggsql extends SQL with a VISUALISE clause for declarative data visualization based on Grammar of Graphics principles. Combine SQL queries with visualization specifications to create charts directly from your data." +copyright = "Copyright (c) 2026 ggsql Team" + +# Binaries to include in the package +binaries = [ + { path = "ggsql", main = true }, + { path = "ggsql-jupyter", main = false }, +] + +# Resources to bundle (optional) +resources = [{ src = "../libs/", target = "libs" }] diff --git a/src/build.rs b/ggsql-cli/build.rs similarity index 100% rename from src/build.rs rename to ggsql-cli/build.rs diff --git a/src/entitlements.plist b/ggsql-cli/entitlements.plist similarity index 100% rename from src/entitlements.plist rename to ggsql-cli/entitlements.plist diff --git a/src/cli.rs b/ggsql-cli/src/main.rs similarity index 100% rename from src/cli.rs rename to ggsql-cli/src/main.rs diff --git a/src/Cargo.toml b/src/Cargo.toml index 30b893c5..e548f4c7 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -7,16 +7,11 @@ license.workspace = true repository.workspace = true homepage.workspace = true description.workspace = true -build = "build.rs" [lib] name = "ggsql" path = "lib.rs" -[[bin]] -name = "ggsql" -path = "cli.rs" - [dependencies] # Parsing tree-sitter.workspace = true @@ -45,9 +40,7 @@ plotters = { workspace = true, optional = true } serde.workspace = true serde_json.workspace = true -# CLI and error handling -clap.workspace = true -anyhow.workspace = true +# Error handling thiserror.workspace = true # Utilities @@ -58,15 +51,6 @@ sprintf = "0.4" const_format.workspace = true uuid.workspace = true -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -# Terminal markdown rendering for `ggsql docs` (native targets only; -# crossterm 0.29 doesn't compile on wasm32) -termimad = "0.31" - -[build-dependencies] -regex.workspace = true -ureq = "3" - [dev-dependencies] jsonschema = "0.44" proptest.workspace = true @@ -86,27 +70,3 @@ ggplot2 = [] builtin-data = [] all-readers = ["duckdb", "postgres", "sqlite", "odbc"] all-writers = ["vegalite", "ggplot2", "plotters"] - -# cargo-packager configuration for cross-platform installers -[package.metadata.packager] -product-name = "ggsql" -identifier = "com.ggsql.app" -category = "DeveloperTool" -publisher = "ggsql Team" -authors = ["ggsql Team"] -icons = ["../doc/assets/logo.png"] -license-file = "../LICENSE.md" -out-dir = "target/release/packager" -homepage = "https://ggsql.org/" -description = "SQL extension for declarative data visualization" -long-description = "ggsql extends SQL with a VISUALISE clause for declarative data visualization based on Grammar of Graphics principles. Combine SQL queries with visualization specifications to create charts directly from your data." -copyright = "Copyright (c) 2026 ggsql Team" - -# Binaries to include in the package -binaries = [ - { path = "ggsql", main = true }, - { path = "ggsql-jupyter", main = false }, -] - -# Resources to bundle (optional) -resources = [{ src = "../libs/", target = "libs" }] From e35f318437dbd2e8a8a3db36a1b849f947defbf0 Mon Sep 17 00:00:00 2001 From: Thomas Lin Pedersen Date: Sun, 26 Apr 2026 16:25:03 +0200 Subject: [PATCH 2/2] add to changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a7c88da..3c0de6ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ skill for llms through the `skill` command (#361) - Rendering of inline plots in Positron had a bad interaction with how we handled auto-resizing in the plot pane. We now have a per-output-location path in the Jupyter kernel (#360) -- Passing the shape aesthetic via `SETTING` now correctly translates named +- Passing the shape aesthetic via `SETTING` now correctly translates named shapes (#368) ### Changed @@ -24,6 +24,7 @@ shapes (#368) before registering them back to the backend. We now keep the data purely on the backend until the layer query as was always intended (#363) - Simplified internal approach to DataFrame with DuckDB reader (#365) +- Moved the CLI to its own module rather than be part of the main crate (#379) ### Removed