Skip to content

Commit b6d0b70

Browse files
committed
refactor: code quality cleanup
1 parent d0f14fe commit b6d0b70

File tree

7 files changed

+40
-21
lines changed

7 files changed

+40
-21
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
with:
1919
submodules: true
2020
- uses: cachix/install-nix-action@v16
21+
# TODO: implement build cache
2122
- run: npm ci
2223
- run: ./compile_sqls.fish
2324
- run: npx vsce package --out sqlnotebook-${{ github.sha }}.vsix
@@ -26,3 +27,15 @@ jobs:
2627
with:
2728
name: sqlnotebook-${{ github.sha }}.vsix
2829
path: sqlnotebook-${{ github.sha }}.vsix
30+
test:
31+
runs-on: ubuntu-20.04
32+
defaults:
33+
run:
34+
shell: nix develop -c bash {0}
35+
steps:
36+
- uses: actions/checkout@v3
37+
with:
38+
submodules: true
39+
- uses: cachix/install-nix-action@v16
40+
- run: npm ci
41+
- run: npm run lint

.vscodeignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
out/test/**
44
src/**
55
.gitignore
6-
vsc-extension-quickstart.md
76
**/tsconfig.json
87
**/.eslintrc.json
98
**/*.map
109
**/*.ts
1110
**/*.tsbuildinfo
1211
sqls
12+
.github
13+
flake.nix
14+
flake.lock
15+
.envrc
16+
.gitmodules
17+
webview

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log
22

3-
## [0.5.0]
3+
## v0.5.0
44

55
- Bundle `sqls` language server into `vscode-sql-notebook`.
66
- When running on a compatible arch/os, notebooks can now

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ and view output interactively.
1515
- Open any `.sql` file as a Notebook.
1616
- Execute query blocks in the Notebook UI and view output.
1717
- Configure database connections in the SQL Notebook sidepanel.
18-
- Supports MySQL PostgreSQL, and MSSQL (OracleDB and SQLite support coming soon).
18+
- Supports MySQL, PostgreSQL, and MSSQL (OracleDB and SQLite support coming soon).
1919
- (unstable) Built-in typed autocomplete with an embeded language server.
2020

2121
## Usage

src/commands.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import { getPool, PoolConfig } from './driver';
88
import { storageKey, globalConnPool, globalLspClient } from './extension';
99
import { getCompiledLSPBinaryPath, sqlsDriverFromDriver } from './lsp';
1010

11-
export const deleteConnectionConfiguration =
12-
(
13-
context: vscode.ExtensionContext,
14-
connectionsSidepanel: SQLNotebookConnections
15-
) =>
16-
async (item: ConnectionListItem) => {
11+
export function deleteConnectionConfiguration(
12+
context: vscode.ExtensionContext,
13+
connectionsSidepanel: SQLNotebookConnections
14+
) {
15+
return async (item: ConnectionListItem) => {
1716
const without = context.globalState
1817
.get<ConnData[]>(storageKey, [])
1918
.filter(({ name }) => name !== item.config.name);
@@ -26,13 +25,13 @@ export const deleteConnectionConfiguration =
2625
);
2726
connectionsSidepanel.refresh();
2827
};
28+
}
2929

30-
export const connectToDatabase =
31-
(
32-
context: vscode.ExtensionContext,
33-
connectionsSidepanel: SQLNotebookConnections
34-
) =>
35-
async (item?: ConnectionListItem) => {
30+
export function connectToDatabase(
31+
context: vscode.ExtensionContext,
32+
connectionsSidepanel: SQLNotebookConnections
33+
) {
34+
return async (item?: ConnectionListItem) => {
3635
let selectedName: string;
3736
if (!item) {
3837
const names = context.globalState
@@ -94,13 +93,15 @@ export const connectToDatabase =
9493
connectionsSidepanel.setActive(null);
9594
}
9695
};
96+
}
9797

9898
function startLanguageServer(conn: ConnData, password?: string) {
9999
try {
100100
const driver = sqlsDriverFromDriver(conn.driver);
101101
const binPath = getCompiledLSPBinaryPath();
102-
if (!binPath)
102+
if (!binPath) {
103103
throw Error('Platform not supported, language server disabled.');
104+
}
104105
if (driver) {
105106
globalLspClient.start({
106107
binPath,

src/extension.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class SQLNotebookController {
179179
writeSuccess(execution, 'Successfully executed query');
180180
return;
181181
}
182-
const tables = result.map((r) => resultToMarkdownTable(r));
182+
const tables = result.map(resultToMarkdownTable);
183183
writeSuccess(execution, tables, 'text/markdown');
184184
}
185185
}
@@ -195,9 +195,7 @@ function resultToMarkdownTable(result: TabularResult): string {
195195
Object.fromEntries(Object.entries(result).map((pair) => [pair[0], '...']))
196196
);
197197
}
198-
return `${markdownHeader(result[0])}\n${result
199-
.map((r) => markdownRow(r))
200-
.join('\n')}`;
198+
return `${markdownHeader(result[0])}\n${result.map(markdownRow).join('\n')}`;
201199
}
202200

203201
function escapeNewline(a: string | number | null): string | number | null {

src/lsp.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export function getCompiledLSPBinaryPath(): string | null {
3737
const goos = { linux: 'linux', darwin: 'darwin', win32: 'windows' }[
3838
platform.toString()
3939
];
40-
if (!goarch && !goos) return null;
40+
if (!goarch && !goos) {
41+
return null;
42+
}
4143
return path.join(
4244
__filename,
4345
'..',

0 commit comments

Comments
 (0)