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
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { applyContext, contextBranch, readContextFile } from
|
|
5
|
-
import { isCi } from
|
|
6
|
-
import { log } from
|
|
7
|
-
import { createBranch, pickBranchInteractively, } from
|
|
8
|
-
import { fillSingleProject } from
|
|
9
|
-
import { looksLikeBranchId } from
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { handler as linkHandler } from
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import prompts from "prompts";
|
|
3
|
+
import { isNeonApiError } from "../api.js";
|
|
4
|
+
import { applyContext, contextBranch, readContextFile } from "../context.js";
|
|
5
|
+
import { isCi } from "../env.js";
|
|
6
|
+
import { log } from "../log.js";
|
|
7
|
+
import { createBranch, pickBranchInteractively, } from "../utils/branch_picker.js";
|
|
8
|
+
import { fillSingleProject } from "../utils/enrichers.js";
|
|
9
|
+
import { looksLikeBranchId } from "../utils/formats.js";
|
|
10
|
+
import { applyPolicyOnCreate, createBranchFromPolicyOnCheckout, } from "./config.js";
|
|
11
|
+
import { autoPullEnvAfterPin } from "./env.js";
|
|
12
|
+
import { handler as linkHandler } from "./link.js";
|
|
13
13
|
// The positional is optional: omitting it in an interactive terminal opens a
|
|
14
14
|
// branch picker. In non-interactive contexts a missing branch is an error.
|
|
15
|
-
export const command =
|
|
16
|
-
export const describe =
|
|
15
|
+
export const command = "checkout [id|name]";
|
|
16
|
+
export const describe = "Pin a branch in the local context (.neon) so subsequent commands target it";
|
|
17
17
|
export const builder = (argv) => argv
|
|
18
|
-
.usage(
|
|
19
|
-
.positional(
|
|
20
|
-
describe:
|
|
21
|
-
type:
|
|
18
|
+
.usage("$0 checkout [id|name] [options]")
|
|
19
|
+
.positional("id", {
|
|
20
|
+
describe: "Branch name or id to check out. Omit to pick interactively from the list of branches.",
|
|
21
|
+
type: "string",
|
|
22
22
|
})
|
|
23
23
|
.options({
|
|
24
|
-
|
|
25
|
-
describe:
|
|
26
|
-
type:
|
|
24
|
+
"project-id": {
|
|
25
|
+
describe: "Project ID",
|
|
26
|
+
type: "string",
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
"env-pull": {
|
|
29
29
|
describe: "Pull the branch's Neon env vars (DATABASE_URL, …) into a local .env after " +
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type:
|
|
30
|
+
"checkout. On by default; use --no-env-pull to skip (e.g. when injecting env at " +
|
|
31
|
+
"runtime with `neon-env run` / `neon dev`).",
|
|
32
|
+
type: "boolean",
|
|
33
33
|
default: true,
|
|
34
34
|
},
|
|
35
35
|
})
|
|
36
36
|
.example([
|
|
37
37
|
[
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
"$0 checkout",
|
|
39
|
+
"Pick a branch interactively from the project in the closest .neon file",
|
|
40
40
|
],
|
|
41
41
|
[
|
|
42
|
-
|
|
42
|
+
"$0 checkout main",
|
|
43
43
|
'Pin the branch named "main" in the closest .neon file',
|
|
44
44
|
],
|
|
45
45
|
[
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
"$0 checkout br-cool-snow-12345678 --project-id project-id-123",
|
|
47
|
+
"Pin a branch by id for an explicit project",
|
|
48
48
|
],
|
|
49
49
|
]);
|
|
50
50
|
export const handler = async (props) => {
|
|
@@ -53,7 +53,7 @@ export const handler = async (props) => {
|
|
|
53
53
|
// Read straight from `.neon` (a name, no API call); silent when nothing is pinned yet.
|
|
54
54
|
const previousBranch = contextBranch(readContextFile(props.contextFile));
|
|
55
55
|
if (previousBranch) {
|
|
56
|
-
log.info(
|
|
56
|
+
log.info("%s Currently on branch %s", chalk.dim("→"), chalk.cyan.bold(previousBranch));
|
|
57
57
|
}
|
|
58
58
|
// Branch listing is project-scoped, so `projectId` is the only thing
|
|
59
59
|
// `checkout` actually needs. Resolve it through the standard chain
|
|
@@ -72,7 +72,7 @@ export const handler = async (props) => {
|
|
|
72
72
|
...(orgId ? { orgId } : {}),
|
|
73
73
|
branch: branchName,
|
|
74
74
|
});
|
|
75
|
-
log.info(
|
|
75
|
+
log.info("Checked out branch %s on project %s%s. Updated %s.", branchId, projectId, orgId ? ` (org ${orgId})` : "", props.contextFile);
|
|
76
76
|
// When checkout *created* the branch and a neon.ts exists, the branch was created straight
|
|
77
77
|
// from the policy (evaluated as a new branch) so its settings/infra are already applied —
|
|
78
78
|
// see `policyApplied`. The fallback below covers the case where the branch was created bare
|
|
@@ -100,11 +100,11 @@ const resolveBranchId = async (props, projectId) => {
|
|
|
100
100
|
.data.branches;
|
|
101
101
|
if (!props.id) {
|
|
102
102
|
const picked = await pickBranchInteractively(branches, {
|
|
103
|
-
message:
|
|
104
|
-
nonInteractiveMessage:
|
|
105
|
-
|
|
103
|
+
message: "Which branch would you like to check out?",
|
|
104
|
+
nonInteractiveMessage: "No branch specified. Pass a branch name or id (e.g. `neonctl checkout main`), " +
|
|
105
|
+
"or run interactively to pick one from a list.",
|
|
106
106
|
});
|
|
107
|
-
if (picked.kind ===
|
|
107
|
+
if (picked.kind === "existing") {
|
|
108
108
|
const existing = branches.find((b) => b.id === picked.branchId);
|
|
109
109
|
return {
|
|
110
110
|
branchId: picked.branchId,
|
|
@@ -145,8 +145,8 @@ const resolveBranchId = async (props, projectId) => {
|
|
|
145
145
|
}
|
|
146
146
|
log.error(notFoundMessage(ref, branches));
|
|
147
147
|
const { create } = await prompts({
|
|
148
|
-
type:
|
|
149
|
-
name:
|
|
148
|
+
type: "confirm",
|
|
149
|
+
name: "create",
|
|
150
150
|
message: `Branch "${ref}" does not exist. Create it now?`,
|
|
151
151
|
initial: true,
|
|
152
152
|
});
|
|
@@ -186,7 +186,7 @@ const createCheckoutBranch = async (props, projectId, name, branches) => {
|
|
|
186
186
|
};
|
|
187
187
|
const notFoundMessage = (ref, branches) => `Branch ${ref} not found.\nAvailable branches: ${branches
|
|
188
188
|
.map((b) => b.name)
|
|
189
|
-
.join(
|
|
189
|
+
.join(", ")}`;
|
|
190
190
|
/**
|
|
191
191
|
* Resolve the org id to heal into the context file.
|
|
192
192
|
*
|
|
@@ -209,7 +209,7 @@ const resolveOrgId = async (props, projectId) => {
|
|
|
209
209
|
if (isNeonApiError(err) && err.status === 401) {
|
|
210
210
|
throw err;
|
|
211
211
|
}
|
|
212
|
-
log.debug(
|
|
212
|
+
log.debug("checkout: could not resolve org id for project %s: %s", projectId, err instanceof Error ? err.message : String(err));
|
|
213
213
|
return undefined;
|
|
214
214
|
}
|
|
215
215
|
};
|
|
@@ -232,21 +232,21 @@ const resolveProjectId = async (props) => {
|
|
|
232
232
|
if (autoDetected) {
|
|
233
233
|
return autoDetected;
|
|
234
234
|
}
|
|
235
|
-
const missingProjectMessage =
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
const missingProjectMessage = "Could not determine which Neon project to check out a branch from. " +
|
|
236
|
+
"Provide one via the --project-id flag " +
|
|
237
|
+
"or a .neon file (created by `neonctl link` / `neonctl set-context`).";
|
|
238
238
|
if (isCi() || !process.stdout.isTTY) {
|
|
239
239
|
throw new Error(missingProjectMessage);
|
|
240
240
|
}
|
|
241
241
|
log.error(missingProjectMessage);
|
|
242
242
|
const { runLink } = await prompts({
|
|
243
|
-
type:
|
|
244
|
-
name:
|
|
245
|
-
message:
|
|
243
|
+
type: "confirm",
|
|
244
|
+
name: "runLink",
|
|
245
|
+
message: "Run `neonctl link` in the current folder to pick a project now?",
|
|
246
246
|
initial: true,
|
|
247
247
|
});
|
|
248
248
|
if (!runLink) {
|
|
249
|
-
throw new Error(
|
|
249
|
+
throw new Error("Aborted: no project selected. Re-run with --project-id or link a project first.");
|
|
250
250
|
}
|
|
251
251
|
await linkHandler({
|
|
252
252
|
...props,
|
|
@@ -257,7 +257,7 @@ const resolveProjectId = async (props) => {
|
|
|
257
257
|
});
|
|
258
258
|
const linked = readContextFile(props.contextFile);
|
|
259
259
|
if (!linked.projectId) {
|
|
260
|
-
throw new Error(
|
|
260
|
+
throw new Error("Linking did not produce a project id. Re-run `neonctl checkout` once the directory is linked.");
|
|
261
261
|
}
|
|
262
262
|
// Carry the freshly-linked org id forward so the merge below keeps it.
|
|
263
263
|
if (linked.orgId) {
|
|
@@ -283,7 +283,7 @@ const tryAutoDetectProject = async (props) => {
|
|
|
283
283
|
if (isNeonApiError(err)) {
|
|
284
284
|
throw err;
|
|
285
285
|
}
|
|
286
|
-
log.debug(
|
|
286
|
+
log.debug("checkout: could not auto-detect a single project: %s", err instanceof Error ? err.message : String(err));
|
|
287
287
|
return undefined;
|
|
288
288
|
}
|
|
289
289
|
};
|