neon 3.0.0 → 3.1.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 +70 -5
- package/dist/_chunks/auth_selection-DGgq6ifc.js +83 -0
- package/dist/_chunks/cmd_pipeline-CUbBO9U_.js +2818 -0
- package/dist/_chunks/credentials-MYdHdKah.js +188 -0
- package/dist/_chunks/env-NbA61JR3.js +585 -0
- package/dist/_chunks/env_services-Tz9G4JeT.js +531 -0
- package/dist/_chunks/paths-DMq0Lt7a.js +151 -0
- package/dist/_chunks/profiles-Ir29rqns.js +217 -0
- package/dist/_chunks/psql-DWH-kc69.js +2169 -0
- package/dist/_chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/_chunks/secure_file-BucZj4yQ.js +39 -0
- package/dist/analytics.js +163 -207
- package/dist/api.js +815 -758
- package/dist/auth.js +121 -141
- package/dist/auth_context.js +39 -53
- package/dist/cli.js +4 -7
- package/dist/commands/api.js +220 -250
- package/dist/commands/api_keys.js +251 -314
- package/dist/commands/auth.js +283 -328
- package/dist/commands/bootstrap.js +372 -437
- package/dist/commands/branches.js +304 -455
- package/dist/commands/bucket.js +374 -514
- package/dist/commands/checkout.js +213 -298
- package/dist/commands/config.js +573 -690
- package/dist/commands/connection_string.js +137 -165
- package/dist/commands/data_api.js +238 -260
- package/dist/commands/databases.js +67 -76
- package/dist/commands/deploy.js +31 -25
- package/dist/commands/dev.js +639 -719
- package/dist/commands/diff.js +156 -200
- package/dist/commands/env.js +255 -305
- package/dist/commands/functions.js +275 -355
- package/dist/commands/index.js +70 -65
- package/dist/commands/init.js +84 -119
- package/dist/commands/inspect.js +55 -55
- package/dist/commands/ip_allow.js +88 -120
- package/dist/commands/link.js +874 -1019
- package/dist/commands/logs.js +291 -0
- package/dist/commands/neon_auth.js +725 -933
- package/dist/commands/operations.js +34 -25
- package/dist/commands/orgs.js +28 -18
- package/dist/commands/profile.js +615 -846
- package/dist/commands/projects.js +313 -373
- package/dist/commands/psql.js +60 -58
- package/dist/commands/roles.js +55 -58
- package/dist/commands/schema_diff.js +87 -131
- package/dist/commands/set_context.js +34 -26
- package/dist/commands/snapshots.js +288 -413
- package/dist/commands/status.js +41 -37
- package/dist/commands/user.js +21 -10
- package/dist/commands/vpc_endpoints.js +85 -113
- package/dist/config.js +7 -6
- package/dist/config_format.js +50 -66
- package/dist/config_template.js +128 -157
- package/dist/context.js +183 -235
- package/dist/current_branch_fast_path.js +40 -49
- package/dist/dev/env.js +2 -446
- package/dist/dev/functions.js +54 -68
- package/dist/dev/inputs.js +46 -58
- package/dist/dev/runtime.js +135 -164
- package/dist/dev/websocket.js +766 -959
- package/dist/env.js +27 -33
- package/dist/env_file.js +118 -132
- package/dist/env_services.js +2 -51
- package/dist/errors.js +57 -68
- package/dist/functions_api.js +45 -43
- package/dist/help.js +189 -140
- package/dist/index.js +182 -257
- package/dist/init/agents.js +137 -118
- package/dist/init/auth.js +58 -68
- package/dist/init/bootstrap.js +325 -396
- package/dist/init/build_config.js +4 -2
- package/dist/init/detect_agent.js +56 -101
- package/dist/init/editors.js +35 -52
- package/dist/init/enrich_output.js +51 -66
- package/dist/init/extension.js +134 -171
- package/dist/init/inspect.js +179 -266
- package/dist/init/interactive.js +510 -622
- package/dist/init/neonctl.js +117 -168
- package/dist/init/orchestrate.js +157 -173
- package/dist/init/phases/auth.js +188 -202
- package/dist/init/phases/cleanup.js +23 -23
- package/dist/init/phases/db.js +251 -277
- package/dist/init/phases/getting_started.js +213 -223
- package/dist/init/phases/mcp.js +174 -224
- package/dist/init/phases/migrations.js +247 -248
- package/dist/init/phases/neon_auth.js +114 -133
- package/dist/init/phases/setup.js +546 -703
- package/dist/init/phases/skills.js +75 -86
- package/dist/init/phases/status.js +72 -67
- package/dist/init/resolve_context.js +102 -99
- package/dist/init/route_command.js +91 -98
- package/dist/init/skills.js +174 -218
- package/dist/init/vsix.js +77 -99
- package/dist/log.js +17 -16
- package/dist/neon_services.js +104 -129
- package/dist/parameters.gen.js +481 -471
- package/dist/pkg.js +17 -19
- package/dist/profile_keys.js +44 -47
- package/dist/psql/cli.js +44 -47
- package/dist/psql/command/cmd_cond.js +231 -406
- package/dist/psql/command/cmd_connect.js +557 -764
- package/dist/psql/command/cmd_copy.js +728 -984
- package/dist/psql/command/cmd_describe.js +1499 -1688
- package/dist/psql/command/cmd_format.js +733 -905
- package/dist/psql/command/cmd_io.js +2 -2193
- package/dist/psql/command/cmd_lo.js +297 -359
- package/dist/psql/command/cmd_meta.js +727 -878
- package/dist/psql/command/cmd_misc.js +138 -172
- package/dist/psql/command/cmd_pipeline.js +2 -1148
- package/dist/psql/command/cmd_restrict.js +119 -155
- package/dist/psql/command/cmd_show.js +529 -688
- package/dist/psql/command/dispatch.js +260 -325
- package/dist/psql/command/inputQueue.js +35 -33
- package/dist/psql/command/shared.js +49 -63
- package/dist/psql/complete/filenames.js +90 -133
- package/dist/psql/complete/index.js +59 -97
- package/dist/psql/complete/matcher.js +236 -300
- package/dist/psql/complete/psqlVars.js +218 -223
- package/dist/psql/complete/queries.js +159 -177
- package/dist/psql/complete/rules.js +1493 -2299
- package/dist/psql/core/common.js +2 -1253
- package/dist/psql/core/help.js +456 -546
- package/dist/psql/core/mainloop.js +692 -1303
- package/dist/psql/core/prompt.js +391 -408
- package/dist/psql/core/settings.js +429 -644
- package/dist/psql/core/sqlHelp.js +480 -554
- package/dist/psql/core/startup.js +2 -846
- package/dist/psql/core/syncVars.js +67 -110
- package/dist/psql/core/variables.js +156 -278
- package/dist/psql/describe/formatters.js +884 -1285
- package/dist/psql/describe/processNamePattern.js +173 -260
- package/dist/psql/describe/queries.js +1368 -2403
- package/dist/psql/describe/versionGate.js +32 -41
- package/dist/psql/index.js +2 -2030
- package/dist/psql/io/history.js +232 -271
- package/dist/psql/io/input.js +103 -108
- package/dist/psql/io/lineEditor/buffer.js +238 -319
- package/dist/psql/io/lineEditor/complete.js +135 -213
- package/dist/psql/io/lineEditor/filename.js +139 -148
- package/dist/psql/io/lineEditor/index.js +653 -870
- package/dist/psql/io/lineEditor/keymap.js +544 -702
- package/dist/psql/io/lineEditor/vt100.js +294 -341
- package/dist/psql/io/pgpass.js +158 -187
- package/dist/psql/io/pgservice.js +146 -183
- package/dist/psql/io/psqlrc.js +328 -403
- package/dist/psql/print/aligned.js +1020 -1683
- package/dist/psql/print/asciidoc.js +180 -214
- package/dist/psql/print/crosstab.js +281 -442
- package/dist/psql/print/csv.js +48 -70
- package/dist/psql/print/html.js +195 -226
- package/dist/psql/print/json.js +75 -88
- package/dist/psql/print/latex.js +291 -364
- package/dist/psql/print/pager.js +171 -242
- package/dist/psql/print/troff.js +194 -226
- package/dist/psql/print/unaligned.js +69 -95
- package/dist/psql/print/units.js +167 -169
- package/dist/psql/scanner/slash.js +428 -483
- package/dist/psql/scanner/sql.js +445 -889
- package/dist/psql/scanner/stringutils.js +309 -379
- package/dist/psql/types/index.js +8 -7
- package/dist/psql/types/scanner.js +25 -22
- package/dist/psql/wire/connection.js +2042 -2803
- package/dist/psql/wire/copy.js +84 -100
- package/dist/psql/wire/notify.js +39 -59
- package/dist/psql/wire/pipeline.js +305 -518
- package/dist/psql/wire/protocol.js +349 -417
- package/dist/psql/wire/sasl.js +180 -265
- package/dist/psql/wire/tls.js +400 -561
- package/dist/storage_api.js +115 -129
- package/dist/test_utils/fixtures.js +94 -113
- package/dist/test_utils/oauth_server.js +10 -7
- package/dist/test_utils/project_dir.js +33 -0
- package/dist/utils/ai_gateway_notice.js +131 -162
- package/dist/utils/api_enums.js +21 -28
- package/dist/utils/auth.js +10 -4
- package/dist/utils/branch_notice.js +20 -19
- package/dist/utils/branch_picker.js +83 -89
- package/dist/utils/cli_name.js +15 -12
- package/dist/utils/compute_units.js +20 -27
- package/dist/utils/config_diff.js +127 -158
- package/dist/utils/enrichers.js +95 -148
- package/dist/utils/esbuild.js +130 -189
- package/dist/utils/flags.js +35 -47
- package/dist/utils/formats.js +8 -15
- package/dist/utils/git_diff.js +69 -80
- package/dist/utils/inspect_db.js +101 -143
- package/dist/utils/inspect_queries.js +179 -142
- package/dist/utils/middlewares.js +39 -45
- package/dist/utils/openapi.js +87 -99
- package/dist/utils/package_manager.js +312 -110
- package/dist/utils/point_in_time.js +49 -53
- package/dist/utils/psql.js +89 -106
- package/dist/utils/service_picker.js +55 -58
- package/dist/utils/string.js +5 -5
- package/dist/utils/ui.js +38 -55
- package/dist/utils/write_sync.js +26 -35
- package/dist/utils/zip.js +4 -3
- package/dist/writer.js +67 -87
- package/package.json +11 -6
- package/dist/_shared/auth_selection.js +0 -86
- package/dist/_shared/credentials.js +0 -209
- package/dist/_shared/env-core/env.js +0 -558
- package/dist/_shared/env-core/reuse-secrets.js +0 -223
- package/dist/_shared/paths.js +0 -148
- package/dist/_shared/profiles.js +0 -276
- package/dist/_shared/secure_file.js +0 -43
package/dist/commands/index.js
CHANGED
|
@@ -1,66 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
import { t as auth_exports } from "./auth.js";
|
|
2
|
+
import { t as api_exports } from "./api.js";
|
|
3
|
+
import { t as api_keys_exports } from "./api_keys.js";
|
|
4
|
+
import { t as bootstrap_exports } from "./bootstrap.js";
|
|
5
|
+
import { t as branches_exports } from "./branches.js";
|
|
6
|
+
import { t as bucket_exports } from "./bucket.js";
|
|
7
|
+
import { t as env_exports } from "./env.js";
|
|
8
|
+
import { t as config_exports } from "./config.js";
|
|
9
|
+
import { t as projects_exports } from "./projects.js";
|
|
10
|
+
import { t as link_exports } from "./link.js";
|
|
11
|
+
import { t as checkout_exports } from "./checkout.js";
|
|
12
|
+
import { t as connection_string_exports } from "./connection_string.js";
|
|
13
|
+
import { t as data_api_exports } from "./data_api.js";
|
|
14
|
+
import { t as databases_exports } from "./databases.js";
|
|
15
|
+
import { t as deploy_exports } from "./deploy.js";
|
|
16
|
+
import { t as dev_exports } from "./dev.js";
|
|
17
|
+
import { t as diff_exports } from "./diff.js";
|
|
18
|
+
import { t as functions_exports } from "./functions.js";
|
|
19
|
+
import { t as init_exports } from "./init.js";
|
|
20
|
+
import { t as inspect_exports } from "./inspect.js";
|
|
21
|
+
import { t as ip_allow_exports } from "./ip_allow.js";
|
|
22
|
+
import { t as logs_exports } from "./logs.js";
|
|
23
|
+
import { t as neon_auth_exports } from "./neon_auth.js";
|
|
24
|
+
import { t as operations_exports } from "./operations.js";
|
|
25
|
+
import { t as orgs_exports } from "./orgs.js";
|
|
26
|
+
import { t as profile_exports } from "./profile.js";
|
|
27
|
+
import { t as psql_exports } from "./psql.js";
|
|
28
|
+
import { t as roles_exports } from "./roles.js";
|
|
29
|
+
import { t as set_context_exports } from "./set_context.js";
|
|
30
|
+
import { t as snapshots_exports } from "./snapshots.js";
|
|
31
|
+
import { t as status_exports } from "./status.js";
|
|
32
|
+
import { t as user_exports } from "./user.js";
|
|
33
|
+
import { t as vpc_endpoints_exports } from "./vpc_endpoints.js";
|
|
34
|
+
//#region src/commands/index.ts
|
|
35
|
+
var commands_default = [
|
|
36
|
+
auth_exports,
|
|
37
|
+
profile_exports,
|
|
38
|
+
api_keys_exports,
|
|
39
|
+
api_exports,
|
|
40
|
+
user_exports,
|
|
41
|
+
orgs_exports,
|
|
42
|
+
projects_exports,
|
|
43
|
+
ip_allow_exports,
|
|
44
|
+
vpc_endpoints_exports,
|
|
45
|
+
neon_auth_exports,
|
|
46
|
+
branches_exports,
|
|
47
|
+
databases_exports,
|
|
48
|
+
roles_exports,
|
|
49
|
+
operations_exports,
|
|
50
|
+
logs_exports,
|
|
51
|
+
snapshots_exports,
|
|
52
|
+
inspect_exports,
|
|
53
|
+
connection_string_exports,
|
|
54
|
+
psql_exports,
|
|
55
|
+
set_context_exports,
|
|
56
|
+
checkout_exports,
|
|
57
|
+
link_exports,
|
|
58
|
+
init_exports,
|
|
59
|
+
data_api_exports,
|
|
60
|
+
functions_exports,
|
|
61
|
+
dev_exports,
|
|
62
|
+
diff_exports,
|
|
63
|
+
config_exports,
|
|
64
|
+
status_exports,
|
|
65
|
+
deploy_exports,
|
|
66
|
+
env_exports,
|
|
67
|
+
bucket_exports,
|
|
68
|
+
bootstrap_exports
|
|
66
69
|
];
|
|
70
|
+
//#endregion
|
|
71
|
+
export { commands_default as default };
|
package/dist/commands/init.js
CHANGED
|
@@ -1,135 +1,100 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "../_chunks/rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { closeAnalytics, sendError } from "../analytics.js";
|
|
3
|
+
import { t as credentialInputs } from "../_chunks/auth_selection-DGgq6ifc.js";
|
|
3
4
|
import { detectAgent } from "../init/detect_agent.js";
|
|
4
5
|
import { enrichResponse } from "../init/enrich_output.js";
|
|
5
6
|
import { interactiveInit } from "../init/interactive.js";
|
|
6
7
|
import { orchestrate } from "../init/orchestrate.js";
|
|
7
8
|
import { routeDataStep } from "../init/route_command.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
.strict(false);
|
|
9
|
+
import { writeAllSync } from "../utils/write_sync.js";
|
|
10
|
+
//#region src/commands/init.ts
|
|
11
|
+
var init_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
builder: () => builder,
|
|
13
|
+
command: () => command,
|
|
14
|
+
describe: () => describe,
|
|
15
|
+
handler: () => handler
|
|
16
|
+
});
|
|
17
|
+
const command = "init";
|
|
18
|
+
const describe = "Initialize a project with Neon using your AI coding assistant";
|
|
19
|
+
const builder = (yargs) => yargs.option("context-file", { hidden: true }).option("agent", {
|
|
20
|
+
alias: "a",
|
|
21
|
+
type: "boolean",
|
|
22
|
+
default: false,
|
|
23
|
+
describe: "Enable agent/JSON mode (agent type is auto-detected)."
|
|
24
|
+
}).option("data", {
|
|
25
|
+
type: "string",
|
|
26
|
+
describe: "JSON object with a \"step\" field to route to a specific phase and phase-specific options."
|
|
27
|
+
}).option("skip-migrations", {
|
|
28
|
+
type: "boolean",
|
|
29
|
+
default: false,
|
|
30
|
+
describe: "Skip the migrations phase."
|
|
31
|
+
}).option("preview", {
|
|
32
|
+
type: "boolean",
|
|
33
|
+
default: false,
|
|
34
|
+
describe: "Enable preview features (e.g. project bootstrapping from templates)."
|
|
35
|
+
}).strict(false);
|
|
36
36
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
* The agent-facing half of `neon init` speaks JSON, and it speaks it on **stdout**:
|
|
38
|
+
* one object, no prefix, nothing else. `log.info` would prefix every line with
|
|
39
|
+
* `INFO: ` and send it to stderr, which is right for a diagnostic and wrong for the
|
|
40
|
+
* payload an agent is expected to parse.
|
|
41
|
+
*/
|
|
42
42
|
const writeAgentResponse = (result) => {
|
|
43
|
-
|
|
43
|
+
writeAllSync(1, `${JSON.stringify(enrichResponse(result), null, 2)}\n`);
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
* A failure has to arrive in the shape the caller asked for. An agent parses stdout and
|
|
47
|
+
* has no branch for "empty stdout, exit 1" — it cannot tell a broken credentials file
|
|
48
|
+
* from a phase that legitimately produced nothing — so the error goes out as JSON too.
|
|
49
|
+
*/
|
|
50
50
|
const writeAgentFailure = (error) => {
|
|
51
|
-
|
|
51
|
+
writeAllSync(1, `${JSON.stringify({
|
|
52
|
+
success: false,
|
|
53
|
+
error: error.message
|
|
54
|
+
}, null, 2)}\n`);
|
|
52
55
|
};
|
|
53
56
|
/** ` at position 12`, or nothing when the parser did not report one. */
|
|
54
57
|
const parsePosition = (parseError) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return at === null ? "" : ` at position ${at[1]}`;
|
|
58
|
+
const at = (parseError instanceof Error ? parseError.message : "").match(/at position (\d+)/);
|
|
59
|
+
return at === null ? "" : ` at position ${at[1]}`;
|
|
58
60
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
catch (parseError) {
|
|
97
|
-
// Neither the payload nor the parser's message may appear here. `--data`
|
|
98
|
-
// carries whatever the caller put in it — a connection string, an API key —
|
|
99
|
-
// and V8 quotes a window of the input around the syntax error, so both would
|
|
100
|
-
// travel into the error message, onto stdout, and into `sendError`'s
|
|
101
|
-
// analytics payload. `shared/cli-core/src/credentials.ts` discards the same
|
|
102
|
-
// message for the same reason. The position is a number and says enough.
|
|
103
|
-
throw new Error(`Invalid JSON in --data flag${parsePosition(parseError)}. Expected a JSON object.`);
|
|
104
|
-
}
|
|
105
|
-
if (typeof data.step === "string") {
|
|
106
|
-
writeAgentResponse(await routeDataStep(data, agent));
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (isAgentMode) {
|
|
111
|
-
writeAgentResponse(await orchestrate({
|
|
112
|
-
agent,
|
|
113
|
-
skipMigrations: argv.skipMigrations,
|
|
114
|
-
preview: argv.preview,
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
await interactiveInit({ preview: argv.preview });
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
const cause = error instanceof Error ? error : new Error(String(error));
|
|
123
|
-
if (isAgentMode) {
|
|
124
|
-
// Agent mode answers and exits here, so nothing else will report this. Attribute
|
|
125
|
-
// it to init and flush before exiting — `process.exit` drops in-flight events.
|
|
126
|
-
sendError(cause, "NEON_INIT_FAILED");
|
|
127
|
-
writeAgentFailure(cause);
|
|
128
|
-
await closeAnalytics();
|
|
129
|
-
process.exit(1);
|
|
130
|
-
}
|
|
131
|
-
// A human gets the top-level handler's single `ERROR: <message>` line on stderr, and
|
|
132
|
-
// its `sendError`. Reporting here as well would file one failure as two events.
|
|
133
|
-
throw cause;
|
|
134
|
-
}
|
|
61
|
+
const handler = async (argv) => {
|
|
62
|
+
const agent = (argv.agent || !process.stdin.isTTY ? detectAgent() : null) || void 0;
|
|
63
|
+
const isAgentMode = argv.agent || agent !== void 0;
|
|
64
|
+
try {
|
|
65
|
+
const selectedProfile = argv.profile?.trim() || credentialInputs().profileEnv.trim();
|
|
66
|
+
if (selectedProfile) {
|
|
67
|
+
const how = argv.profile?.trim() ? "--profile was passed, so" : "NEON_PROFILE is set, so";
|
|
68
|
+
throw new Error(`${how} \`neon init\` would run as the default account instead of "${selectedProfile}", and it does not support profile selection yet. Run it without one, or set the project up with \`neon --profile ${selectedProfile} link\`.`);
|
|
69
|
+
}
|
|
70
|
+
if (argv.data && isAgentMode) {
|
|
71
|
+
let data;
|
|
72
|
+
try {
|
|
73
|
+
data = JSON.parse(argv.data);
|
|
74
|
+
} catch (parseError) {
|
|
75
|
+
throw new Error(`Invalid JSON in --data flag${parsePosition(parseError)}. Expected a JSON object.`);
|
|
76
|
+
}
|
|
77
|
+
if (typeof data.step === "string") {
|
|
78
|
+
writeAgentResponse(await routeDataStep(data, agent));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (isAgentMode) writeAgentResponse(await orchestrate({
|
|
83
|
+
agent,
|
|
84
|
+
skipMigrations: argv.skipMigrations,
|
|
85
|
+
preview: argv.preview
|
|
86
|
+
}));
|
|
87
|
+
else await interactiveInit({ preview: argv.preview });
|
|
88
|
+
} catch (error) {
|
|
89
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
90
|
+
if (isAgentMode) {
|
|
91
|
+
sendError(cause, "NEON_INIT_FAILED");
|
|
92
|
+
writeAgentFailure(cause);
|
|
93
|
+
await closeAnalytics();
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
throw cause;
|
|
97
|
+
}
|
|
135
98
|
};
|
|
99
|
+
//#endregion
|
|
100
|
+
export { builder, command, describe, handler, init_exports as t };
|
package/dist/commands/inspect.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
+
import { t as __exportAll } from "../_chunks/rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { writer } from "../writer.js";
|
|
1
3
|
import { fillSingleProject } from "../utils/enrichers.js";
|
|
2
4
|
import { resolveConnectionUri, runInspectQuery } from "../utils/inspect_db.js";
|
|
3
|
-
import { INSPECT_QUERIES
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { INSPECT_QUERIES } from "../utils/inspect_queries.js";
|
|
6
|
+
//#region src/commands/inspect.ts
|
|
7
|
+
var inspect_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
aliases: () => aliases,
|
|
9
|
+
builder: () => builder,
|
|
10
|
+
command: () => command,
|
|
11
|
+
describe: () => describe,
|
|
12
|
+
handler: () => handler
|
|
13
|
+
});
|
|
14
|
+
const command = "inspect";
|
|
15
|
+
const describe = "Inspect a database's health and configuration";
|
|
16
|
+
const aliases = ["inspection"];
|
|
8
17
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
* `fillSingleProject` hits the API to auto-resolve a project. When the user
|
|
19
|
+
* passes `--db-url` we bypass the Neon API entirely, so skip it.
|
|
20
|
+
*/
|
|
12
21
|
const fillSingleProjectUnlessDbUrl = async (props) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return fillSingleProject(props);
|
|
22
|
+
if (props.dbUrl) return props;
|
|
23
|
+
return fillSingleProject(props);
|
|
17
24
|
};
|
|
18
25
|
const runSubcommand = async (name, props) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
emptyMessage: query.emptyMessage,
|
|
27
|
-
});
|
|
26
|
+
const query = INSPECT_QUERIES[name];
|
|
27
|
+
const connectionUri = props.dbUrl ?? (await resolveConnectionUri(props)).connectionUri;
|
|
28
|
+
const rows = await runInspectQuery(connectionUri, query.sql, { requiresExtension: query.requiresExtension });
|
|
29
|
+
writer(props).end(rows, {
|
|
30
|
+
fields: query.fields,
|
|
31
|
+
emptyMessage: query.emptyMessage
|
|
32
|
+
});
|
|
28
33
|
};
|
|
29
34
|
const dbBuilder = (argv) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.middleware(fillSingleProjectUnlessDbUrl);
|
|
55
|
-
for (const name of Object.keys(INSPECT_QUERIES)) {
|
|
56
|
-
builder = builder.command(name, INSPECT_QUERIES[name].describe, (yargs) => yargs, (args) => runSubcommand(name, args));
|
|
57
|
-
}
|
|
58
|
-
return builder;
|
|
35
|
+
let builder = argv.usage("$0 inspect db <sub-command> [options]").options({
|
|
36
|
+
"project-id": {
|
|
37
|
+
describe: "Project ID",
|
|
38
|
+
type: "string"
|
|
39
|
+
},
|
|
40
|
+
branch: {
|
|
41
|
+
describe: "Branch ID or name",
|
|
42
|
+
type: "string"
|
|
43
|
+
},
|
|
44
|
+
"database-name": {
|
|
45
|
+
describe: "Database name",
|
|
46
|
+
type: "string"
|
|
47
|
+
},
|
|
48
|
+
"role-name": {
|
|
49
|
+
describe: "Role name",
|
|
50
|
+
type: "string"
|
|
51
|
+
},
|
|
52
|
+
"db-url": {
|
|
53
|
+
describe: "Inspect any Postgres via a connection string, bypassing the Neon API (project/branch resolution is skipped)",
|
|
54
|
+
type: "string"
|
|
55
|
+
}
|
|
56
|
+
}).middleware(fillSingleProjectUnlessDbUrl);
|
|
57
|
+
for (const name of Object.keys(INSPECT_QUERIES)) builder = builder.command(name, INSPECT_QUERIES[name].describe, (yargs) => yargs, (args) => runSubcommand(name, args));
|
|
58
|
+
return builder;
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export const handler = (args) => {
|
|
64
|
-
return args;
|
|
60
|
+
const builder = (argv) => argv.usage("$0 inspect <sub-command> [options]").command("db", "Run a diagnostic query against a branch's Postgres", dbBuilder);
|
|
61
|
+
const handler = (args) => {
|
|
62
|
+
return args;
|
|
65
63
|
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { aliases, builder, command, describe, handler, inspect_exports as t };
|