neonctl 2.28.0 → 2.29.1
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 +71 -71
- package/dist/analytics.js +35 -33
- package/dist/api.js +34 -34
- package/dist/auth.js +50 -44
- package/dist/cli.js +2 -2
- package/dist/commands/auth.js +58 -52
- package/dist/commands/bootstrap.js +115 -157
- package/dist/commands/branches.js +154 -147
- package/dist/commands/bucket.js +124 -118
- package/dist/commands/checkout.js +49 -49
- package/dist/commands/config.js +212 -88
- package/dist/commands/connection_string.js +62 -62
- package/dist/commands/data_api.js +96 -96
- package/dist/commands/databases.js +23 -23
- package/dist/commands/deploy.js +12 -12
- package/dist/commands/dev.js +114 -114
- package/dist/commands/env.js +43 -43
- package/dist/commands/functions.js +97 -98
- package/dist/commands/index.js +26 -26
- package/dist/commands/init.js +23 -22
- package/dist/commands/ip_allow.js +29 -29
- package/dist/commands/link.js +223 -166
- package/dist/commands/neon_auth.js +381 -363
- package/dist/commands/operations.js +11 -11
- package/dist/commands/orgs.js +8 -8
- package/dist/commands/projects.js +101 -99
- package/dist/commands/psql.js +31 -31
- package/dist/commands/roles.js +21 -21
- package/dist/commands/schema_diff.js +23 -23
- package/dist/commands/set_context.js +17 -17
- package/dist/commands/status.js +17 -17
- package/dist/commands/user.js +5 -5
- package/dist/commands/vpc_endpoints.js +50 -50
- package/dist/config.js +7 -7
- package/dist/config_format.js +5 -5
- package/dist/context.js +23 -16
- package/dist/current_branch_fast_path.js +6 -6
- package/dist/dev/env.js +34 -34
- package/dist/dev/functions.js +4 -4
- package/dist/dev/inputs.js +6 -6
- package/dist/dev/runtime.js +25 -25
- package/dist/env.js +14 -14
- package/dist/env_file.js +13 -13
- package/dist/errors.js +19 -19
- package/dist/functions_api.js +10 -10
- package/dist/help.js +15 -15
- package/dist/index.js +94 -92
- package/dist/log.js +2 -2
- package/dist/pkg.js +5 -5
- package/dist/psql/cli.js +4 -2
- package/dist/psql/command/cmd_cond.js +61 -61
- package/dist/psql/command/cmd_connect.js +159 -154
- package/dist/psql/command/cmd_copy.js +107 -97
- package/dist/psql/command/cmd_describe.js +368 -363
- package/dist/psql/command/cmd_format.js +276 -263
- package/dist/psql/command/cmd_io.js +269 -263
- package/dist/psql/command/cmd_lo.js +74 -66
- package/dist/psql/command/cmd_meta.js +148 -148
- package/dist/psql/command/cmd_misc.js +17 -17
- package/dist/psql/command/cmd_pipeline.js +142 -135
- package/dist/psql/command/cmd_restrict.js +25 -25
- package/dist/psql/command/cmd_show.js +183 -168
- package/dist/psql/command/dispatch.js +26 -26
- package/dist/psql/command/shared.js +14 -14
- package/dist/psql/complete/filenames.js +16 -16
- package/dist/psql/complete/index.js +4 -4
- package/dist/psql/complete/matcher.js +33 -32
- package/dist/psql/complete/psqlVars.js +173 -173
- package/dist/psql/complete/queries.js +5 -3
- package/dist/psql/complete/rules.js +900 -863
- package/dist/psql/core/common.js +136 -133
- package/dist/psql/core/help.js +343 -343
- package/dist/psql/core/mainloop.js +160 -153
- package/dist/psql/core/prompt.js +126 -123
- package/dist/psql/core/settings.js +111 -111
- package/dist/psql/core/sqlHelp.js +150 -150
- package/dist/psql/core/startup.js +211 -205
- package/dist/psql/core/syncVars.js +14 -14
- package/dist/psql/core/variables.js +24 -24
- package/dist/psql/describe/formatters.js +302 -289
- package/dist/psql/describe/processNamePattern.js +28 -28
- package/dist/psql/describe/queries.js +656 -651
- package/dist/psql/index.js +436 -411
- package/dist/psql/io/history.js +36 -36
- package/dist/psql/io/input.js +15 -15
- package/dist/psql/io/lineEditor/buffer.js +27 -25
- package/dist/psql/io/lineEditor/complete.js +15 -15
- package/dist/psql/io/lineEditor/filename.js +22 -22
- package/dist/psql/io/lineEditor/index.js +65 -62
- package/dist/psql/io/lineEditor/keymap.js +325 -318
- package/dist/psql/io/lineEditor/vt100.js +60 -60
- package/dist/psql/io/pgpass.js +18 -18
- package/dist/psql/io/pgservice.js +14 -14
- package/dist/psql/io/psqlrc.js +46 -46
- package/dist/psql/print/aligned.js +175 -166
- package/dist/psql/print/asciidoc.js +51 -51
- package/dist/psql/print/crosstab.js +34 -31
- package/dist/psql/print/csv.js +25 -22
- package/dist/psql/print/html.js +54 -54
- package/dist/psql/print/json.js +12 -12
- package/dist/psql/print/latex.js +118 -118
- package/dist/psql/print/pager.js +28 -26
- package/dist/psql/print/troff.js +48 -48
- package/dist/psql/print/unaligned.js +15 -14
- package/dist/psql/print/units.js +17 -17
- package/dist/psql/scanner/slash.js +48 -46
- package/dist/psql/scanner/sql.js +88 -84
- package/dist/psql/scanner/stringutils.js +21 -17
- package/dist/psql/types/index.js +7 -7
- package/dist/psql/types/scanner.js +8 -8
- package/dist/psql/wire/connection.js +341 -327
- package/dist/psql/wire/copy.js +7 -7
- package/dist/psql/wire/pipeline.js +26 -24
- package/dist/psql/wire/protocol.js +102 -102
- package/dist/psql/wire/sasl.js +62 -62
- package/dist/psql/wire/tls.js +79 -73
- package/dist/storage_api.js +15 -15
- package/dist/test_utils/fixtures.js +34 -31
- package/dist/test_utils/oauth_server.js +5 -5
- package/dist/utils/api_enums.js +13 -13
- package/dist/utils/branch_notice.js +5 -5
- package/dist/utils/branch_picker.js +26 -26
- package/dist/utils/compute_units.js +4 -4
- package/dist/utils/enrichers.js +20 -15
- package/dist/utils/esbuild.js +28 -28
- package/dist/utils/formats.js +1 -1
- package/dist/utils/middlewares.js +3 -3
- package/dist/utils/package_manager.js +68 -0
- package/dist/utils/point_in_time.js +12 -12
- package/dist/utils/psql.js +30 -30
- package/dist/utils/string.js +2 -2
- package/dist/utils/ui.js +9 -9
- package/dist/utils/zip.js +1 -1
- package/dist/writer.js +17 -17
- package/package.json +6 -7
package/dist/utils/psql.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { spawn } from
|
|
2
|
-
import which from
|
|
3
|
-
import { closeAnalytics, trackEvent } from
|
|
4
|
-
import { log } from
|
|
5
|
-
const FALLBACK_ENV =
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import which from "which";
|
|
3
|
+
import { closeAnalytics, trackEvent } from "../analytics.js";
|
|
4
|
+
import { log } from "../log.js";
|
|
5
|
+
const FALLBACK_ENV = "NEONCTL_PSQL_FALLBACK";
|
|
6
6
|
/** Max time we wait for the analytics flush before handing off to psql. */
|
|
7
7
|
const ANALYTICS_FLUSH_TIMEOUT_MS = 3000;
|
|
8
8
|
/**
|
|
@@ -12,28 +12,28 @@ const ANALYTICS_FLUSH_TIMEOUT_MS = 3000;
|
|
|
12
12
|
* cases rather than a misleading `false`.
|
|
13
13
|
*/
|
|
14
14
|
const planPsql = async (opts) => {
|
|
15
|
-
if (opts.mode ===
|
|
15
|
+
if (opts.mode === "ts") {
|
|
16
16
|
return {
|
|
17
|
-
implementation:
|
|
18
|
-
reason:
|
|
17
|
+
implementation: "ts",
|
|
18
|
+
reason: "forced_flag",
|
|
19
19
|
nativeAvailable: null,
|
|
20
20
|
nativePath: null,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
if (process.env[FALLBACK_ENV] ===
|
|
23
|
+
if (process.env[FALLBACK_ENV] === "1") {
|
|
24
24
|
return {
|
|
25
|
-
implementation:
|
|
26
|
-
reason:
|
|
25
|
+
implementation: "ts",
|
|
26
|
+
reason: "forced_env",
|
|
27
27
|
nativeAvailable: null,
|
|
28
28
|
nativePath: null,
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
const nativePath = await which(
|
|
31
|
+
const nativePath = await which("psql", { nothrow: true });
|
|
32
32
|
const nativeAvailable = nativePath !== null;
|
|
33
|
-
if (opts.mode ===
|
|
33
|
+
if (opts.mode === "native") {
|
|
34
34
|
return {
|
|
35
|
-
implementation:
|
|
36
|
-
reason:
|
|
35
|
+
implementation: "native",
|
|
36
|
+
reason: "forced_native",
|
|
37
37
|
nativeAvailable,
|
|
38
38
|
nativePath,
|
|
39
39
|
};
|
|
@@ -41,14 +41,14 @@ const planPsql = async (opts) => {
|
|
|
41
41
|
// 'auto' (or unset): strict fallback — prefer native, TS only if missing.
|
|
42
42
|
return nativeAvailable
|
|
43
43
|
? {
|
|
44
|
-
implementation:
|
|
45
|
-
reason:
|
|
44
|
+
implementation: "native",
|
|
45
|
+
reason: "native_available",
|
|
46
46
|
nativeAvailable,
|
|
47
47
|
nativePath,
|
|
48
48
|
}
|
|
49
49
|
: {
|
|
50
|
-
implementation:
|
|
51
|
-
reason:
|
|
50
|
+
implementation: "ts",
|
|
51
|
+
reason: "fallback_no_native",
|
|
52
52
|
nativeAvailable,
|
|
53
53
|
nativePath,
|
|
54
54
|
};
|
|
@@ -64,7 +64,7 @@ const planPsql = async (opts) => {
|
|
|
64
64
|
* analytics is disabled (`--analytics false`), since the client is absent.
|
|
65
65
|
*/
|
|
66
66
|
const reportPsqlInvocation = async (plan) => {
|
|
67
|
-
trackEvent(
|
|
67
|
+
trackEvent("psql_invoked", {
|
|
68
68
|
implementation: plan.implementation,
|
|
69
69
|
reason: plan.reason,
|
|
70
70
|
nativeAvailable: plan.nativeAvailable,
|
|
@@ -72,11 +72,11 @@ const reportPsqlInvocation = async (plan) => {
|
|
|
72
72
|
await closeAnalytics({ timeout: ANALYTICS_FLUSH_TIMEOUT_MS });
|
|
73
73
|
};
|
|
74
74
|
const execNative = async (binary, connection_uri, args) => {
|
|
75
|
-
log.info(
|
|
75
|
+
log.info("Connecting to the database using psql...");
|
|
76
76
|
const child = spawn(binary, [connection_uri, ...args], {
|
|
77
|
-
stdio:
|
|
77
|
+
stdio: "inherit",
|
|
78
78
|
});
|
|
79
|
-
for (const signame of [
|
|
79
|
+
for (const signame of ["SIGINT", "SIGTERM"]) {
|
|
80
80
|
process.on(signame, (code) => {
|
|
81
81
|
if (!child.killed && code !== null) {
|
|
82
82
|
child.kill(code);
|
|
@@ -84,15 +84,15 @@ const execNative = async (binary, connection_uri, args) => {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
return new Promise((_, reject) => {
|
|
87
|
-
child.on(
|
|
87
|
+
child.on("exit", (code) => {
|
|
88
88
|
process.exit(code === null ? 1 : code);
|
|
89
89
|
});
|
|
90
|
-
child.on(
|
|
90
|
+
child.on("error", reject);
|
|
91
91
|
});
|
|
92
92
|
};
|
|
93
93
|
const execTs = async (connection_uri, args) => {
|
|
94
|
-
log.info(
|
|
95
|
-
const { runPsql } = await import(
|
|
94
|
+
log.info("Connecting to the database using embedded psql (TypeScript)...");
|
|
95
|
+
const { runPsql } = await import("../psql/index.js");
|
|
96
96
|
const code = await runPsql([connection_uri, ...args], {
|
|
97
97
|
stdin: process.stdin,
|
|
98
98
|
stdout: process.stdout,
|
|
@@ -103,9 +103,9 @@ const execTs = async (connection_uri, args) => {
|
|
|
103
103
|
export const psql = async (connection_uri, args = [], opts = {}) => {
|
|
104
104
|
const plan = await planPsql(opts);
|
|
105
105
|
await reportPsqlInvocation(plan);
|
|
106
|
-
if (plan.implementation ===
|
|
107
|
-
if (plan.reason ===
|
|
108
|
-
log.info(
|
|
106
|
+
if (plan.implementation === "ts") {
|
|
107
|
+
if (plan.reason === "fallback_no_native") {
|
|
108
|
+
log.info("psql binary not found on PATH; falling back to embedded TypeScript psql");
|
|
109
109
|
}
|
|
110
110
|
return execTs(connection_uri, args);
|
|
111
111
|
}
|
package/dist/utils/string.js
CHANGED
package/dist/utils/ui.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export const consumeNextMatching = (lines, matcher) => {
|
|
5
5
|
while (lines.length > 0) {
|
|
6
6
|
const line = lines.shift().trim();
|
|
7
|
-
if (line ===
|
|
7
|
+
if (line === "") {
|
|
8
8
|
continue;
|
|
9
9
|
}
|
|
10
10
|
if (matcher.test(line)) {
|
|
@@ -23,7 +23,7 @@ export const consumeBlockIfMatches = (lines, matcher) => {
|
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
25
25
|
let line = lines.shift();
|
|
26
|
-
while (line.trim() ===
|
|
26
|
+
while (line.trim() === "") {
|
|
27
27
|
line = lines.shift();
|
|
28
28
|
}
|
|
29
29
|
if (!matcher.test(line)) {
|
|
@@ -33,7 +33,7 @@ export const consumeBlockIfMatches = (lines, matcher) => {
|
|
|
33
33
|
result.push(line);
|
|
34
34
|
while (lines.length > 0) {
|
|
35
35
|
line = lines.shift();
|
|
36
|
-
if (line.trim() ===
|
|
36
|
+
if (line.trim() === "") {
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
39
39
|
result.push(line);
|
|
@@ -42,18 +42,18 @@ export const consumeBlockIfMatches = (lines, matcher) => {
|
|
|
42
42
|
};
|
|
43
43
|
export const splitColumns = (line) => {
|
|
44
44
|
const result = line.trim().split(/\s{2,}/);
|
|
45
|
-
result[1] = result[1] ??
|
|
45
|
+
result[1] = result[1] ?? "";
|
|
46
46
|
if (result.length > 2) {
|
|
47
|
-
result[1] = result.slice(1).join(
|
|
47
|
+
result[1] = result.slice(1).join(" ");
|
|
48
48
|
}
|
|
49
49
|
return result;
|
|
50
50
|
};
|
|
51
51
|
export const drawPointer = (width) => {
|
|
52
52
|
const result = [];
|
|
53
|
-
result.push(
|
|
53
|
+
result.push("└");
|
|
54
54
|
for (let i = 0; i < width - 4; i++) {
|
|
55
|
-
result.push(
|
|
55
|
+
result.push("─");
|
|
56
56
|
}
|
|
57
|
-
result.push(
|
|
58
|
-
return result.join(
|
|
57
|
+
result.push(">");
|
|
58
|
+
return result.join("");
|
|
59
59
|
};
|
package/dist/utils/zip.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { zipSync } from
|
|
1
|
+
import { zipSync } from "fflate";
|
|
2
2
|
// Zip the esbuild output (index.mjs) into the archive the Functions deploy endpoint
|
|
3
3
|
// expects. Compression level 6 matches the previous bundler.
|
|
4
4
|
export const zipBundle = (entries) => zipSync(entries, { level: 6 });
|
package/dist/writer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Table from
|
|
3
|
-
import
|
|
4
|
-
import { isCi } from
|
|
5
|
-
import { isObject, toSnakeCase } from
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import Table from "cli-table";
|
|
3
|
+
import YAML from "yaml";
|
|
4
|
+
import { isCi } from "./env.js";
|
|
5
|
+
import { isObject, toSnakeCase } from "./utils/string.js";
|
|
6
6
|
const writeYaml = (chunks) => {
|
|
7
7
|
return YAML.stringify(chunks.length === 1
|
|
8
8
|
? chunks[0].data
|
|
@@ -20,21 +20,21 @@ const writeJson = (chunks) => {
|
|
|
20
20
|
])), null, 2);
|
|
21
21
|
};
|
|
22
22
|
const writeTable = (chunks, out) => {
|
|
23
|
-
chunks.forEach(({ data, config: { emptyMessage, fields, title, renderColumns = {} } }) => {
|
|
23
|
+
chunks.forEach(({ data, config: { emptyMessage, fields, title, renderColumns = {} }, }) => {
|
|
24
24
|
const arrayData = Array.isArray(data) ? data : [data];
|
|
25
25
|
if (!arrayData.length && emptyMessage) {
|
|
26
|
-
out.write(
|
|
26
|
+
out.write("\n" + emptyMessage + "\n");
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
const fieldsFiltered = fields.filter((field) => arrayData.some((item) => item[field] !== undefined && item[field] !==
|
|
29
|
+
const fieldsFiltered = fields.filter((field) => arrayData.some((item) => item[field] !== undefined && item[field] !== ""));
|
|
30
30
|
const table = new Table({
|
|
31
31
|
style: {
|
|
32
|
-
head: [
|
|
32
|
+
head: ["green"],
|
|
33
33
|
},
|
|
34
34
|
head: fieldsFiltered.map((field) => field
|
|
35
|
-
.split(
|
|
35
|
+
.split("_")
|
|
36
36
|
.map((word) => word[0].toUpperCase() + word.slice(1))
|
|
37
|
-
.join(
|
|
37
|
+
.join(" ")),
|
|
38
38
|
});
|
|
39
39
|
arrayData.forEach((item) => {
|
|
40
40
|
table.push(fieldsFiltered.map((field) => {
|
|
@@ -43,17 +43,17 @@ const writeTable = (chunks, out) => {
|
|
|
43
43
|
return renderColumns[field]?.(item);
|
|
44
44
|
}
|
|
45
45
|
return Array.isArray(value)
|
|
46
|
-
? value.join(
|
|
46
|
+
? value.join("\n")
|
|
47
47
|
: isObject(value)
|
|
48
48
|
? JSON.stringify(value, null, 2)
|
|
49
|
-
: (value ??
|
|
49
|
+
: (value ?? "");
|
|
50
50
|
}));
|
|
51
51
|
});
|
|
52
52
|
if (title) {
|
|
53
|
-
out.write((isCi() ? title : chalk.bold(title)) +
|
|
53
|
+
out.write((isCi() ? title : chalk.bold(title)) + "\n");
|
|
54
54
|
}
|
|
55
55
|
out.write(table.toString());
|
|
56
|
-
out.write(
|
|
56
|
+
out.write("\n");
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
@@ -85,10 +85,10 @@ export const writer = (props) => {
|
|
|
85
85
|
if (args.length === 2) {
|
|
86
86
|
chunks.push({ data: args[0], config: args[1] });
|
|
87
87
|
}
|
|
88
|
-
if (props.output ==
|
|
88
|
+
if (props.output == "yaml") {
|
|
89
89
|
return out.write(writeYaml(chunks));
|
|
90
90
|
}
|
|
91
|
-
if (props.output ==
|
|
91
|
+
if (props.output == "json") {
|
|
92
92
|
return out.write(writeJson(chunks));
|
|
93
93
|
}
|
|
94
94
|
writeTable(chunks, out);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neonctl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.1",
|
|
4
4
|
"description": "CLI tool for Neon Serverless Postgres",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"which": "3.0.1",
|
|
52
52
|
"yaml": "2.4.5",
|
|
53
53
|
"yargs": "17.7.2",
|
|
54
|
+
"@neon/config": "0.8.1",
|
|
54
55
|
"@neon/sdk": "0.1.0",
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@neondatabase/env": "0.8.1"
|
|
56
|
+
"@neon/env": "0.9.0",
|
|
57
|
+
"@neon/config-runtime": "0.8.1"
|
|
58
58
|
},
|
|
59
59
|
"optionalDependencies": {
|
|
60
60
|
"esbuild": "0.28.0"
|
|
@@ -82,7 +82,6 @@
|
|
|
82
82
|
"node-pty": "1.1.0",
|
|
83
83
|
"oauth2-mock-server": "8.1.0",
|
|
84
84
|
"openapi-types": "12.1.3",
|
|
85
|
-
"prettier": "3.3.3",
|
|
86
85
|
"rollup": "3.29.4",
|
|
87
86
|
"strip-ansi": "7.1.0",
|
|
88
87
|
"tsx": "4.22.3",
|
|
@@ -114,8 +113,8 @@
|
|
|
114
113
|
"build": "pnpm generateParams && pnpm clean && tsc -p tsconfig.build.json && cp src/*.html ./dist",
|
|
115
114
|
"bundle": "node pkg.js",
|
|
116
115
|
"typecheck": "tsc --noEmit",
|
|
117
|
-
"lint": "pnpm typecheck && eslint src
|
|
118
|
-
"lint:fix": "pnpm typecheck && eslint src --fix
|
|
116
|
+
"lint": "pnpm typecheck && eslint src",
|
|
117
|
+
"lint:fix": "pnpm typecheck && eslint src --fix",
|
|
119
118
|
"test": "pnpm build && vitest run",
|
|
120
119
|
"test:ci": "pnpm build && vitest run",
|
|
121
120
|
"test:conformance": "vitest run --config tests/psql-conformance/vitest.config.ts"
|