Skip to content

Commit 0f2806d

Browse files
fix: vscode settings relative path (#11)
1 parent d6b2bbb commit 0f2806d

File tree

8 files changed

+74
-1
lines changed

8 files changed

+74
-1
lines changed

.vscode/launch.json

+14
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@
4444
"outFiles": ["${workspaceFolder}/out/**/*.js"],
4545
"sourceMapRenames": true
4646
},
47+
{
48+
"name": "🧩 Debug Extension (VSCode Settings Strategy)",
49+
"type": "extensionHost",
50+
"request": "launch",
51+
"args": [
52+
"--disable-extensions",
53+
"--extensionDevelopmentKind=node",
54+
"--extensionDevelopmentPath=${workspaceFolder}",
55+
"--log=supabase.postgrestools-vscode:debug",
56+
"${workspaceFolder}/test/fixtures/vscode-settings-strat"
57+
],
58+
"outFiles": ["${workspaceFolder}/out/**/*.js"],
59+
"sourceMapRenames": true
60+
},
4761
{
4862
"name": "🧩 Debug Extension (Simple Project Global Binary)",
4963
"type": "extensionHost",

src/binary-finder-strategies.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const vsCodeSettingsStrategy: BinaryFindStrategy = {
7070
logger.debug("Binary Setting is a string", { binSetting });
7171

7272
const resolvedPath = binSetting.startsWith(".")
73-
? Uri.joinPath(path, binSetting).toString()
73+
? Uri.joinPath(path, binSetting).fsPath
7474
: binSetting;
7575

7676
logger.debug("Looking for binary at path", { resolvedPath });

src/session.ts

+11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ export const createSession = async (
4343
return;
4444
}
4545

46+
if (!fileIsExecutable(findResult.bin)) {
47+
window.showErrorMessage(`
48+
The binary you've pointed to is not executable.
49+
(${findResult.bin.fsPath})
50+
`);
51+
logger.error("Found binary is not executable.");
52+
return;
53+
}
54+
4655
logger.info("Copying binary to temp location", {
4756
currentLocation: findResult.bin.fsPath,
4857
});
@@ -96,6 +105,8 @@ const copyBinaryToTemporaryLocation = async (
96105
.split(":")[1]
97106
.trim();
98107

108+
logger.debug(`Retrieved version from binary`, { version });
109+
99110
const location = Uri.joinPath(
100111
state.context.globalStorageUri,
101112
"tmp-bin",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"postgrestools.bin": "./bin/postgrestools"
3+
// "postgrestools.bin": "/bin/postgrestools"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# VSCode Settings Strategy
2+
3+
A bread-and-butter project with a `postgrestools.jsonc` on top level and SQL files in the `test` folder.
4+
The goal is to let the `.vscode/settings.json` point to a binary and have that config working correctly.
5+
6+
## Expectations
7+
8+
The extension should recognize the `postgrestools.jsonc` file and connect with the right database. It should work when opening the `src/test.sql` file.
9+
10+
## Test protocol
11+
12+
### Via VSCode Settings
13+
14+
0. Follow the instructions in `GLOBAL_SETUP.md`.
15+
1. Download a matching [postgrestools binary](https://github.com/supabase-community/postgres_lsp/releases/latest) and move it into `./bin`.
16+
2. Open the `.vscode/settings.json` and point to the binary, either via an absolute path or a relative path.
17+
3. You should not be prompted for any binary installations.
18+
4. The extension should work when you open the `src/test.sql` file.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"vcs": {
3+
"enabled": false,
4+
"clientKind": "git",
5+
"useIgnoreFile": false
6+
},
7+
"files": {
8+
"ignore": []
9+
},
10+
"linter": {
11+
"enabled": true,
12+
"rules": {
13+
"recommended": true
14+
}
15+
},
16+
"db": {
17+
"host": "127.0.0.1",
18+
"port": 3333,
19+
"username": "postgres",
20+
"password": "example",
21+
"database": "postgres",
22+
"connTimeoutSecs": 10
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select * from users;

0 commit comments

Comments
 (0)