Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ node_modules
server
test/
img/
esbuild.js
qcumber.sh
esbuild.mjs
sonar-project.properties
eslint.config.cjs
eslint.config.mjs
Expand Down
96 changes: 49 additions & 47 deletions esbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import { context, build } from "esbuild";
import { copyFileSync, mkdirSync } from "fs";
import { sync } from "glob";
import { join, basename } from "path";

function copyFiles(srcPattern, destDir) {
sync(srcPattern).forEach((file) => {
const destFile = join(destDir, basename(file));
copyFileSync(file, destFile);
});
}

const minify = process.argv.includes("--minify");
const sourcemap = process.argv.includes("--sourcemap");
Expand All @@ -22,59 +12,71 @@ const baseConfig = {
bundle: true,
};

const extensionConfig = {
const cssConfig = {
...baseConfig,
outfile: "./out/extension.js",
entryPoints: ["./src/extension.ts"],
entryPoints: [
"./src/webview/styles/style.css",
"./src/webview/styles/light.css",
],
outdir: "./out",
};

const webviewConfig = {
...baseConfig,
entryPoints: ["./src/webview/main.ts"],
outfile: "./out/webview.js",
format: "esm",
target: "es2020",
external: ["vscode"],
format: "cjs",
platform: "node",
};

const serverConfig = {
...baseConfig,
outfile: "./out/server.js",
entryPoints: ["./server/src/server.ts"],
outfile: "./out/server.js",
format: "cjs",
external: ["vscode"],
platform: "node",
external: ["vscode"],
};

const webviewConfig = {
const extensionConfig = {
...baseConfig,
target: "es2020",
format: "esm",
entryPoints: ["./src/webview/main.ts"],
entryPoints: ["./src/extension.ts"],
outfile: "./out/extension.js",
format: "cjs",
platform: "node",
external: ["vscode"],
outfile: "./out/webview.js",
};

(async () => {
try {
mkdirSync("./out", { recursive: true });
copyFiles("src/webview/styles/*.css", "./out");

if (watch) {
console.log("esbuild:started");
const contexts = await Promise.all([
context(serverConfig),
context(webviewConfig),
context(extensionConfig),
]);
await Promise.all(contexts.map((ctx) => ctx.rebuild())).finally(() =>
if (watch) {
console.log("esbuild:started");
Promise.all([
context(cssConfig),
context(webviewConfig),
context(serverConfig),
context(extensionConfig),
])
.then((contexts) =>
Promise.all(contexts.map((ctx) => ctx.rebuild())).finally(() =>
Promise.all(contexts.map((ctx) => ctx.watch({ delay: 500 })))
.then(() => console.log("esbuild:watching"))
.catch((err) => {
console.error(err);
.catch((error) => {
console.error(error);
process.exit(1);
}),
);
} else {
await build(serverConfig);
await build(webviewConfig);
await build(extensionConfig);
}
} catch (err) {
console.error(err);
}
})();
),
)
.catch((error) => {
console.error(error);
});
} else {
Promise.all([
build(cssConfig),
build(webviewConfig),
build(serverConfig),
build(extensionConfig),
]).catch((error) => {
console.error(error);
process.exit(1);
});
}
6 changes: 2 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ import * as tseslint from "typescript-eslint";
const currentYear = new Date().getFullYear();

export default [
{
ignores: ["**/*.d.ts", "**/*.js", "**/*.mjs", "src/ipc/**", "test/fixtures/**"],
},
{ ignores: ["**/*.d.ts", "**/*.js", "**/*.mjs", "src/ipc/**/*"] },
js.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2020,
sourceType: "module",
},
},
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@
},
{
"command": "kdb.connections.edit",
"when": "view == kdb-servers && (viewItem in kdb.rootNodes || viewItem in kdb.insightsNodes)",
"when": "view == kdb-servers && viewItem not in kdb.kdbQuickNodes && (viewItem in kdb.rootNodes || viewItem in kdb.insightsNodes)",
"group": "connection@4"
},
{
Expand All @@ -981,12 +981,12 @@
},
{
"command": "kdb.connections.addAuthentication",
"when": "view == kdb-servers && viewItem not in kdb.insightsNodes && viewItem in kdb.kdbNodesWithoutAuth && viewItem not in kdb.local",
"when": "view == kdb-servers && viewItem not in kdb.kdbQuickNodes && viewItem not in kdb.insightsNodes && viewItem in kdb.kdbNodesWithoutAuth && viewItem not in kdb.local",
"group": "connection@3"
},
{
"command": "kdb.connections.enableTLS",
"when": "view == kdb-servers && viewItem not in kdb.insightsNodes && viewItem in kdb.kdbNodesWithoutTls && viewItem not in kdb.local",
"when": "view == kdb-servers && viewItem not in kdb.kdbQuickNodes && viewItem not in kdb.insightsNodes && viewItem in kdb.kdbNodesWithoutTls && viewItem not in kdb.local",
"group": "connection@4"
},
{
Expand All @@ -1006,12 +1006,12 @@
},
{
"command": "kdb.connections.remove.kdb",
"when": "view == kdb-servers && viewItem in kdb.rootNodes",
"when": "view == kdb-servers && viewItem in kdb.rootNodes && viewItem not in kdb.kdbQuickNodes",
"group": "connection@5"
},
{
"command": "kdb.connections.export.single",
"when": "view == kdb-servers && (viewItem in kdb.rootNodes || viewItem in kdb.insightsNodes)",
"when": "view == kdb-servers && viewItem not in kdb.kdbQuickNodes && (viewItem in kdb.rootNodes || viewItem in kdb.insightsNodes)",
"group": "connection@6"
},
{
Expand Down Expand Up @@ -1201,8 +1201,8 @@
},
"scripts": {
"update-deps": "ncu --target patch -u",
"format": "prettier --write \"**/*.+(js|ts)\"",
"lint": "eslint $(git ls-files '*.ts') --fix --no-warn-ignored",
"format": "prettier --write \"**/*.ts\"",
"lint": "eslint --fix --no-warn-ignored",
"esbuild-base": "rimraf out && node ./esbuild.mjs",
"watch": "npm run -S esbuild-base -- --sourcemap --watch",
"build": "npm run -S esbuild-base -- --sourcemap",
Expand Down
18 changes: 9 additions & 9 deletions ref_card.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@
| Run.Cell.ie.dap.q | | src/utils/queryUtils.ts |
| Run.Cell.ie.dap.py | | src/utils/queryUtils.ts |
| ¦ | | |
| Run.Workbook.kdb.quick.q | | |
| Run.Workbook.kdb.quick.py | | |
| Run.Workbook.kdb.quick.sql | | |
| Run.File.kdb.quick.q | | |
| Run.File.kdb.quick.py | | |
| Run.File.kdb.quick.sql | | |
| Run.Cell.kdb.quick.q | | |
| Run.Cell.kdb.quick.py | | |
| Run.Cell.kdb.quick.sql | | |
| Run.Workbook.kdb.quick.q | | src/utils/queryUtils.ts |
| Run.Workbook.kdb.quick.py | | src/utils/queryUtils.ts |
| Run.Workbook.kdb.quick.sql | | src/utils/queryUtils.ts |
| Run.File.kdb.quick.q | | src/utils/queryUtils.ts |
| Run.File.kdb.quick.py | | src/utils/queryUtils.ts |
| Run.File.kdb.quick.sql | | src/utils/queryUtils.ts |
| Run.Cell.kdb.quick.q | | src/utils/queryUtils.ts |
| Run.Cell.kdb.quick.py | | src/utils/queryUtils.ts |
| Run.Cell.kdb.quick.sql | | src/utils/queryUtils.ts |
| ¦ | | |
| Run.Datasource.api | | src/utils/queryUtils.ts |
| Run.Datasource.qsql | | src/utils/queryUtils.ts |
Expand Down
82 changes: 82 additions & 0 deletions src/commands/serverCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1429,3 +1429,85 @@ function isValidExportedConnections(data: any): data is ExportedConnections {
Array.isArray(data.connections.KDB)
);
}

const quickConnections: ServerDetails[] = [];

function getQuickLabel(conn: ServerDetails) {
return `${conn.serverAlias} [${conn.serverName}:${conn.serverPort}]`;
}

function getQuickDetail(host: string, port: string, user: string) {
return quickConnections.find(
(conn) =>
conn.serverName === host &&
conn.serverPort === port &&
conn.username === user,
);
}

async function removeQuickDetail(conn: ServerDetails) {
quickConnections.splice(quickConnections.indexOf(conn), 1);
const label = getQuickLabel(conn);
ext.connectedConnectionList
.find((conn) => conn.connLabel === label)
?.disconnect();
await refreshQuickProvider();
}

async function refreshQuickProvider() {
const servers = getServers();
quickConnections.forEach((conn) => (servers[conn.serverAlias] = conn));
await commands.executeCommand(
"setContext",
"kdb.kdbQuickNodes",
quickConnections.map((conn) => getQuickLabel(conn)),
);
ext.serverProvider.refresh(servers);
}

export async function setQuickPassword(
host: string,
port: string,
user: string,
pass: string,
) {
const conn = getQuickDetail(host, port, user);
if (conn) await removeQuickDetail(conn);
await ext.secretSettings.storeAuthData(
`${host}:${port}:${user}`,
`${user}:${pass}`,
);
}

export async function ensureQuickConnection(server: string) {
const [host, port, user] = server.split(":");

let connection = getQuickDetail(host, port, user);
if (!connection) {
const serverAlias = "(Connection " + (quickConnections.length + 1) + ")";
if (user) {
let auth = await ext.secretSettings.getAuthData(server);
if (!auth) {
const password = await window.showInputBox({
password: true,
prompt: `Enter password for ${server}`,
});
auth = `${user}:${password ?? ""}`;
await ext.secretSettings.storeAuthData(server, auth);
}
await ext.secretSettings.storeAuthData(serverAlias, auth);
}
connection = {
serverAlias,
serverName: host,
serverPort: port,
username: user,
auth: !!user,
tls: false,
};
quickConnections.push(connection);
await refreshQuickProvider();
}

return connection.serverAlias;
}
Loading