From 723c5127b17117a64daaf0b08b3cb63daf4ded58 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Fri, 24 Oct 2025 11:08:56 +0200 Subject: [PATCH 1/2] progress --- docs/codegen/src/cli_doc.rs | 2 +- docs/configuration.md | 2 +- docs/features/linting.md | 6 ++-- docs/getting_started.md | 14 ++++---- docs/guides/checking_migrations.md | 4 +-- docs/guides/configure_database.md | 14 ++++---- docs/guides/continuous_integration.md | 6 ++-- docs/guides/ide_setup.md | 4 +-- docs/guides/vcs_integration.md | 6 ++-- docs/manual_installation.md | 36 +++++++++---------- docs/reference/cli.md | 52 +++++++++++++-------------- 11 files changed, 73 insertions(+), 73 deletions(-) diff --git a/docs/codegen/src/cli_doc.rs b/docs/codegen/src/cli_doc.rs index b6c4a75b8..246aad36d 100644 --- a/docs/codegen/src/cli_doc.rs +++ b/docs/codegen/src/cli_doc.rs @@ -11,7 +11,7 @@ pub fn generate_cli_doc(docs_dir: &Path) -> anyhow::Result<()> { let new_content = utils::replace_section( &content, "CLI_REF", - &pgt_command().render_markdown("postgrestools"), + &pgt_command().render_markdown("postgres-language-server"), ); fs::write(file_path, &new_content)?; diff --git a/docs/configuration.md b/docs/configuration.md index 16a9c137b..3d74220a9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -54,7 +54,7 @@ You can control the files/folders to process using different strategies, either The first way to control which files and folders are processed is to list them in the CLI. In the following command, we only check `file1.sql` and all the files in the `src` folder, because folders are recursively traversed. ```shell -postgrestools check file1.js src/ +postgres-language-server check file1.js src/ ``` ### Control files via configuration diff --git a/docs/features/linting.md b/docs/features/linting.md index 3e27fffd9..42ef08dd8 100644 --- a/docs/features/linting.md +++ b/docs/features/linting.md @@ -54,13 +54,13 @@ The linter can also be used via the CLI for CI integration: ```bash # Lint specific files -postgrestools check migrations/ +postgres-language-server check migrations/ # With specific rules -postgrestools check migrations/ --only safety/banDropColumn +postgres-language-server check migrations/ --only safety/banDropColumn # Skip certain rules -postgrestools check migrations/ --skip safety/banDropTable +postgres-language-server check migrations/ --skip safety/banDropTable ``` See the [CLI Reference](../reference/cli.md) for more options, and check the guide on [linting migrations]('../guides/checking_migrations.md'). diff --git a/docs/getting_started.md b/docs/getting_started.md index 21fefb778..f928ccb2f 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -7,7 +7,7 @@ The Postgres Language Server can be installed as a development dependency of you We recommend creating a `postgres-language-server.jsonc` configuration file for each project. This eliminates repetitive CLI options and ensures that consistent configuration in your editor. Some options are only available from a configuration file. This step is optional though: if you are happy with the defaults, you don’t need a configuration file. To create the `postgres-language-server.jsonc` file, run the `init` command in the root folder of your project: ```sh -postgrestools init +postgres-language-server init ``` You’ll now have a `postgres-language-server.jsonc` file in your directory: @@ -45,9 +45,9 @@ You’ll now have a `postgres-language-server.jsonc` file in your directory: [//]: # "END DEFAULT_CONFIGURATION" -Make sure to edit the database connection settings to connect to your local development database. To see all options, run `postgrestools --help`. +Make sure to edit the database connection settings to connect to your local development database. To see all options, run `postgres-language-server --help`. -You can use your current `postgrestools` version instead of "latest" in the `$schema` URL, e.g. `https://pgtools.dev/0.8.1/schema.json`. +You can use your current `postgres-language-server` version instead of "latest" in the `$schema` URL, e.g. `https://pg-language-server.com/0.8.1/schema.json`. ## Usage @@ -59,13 +59,13 @@ The CLI exposes a `check` command that will run all checks on the given files or ```sh # check a specific file -postgrestools check myfile.sql +postgres-language-server check myfile.sql # check a directory -postgrestools check supabase/migrations +postgres-language-server check supabase/migrations ``` -Run `postgrestools --help` for all options. The CLI options take precedence over what is loaded from `postgres-language-server.jsonc`. +Run `postgres-language-server --help` for all options. The CLI options take precedence over what is loaded from `postgres-language-server.jsonc`. ### Editor Integrations @@ -78,7 +78,7 @@ The Postgres Language Server is available as an extension in your favorite edito ### Continuous Integration -Run `postgrestools check` in your CI pipeline to lint your schema changes and enforce code quality across your team. We provide a [GitHub Action](https://github.com/supabase-community/postgrestools-cli-action) to setup the Postgres Language Server in your runner. +Run `postgres-language-server check` in your CI pipeline to lint your schema changes and enforce code quality across your team. We provide a [GitHub Action](https://github.com/supabase-community/postgrestools-cli-action) to setup the Postgres Language Server in your runner. See the [Continuous Integration](/guides/continuous_integration) guide for an example. diff --git a/docs/guides/checking_migrations.md b/docs/guides/checking_migrations.md index 07b651bfe..74583613b 100644 --- a/docs/guides/checking_migrations.md +++ b/docs/guides/checking_migrations.md @@ -5,7 +5,7 @@ Postgres Language Tools comes with a `check` command that can be integrated into To run it, simply point at your migrations directory. ```sh -postgrestools check supabase/migrations +postgres-language-server check supabase/migrations ``` When you are setting it up in an existing project, you might want to ignore all migrations that are already applied. To do so, add `migrationsDir` and `after` to your `postgres-language-server.jsonc` file @@ -23,7 +23,7 @@ When you are setting it up in an existing project, you might want to ignore all Alternatively, pass them directly. ``` -postgrestools check supabase/migrations --migrations-dir="supabase/migrations" --after=1740868021 +postgres-language-server check supabase/migrations --migrations-dir="supabase/migrations" --after=1740868021 ``` This will only check migrations after the specified timestamp. diff --git a/docs/guides/configure_database.md b/docs/guides/configure_database.md index da4b69d2d..09ec2e400 100644 --- a/docs/guides/configure_database.md +++ b/docs/guides/configure_database.md @@ -45,12 +45,12 @@ Configure database connection details in your `postgres-language-server.jsonc` f The language server primarily needs read access to your database schema. Consider creating a dedicated user with limited permissions: ```sql -CREATE USER postgrestools_lsp WITH PASSWORD 'secure_password'; -GRANT CONNECT ON DATABASE your_database TO postgrestools_lsp; -GRANT USAGE ON SCHEMA public TO postgrestools_lsp; -GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgrestools_lsp; -GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO postgrestools_lsp; -GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO postgrestools_lsp; +CREATE USER postgres_language_server WITH PASSWORD 'secure_password'; +GRANT CONNECT ON DATABASE your_database TO postgres_language_server; +GRANT USAGE ON SCHEMA public TO postgres_language_server; +GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres_language_server; +GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO postgres_language_server; +GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO postgres_language_server; ``` ### Statement Execution Control @@ -79,7 +79,7 @@ If you prefer to work without a database connection, you can disable all databas Or use the command line flag: ```bash -postgrestools check sql/ --disable-db +postgres-language-server check sql/ --disable-db ``` When disabled, you'll still get: diff --git a/docs/guides/continuous_integration.md b/docs/guides/continuous_integration.md index 44ac4c2d3..06e1a8e27 100644 --- a/docs/guides/continuous_integration.md +++ b/docs/guides/continuous_integration.md @@ -4,7 +4,7 @@ Running the Postgres Language Server in a CI environment can boost your teams co ### GitHub Actions -We provide a first-party [GitHub Action](https://github.com/supabase-community/postgrestools-cli-action) to setup the CLI in your runner. Here’s what a simple workflow might look like: +We provide a first-party [GitHub Action](https://github.com/supabase-community/postgrestools-cli-action) to setup the CLI in your runner. Here's what a simple workflow might look like: ```yaml jobs: @@ -15,7 +15,7 @@ jobs: - uses: supabase-community/pglt-cli-action@main with: version: latest - - run: postgrestools check --skip-db sql/ + - run: postgres-language-server check --skip-db sql/ ``` You likely want to setup Postgres to enable more advanced checks: @@ -38,7 +38,7 @@ jobs: - uses: supabase-community/pglt-cli-action@main with: version: latest - - run: postgrestools check sql/ + - run: postgres-language-server check sql/ ``` A common use-case is to check your migration files. Check out [the dedicated guide](./checking_migrations.md) for details. diff --git a/docs/guides/ide_setup.md b/docs/guides/ide_setup.md index b97c6c249..9689705f5 100644 --- a/docs/guides/ide_setup.md +++ b/docs/guides/ide_setup.md @@ -40,13 +40,13 @@ Using the binary via CLI is very efficient, although you will not be able to pro If order to do so, you first need to start a daemon process with the start command: ```shell -postgrestools start +postgres-language-server start ``` Then, every command needs to add the `--use-server` options, e.g.: ```shell -postgrestools check --use-server --stdin-file-path=dummy.sql +postgres-language-server check --use-server --stdin-file-path=dummy.sql ``` diff --git a/docs/guides/vcs_integration.md b/docs/guides/vcs_integration.md index e22e83676..7366c4012 100644 --- a/docs/guides/vcs_integration.md +++ b/docs/guides/vcs_integration.md @@ -50,13 +50,13 @@ First, you have to update your configuration file with the default branch via th Add the `--changed` option to your command to process only those files that your VCS acknowledged as “changed”. The language server will determine the changed files from the branch `main` and your current revision: ```shell -postgrestools check --changed +postgres-language-server check --changed ``` Alternatively, you can use the option `--since` to specify an arbitrary branch. This option takes precedence over the option `vcs.defaultBranch`. For example, you might want to check your changes against the `next` branch: ```shell -postgrestools check --changed --since=next +postgres-language-server check --changed --since=next ``` ## Process only staged files @@ -64,6 +64,6 @@ postgrestools check --changed --since=next Before committing your changes, you may want to check the files that have been added to the index, also known as staged files. Add the `--staged` option to process only those files: ```shell -postgrestools check --staged +postgres-language-server check --staged ``` diff --git a/docs/manual_installation.md b/docs/manual_installation.md index 2c20f9dc2..b69b2127b 100644 --- a/docs/manual_installation.md +++ b/docs/manual_installation.md @@ -8,12 +8,12 @@ You have to pick the correct binary for your platform. The following table shoul | CPU Architecture | Operating System | Binary name | |------------------|------------------|-------------| -| x86_64 | Linux | `postgrestools-x86_64-unknown-linux-gnu` | -| aarch64 | Linux | `postgrestools-aarch64-unknown-linux-gnu` | -| x86_64 | macOS | `postgrestools-x86_64-apple-darwin` | -| aarch64 (M1/M2) | macOS | `postgrestools-aarch64-apple-darwin` | -| x86_64 | Windows | `postgrestools-x86_64-pc-windows-msvc.exe` | -| aarch64 | Windows | `postgrestools-aarch64-pc-windows-msvc.exe` | +| x86_64 | Linux | `postgres-language-server_x86_64-unknown-linux-gnu` | +| aarch64 | Linux | `postgres-language-server_aarch64-unknown-linux-gnu` | +| x86_64 | macOS | `postgres-language-server_x86_64-apple-darwin` | +| aarch64 (M1/M2) | macOS | `postgres-language-server_aarch64-apple-darwin` | +| x86_64 | Windows | `postgres-language-server_x86_64-pc-windows-msvc.exe` | +| aarch64 | Windows | `postgres-language-server_aarch64-pc-windows-msvc.exe` | > **Note**: Use the Linux variant for Windows Subsystem for Linux (WSL). @@ -24,30 +24,30 @@ We were not able to publish to Homebrew yet due to naming conflicts. We are acti ### Using a published binary -To install postgrestools, grab the executable for your platform from the latest CLI release on GitHub and give it execution permission. +To install postgres-language-server, grab the executable for your platform from the latest CLI release on GitHub and give it execution permission. ```bash # macOS arm (M1 or newer) -curl -L https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgrestools-aarch64-apple-darwin -o postgrestools -chmod +x postgrestools +curl -L https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgres-language-server_aarch64-apple-darwin -o postgres-language-server +chmod +x postgres-language-server # macOS x86_64 -curl -L https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgrestools-x86_64-apple-darwin -o postgrestools -chmod +x postgrestools +curl -L https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgres-language-server_x86_64-apple-darwin -o postgres-language-server +chmod +x postgres-language-server # Linux (x86_64) -curl -L https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgrestools-x86_64-unknown-linux-gnu -o postgrestools -chmod +x postgrestools +curl -L https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgres-language-server_x86_64-unknown-linux-gnu -o postgres-language-server +chmod +x postgres-language-server # Linux (aarch64) -curl -L https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgrestools-aarch64-unknown-linux-gnu -o postgrestools -chmod +x postgrestools +curl -L https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgres-language-server_aarch64-unknown-linux-gnu -o postgres-language-server +chmod +x postgres-language-server # Windows (x86_64, PowerShell) -Invoke-WebRequest -Uri "https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgrestools-x86_64-pc-windows-msvc.exe" -OutFile "postgrestools.exe" +Invoke-WebRequest -Uri "https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgres-language-server_x86_64-pc-windows-msvc.exe" -OutFile "postgres-language-server.exe" # Windows (aarch64, PowerShell) -Invoke-WebRequest -Uri "https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgrestools-aarch64-pc-windows-msvc.exe" -OutFile "postgrestools.exe" +Invoke-WebRequest -Uri "https://github.com/supabase-community/postgres-language-server/releases/latest/download/postgres-language-server_aarch64-pc-windows-msvc.exe" -OutFile "postgres-language-server.exe" ``` -Now you can use the Postgres Language Server by simply running `./postgrestools`. +Now you can use the Postgres Language Server by simply running `./postgres-language-server`. diff --git a/docs/reference/cli.md b/docs/reference/cli.md index d2e8bdb5a..5e6f64f27 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -4,20 +4,20 @@ # Command summary -- [`postgrestools`↴](#postgrestools) -- [`postgrestools version`↴](#postgrestools-version) -- [`postgrestools check`↴](#postgrestools-check) -- [`postgrestools start`↴](#postgrestools-start) -- [`postgrestools stop`↴](#postgrestools-stop) -- [`postgrestools init`↴](#postgrestools-init) -- [`postgrestools lsp-proxy`↴](#postgrestools-lsp-proxy) -- [`postgrestools clean`↴](#postgrestools-clean) +- [`postgres-language-server`↴](#postgres-language-server) +- [`postgres-language-server version`↴](#postgres-language-server-version) +- [`postgres-language-server check`↴](#postgres-language-server-check) +- [`postgres-language-server start`↴](#postgres-language-server-start) +- [`postgres-language-server stop`↴](#postgres-language-server-stop) +- [`postgres-language-server init`↴](#postgres-language-server-init) +- [`postgres-language-server lsp-proxy`↴](#postgres-language-server-lsp-proxy) +- [`postgres-language-server clean`↴](#postgres-language-server-clean) -## postgrestools +## postgres-language-server PostgresTools official CLI. Use it to check the health of your project or run it to check single files. -**Usage**: **`postgrestools`** _`COMMAND ...`_ +**Usage**: **`postgres-language-server`** _`COMMAND ...`_ **Available options:** @@ -43,11 +43,11 @@ PostgresTools official CLI. Use it to check the health of your project or run it - **`clean`** — Cleans the logs emitted by the daemon. -## postgrestools version +## postgres-language-server version Shows the version information and quit. -**Usage**: **`postgrestools`** **`version`** +**Usage**: **`postgres-language-server`** **`version`** **Global options applied to all commands** @@ -60,7 +60,7 @@ Shows the version information and quit. - **` --verbose`** — Print additional diagnostics, and some diagnostics show more information. Also, print out what files were processed and which ones were modified. - **` --config-path`**=_`PATH`_ — - Set the file path to the configuration file, or the directory path to find `postgrestools.jsonc`. If used, it disables the default configuration file resolution. + Set the file path to the configuration file, or the directory path to find `postgres-language-server.jsonc`. If used, it disables the default configuration file resolution. - **` --max-diagnostics`**=_`>`_ — Cap the amount of diagnostics displayed. When `none` is provided, the limit is lifted. [default: 20] @@ -91,11 +91,11 @@ Shows the version information and quit. - **`-h`**, **`--help`** — Prints help information -## postgrestools check +## postgres-language-server check Runs everything to the requested files. -**Usage**: **`postgrestools`** **`check`** \[**`--staged`**\] \[**`--changed`**\] \[**`--since`**=_`REF`_\] \[_`PATH`_\]... +**Usage**: **`postgres-language-server`** **`check`** \[**`--staged`**\] \[**`--changed`**\] \[**`--since`**=_`REF`_\] \[_`PATH`_\]... **The configuration that is contained inside the configuration file.** @@ -106,7 +106,7 @@ Runs everything to the requested files. - **` --vcs-use-ignore-file`**=_``_ — Whether we should use the VCS ignore file. When [true], we will ignore the files specified in the ignore file. - **` --vcs-root`**=_`PATH`_ — - The folder where we should check for VCS files. By default, we will use the same folder where `postgrestools.jsonc` was found. + The folder where we should check for VCS files. By default, we will use the same folder where `postgres-language-server.jsonc` was found. If we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted @@ -192,11 +192,11 @@ Runs everything to the requested files. - **`-h`**, **`--help`** — Prints help information -## postgrestools start +## postgres-language-server start Starts the daemon server process. -**Usage**: **`postgrestools`** **`start`** \[**`--config-path`**=_`PATH`_\] +**Usage**: **`postgres-language-server`** **`start`** \[**`--config-path`**=_`PATH`_\] **Available options:** @@ -213,33 +213,33 @@ Starts the daemon server process. - **`-h`**, **`--help`** — Prints help information -## postgrestools stop +## postgres-language-server stop Stops the daemon server process. -**Usage**: **`postgrestools`** **`stop`** +**Usage**: **`postgres-language-server`** **`stop`** **Available options:** - **`-h`**, **`--help`** — Prints help information -## postgrestools init +## postgres-language-server init Bootstraps a new project. Creates a configuration file with some defaults. -**Usage**: **`postgrestools`** **`init`** +**Usage**: **`postgres-language-server`** **`init`** **Available options:** - **`-h`**, **`--help`** — Prints help information -## postgrestools lsp-proxy +## postgres-language-server lsp-proxy Acts as a server for the Language Server Protocol over stdin/stdout. -**Usage**: **`postgrestools`** **`lsp-proxy`** \[**`--config-path`**=_`PATH`_\] +**Usage**: **`postgres-language-server`** **`lsp-proxy`** \[**`--config-path`**=_`PATH`_\] **Available options:** @@ -256,11 +256,11 @@ Acts as a server for the Language Server Protocol over stdin/stdout. - **`-h`**, **`--help`** — Prints help information -## postgrestools clean +## postgres-language-server clean Cleans the logs emitted by the daemon. -**Usage**: **`postgrestools`** **`clean`** +**Usage**: **`postgres-language-server`** **`clean`** **Available options:** From 65f5867ba2d340895be6e2440bba84c02c157f86 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Fri, 24 Oct 2025 11:10:03 +0200 Subject: [PATCH 2/2] progress --- .github/workflows/pull_request.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ccf745452..616f1a83d 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -112,8 +112,9 @@ jobs: sleep 1 done - - name: Install tree-sitter-cli - run: cargo install tree-sitter-cli + - uses: tree-sitter/setup-action@v2 + with: + install-lib: false - name: Setup sqlx-cli run: cargo install sqlx-cli @@ -170,8 +171,9 @@ jobs: - name: Setup Postgres uses: ./.github/actions/setup-postgres - - name: Install tree-sitter-cli - run: cargo install tree-sitter-cli + - uses: tree-sitter/setup-action@v2 + with: + install-lib: false - name: Run tests run: cargo test --workspace @@ -201,8 +203,9 @@ jobs: uses: moonrepo/setup-rust@v1 with: cache-base: main - - name: Install tree-sitter-cli - run: cargo install tree-sitter-cli + - uses: tree-sitter/setup-action@v2 + with: + install-lib: false - name: Build main binary run: cargo build -p pgt_cli --release - name: Setup Bun @@ -244,8 +247,9 @@ jobs: cache-base: main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Install tree-sitter-cli - run: cargo install tree-sitter-cli + - uses: tree-sitter/setup-action@v2 + with: + install-lib: false - name: Ensure RustFMT on nightly toolchain run: rustup component add rustfmt --toolchain nightly - name: echo toolchain