@dbx-app/cli 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-format.d.ts +2 -3
- package/dist/cli-format.js +2 -14
- package/dist/cli.js +2 -3
- package/package.json +2 -2
package/dist/cli-format.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { formatCell, mdTable, type ConnectionConfig } from "@dbx-app/node-core";
|
|
2
|
+
export { formatCell, mdTable };
|
|
2
3
|
export interface ConnectionSummary {
|
|
3
4
|
name: string;
|
|
4
5
|
type: string;
|
|
@@ -16,6 +17,4 @@ export interface ErrorPayload {
|
|
|
16
17
|
}
|
|
17
18
|
export declare function errorPayload(code: string, message: string): ErrorPayload;
|
|
18
19
|
export declare function formatErrorMessage(code: string, message: string): string;
|
|
19
|
-
export declare function mdTable(headers: string[], rows: string[][]): string;
|
|
20
|
-
export declare function formatCell(value: unknown): string;
|
|
21
20
|
export declare function csvTable<T extends object>(headers: string[], rows: T[]): string;
|
package/dist/cli-format.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { formatCell, mdTable } from "@dbx-app/node-core";
|
|
2
|
+
export { formatCell, mdTable };
|
|
1
3
|
export function connectionSummary(connection) {
|
|
2
4
|
return {
|
|
3
5
|
name: connection.name,
|
|
@@ -21,20 +23,6 @@ function errorHint(code, message) {
|
|
|
21
23
|
}
|
|
22
24
|
return undefined;
|
|
23
25
|
}
|
|
24
|
-
export function mdTable(headers, rows) {
|
|
25
|
-
const widths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] || "").length), 3));
|
|
26
|
-
const header = `| ${headers.map((h, i) => h.padEnd(widths[i])).join(" | ")} |`;
|
|
27
|
-
const sep = `| ${widths.map((w) => "-".repeat(w)).join(" | ")} |`;
|
|
28
|
-
const body = rows.map((r) => `| ${r.map((c, i) => (c || "").padEnd(widths[i])).join(" | ")} |`).join("\n");
|
|
29
|
-
return body ? `${header}\n${sep}\n${body}` : `${header}\n${sep}`;
|
|
30
|
-
}
|
|
31
|
-
export function formatCell(value) {
|
|
32
|
-
if (value === null || value === undefined)
|
|
33
|
-
return "NULL";
|
|
34
|
-
if (typeof value === "object")
|
|
35
|
-
return JSON.stringify(value);
|
|
36
|
-
return String(value);
|
|
37
|
-
}
|
|
38
26
|
export function csvTable(headers, rows) {
|
|
39
27
|
const lines = [headers.map(csvCell).join(",")];
|
|
40
28
|
for (const row of rows) {
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import {
|
|
4
|
-
import { buildSchemaContext, createBackend, DIRECT_QUERY_TYPES, BRIDGE_REQUIRED_TYPES, evaluateSqlSafety, formatSchemaContext, getDbxDiagnostics, postBridge, sqlSafetyFromEnv, } from "@dbx-app/node-core";
|
|
3
|
+
import { buildSchemaContext, createBackend, DIRECT_QUERY_TYPES, BRIDGE_REQUIRED_TYPES, evaluateSqlSafety, formatSchemaContext, getDbxDiagnostics, isMainModule, postBridge, sqlSafetyFromEnv, } from "@dbx-app/node-core";
|
|
5
4
|
import { connectionSummary, csvTable, errorPayload, formatCell, formatErrorMessage, mdTable } from "./cli-format.js";
|
|
6
5
|
class CliError extends Error {
|
|
7
6
|
code;
|
|
@@ -342,7 +341,7 @@ async function main() {
|
|
|
342
341
|
process.stderr.write(result.stderr);
|
|
343
342
|
process.exitCode = result.exitCode;
|
|
344
343
|
}
|
|
345
|
-
if (
|
|
344
|
+
if (isMainModule(import.meta.url, process.argv[1])) {
|
|
346
345
|
main().catch((error) => {
|
|
347
346
|
console.error(error instanceof Error ? error.message : String(error));
|
|
348
347
|
process.exitCode = 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbx-app/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Command line interface for DBX database connections, schema, and safe queries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/t8y2/dbx/tree/main/packages/cli",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@dbx-app/node-core": "^0.4.
|
|
34
|
+
"@dbx-app/node-core": "^0.4.5"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^22.15.21",
|