neon 3.2.2 → 3.3.0
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/README.md +70 -30
- package/dist/_chunks/{auth_selection-DGgq6ifc.js → auth_selection-CV_3n1du.js} +1 -1
- package/dist/_chunks/{cmd_pipeline-CUbBO9U_.js → cmd_pipeline-CEk93dGN.js} +8 -6
- package/dist/_chunks/credential_io-D2vw1UOw.js +409 -0
- package/dist/_chunks/{paths-DMq0Lt7a.js → paths-g3DRqJiD.js} +1 -1
- package/dist/_chunks/{profiles-Ir29rqns.js → profiles-CVXNvU2r.js} +106 -66
- package/dist/_chunks/{psql-DWH-kc69.js → psql-BNljLda2.js} +8 -7
- package/dist/_chunks/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-8H4AJuhK.js} +1 -0
- package/dist/analytics.js +19 -5
- package/dist/auth_context.js +25 -24
- package/dist/commands/api.js +1 -1
- package/dist/commands/api_keys.js +1 -1
- package/dist/commands/auth.js +121 -80
- package/dist/commands/bootstrap.js +2 -2
- package/dist/commands/branches.js +1 -1
- package/dist/commands/bucket.js +1 -1
- package/dist/commands/checkout.js +1 -1
- package/dist/commands/config.js +1 -1
- package/dist/commands/connection_string.js +1 -1
- package/dist/commands/data_api.js +1 -1
- package/dist/commands/databases.js +1 -1
- package/dist/commands/deploy.js +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/diff.js +1 -1
- package/dist/commands/env.js +1 -1
- package/dist/commands/functions.js +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/inspect.js +1 -1
- package/dist/commands/ip_allow.js +1 -1
- package/dist/commands/link.js +1 -1
- package/dist/commands/logs.js +1 -1
- package/dist/commands/neon_auth.js +1 -1
- package/dist/commands/open.js +1 -1
- package/dist/commands/operations.js +1 -1
- package/dist/commands/orgs.js +1 -1
- package/dist/commands/profile.js +183 -202
- package/dist/commands/projects.js +1 -1
- package/dist/commands/psql.js +1 -1
- package/dist/commands/roles.js +1 -1
- package/dist/commands/schema_diff.js +15 -13
- package/dist/commands/set_context.js +1 -1
- package/dist/commands/snapshots.js +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/user.js +1 -1
- package/dist/commands/vpc_endpoints.js +1 -1
- package/dist/config.js +1 -1
- package/dist/credential_io.js +2 -0
- package/dist/index.js +27 -25
- package/dist/init/auth.js +14 -25
- package/dist/keyring.js +42 -0
- package/dist/psql/cli.js +1 -1
- package/dist/psql/command/cmd_connect.js +4 -3
- package/dist/psql/command/cmd_copy.js +65 -62
- package/dist/psql/command/cmd_io.js +1 -1
- package/dist/psql/command/cmd_pipeline.js +1 -1
- package/dist/psql/command/dispatch.js +1 -1
- package/dist/psql/core/common.js +1 -1
- package/dist/psql/core/mainloop.js +1 -1
- package/dist/psql/core/startup.js +1 -1
- package/dist/psql/index.js +1 -1
- package/dist/psql/io/psqlrc.js +13 -11
- package/dist/psql/print/aligned.js +9 -5
- package/dist/psql/wire/tls.js +11 -9
- package/dist/retire_credential.js +86 -0
- package/dist/utils/inspect_db.js +1 -1
- package/dist/utils/middlewares.js +1 -1
- package/package.json +5 -4
- package/dist/_chunks/credentials-MYdHdKah.js +0 -188
- package/dist/_chunks/secure_file-BucZj4yQ.js +0 -39
|
@@ -87,19 +87,21 @@ const generateHeader = (pointInTime) => {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
const parseSchemaDiffParams = async (props) => {
|
|
90
|
-
if (!props.compareSource)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
if (!props.compareSource) {
|
|
91
|
+
if (props.baseBranch) {
|
|
92
|
+
props.compareSource = props.baseBranch;
|
|
93
|
+
props.baseBranch = props.branch;
|
|
94
|
+
} else if (props.branch) {
|
|
95
|
+
const { data } = await props.apiClient.listProjectBranches({ projectId: props.projectId });
|
|
96
|
+
if (data.branches.find((b) => b.id === props.branch || b.name === props.branch)?.parent_id == void 0) throw new Error(`No branch specified. Your context branch (${props.branch}) has no parent, so no comparison is possible.`);
|
|
97
|
+
log.info(`No branches specified. Comparing your context branch '${props.branch}' with its parent`);
|
|
98
|
+
props.compareSource = "^parent";
|
|
99
|
+
} else {
|
|
100
|
+
const { data } = await props.apiClient.listProjectBranches({ projectId: props.projectId });
|
|
101
|
+
if (data.branches.find((b) => b.default)?.parent_id == void 0) throw new Error("No branch specified. Include a base branch or add a set-context branch to continue. Your default branch has no parent, so no comparison is possible.");
|
|
102
|
+
log.info(`No branches specified. Comparing default branch with its parent`);
|
|
103
|
+
props.compareSource = "^parent";
|
|
104
|
+
}
|
|
103
105
|
}
|
|
104
106
|
return props;
|
|
105
107
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "../_chunks/rolldown-runtime-
|
|
1
|
+
import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
|
|
2
2
|
import { log } from "../log.js";
|
|
3
3
|
import { applyContext } from "../context.js";
|
|
4
4
|
import { getCliName } from "../utils/cli_name.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "../_chunks/rolldown-runtime-
|
|
1
|
+
import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
|
|
2
2
|
import { log } from "../log.js";
|
|
3
3
|
import { retryOnLock } from "../api.js";
|
|
4
4
|
import { writer } from "../writer.js";
|
package/dist/commands/status.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "../_chunks/rolldown-runtime-
|
|
1
|
+
import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
|
|
2
2
|
import { fillSingleProject } from "../utils/enrichers.js";
|
|
3
3
|
import { status } from "./config.js";
|
|
4
4
|
//#region src/commands/status.ts
|
package/dist/commands/user.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "../_chunks/rolldown-runtime-
|
|
1
|
+
import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
|
|
2
2
|
import { writer } from "../writer.js";
|
|
3
3
|
//#region src/commands/user.ts
|
|
4
4
|
var user_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "../_chunks/rolldown-runtime-
|
|
1
|
+
import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
|
|
2
2
|
import { log } from "../log.js";
|
|
3
3
|
import { writer } from "../writer.js";
|
|
4
4
|
import { fillSingleOrg, fillSingleProject } from "../utils/enrichers.js";
|
package/dist/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isCi } from "./env.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as isInsideConfigDir, i as defaultDir, o as isOwnedCredentialPath, r as credentialsPath, t as CREDENTIALS_FILE } from "./_chunks/paths-g3DRqJiD.js";
|
|
3
3
|
import { existsSync, mkdirSync } from "node:fs";
|
|
4
4
|
//#region src/config.ts
|
|
5
5
|
const ensureConfigDir = ({ "config-dir": configDirArg, "force-auth": forceAuth }) => {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { log } from "./log.js";
|
|
2
2
|
import pkg_default from "./pkg.js";
|
|
3
3
|
import { isNeonApiError, messageFromBody } from "./api.js";
|
|
4
|
-
import {
|
|
4
|
+
import { i as defaultDir } from "./_chunks/paths-g3DRqJiD.js";
|
|
5
5
|
import { ensureConfigDir } from "./config.js";
|
|
6
6
|
import { authFailureMessage, credentialsToClearOn401, getAuthContext } from "./auth_context.js";
|
|
7
7
|
import { currentContextFile, enrichFromContext } from "./context.js";
|
|
@@ -128,34 +128,36 @@ async function handleError(msg, err) {
|
|
|
128
128
|
sendError(error, "NETWORK_ERROR");
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
|
-
if (isNeonApiError(err))
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
} else if (err.status === 401) {
|
|
136
|
-
sendError(err, "AUTH_FAILED");
|
|
137
|
-
const context = getAuthContext();
|
|
138
|
-
const staleCredentials = credentialsToClearOn401(context);
|
|
139
|
-
if (staleCredentials === null) {
|
|
140
|
-
log.error(authFailureMessage(context));
|
|
131
|
+
if (isNeonApiError(err)) {
|
|
132
|
+
if (err.code === "ECONNABORTED") {
|
|
133
|
+
log.error("Request timed out");
|
|
134
|
+
sendError(err, "REQUEST_TIMEOUT");
|
|
141
135
|
return false;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
136
|
+
} else if (err.status === 401) {
|
|
137
|
+
sendError(err, "AUTH_FAILED");
|
|
138
|
+
const context = getAuthContext();
|
|
139
|
+
const staleCredentials = credentialsToClearOn401(context);
|
|
140
|
+
if (staleCredentials === null) {
|
|
141
|
+
log.error(authFailureMessage(context));
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
log.info("Authentication failed, deleting credentials...");
|
|
145
|
+
try {
|
|
146
|
+
if (context === null) return false;
|
|
147
|
+
deleteCredentialsAt(staleCredentials, context.configDir);
|
|
148
|
+
return true;
|
|
149
|
+
} catch (deleteErr) {
|
|
150
|
+
log.debug("Failed to delete credentials: %s", deleteErr instanceof Error ? deleteErr.message : "unknown error");
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
const serverMessage = messageFromBody(err.data);
|
|
155
|
+
if (serverMessage) log.error(serverMessage);
|
|
156
|
+
log.debug("status: %d %s | path: %s", err.status, err.statusText, err.requestPath);
|
|
157
|
+
sendError(err, "API_ERROR");
|
|
149
158
|
return false;
|
|
150
159
|
}
|
|
151
160
|
} else {
|
|
152
|
-
const serverMessage = messageFromBody(err.data);
|
|
153
|
-
if (serverMessage) log.error(serverMessage);
|
|
154
|
-
log.debug("status: %d %s | path: %s", err.status, err.statusText, err.requestPath);
|
|
155
|
-
sendError(err, "API_ERROR");
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
161
|
const error = err instanceof Error ? err : new Error(msg || "Unknown error");
|
|
160
162
|
sendError(error, matchErrorCode(error.message));
|
|
161
163
|
log.error(error.message);
|
package/dist/init/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { l as locationForName, t as DEFAULT_PROFILE } from "../_chunks/profiles-CVXNvU2r.js";
|
|
2
|
+
import { l as interpretCredentials, t as storeFor } from "../_chunks/credential_io-D2vw1UOw.js";
|
|
3
|
+
import { n as configDir } from "../_chunks/paths-g3DRqJiD.js";
|
|
4
4
|
import { log } from "@clack/prompts";
|
|
5
5
|
import { execa } from "execa";
|
|
6
6
|
//#region src/init/auth.ts
|
|
@@ -26,8 +26,10 @@ async function ensureNeonctlAuth(options) {
|
|
|
26
26
|
return true;
|
|
27
27
|
} catch (error) {
|
|
28
28
|
const msg = error instanceof Error ? error.message : "Unknown error";
|
|
29
|
-
if (!quiet)
|
|
30
|
-
|
|
29
|
+
if (!quiet) {
|
|
30
|
+
if (msg.includes("interactive auth") || msg.includes("CI")) log.error("Auth requires an interactive terminal. Run neon init in your system terminal (outside the chat) to sign in.");
|
|
31
|
+
else log.error(`Authentication failed: ${msg}`);
|
|
32
|
+
}
|
|
31
33
|
return false;
|
|
32
34
|
}
|
|
33
35
|
}
|
|
@@ -38,29 +40,16 @@ async function isAuthenticated() {
|
|
|
38
40
|
return await getNeonctlAccessToken() !== null;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* Shares the reader with `neon` and `@neon/env` rather than keeping a copy — the inline path
|
|
44
|
-
* resolution this replaced was the third implementation of "where is the config directory", and
|
|
45
|
-
* it also looked only for `access_token`, so an account signed in with an API key read as not
|
|
46
|
-
* authenticated and got sent to a browser. See `internals/cli-core/README.md`.
|
|
47
|
-
*
|
|
48
|
-
* `null` means *absent*, and only absent. A file that exists and cannot be read throws: this
|
|
49
|
-
* value decides whether to start a browser sign-in, and a sign-in overwrites the file it could
|
|
50
|
-
* not read — as a different account, if a different one is chosen. Catching every error here
|
|
51
|
-
* made a damaged credential indistinguishable from a fresh machine.
|
|
43
|
+
* Sharing the reader keeps init aligned with CLI path and API-key handling.
|
|
44
|
+
* Unreadable credentials throw so browser sign-in cannot overwrite them.
|
|
52
45
|
*/
|
|
53
46
|
async function getNeonctlAccessToken() {
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
const credential = interpretCredentials(read.credentials, {
|
|
59
|
-
path,
|
|
60
|
-
profile: DEFAULT_PROFILE
|
|
61
|
-
});
|
|
47
|
+
const at = locationForName(configDir(), DEFAULT_PROFILE);
|
|
48
|
+
const loaded = storeFor(configDir()).read(at);
|
|
49
|
+
if (loaded === null) return null;
|
|
50
|
+
const credential = interpretCredentials(loaded.credentials, at, loaded.backend);
|
|
62
51
|
if (credential.kind === "api_key") return credential.apiKey;
|
|
63
|
-
const token =
|
|
52
|
+
const token = loaded.credentials.access_token;
|
|
64
53
|
return typeof token === "string" && token.trim() !== "" ? token : null;
|
|
65
54
|
}
|
|
66
55
|
//#endregion
|
package/dist/keyring.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region src/keyring.ts
|
|
3
|
+
const isPackaged = () => process.pkg !== void 0;
|
|
4
|
+
const isMissingItem = (err) => {
|
|
5
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
6
|
+
return /no matching entry|not found|password not found/i.test(message);
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A literal addon specifier makes the standalone bundle require a native module
|
|
10
|
+
* that packaged binaries cannot load.
|
|
11
|
+
*/
|
|
12
|
+
const tryLoadKeyring = () => {
|
|
13
|
+
if (isPackaged()) return null;
|
|
14
|
+
try {
|
|
15
|
+
const { Entry } = createRequire(import.meta.url)(["@napi-rs", "keyring"].join("/"));
|
|
16
|
+
return {
|
|
17
|
+
get(service, account) {
|
|
18
|
+
try {
|
|
19
|
+
return new Entry(service, account).getPassword();
|
|
20
|
+
} catch (err) {
|
|
21
|
+
if (isMissingItem(err)) return null;
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
set(service, account, password) {
|
|
26
|
+
new Entry(service, account).setPassword(password);
|
|
27
|
+
},
|
|
28
|
+
delete(service, account) {
|
|
29
|
+
try {
|
|
30
|
+
return new Entry(service, account).deletePassword();
|
|
31
|
+
} catch (err) {
|
|
32
|
+
if (isMissingItem(err)) return false;
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { tryLoadKeyring };
|
package/dist/psql/cli.js
CHANGED
|
@@ -416,9 +416,10 @@ const buildConninfoRows = (ctx, db) => {
|
|
|
416
416
|
const rows = [];
|
|
417
417
|
rows.push(["Database", database]);
|
|
418
418
|
rows.push(["Client User", user]);
|
|
419
|
-
if (host.startsWith("/"))
|
|
420
|
-
|
|
421
|
-
|
|
419
|
+
if (host.startsWith("/")) {
|
|
420
|
+
if (hostaddr !== null && hostaddr.length > 0) rows.push(["Host Address", hostaddr]);
|
|
421
|
+
else rows.push(["Socket Directory", host]);
|
|
422
|
+
} else {
|
|
422
423
|
rows.push(["Host", host]);
|
|
423
424
|
if (hostaddr !== null && hostaddr.length > 0 && hostaddr !== host) rows.push(["Host Address", hostaddr]);
|
|
424
425
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { writeErr, writeOut } from "./shared.js";
|
|
2
2
|
import { pumpReadable } from "../wire/copy.js";
|
|
3
|
-
import { m as getPipelineState } from "../../_chunks/cmd_pipeline-
|
|
3
|
+
import { m as getPipelineState } from "../../_chunks/cmd_pipeline-CEk93dGN.js";
|
|
4
4
|
import { createReadStream, createWriteStream, promises } from "node:fs";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
6
|
import { Buffer } from "node:buffer";
|
|
@@ -603,74 +603,77 @@ const doCopy = async (conn, opts) => {
|
|
|
603
603
|
let fromStdin = false;
|
|
604
604
|
/** Cleanup callbacks run in `finally`. */
|
|
605
605
|
const cleanups = [];
|
|
606
|
-
if (opts.direction === "from")
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
606
|
+
if (opts.direction === "from") {
|
|
607
|
+
if (opts.file !== null) {
|
|
608
|
+
if (opts.program) {
|
|
609
|
+
try {
|
|
610
|
+
program = spawnProgram(opts.file, "from");
|
|
611
|
+
} catch (err) {
|
|
612
|
+
return failWith(`could not execute command "${opts.file}": ${err instanceof Error ? err.message : String(err)}`);
|
|
613
|
+
}
|
|
614
|
+
readable = program.readable;
|
|
615
|
+
const p = program;
|
|
616
|
+
cleanups.push(async () => {
|
|
617
|
+
try {
|
|
618
|
+
p.child.stdout?.destroy();
|
|
619
|
+
} catch {}
|
|
620
|
+
await p.closed;
|
|
621
|
+
});
|
|
622
|
+
} else {
|
|
623
|
+
try {
|
|
624
|
+
if ((await promises.stat(opts.file)).isDirectory()) return failWith(`${opts.file}: cannot copy from/to a directory`);
|
|
625
|
+
} catch (err) {
|
|
626
|
+
return failWith(`${opts.file}: ${err instanceof Error ? err.message : String(err)}`);
|
|
627
|
+
}
|
|
628
|
+
const stream = createReadStream(opts.file);
|
|
629
|
+
readable = stream;
|
|
630
|
+
cleanups.push(() => new Promise((resolve) => {
|
|
631
|
+
if (stream.destroyed) {
|
|
632
|
+
resolve();
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
stream.once("close", () => {
|
|
636
|
+
resolve();
|
|
637
|
+
});
|
|
638
|
+
stream.destroy();
|
|
639
|
+
}));
|
|
640
|
+
}
|
|
641
|
+
} else {
|
|
642
|
+
readable = process.stdin;
|
|
643
|
+
fromStdin = true;
|
|
611
644
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
cleanups.push(async () => {
|
|
645
|
+
} else if (opts.file !== null) {
|
|
646
|
+
if (opts.program) {
|
|
615
647
|
try {
|
|
616
|
-
|
|
617
|
-
} catch {
|
|
618
|
-
|
|
619
|
-
});
|
|
620
|
-
} else {
|
|
621
|
-
try {
|
|
622
|
-
if ((await promises.stat(opts.file)).isDirectory()) return failWith(`${opts.file}: cannot copy from/to a directory`);
|
|
623
|
-
} catch (err) {
|
|
624
|
-
return failWith(`${opts.file}: ${err instanceof Error ? err.message : String(err)}`);
|
|
625
|
-
}
|
|
626
|
-
const stream = createReadStream(opts.file);
|
|
627
|
-
readable = stream;
|
|
628
|
-
cleanups.push(() => new Promise((resolve) => {
|
|
629
|
-
if (stream.destroyed) {
|
|
630
|
-
resolve();
|
|
631
|
-
return;
|
|
648
|
+
program = spawnProgram(opts.file, "to");
|
|
649
|
+
} catch (err) {
|
|
650
|
+
return failWith(`could not execute command "${opts.file}": ${err instanceof Error ? err.message : String(err)}`);
|
|
632
651
|
}
|
|
633
|
-
|
|
634
|
-
|
|
652
|
+
writable = program.writable;
|
|
653
|
+
const p = program;
|
|
654
|
+
cleanups.push(async () => {
|
|
655
|
+
try {
|
|
656
|
+
p.child.stdin?.end();
|
|
657
|
+
} catch {}
|
|
658
|
+
await p.closed;
|
|
635
659
|
});
|
|
636
|
-
|
|
637
|
-
}));
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
readable = process.stdin;
|
|
641
|
-
fromStdin = true;
|
|
642
|
-
}
|
|
643
|
-
else if (opts.file !== null) if (opts.program) {
|
|
644
|
-
try {
|
|
645
|
-
program = spawnProgram(opts.file, "to");
|
|
646
|
-
} catch (err) {
|
|
647
|
-
return failWith(`could not execute command "${opts.file}": ${err instanceof Error ? err.message : String(err)}`);
|
|
648
|
-
}
|
|
649
|
-
writable = program.writable;
|
|
650
|
-
const p = program;
|
|
651
|
-
cleanups.push(async () => {
|
|
660
|
+
} else {
|
|
652
661
|
try {
|
|
653
|
-
|
|
662
|
+
if ((await promises.stat(opts.file).catch(() => null))?.isDirectory()) return failWith(`${opts.file}: cannot copy from/to a directory`);
|
|
654
663
|
} catch {}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
try {
|
|
659
|
-
if ((await promises.stat(opts.file).catch(() => null))?.isDirectory()) return failWith(`${opts.file}: cannot copy from/to a directory`);
|
|
660
|
-
} catch {}
|
|
661
|
-
const stream = createWriteStream(opts.file);
|
|
662
|
-
stream.once("error", (e) => {
|
|
663
|
-
fileWriteErrors.push(e);
|
|
664
|
-
});
|
|
665
|
-
writable = stream;
|
|
666
|
-
cleanups.push(() => new Promise((resolve, reject) => {
|
|
667
|
-
stream.end((err) => {
|
|
668
|
-
if (err) reject(err);
|
|
669
|
-
else resolve();
|
|
664
|
+
const stream = createWriteStream(opts.file);
|
|
665
|
+
stream.once("error", (e) => {
|
|
666
|
+
fileWriteErrors.push(e);
|
|
670
667
|
});
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
668
|
+
writable = stream;
|
|
669
|
+
cleanups.push(() => new Promise((resolve, reject) => {
|
|
670
|
+
stream.end((err) => {
|
|
671
|
+
if (err) reject(err);
|
|
672
|
+
else resolve();
|
|
673
|
+
});
|
|
674
|
+
}));
|
|
675
|
+
}
|
|
676
|
+
} else writable = process.stdout;
|
|
674
677
|
let tag = null;
|
|
675
678
|
try {
|
|
676
679
|
if (opts.direction === "from") {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as cmdPrint, C as cmdGdesc, D as cmdInclude, E as cmdGx, F as registerIoCommands, M as cmdWrite, N as formatWatchTimestamp, O as cmdIncludeRel, P as getQueryFout, S as cmdG, T as cmdGset, b as WATCH_TEST_CONTROLLER, j as cmdWatch, k as cmdOut, w as cmdGexec, x as clearPipelineGateErrors, y as DEFAULT_WATCH_INTERVAL } from "../../_chunks/cmd_pipeline-
|
|
1
|
+
import { A as cmdPrint, C as cmdGdesc, D as cmdInclude, E as cmdGx, F as registerIoCommands, M as cmdWrite, N as formatWatchTimestamp, O as cmdIncludeRel, P as getQueryFout, S as cmdG, T as cmdGset, b as WATCH_TEST_CONTROLLER, j as cmdWatch, k as cmdOut, w as cmdGexec, x as clearPipelineGateErrors, y as DEFAULT_WATCH_INTERVAL } from "../../_chunks/cmd_pipeline-CEk93dGN.js";
|
|
2
2
|
export { DEFAULT_WATCH_INTERVAL, WATCH_TEST_CONTROLLER, clearPipelineGateErrors, cmdG, cmdGdesc, cmdGexec, cmdGset, cmdGx, cmdInclude, cmdIncludeRel, cmdOut, cmdPrint, cmdWatch, cmdWrite, formatWatchTimestamp, getQueryFout, registerIoCommands };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as cmdGdesc, _ as stagedNamedBindPresent, a as cmdFlush, c as cmdParse, d as cmdSyncPipeline, f as consumeBindState, g as registerPipelineCommands, h as lookupPrepared, i as cmdEndPipeline, l as cmdSendPipeline, m as getPipelineState, n as cmdBindNamed, o as cmdFlushRequest, p as dropPrepared, r as cmdClosePrepared, s as cmdGetResults, t as cmdBind, u as cmdStartPipeline, v as stashPrepared } from "../../_chunks/cmd_pipeline-
|
|
1
|
+
import { C as cmdGdesc, _ as stagedNamedBindPresent, a as cmdFlush, c as cmdParse, d as cmdSyncPipeline, f as consumeBindState, g as registerPipelineCommands, h as lookupPrepared, i as cmdEndPipeline, l as cmdSendPipeline, m as getPipelineState, n as cmdBindNamed, o as cmdFlushRequest, p as dropPrepared, r as cmdClosePrepared, s as cmdGetResults, t as cmdBind, u as cmdStartPipeline, v as stashPrepared } from "../../_chunks/cmd_pipeline-CEk93dGN.js";
|
|
2
2
|
export { cmdBind, cmdBindNamed, cmdClosePrepared, cmdEndPipeline, cmdFlush, cmdFlushRequest, cmdGdesc, cmdGetResults, cmdParse, cmdSendPipeline, cmdStartPipeline, cmdSyncPipeline, consumeBindState, dropPrepared, getPipelineState, lookupPrepared, registerPipelineCommands, stagedNamedBindPresent, stashPrepared };
|
|
@@ -2,7 +2,7 @@ import { writeErr } from "./shared.js";
|
|
|
2
2
|
import { scanSlashArgs } from "../scanner/slash.js";
|
|
3
3
|
import { registerConnectCommands } from "./cmd_connect.js";
|
|
4
4
|
import { cmdCd, cmdCopyright, cmdEcho, cmdEdit, cmdErrverbose, cmdGetenv, cmdHelpSQL, cmdPrompt, cmdQecho, cmdQuit, cmdReset, cmdS, cmdSet, cmdSetenv, cmdShell, cmdSlashHelp, cmdTiming, cmdUnset, cmdWarn } from "./cmd_meta.js";
|
|
5
|
-
import { F as registerIoCommands, g as registerPipelineCommands } from "../../_chunks/cmd_pipeline-
|
|
5
|
+
import { F as registerIoCommands, g as registerPipelineCommands } from "../../_chunks/cmd_pipeline-CEk93dGN.js";
|
|
6
6
|
import { cmdA, cmdC, cmdEncoding, cmdF, cmdH, cmdPset, cmdT, cmdTitleAttr, cmdX } from "./cmd_format.js";
|
|
7
7
|
import { registerCopyCommands } from "./cmd_copy.js";
|
|
8
8
|
import { registerDescribeCommands } from "./cmd_describe.js";
|
package/dist/psql/core/common.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { B as psqlExec, G as writeQueryError, H as renderResultSet, I as __testing, L as captureLastError, R as executeAndPrint, U as sendQuery, V as refreshErrorVars, W as stripLeadingCommentsAndWS, z as pickOut } from "../../_chunks/cmd_pipeline-
|
|
1
|
+
import { B as psqlExec, G as writeQueryError, H as renderResultSet, I as __testing, L as captureLastError, R as executeAndPrint, U as sendQuery, V as refreshErrorVars, W as stripLeadingCommentsAndWS, z as pickOut } from "../../_chunks/cmd_pipeline-CEk93dGN.js";
|
|
2
2
|
export { __testing, captureLastError, executeAndPrint, pickOut, psqlExec, refreshErrorVars, renderResultSet, sendQuery, stripLeadingCommentsAndWS, writeQueryError };
|
|
@@ -2,7 +2,7 @@ import { COND_COMMAND_NAMES, attachCondStack, cmdElif, cmdElse, cmdEndif, cmdIf
|
|
|
2
2
|
import { scanSlashArgs } from "../scanner/slash.js";
|
|
3
3
|
import { formatDurationMs } from "../print/units.js";
|
|
4
4
|
import { appendHistory, defaultHistoryPath, loadHistory, resolveHistSize, truncateHistory } from "../io/history.js";
|
|
5
|
-
import { G as writeQueryError, H as renderResultSet, L as captureLastError, U as sendQuery, V as refreshErrorVars, f as consumeBindState, m as getPipelineState, z as pickOut } from "../../_chunks/cmd_pipeline-
|
|
5
|
+
import { G as writeQueryError, H as renderResultSet, L as captureLastError, U as sendQuery, V as refreshErrorVars, f as consumeBindState, m as getPipelineState, z as pickOut } from "../../_chunks/cmd_pipeline-CEk93dGN.js";
|
|
6
6
|
import { consumeNext } from "../command/inputQueue.js";
|
|
7
7
|
import { psqlCompleter } from "../complete/index.js";
|
|
8
8
|
import { LineEditor } from "../io/lineEditor/index.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { f as CLIENT_VERSION, h as parseStartupArgs, m as formatParseError, p as applyStartupArgs } from "../../_chunks/psql-
|
|
1
|
+
import { f as CLIENT_VERSION, h as parseStartupArgs, m as formatParseError, p as applyStartupArgs } from "../../_chunks/psql-BNljLda2.js";
|
|
2
2
|
export { CLIENT_VERSION, applyStartupArgs, formatParseError, parseStartupArgs };
|
package/dist/psql/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as mergeConnectOptions, c as parseConnectionUriService, d as serviceEntryToConnectOptions, i as looksLikeConnectionString, l as parseConninfo, n as envConnectionDefaults, o as parseConnectionUri, r as libpqConnectionDefaults, s as parseConnectionUriPartial, t as defaultClientCertDefaults, u as runPsql } from "../_chunks/psql-
|
|
1
|
+
import { a as mergeConnectOptions, c as parseConnectionUriService, d as serviceEntryToConnectOptions, i as looksLikeConnectionString, l as parseConninfo, n as envConnectionDefaults, o as parseConnectionUri, r as libpqConnectionDefaults, s as parseConnectionUriPartial, t as defaultClientCertDefaults, u as runPsql } from "../_chunks/psql-BNljLda2.js";
|
|
2
2
|
export { defaultClientCertDefaults, envConnectionDefaults, libpqConnectionDefaults, looksLikeConnectionString, mergeConnectOptions, parseConnectionUri, parseConnectionUriPartial, parseConnectionUriService, parseConninfo, runPsql, serviceEntryToConnectOptions };
|
package/dist/psql/io/psqlrc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COND_COMMAND_NAMES, attachCondStack } from "../command/cmd_cond.js";
|
|
2
2
|
import { scanSlashArgs } from "../scanner/slash.js";
|
|
3
|
-
import { U as sendQuery } from "../../_chunks/cmd_pipeline-
|
|
3
|
+
import { U as sendQuery } from "../../_chunks/cmd_pipeline-CEk93dGN.js";
|
|
4
4
|
import { dispatchBackslash } from "../command/dispatch.js";
|
|
5
5
|
import { initialScanState } from "../types/scanner.js";
|
|
6
6
|
import { scanSql } from "../scanner/sql.js";
|
|
@@ -284,16 +284,18 @@ const executeInputString = async (input, ctx, opts = {}) => {
|
|
|
284
284
|
queryBuf += r.sql;
|
|
285
285
|
working = "";
|
|
286
286
|
}
|
|
287
|
-
if (queryBuf.trim().length > 0 && ctx.settings.db && ctx.cond.isActive())
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
287
|
+
if (queryBuf.trim().length > 0 && ctx.settings.db && ctx.cond.isActive()) {
|
|
288
|
+
if (print) {
|
|
289
|
+
if ((await sendQuery(ctx, queryBuf)).hadError) hadError = true;
|
|
290
|
+
noteConnectionLost();
|
|
291
|
+
} else try {
|
|
292
|
+
await ctx.settings.db.execSimple(queryBuf);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
295
|
+
ctx.stderr.write(`psql: ERROR: ${msg}\n`);
|
|
296
|
+
hadError = true;
|
|
297
|
+
noteConnectionLost();
|
|
298
|
+
}
|
|
297
299
|
}
|
|
298
300
|
return {
|
|
299
301
|
hadError,
|
|
@@ -458,8 +458,10 @@ const buildRule = (widths, border, glyphs, position) => {
|
|
|
458
458
|
for (let i = 0; i < widths.length; i++) {
|
|
459
459
|
const pad = border === 0 ? 0 : 1;
|
|
460
460
|
out += hrule.repeat(widths[i] + pad * 2);
|
|
461
|
-
if (i < widths.length - 1)
|
|
462
|
-
|
|
461
|
+
if (i < widths.length - 1) {
|
|
462
|
+
if (border === 0) out += " ";
|
|
463
|
+
else out += mid;
|
|
464
|
+
}
|
|
463
465
|
}
|
|
464
466
|
if (border === 2 || border === 3) out += right;
|
|
465
467
|
return out;
|
|
@@ -980,9 +982,11 @@ const renderVerticalCell = (headerLines, dataLines, nameWidth, dwidth, border, g
|
|
|
980
982
|
if (border === 0 && hmultiline && !oldAscii) swidth++;
|
|
981
983
|
out += " ".repeat(swidth);
|
|
982
984
|
}
|
|
983
|
-
if (border > 0)
|
|
984
|
-
|
|
985
|
-
|
|
985
|
+
if (border > 0) {
|
|
986
|
+
if (offset !== 0) out += glyphs.midvruleWrap;
|
|
987
|
+
else if (dLine === 0) out += vrule;
|
|
988
|
+
else out += glyphs.midvruleNl;
|
|
989
|
+
}
|
|
986
990
|
if (!dcomplete) {
|
|
987
991
|
const chunk = dataChunks[dLine];
|
|
988
992
|
out += offset === 0 ? " " : glyphs.wrapLeft;
|
package/dist/psql/wire/tls.js
CHANGED
|
@@ -105,15 +105,17 @@ async function negotiateTls(socket, sslMode, tlsOpts = {}, fileOpts = {}, negoti
|
|
|
105
105
|
*/
|
|
106
106
|
async function loadTlsFileOptions(tlsOpts, fileOpts, sslMode) {
|
|
107
107
|
const merged = { ...tlsOpts };
|
|
108
|
-
if ((sslMode === void 0 || sslMode === "verify-ca" || sslMode === "verify-full") && fileOpts.sslrootcert !== void 0 && fileOpts.sslrootcert !== "")
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
if ((sslMode === void 0 || sslMode === "verify-ca" || sslMode === "verify-full") && fileOpts.sslrootcert !== void 0 && fileOpts.sslrootcert !== "") {
|
|
109
|
+
if (fileOpts.sslrootcert === "system") {
|
|
110
|
+
const systemCas = [];
|
|
111
|
+
const sslCertFile = process.env.SSL_CERT_FILE;
|
|
112
|
+
if (sslCertFile !== void 0 && sslCertFile !== "") systemCas.push(await readPem("sslrootcert", sslCertFile, "CERTIFICATE"));
|
|
113
|
+
const sslCertDir = process.env.SSL_CERT_DIR;
|
|
114
|
+
if (sslCertDir !== void 0 && sslCertDir !== "") systemCas.push(...await readCaDir(sslCertDir));
|
|
115
|
+
if (systemCas.length === 1) merged.ca = systemCas[0];
|
|
116
|
+
else if (systemCas.length > 1) merged.ca = systemCas;
|
|
117
|
+
} else merged.ca = await readPem("sslrootcert", fileOpts.sslrootcert, "CERTIFICATE");
|
|
118
|
+
}
|
|
117
119
|
const certMode = fileOpts.sslcertmode ?? "allow";
|
|
118
120
|
const clientCert = fileOpts.sslcert !== void 0 && fileOpts.sslcert !== "" ? fileOpts.sslcert : void 0;
|
|
119
121
|
if (certMode === "require" && clientCert === void 0) throw new Error(`sslcertmode value "require" requires a client certificate`);
|