neon 9.7.2 → 9.9.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 +4 -4
- package/dist/_chunks/{auth-DY5Bm7Ym.js → auth-CEb642X3.js} +20 -9
- package/dist/_chunks/{auth_selection-CwGLN9Qz.js → auth_selection-D81EvEz9.js} +1 -1
- package/dist/_chunks/{checkout-B_hB_ELY.js → checkout-9zUY4N8W.js} +2 -2
- package/dist/_chunks/{claim-Dv5wARrN.js → claim-D7fATGLw.js} +1 -1
- package/dist/_chunks/{config-DFj1Btk-.js → config-CUWOp44_.js} +1 -1
- package/dist/_chunks/{credential_io-DbeSh3Pl.js → credential_io-BHwacMdt.js} +1 -1
- package/dist/_chunks/{credentials-BMBNmW0t.js → credentials-KV1jlK-n.js} +13 -2
- package/dist/_chunks/{data_api-CHDwvMTG.js → data_api-BpSGbdZf.js} +1 -1
- package/dist/_chunks/{deploy-CVJIahZE.js → deploy-BUkXtacE.js} +1 -1
- package/dist/_chunks/{dev-CtIzg7vq.js → dev-Dp6LuAe2.js} +1 -1
- package/dist/_chunks/{git-CIBowi6T.js → git-BISnX9MB.js} +2 -2
- package/dist/_chunks/{incidents-D6rDn1g2.js → incidents-BSFkUu1P.js} +5 -1
- package/dist/_chunks/{init-AKhj0lHa.js → init-BSwLzxjX.js} +3 -3
- package/dist/_chunks/{link-mdFXf8dW.js → link-CfbTC-or.js} +11 -13
- package/dist/_chunks/{profile-Qoyql0AR.js → profile-BVkmMwHO.js} +68 -28
- package/dist/_chunks/{profiles-DTazQtjK.js → profiles-kpRUx7gU.js} +32 -2
- package/dist/_chunks/{status-DRWS1u6H.js → status-BM42rYe1.js} +1 -1
- package/dist/analytics.js +1 -1
- package/dist/auth_recovery.js +2 -2
- package/dist/commands/auth.js +1 -1
- package/dist/commands/checkout.js +1 -1
- package/dist/commands/claim.js +1 -1
- package/dist/commands/config.js +1 -1
- package/dist/commands/credentials.js +1 -1
- package/dist/commands/data_api.js +1 -1
- package/dist/commands/deploy.js +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/functions_new.js +1 -1
- package/dist/commands/git.js +1 -1
- package/dist/commands/incidents.js +1 -1
- package/dist/commands/index.js +14 -14
- package/dist/commands/init.js +1 -1
- package/dist/commands/link.js +1 -1
- package/dist/commands/profile.js +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/credential_io.js +1 -1
- package/dist/dev/runtime.js +1 -1
- package/dist/functions/scaffold.js +3 -1
- package/dist/hosts.js +130 -0
- package/dist/index.js +8 -6
- package/dist/init/auth.js +1 -1
- package/dist/init/chrome.js +1 -0
- package/dist/init/copy.js +1 -1
- package/dist/init/deploy.js +2 -2
- package/dist/init/detect.js +3 -3
- package/dist/init/link.js +4 -5
- package/dist/init/run.js +16 -10
- package/dist/retire_credential.js +1 -1
- package/dist/utils/middlewares.js +1 -1
- package/dist/utils/package_manager.js +30 -3
- package/dist/utils/staging.js +6 -16
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -898,7 +898,7 @@ The target directory must be empty unless you pass `--force` (a lone `.git` is i
|
|
|
898
898
|
|
|
899
899
|
`neon init` sets up coding agents and this directory for Neon. In a terminal it asks **Recommended** or **Custom**. `-y` is Recommended with no prompts. `-y` with `--skill`, MCP flags, `--no-agent-setup`, or `--claimable` is Custom using those flags.
|
|
900
900
|
|
|
901
|
-
Recommended installs the Neon plugin for every detected agent (global config, project folders, and the host CLI). Plugin-capable agents get the plugin; the rest get skills and MCP. If none are detected, it installs the default Neon skills for Cursor and Codex in this directory (`./.agents/skills`) and does not configure MCP. It then links a project when the CLI is authenticated, and writes
|
|
901
|
+
Recommended installs the Neon plugin for every detected agent (global config, project folders, and the host CLI). Plugin-capable agents get the plugin; the rest get skills and MCP. If none are detected, it installs the default Neon skills for Cursor and Codex in this directory (`./.agents/skills`) and does not configure MCP. It then links a project when the CLI is authenticated, and writes `neon.ts` using the package manager already in the directory. When init links an existing project, `neon.ts` is written from that branch's current services, as `neon config init --from-branch` does; a new project, an already-linked directory, or an offline pin gets the starter policy (Postgres only).
|
|
902
902
|
|
|
903
903
|
Unauthenticated `-y` skips linking and prints the next step: sign up at https://neon.com/signup, then `neon login`, `neon link`, or `neon claim create` (no account, expires in 72 hours unless claimed). `-y` never opens a browser. Without `-y`, a signed-out init with no terminal on stdin, stdout, or stderr stops at the link step with the sign-in error that names `neon login`. `-y` with `--project-id` or other account flags links when the CLI is already signed in. Without credentials, `--org-id`, `--project-id`, and `--branch` together write `.neon` offline (as `neon link --no-checks` does), and init prints `neon login` as the next step; Neon checks the IDs on the first command that reaches it. With only some of those flags, init still installs agent tooling and writes `neon.ts`, then prints `neon login` and the `neon link` command with those flags.
|
|
904
904
|
|
|
@@ -906,7 +906,7 @@ When init picks MCP auth (no `--mcp-auth`) and the CLI credential is an organiza
|
|
|
906
906
|
|
|
907
907
|
When the Neon plugin, skills, or MCP setup fails for an agent, init runs the remaining agent steps, links (or writes `.neon` offline), and writes `neon.ts` as it would have, then reports `Neon setup failed.` with the error and the `neon plugins`, `neon skills`, or `neon mcp` command to retry, and exits 1.
|
|
908
908
|
|
|
909
|
-
Custom asks how to add Neon to coding agents (plugin, skills and MCP separately, or skip), then how to get a project (sign in and link, or a claimable project when you are not signed in), then which services `neon.ts` should declare. Skills and MCP use separate agent pickers, and either can be skipped. Postgres is listed first as always included. The package manager is inferred from the directory; Custom asks only when none is detected. `--skill` selects skills (not the plugin) and skips that picker. MCP flags (`--mcp-config-location`, `--mcp-auth`, `--mcp-project-scoped`) select skills and MCP. `--mcp-config-location` is where the config is written: `global` maps to `neon mcp`, and `project` maps to `neon mcp --project`. With `-y`, the location defaults to `global`; interactive Custom asks. If some selected agents cannot write that location, init warns and skips MCP for those agents while continuing with the supported agents. It fails when none of the selected agents support the location. `--mcp-project-scoped` limits MCP tools to the linked Neon project by passing its ID to `neon mcp --project-id`. Omitted is false, including in Custom; there is no prompt. `--no-agent-setup` skips agent setup.
|
|
909
|
+
Custom asks how to add Neon to coding agents (plugin, skills and MCP separately, or skip), then how to get a project (sign in and link, or a claimable project when you are not signed in), then which services `neon.ts` should declare (skipped when it linked an existing project, whose `neon.ts` is written from the branch). Skills and MCP use separate agent pickers, and either can be skipped. Postgres is listed first as always included. The package manager is inferred from the directory; Custom asks only when none is detected. `--skill` selects skills (not the plugin) and skips that picker. MCP flags (`--mcp-config-location`, `--mcp-auth`, `--mcp-project-scoped`) select skills and MCP. `--mcp-config-location` is where the config is written: `global` maps to `neon mcp`, and `project` maps to `neon mcp --project`. With `-y`, the location defaults to `global`; interactive Custom asks. If some selected agents cannot write that location, init warns and skips MCP for those agents while continuing with the supported agents. It fails when none of the selected agents support the location. `--mcp-project-scoped` limits MCP tools to the linked Neon project by passing its ID to `neon mcp --project-id`. Omitted is false, including in Custom; there is no prompt. `--no-agent-setup` skips agent setup.
|
|
910
910
|
|
|
911
911
|
Empty directories are set up in place. `neon init` does not scaffold starter files.
|
|
912
912
|
|
|
@@ -924,7 +924,7 @@ Without a TTY, pass `-y` or enough flags to answer every question. `-y` alone is
|
|
|
924
924
|
|
|
925
925
|
`--project-id`, `--org-id`, `--project-name`, `--region-id`, and `--branch` are forwarded to `link`. They select linking. A linked directory is not relinked unless you pass one of those flags.
|
|
926
926
|
|
|
927
|
-
Init pulls the branch's env vars once, after the `neon.ts` step, so the pull includes what `neon.ts` declares. The AI Gateway and Functions need no deploy and are pulled immediately. When `neon.ts` declares Auth, the Data API, Object Storage, or Realtime, init pulls Postgres, plus the AI Gateway and the scaffolded function's URL when declared. `neon deploy` provisions the rest and pulls their env vars. An existing `neon.ts` is pulled by `link` as usual.
|
|
927
|
+
Init pulls the branch's env vars once, after the `neon.ts` step, so the pull includes what `neon.ts` declares. A `neon.ts` written from the branch declares only services the branch already runs, so all of them are pulled. The AI Gateway and Functions need no deploy and are pulled immediately. When `neon.ts` declares Auth, the Data API, Object Storage, or Realtime, init pulls Postgres, plus the AI Gateway and the scaffolded function's URL when declared. `neon deploy` provisions the rest and pulls their env vars. An existing `neon.ts` is pulled by `link` as usual.
|
|
928
928
|
|
|
929
929
|
A failed step stops the rest. `--profile` and `--config-dir` are forwarded to each child. `--output json` and `--output yaml` are refused; the commands init runs print their own output.
|
|
930
930
|
|
|
@@ -1175,7 +1175,7 @@ neon credentials rotate nak_live_…
|
|
|
1175
1175
|
neon credentials revoke nak_live_…
|
|
1176
1176
|
```
|
|
1177
1177
|
|
|
1178
|
-
`create` always issues a customer-managed (`user`) credential. `--scope` is repeatable; `--help` lists the values. `reveal` and `rotate` print `api_token` and `s3_secret_access_key`. Rotation keeps the same `token_id` (it is the `AWS_ACCESS_KEY_ID`) and is not idempotent: a retry after a lost response mints another secret.
|
|
1178
|
+
`create` always issues a customer-managed (`user`) credential. `--scope` is repeatable; `--help` lists the values. `reveal` and `rotate` print `api_token` and `s3_secret_access_key`. `reveal` also prints the credential's `name` and `scopes` from `list`, plus its `branch_id` in JSON and YAML output. `branch_id` is the branch the credential was issued on, which can be an ancestor of `--branch`. When `--branch` does not list the credential, `reveal` warns and prints no `branch_id`. Rotation keeps the same `token_id` (it is the `AWS_ACCESS_KEY_ID`) and is not idempotent: a retry after a lost response mints another secret.
|
|
1179
1179
|
|
|
1180
1180
|
All sub-commands honor the [global options](#global-options), including `--output json|yaml|table`.
|
|
1181
1181
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
|
|
2
|
-
import { a as OAUTH, i as API_KEY, l as interpretCredentials, s as credentialLabel, t as storeFor } from "./credential_io-
|
|
2
|
+
import { a as OAUTH, i as API_KEY, l as interpretCredentials, s as credentialLabel, t as storeFor } from "./credential_io-BHwacMdt.js";
|
|
3
3
|
import { hasTerminal, isCi } from "../env.js";
|
|
4
4
|
import { log } from "../log.js";
|
|
5
5
|
import { withExclusiveLock } from "../refresh_lock.js";
|
|
@@ -7,12 +7,13 @@ import { getApiClient, isNeonApiError } from "../api.js";
|
|
|
7
7
|
import { setAuthContext } from "../auth_context.js";
|
|
8
8
|
import { a as isOwnedCredentialPath } from "./paths-B55ZfOg1.js";
|
|
9
9
|
import { currentContextFile, isAskCommand, isClaimCommand, isConfigAdd, isConfigInit, isCurrentBranchProbe, isDocsCommand, isFeedbackCommand, isFunctionsTemplateCommand, isGitLocalCommand, isIncidentsCommand, isInspectDbUrl, isMcpCommand, isMcpOauth, isPluginsCommand, isProfileCommand, isSkillsCommand, isUnfollowedGitHookSync, readContextFile } from "../context.js";
|
|
10
|
-
import { _ as
|
|
10
|
+
import { _ as readProfiles, b as upsertProfile, f as locationForName, g as profilesUsingPath, i as assertValidProfileName, m as newProfileLocation, n as KEYRING_CREDENTIALS, p as locationOf, r as assertProfilesUsable, t as DEFAULT_PROFILE, u as isKeyringPointer, v as resolveProfile, y as selectProfileName } from "./profiles-kpRUx7gU.js";
|
|
11
11
|
import { extendTokenSet } from "../utils/auth.js";
|
|
12
12
|
import { AuthRefreshError, auth, classifyRefreshFailure, refreshToken } from "../auth.js";
|
|
13
|
-
import { i as selectCredential, n as displacedProfileWarning, t as credentialInputs } from "./auth_selection-
|
|
13
|
+
import { i as selectCredential, n as displacedProfileWarning, t as credentialInputs } from "./auth_selection-D81EvEz9.js";
|
|
14
14
|
import { ClaimableClient, ClaimableServiceError } from "../claimable/api.js";
|
|
15
15
|
import { assertionHasExpired, claimableCredentialsExist, claimableCredentialsPath, readLinkedClaimableCredentials, shouldUseClaimableCredentials } from "../claimable/state.js";
|
|
16
|
+
import { hostUpdateFor, hostsForProfile, issuingHosts } from "../hosts.js";
|
|
16
17
|
import { readOutgoingCredential, retirePreviousCredential } from "../retire_credential.js";
|
|
17
18
|
import { getCliName } from "../utils/cli_name.js";
|
|
18
19
|
import { helpEpilogue, helpWidth, wrapHelpText } from "../utils/help_text.js";
|
|
@@ -59,9 +60,14 @@ const builder = (yargs) => yargs.option("context-file", { hidden: true }).option
|
|
|
59
60
|
type: "boolean"
|
|
60
61
|
}).example("$0 login", "Sign in with a browser").example("$0 login --profile work", "Save a browser session in profile work").example("$0 projects list --api-key \"$KEY\"", "Use an existing API key for this command").example("NEON_API_KEY=\"$KEY\" $0 projects list", "Use an existing API key from the environment").example("$0 profile create agent --api-key \"$KEY\"", "Store an existing API key").example("echo \"$KEY\" | $0 profile create agent --api-key -", "Store a key read from stdin").example("$0 profile create ci --mint", "Sign in once in a browser and store a new API key").epilogue(authHelpEpilogue());
|
|
61
62
|
const handler = async (args) => {
|
|
62
|
-
|
|
63
|
+
const target = selectProfileName(args.profile);
|
|
64
|
+
await authFlow({
|
|
65
|
+
...args,
|
|
66
|
+
...hostsForProfile(args.configDir, target),
|
|
67
|
+
hosts: hostUpdateFor(target)
|
|
68
|
+
});
|
|
63
69
|
};
|
|
64
|
-
const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "force-auth": forceAuthKebab, allowUnsafeTls, profile, keyring }) => {
|
|
70
|
+
const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "force-auth": forceAuthKebab, allowUnsafeTls, profile, keyring, hosts }) => {
|
|
65
71
|
const profileName = selectProfileName(profile);
|
|
66
72
|
const isNamed = profileName !== DEFAULT_PROFILE;
|
|
67
73
|
if (isNamed) assertValidProfileName(profileName);
|
|
@@ -75,6 +81,10 @@ const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "f
|
|
|
75
81
|
let previousFile;
|
|
76
82
|
let previousWasKeyring = false;
|
|
77
83
|
let previousOutgoing = null;
|
|
84
|
+
const previousHosts = issuingHosts(configDir, profileName, {
|
|
85
|
+
apiHost,
|
|
86
|
+
oauthHost
|
|
87
|
+
});
|
|
78
88
|
try {
|
|
79
89
|
const previous = resolveProfile(configDir, profileName);
|
|
80
90
|
previousWasKeyring = previous.storage === "keyring";
|
|
@@ -103,7 +113,8 @@ const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "f
|
|
|
103
113
|
upsertProfile(configDir, profileName, {
|
|
104
114
|
credentials: at.storage === "keyring" ? KEYRING_CREDENTIALS : at.path,
|
|
105
115
|
...identity.email ? { label: identity.email } : {},
|
|
106
|
-
...identity.id ? { userId: identity.id } : {}
|
|
116
|
+
...identity.id ? { userId: identity.id } : {},
|
|
117
|
+
...hosts
|
|
107
118
|
});
|
|
108
119
|
} catch (err) {
|
|
109
120
|
if (at.storage === "keyring" && !previousWasKeyring) {
|
|
@@ -113,8 +124,7 @@ const authFlow = async ({ configDir, oauthHost, clientId, apiHost, forceAuth, "f
|
|
|
113
124
|
throw err instanceof Error ? err : new Error(String(err));
|
|
114
125
|
}
|
|
115
126
|
if (at.storage === "keyring") await retirePreviousCredential({
|
|
116
|
-
|
|
117
|
-
oauthHost,
|
|
127
|
+
...previousHosts,
|
|
118
128
|
clientId,
|
|
119
129
|
...allowUnsafeTls ? { allowUnsafeTls } : {}
|
|
120
130
|
}, profileName, previousOutgoing);
|
|
@@ -493,7 +503,8 @@ const ensureAuth = async (props) => {
|
|
|
493
503
|
if (!(props.forceAuth ?? props["force-auth"]) && !isCi() && !hasTerminal()) throw new Error(`Not signed in: profile "${selection.profile}" ${state}, and this shell has no terminal to start a browser sign-in from. ${signInHint}`);
|
|
494
504
|
const apiKey = await authFlow({
|
|
495
505
|
...props,
|
|
496
|
-
profile: selection.profile
|
|
506
|
+
profile: selection.profile,
|
|
507
|
+
hosts: hostUpdateFor(selection.profile)
|
|
497
508
|
});
|
|
498
509
|
props.apiKey = apiKey;
|
|
499
510
|
props.apiClient = getApiClient({
|
|
@@ -12,8 +12,8 @@ import { fillSingleProject, listAllProjectBranches } from "../utils/enrichers.js
|
|
|
12
12
|
import { buildCheckoutEvent, readGitContext } from "../utils/git.js";
|
|
13
13
|
import { buildHookBranch, loadHookConfig, resolveHookEnv, runCheckoutAfterHook, runCheckoutBeforeHook, runCreateAfterHook, runCreateBeforeHook } from "../utils/hooks.js";
|
|
14
14
|
import { n as autoPullEnvAfterPin } from "./env-DxcO3oJk.js";
|
|
15
|
-
import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-
|
|
16
|
-
import { i as handler$1 } from "./link-
|
|
15
|
+
import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-CUWOp44_.js";
|
|
16
|
+
import { i as handler$1 } from "./link-CfbTC-or.js";
|
|
17
17
|
import chalk from "chalk";
|
|
18
18
|
import prompts from "prompts";
|
|
19
19
|
// src/commands/checkout.ts
|
|
@@ -3,7 +3,7 @@ import { isCi } from "../env.js";
|
|
|
3
3
|
import { log } from "../log.js";
|
|
4
4
|
import { getApiClient } from "../api.js";
|
|
5
5
|
import { applyContext, contextBranch, readContextFile } from "../context.js";
|
|
6
|
-
import { t as credentialInputs } from "./auth_selection-
|
|
6
|
+
import { t as credentialInputs } from "./auth_selection-D81EvEz9.js";
|
|
7
7
|
import { ClaimableClient, ClaimableServiceError } from "../claimable/api.js";
|
|
8
8
|
import { assertionHasExpired, listClaimableCredentials, readClaimableCredentials, readLinkedClaimableCredentials, removeClaimableCredentials, writeClaimableCredentials } from "../claimable/state.js";
|
|
9
9
|
import { NEON_SERVICES, deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOption } from "../neon_services.js";
|
|
@@ -7,7 +7,7 @@ import "../config.js";
|
|
|
7
7
|
import { contextBranch, ensureDirectoryGitignored, readContextFile } from "../context.js";
|
|
8
8
|
import { DetailedError } from "../errors.js";
|
|
9
9
|
import { getCliName } from "../utils/cli_name.js";
|
|
10
|
-
import { l as existingApiClient } from "./auth-
|
|
10
|
+
import { l as existingApiClient } from "./auth-CEb642X3.js";
|
|
11
11
|
import { NEON_SERVICES, NEON_SERVICE_LABELS, deprecatedServiceMessage, servicesFlagValue, servicesOption } from "../neon_services.js";
|
|
12
12
|
import { FUNCTION_FILENAME, FUNCTION_SLUG, FUNCTION_TEMPLATE, REQUIRED_PACKAGES, dataApiChoiceFromView, parseConfigInitServices, renderFunctionSource, renderNeonConfig, renderNeonConfigFromView } from "../config_template.js";
|
|
13
13
|
import { TYPESCRIPT_EXTENSION, asRelativeModulePath, editNeonConfig } from "../config_edit.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as writeSecretFile } from "./secure_file-Caskdohg.js";
|
|
2
2
|
import { a as isOwnedCredentialPath } from "./paths-B55ZfOg1.js";
|
|
3
|
-
import {
|
|
3
|
+
import { S as CRED_STORAGE_KEYRING, h as profilesFilePath, x as CRED_STORAGE_FILE } from "./profiles-kpRUx7gU.js";
|
|
4
4
|
import { tryLoadKeyring } from "../keyring.js";
|
|
5
5
|
import { existsSync, readFileSync, rmSync } from "node:fs";
|
|
6
6
|
import { dirname } from "node:path";
|
|
@@ -127,10 +127,21 @@ const create = async (props) => {
|
|
|
127
127
|
}));
|
|
128
128
|
reportSecrets(props, data, "Store these secrets now: they are not shown again unless you run neon credentials reveal.");
|
|
129
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* The reveal endpoint returns only the secrets, and it reveals any credential in the
|
|
132
|
+
* project whatever branch the path names. The branch listing supplies `branch_id`,
|
|
133
|
+
* `name`, and `scopes`, so scripts can check which branch the secret belongs to.
|
|
134
|
+
*/
|
|
130
135
|
const reveal = async (props) => {
|
|
131
136
|
const branchId = await branchIdFromProps(props);
|
|
132
|
-
const { data } = await withCredentialNotFound(props.tokenId, branchId, () => props.apiClient.revealCredential(props.projectId, branchId, props.tokenId));
|
|
133
|
-
|
|
137
|
+
const { data: secret } = await withCredentialNotFound(props.tokenId, branchId, () => props.apiClient.revealCredential(props.projectId, branchId, props.tokenId));
|
|
138
|
+
const { data: listing } = await props.apiClient.listCredentials(props.projectId, branchId);
|
|
139
|
+
const meta = listing.credentials.find((c) => c.token_id === secret.token_id);
|
|
140
|
+
reportSecrets(props, meta ? {
|
|
141
|
+
...meta,
|
|
142
|
+
...secret
|
|
143
|
+
} : secret, "These are live secrets. Treat them like a password.");
|
|
144
|
+
if (!meta) log.warning(`Credential ${secret.token_id} is not listed on branch ${branchId}, so the output has no branch_id, name, or scopes. Confirm which branch issued it before you use it on ${branchId}.`);
|
|
134
145
|
};
|
|
135
146
|
const rotate = async (props) => {
|
|
136
147
|
const branchId = await branchIdFromProps(props);
|
|
@@ -101,7 +101,7 @@ const builder = (argv) => argv.usage("$0 data-api <sub-command> [options]").opti
|
|
|
101
101
|
},
|
|
102
102
|
"add-default-grants": {
|
|
103
103
|
type: "boolean",
|
|
104
|
-
describe: "Grant
|
|
104
|
+
describe: "Grant authenticated users read and write access to public-schema tables, including tables the database owner creates later"
|
|
105
105
|
},
|
|
106
106
|
"skip-auth-schema": {
|
|
107
107
|
type: "boolean",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
|
|
2
2
|
import { fillSingleProject } from "../utils/enrichers.js";
|
|
3
|
-
import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-
|
|
3
|
+
import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-CUWOp44_.js";
|
|
4
4
|
import { DEPLOY_COMMANDS_EPILOGUE } from "../commands/deploy_help.js";
|
|
5
5
|
// src/commands/deploy.ts
|
|
6
6
|
var deploy_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -7,7 +7,7 @@ import { t as NEON_DEV_FUNCTION_PORTS } from "./env-EJU-0InB.js";
|
|
|
7
7
|
import { branchIdResolve } from "../utils/enrichers.js";
|
|
8
8
|
import { bundleEntry } from "../utils/esbuild.js";
|
|
9
9
|
import { a as resolveDevEnv } from "./env-CFBmcKyo.js";
|
|
10
|
-
import { f as envFlag } from "./config-
|
|
10
|
+
import { f as envFlag } from "./config-CUWOp44_.js";
|
|
11
11
|
import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
|
|
12
12
|
import { resolveWatchInputs } from "../dev/inputs.js";
|
|
13
13
|
import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -5,8 +5,8 @@ import { CONTEXT_FILE, contextBranch, gitBranchMap, gitBranchMapping, isUnfollow
|
|
|
5
5
|
import { writer } from "../writer.js";
|
|
6
6
|
import { neonSafeBranchName } from "../utils/branch_name.js";
|
|
7
7
|
import { currentGitBranch, gitPull, gitRepoRoot, hasUpstream, installPostCheckoutHook, isGitRepo, isManagedHook, localGitBranches, postCheckoutHookPath, readGitContext, removePostCheckoutHook } from "../utils/git.js";
|
|
8
|
-
import { o as quoteFlagValue } from "./link-
|
|
9
|
-
import { o as handler$1 } from "./checkout-
|
|
8
|
+
import { o as quoteFlagValue } from "./link-CfbTC-or.js";
|
|
9
|
+
import { o as handler$1 } from "./checkout-9zUY4N8W.js";
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
11
11
|
import { join } from "node:path";
|
|
12
12
|
import chalk from "chalk";
|
|
@@ -13,7 +13,11 @@ var incidents_exports = /* @__PURE__ */ __exportAll({
|
|
|
13
13
|
});
|
|
14
14
|
const command = "incidents";
|
|
15
15
|
const describe = "Show open Neon incidents and maintenance";
|
|
16
|
-
const builder = (argv) => argv.usage("$0 incidents").strict().check(noPassthrough("incidents")).example("$0 incidents", describe).example("$0 incidents -o json", "Print the full report as JSON").epilogue([
|
|
16
|
+
const builder = (argv) => argv.usage("$0 incidents").strict().check(noPassthrough("incidents")).example("$0 incidents", describe).example("$0 incidents -o json", "Print the full report as JSON").epilogue([
|
|
17
|
+
"",
|
|
18
|
+
"Reads the public status page at https://neonstatus.com. No login or linked project is needed.",
|
|
19
|
+
"Updated At (`updated_at` in JSON) is when the status page last updated the overall status, not when this command fetched it."
|
|
20
|
+
].join("\n"));
|
|
17
21
|
const handler = async (props) => {
|
|
18
22
|
const report = await fetchReport();
|
|
19
23
|
if (props.output === "json" || props.output === "yaml") {
|
|
@@ -24,7 +24,7 @@ const builder = (yargs) => yargs.usage("$0 init [options]").option("context-file
|
|
|
24
24
|
alias: "y",
|
|
25
25
|
type: "boolean",
|
|
26
26
|
default: false,
|
|
27
|
-
describe: "Skip prompts. Alone: Recommended (detected agents, link when authenticated,
|
|
27
|
+
describe: "Skip prompts. Alone: Recommended (detected agents, link when authenticated, neon.ts). With --skill, MCP flags, --no-agent-setup, or --claimable: Custom using those flags"
|
|
28
28
|
}).option("agent-setup", {
|
|
29
29
|
type: "boolean",
|
|
30
30
|
default: true,
|
|
@@ -48,7 +48,7 @@ const builder = (yargs) => yargs.usage("$0 init [options]").option("context-file
|
|
|
48
48
|
describe: "Link a Neon project during setup. Use --no-link to skip without being asked"
|
|
49
49
|
}).option("config", {
|
|
50
50
|
type: "boolean",
|
|
51
|
-
describe: "Create neon.ts after linking. Use --no-config to skip. Omitted in Custom: you will be asked"
|
|
51
|
+
describe: "Create neon.ts after linking: from the branch's services when init links an existing project, otherwise the starter policy. Use --no-config to skip. Omitted in Custom: you will be asked"
|
|
52
52
|
}).option("services", servicesOption({
|
|
53
53
|
key: "services",
|
|
54
54
|
allowed: NEON_SERVICES,
|
|
@@ -99,7 +99,7 @@ const builder = (yargs) => yargs.usage("$0 init [options]").option("context-file
|
|
|
99
99
|
alias: "o",
|
|
100
100
|
hidden: true,
|
|
101
101
|
describe: "Not supported; the commands init runs print their own output"
|
|
102
|
-
}).example("$0 init", "Recommended or Custom setup").example("$0 init -y", "Recommended setup without prompts").example("$0 init -y --skill neon --mcp-auth oauth --mcp-config-location project", "Custom: those skills and MCP, Recommended defaults for the rest").example("$0 init --no-agent-setup --claimable", "Skip agent setup and create a claimable project").example("$0 init --agent cursor --agent claude-code", "Skip agent selection; install tooling for those agents").epilogue(helpEpilogue("Recommended setup installs tooling for detected coding agents, links a Neon project when the CLI is authenticated or the session is interactive, and writes
|
|
102
|
+
}).example("$0 init", "Recommended or Custom setup").example("$0 init -y", "Recommended setup without prompts").example("$0 init -y --skill neon --mcp-auth oauth --mcp-config-location project", "Custom: those skills and MCP, Recommended defaults for the rest").example("$0 init --no-agent-setup --claimable", "Skip agent setup and create a claimable project").example("$0 init --agent cursor --agent claude-code", "Skip agent selection; install tooling for those agents").epilogue(helpEpilogue("Recommended setup installs tooling for detected coding agents, links a Neon project when the CLI is authenticated or the session is interactive, and writes neon.ts: from the branch's current services when it links an existing project, otherwise the starter policy.", "init sets up the current directory in place. It does not scaffold starter files.", "-y alone is Recommended. -y with --skill, MCP flags, --no-agent-setup, or --claimable is Custom: those flags, Recommended defaults for unanswered questions. -y never opens a browser.", "--skill selects skills (not the plugin). MCP flags select skills and MCP. --no-agent-setup skips agent setup. --agent without those flags installs the plugin (and skills/MCP for agents the plugin cannot cover).", "Without a TTY, pass -y or enough flags to answer every question.", "--agent / -a is forwarded to plugins, or to skills and mcp. It skips agent selection, including with -y.", helpCsv("Plugin agents", initPluginAgents()), helpCsv("Skills and MCP agents", initSkillsMcpAgents()), helpCsv("Skills", listSkillIds()))).check((argv) => {
|
|
103
103
|
if (argv.data !== void 0) throw new Error(removedProtocol());
|
|
104
104
|
if (argv.help !== true && (argv.output === "json" || argv.output === "yaml")) throw new Error(`\`${getCliName()} init\` does not support --output. The commands it runs print their own output.`);
|
|
105
105
|
return true;
|
|
@@ -14,7 +14,7 @@ import { createBranch, pickBranchInteractively } from "../utils/branch_picker.js
|
|
|
14
14
|
import { looksLikeBranchId } from "../utils/formats.js";
|
|
15
15
|
import { listAllProjectBranches } from "../utils/enrichers.js";
|
|
16
16
|
import { n as autoPullEnvAfterPin } from "./env-DxcO3oJk.js";
|
|
17
|
-
import { h as initCmd } from "./config-
|
|
17
|
+
import { h as initCmd } from "./config-CUWOp44_.js";
|
|
18
18
|
import { formatLinkSummary } from "../commands/link_output.js";
|
|
19
19
|
import { r as REGIONS } from "./projects-a3X4OFEJ.js";
|
|
20
20
|
import prompts from "prompts";
|
|
@@ -106,6 +106,7 @@ const builder = (argv) => argv.usage("$0 link [options]").options({
|
|
|
106
106
|
["$0 link --no-checks --org-id org-… --project-id polished-snowflake-12345678 --branch main", "Write the context offline (no API calls, no verification)"],
|
|
107
107
|
["$0 link --clear", "Forget the current org/project/branch context"]
|
|
108
108
|
]).epilogue(helpEpilogue("Non-interactive (CI, scripts, agents):", ...nonInteractiveLinkCommands().map((command) => ` ${command}`), orgScopedKeyHint)).strict();
|
|
109
|
+
/** Resolves to `undefined` when nothing was verified: `--clear`, `--no-checks`, or a declined re-link. */
|
|
109
110
|
const runLink = async (props) => {
|
|
110
111
|
if (props.clear) {
|
|
111
112
|
clearContext(props.contextFile);
|
|
@@ -119,14 +120,10 @@ const runLink = async (props) => {
|
|
|
119
120
|
validateInputs(inputs);
|
|
120
121
|
const existing = readContextFile(props.contextFile);
|
|
121
122
|
if (props.yes && hasIncompleteCreationInputs(inputs)) throw incompleteCreationError(props, inputs);
|
|
122
|
-
if (canResolveNonInteractively(inputs, existing))
|
|
123
|
-
await runNonInteractive(props, inputs, existing);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
123
|
+
if (canResolveNonInteractively(inputs, existing)) return runNonInteractive(props, inputs, existing);
|
|
126
124
|
if (props.yes) {
|
|
127
125
|
const resolved = await resolveYesInputs(props, inputs);
|
|
128
|
-
|
|
129
|
-
return;
|
|
126
|
+
return runNonInteractive(props, resolved, existing);
|
|
130
127
|
}
|
|
131
128
|
if (!canPromptInteractively()) {
|
|
132
129
|
if (missingProjectForOrg(inputs)) throw orgNeedsProjectError(props, inputs);
|
|
@@ -138,7 +135,7 @@ const runLink = async (props) => {
|
|
|
138
135
|
orgScopedKeyHint
|
|
139
136
|
].join("\n"));
|
|
140
137
|
}
|
|
141
|
-
|
|
138
|
+
return runInteractive(props, inputs);
|
|
142
139
|
};
|
|
143
140
|
const handler = runLink;
|
|
144
141
|
const parseInputs = (props) => {
|
|
@@ -452,7 +449,7 @@ const runNonInteractive = async (props, inputs, existing) => {
|
|
|
452
449
|
projectName: created.project.name,
|
|
453
450
|
regionId: created.project.region_id
|
|
454
451
|
});
|
|
455
|
-
return;
|
|
452
|
+
return { created: true };
|
|
456
453
|
}
|
|
457
454
|
if (inputs.projectId) {
|
|
458
455
|
const listBranches = branchListing(props, inputs.projectId);
|
|
@@ -472,7 +469,7 @@ const runNonInteractive = async (props, inputs, existing) => {
|
|
|
472
469
|
branchRef: resolved.ref,
|
|
473
470
|
created: false
|
|
474
471
|
});
|
|
475
|
-
return;
|
|
472
|
+
return { created: false };
|
|
476
473
|
}
|
|
477
474
|
if (inputs.branch && existing.projectId) {
|
|
478
475
|
const projectId = existing.projectId;
|
|
@@ -493,7 +490,7 @@ const runNonInteractive = async (props, inputs, existing) => {
|
|
|
493
490
|
branchRef: resolved.ref,
|
|
494
491
|
created: false
|
|
495
492
|
});
|
|
496
|
-
return;
|
|
493
|
+
return { created: false };
|
|
497
494
|
}
|
|
498
495
|
throw orgNeedsProjectError(props, inputs);
|
|
499
496
|
};
|
|
@@ -533,7 +530,7 @@ const runInteractive = async (props, inputs) => {
|
|
|
533
530
|
projectName: created.project.name,
|
|
534
531
|
regionId: created.project.region_id
|
|
535
532
|
});
|
|
536
|
-
return;
|
|
533
|
+
return { created: true };
|
|
537
534
|
}
|
|
538
535
|
const projects = await listAllProjects(props, orgId);
|
|
539
536
|
const action = await promptProjectChoice(projects, inputs.projectName, { allowCreate: !inputs.branch });
|
|
@@ -555,7 +552,7 @@ const runInteractive = async (props, inputs) => {
|
|
|
555
552
|
projectName: action.name,
|
|
556
553
|
regionId: action.regionId
|
|
557
554
|
});
|
|
558
|
-
return;
|
|
555
|
+
return { created: false };
|
|
559
556
|
}
|
|
560
557
|
if (inputs.branch) throw new Error(`Conflicting inputs: --branch pins a branch of an existing project, but creating a project starts from its default branch. Link an existing project, or omit --branch and create first.`);
|
|
561
558
|
const projectName = inputs.projectName ?? await promptProjectName(action.suggestedName);
|
|
@@ -583,6 +580,7 @@ const runInteractive = async (props, inputs) => {
|
|
|
583
580
|
projectName: created.project.name,
|
|
584
581
|
regionId: created.project.region_id
|
|
585
582
|
});
|
|
583
|
+
return { created: true };
|
|
586
584
|
};
|
|
587
585
|
const confirmRelinkIfNeeded = async (props) => {
|
|
588
586
|
const existing = readContextFile(props.contextFile);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
|
|
2
2
|
import { t as writeSecretFile } from "./secure_file-Caskdohg.js";
|
|
3
|
-
import { c as describeScope, d as scopeOf, l as interpretCredentials, n as KEYRING_SERVICE, o as apiKeyCredentials, r as keyringAccount, s as credentialLabel, t as storeFor } from "./credential_io-
|
|
3
|
+
import { c as describeScope, d as scopeOf, l as interpretCredentials, n as KEYRING_SERVICE, o as apiKeyCredentials, r as keyringAccount, s as credentialLabel, t as storeFor } from "./credential_io-BHwacMdt.js";
|
|
4
4
|
import { isCi } from "../env.js";
|
|
5
5
|
import { log } from "../log.js";
|
|
6
6
|
import { getApiClient, isNeonApiError } from "../api.js";
|
|
7
7
|
import { setAuthContext } from "../auth_context.js";
|
|
8
8
|
import { a as isOwnedCredentialPath, n as credentialsPath } from "./paths-B55ZfOg1.js";
|
|
9
|
-
import { _ as
|
|
9
|
+
import { S as CRED_STORAGE_KEYRING, _ as readProfiles, a as canDropProfilesFile, b as upsertProfile, d as listProfiles, f as locationForName, g as profilesUsingPath, h as profilesFilePath, i as assertValidProfileName, m as newProfileLocation, n as KEYRING_CREDENTIALS, o as credentialsDisplay, p as locationOf, r as assertProfilesUsable, s as hostsOf, u as isKeyringPointer, v as resolveProfile, x as CRED_STORAGE_FILE, y as selectProfileName } from "./profiles-kpRUx7gU.js";
|
|
10
10
|
import { auth, revokeToken } from "../auth.js";
|
|
11
|
-
import { t as credentialInputs } from "./auth_selection-
|
|
11
|
+
import { t as credentialInputs } from "./auth_selection-D81EvEz9.js";
|
|
12
|
+
import { hostUpdateFor, hostsForProfile, issuingHosts } from "../hosts.js";
|
|
12
13
|
import { readOutgoingCredential, retirePreviousCredential, revokeTokenSet, withdrawKey } from "../retire_credential.js";
|
|
13
|
-
import { m as usableCredential, n as authFlow } from "./auth-
|
|
14
|
+
import { m as usableCredential, n as authFlow } from "./auth-CEb642X3.js";
|
|
14
15
|
import { identityFromAuthDetails, isApiKeyMethod, mintedKeyName, notAnApiKeyMessage } from "../profile_keys.js";
|
|
15
16
|
import { writer } from "../writer.js";
|
|
16
17
|
import { noPassthrough, single } from "../utils/flags.js";
|
|
@@ -70,11 +71,11 @@ const builder = (argv) => argv.usage("$0 profile <sub-command> [options]").comma
|
|
|
70
71
|
throw new Error(`--force is no longer a flag. \`neon profile create ${name}\` always replaces an existing profile and revokes the credential it held. Drop --force.`);
|
|
71
72
|
}
|
|
72
73
|
return true;
|
|
73
|
-
}).example("$0 profile create work", "Sign in with the browser, like `neon login --profile work`").example("$0 profile create work --api-key \"$KEY\"", "Store a key you already have").example("echo \"$KEY\" | $0 profile create work --api-key -", "Or pipe it, so it never reaches the process arguments").example("$0 profile create ci --mint --org-id org-abc-123", "One browser sign-in, then an org-scoped key and no session left behind").example("$0 profile create work --keyring", "Store the credential in the OS keyring instead of a file"), async (args) => await create(args)).command("rotate-key <name>", "Mint a fresh API key for a profile, at the same scope, and revoke the one it replaces", (y) => y.positional("name", {
|
|
74
|
+
}).example("$0 profile create work", "Sign in with the browser, like `neon login --profile work`").example("$0 profile create work --api-key \"$KEY\"", "Store a key you already have").example("echo \"$KEY\" | $0 profile create work --api-key -", "Or pipe it, so it never reaches the process arguments").example("$0 profile create ci --mint --org-id org-abc-123", "One browser sign-in, then an org-scoped key and no session left behind").example("$0 profile create work --keyring", "Store the credential in the OS keyring instead of a file"), async (args) => await create(withProfileHosts(args))).command("rotate-key <name>", "Mint a fresh API key for a profile, at the same scope, and revoke the one it replaces", (y) => y.positional("name", {
|
|
74
75
|
describe: "Profile to rotate",
|
|
75
76
|
type: "string",
|
|
76
77
|
demandOption: true
|
|
77
|
-
}).strict().check(noPassthrough("profile rotate-key")), async (args) => await rotateKey(args)).command("remove <name>", "Revoke a profile's credential where possible, and remove it", (y) => y.positional("name", {
|
|
78
|
+
}).strict().check(noPassthrough("profile rotate-key")), async (args) => await rotateKey(withProfileHosts(args))).command("remove <name>", "Revoke a profile's credential where possible, and remove it", (y) => y.positional("name", {
|
|
78
79
|
describe: "Profile to remove",
|
|
79
80
|
type: "string",
|
|
80
81
|
demandOption: true
|
|
@@ -83,9 +84,17 @@ const builder = (argv) => argv.usage("$0 profile <sub-command> [options]").comma
|
|
|
83
84
|
describe: "Skip the confirmation prompt",
|
|
84
85
|
type: "boolean",
|
|
85
86
|
default: false
|
|
86
|
-
}).strict().check(noPassthrough("profile remove")), async (args) => await remove(args));
|
|
87
|
+
}).strict().check(noPassthrough("profile remove")), async (args) => await remove(withProfileHosts(args)));
|
|
87
88
|
const handler = (_args) => {};
|
|
88
89
|
/**
|
|
90
|
+
* These subcommands act on the profile they name, which credential selection never picked, so
|
|
91
|
+
* the hosts the middleware resolved may belong to another profile.
|
|
92
|
+
*/
|
|
93
|
+
const withProfileHosts = (props) => ({
|
|
94
|
+
...props,
|
|
95
|
+
...hostsForProfile(props.configDir, props.name)
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
89
98
|
* Refuse a global credential flag that a `profile` subcommand cannot honour.
|
|
90
99
|
*
|
|
91
100
|
* These commands name their target as a positional and authenticate as that profile, so both
|
|
@@ -172,6 +181,8 @@ const list = async (props) => {
|
|
|
172
181
|
return {
|
|
173
182
|
active: p.name === active ? "*" : "",
|
|
174
183
|
name: p.name,
|
|
184
|
+
...p.apiHost !== void 0 ? { apiHost: p.apiHost } : {},
|
|
185
|
+
...p.oauthHost !== void 0 ? { oauthHost: p.oauthHost } : {},
|
|
175
186
|
account: p.label ?? p.userId ?? storedUserId ?? "-",
|
|
176
187
|
auth,
|
|
177
188
|
scope: auth === "oauth" ? describeScope({}) : stored !== null && auth === "api key" ? describeScope(scopeOf(stored)) : "-",
|
|
@@ -180,16 +191,27 @@ const list = async (props) => {
|
|
|
180
191
|
credentials: props.output === "table" ? credentialsListValue(p, props.configDir) : credentialsDisplay(p)
|
|
181
192
|
};
|
|
182
193
|
});
|
|
183
|
-
|
|
194
|
+
const fields = [
|
|
195
|
+
"active",
|
|
196
|
+
"name",
|
|
197
|
+
"account",
|
|
198
|
+
"auth",
|
|
199
|
+
"credentials",
|
|
200
|
+
"scope"
|
|
201
|
+
];
|
|
202
|
+
if (props.output !== "table") {
|
|
203
|
+
writer(props).end(rows, {
|
|
204
|
+
title: "Profiles",
|
|
205
|
+
fields
|
|
206
|
+
});
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
writer(props).end(rows.map(({ apiHost, ...row }) => ({
|
|
210
|
+
...row,
|
|
211
|
+
api_host: apiHost
|
|
212
|
+
})), {
|
|
184
213
|
title: "Profiles",
|
|
185
|
-
fields: [
|
|
186
|
-
"active",
|
|
187
|
-
"name",
|
|
188
|
-
"account",
|
|
189
|
-
"auth",
|
|
190
|
-
"credentials",
|
|
191
|
-
"scope"
|
|
192
|
-
]
|
|
214
|
+
fields: [...fields, "api_host"]
|
|
193
215
|
});
|
|
194
216
|
};
|
|
195
217
|
const credentialsListValue = (profile, configDir) => {
|
|
@@ -297,11 +319,13 @@ const create = async (props) => {
|
|
|
297
319
|
rejectProfileFlag(props, "create");
|
|
298
320
|
assertValidProfileName(name);
|
|
299
321
|
assertProfilesUsable(props.configDir, name);
|
|
322
|
+
const hosts = hostUpdateFor(name);
|
|
323
|
+
const previousHosts = issuingHosts(props.configDir, name, props);
|
|
300
324
|
if (props.keyring === true) storeFor(props.configDir).assertKeyringWritable(existingLocation(props.configDir, name)?.storage === "keyring" ? name : void 0);
|
|
301
325
|
const suppliedKey = credentialInputs().apiKeyFlag.trim() !== "";
|
|
302
326
|
if (props.mint) {
|
|
303
327
|
if (suppliedKey) throw new Error("--mint creates a new key, so it cannot be combined with --api-key. Drop one.");
|
|
304
|
-
await createByMinting(props);
|
|
328
|
+
await createByMinting(props, hosts, previousHosts);
|
|
305
329
|
return;
|
|
306
330
|
}
|
|
307
331
|
if ((props.orgId ?? props.projectId) !== void 0) throw new Error("--org-id and --project-id only apply with --mint: they choose what a key we mint can reach, and a key you supply already has a scope.");
|
|
@@ -314,9 +338,13 @@ const create = async (props) => {
|
|
|
314
338
|
...props,
|
|
315
339
|
_: ["auth"],
|
|
316
340
|
profile: name,
|
|
317
|
-
keyring: props.keyring
|
|
341
|
+
keyring: props.keyring,
|
|
342
|
+
hosts
|
|
318
343
|
}) === "") throw new Error(`Could not save credentials for profile "${name}".`);
|
|
319
|
-
if (at.storage !== "keyring") await retirePreviousCredential(
|
|
344
|
+
if (at.storage !== "keyring") await retirePreviousCredential({
|
|
345
|
+
...props,
|
|
346
|
+
...previousHosts
|
|
347
|
+
}, name, previous);
|
|
320
348
|
const signedIn = readProfiles(props.configDir, log.warning)?.profiles[name];
|
|
321
349
|
report(props, {
|
|
322
350
|
name,
|
|
@@ -340,12 +368,15 @@ const create = async (props) => {
|
|
|
340
368
|
...identity.orgId !== void 0 ? { scope: { orgId: identity.orgId } } : {}
|
|
341
369
|
}));
|
|
342
370
|
try {
|
|
343
|
-
recordProfile(props, name, at, identity);
|
|
371
|
+
recordProfile(props, name, at, identity, hosts);
|
|
344
372
|
} catch (err) {
|
|
345
373
|
if (at.storage === "keyring" && existing?.storage !== "keyring") warnIfKeyringRollbackUnconfirmed(storeFor(props.configDir).delete(at, { required: false }), name);
|
|
346
374
|
throw err instanceof Error ? err : new Error(String(err));
|
|
347
375
|
}
|
|
348
|
-
await retirePreviousCredential(
|
|
376
|
+
await retirePreviousCredential({
|
|
377
|
+
...props,
|
|
378
|
+
...previousHosts
|
|
379
|
+
}, name, previous, apiKey);
|
|
349
380
|
if (at.storage === "keyring" && existing?.storage === "file") deleteLeftoverOwnedFile(props.configDir, existing.path, name);
|
|
350
381
|
report(props, {
|
|
351
382
|
name,
|
|
@@ -382,11 +413,16 @@ const warnAboutReach = (scope) => {
|
|
|
382
413
|
*/
|
|
383
414
|
const report = (props, record) => {
|
|
384
415
|
const out = writer(props);
|
|
416
|
+
const entry = readProfiles(props.configDir)?.profiles[record.name];
|
|
417
|
+
const hosts = entry === void 0 ? {} : hostsOf(entry);
|
|
385
418
|
if (props.output === "table") {
|
|
386
|
-
log.info("Profile \"%s\" now holds %s for %s (%s), in %s", record.name, record.auth, record.account, record.scope, record.credentials);
|
|
419
|
+
log.info("Profile \"%s\" now holds %s for %s (%s), in %s%s", record.name, record.auth, record.account, record.scope, record.credentials, hosts.apiHost !== void 0 ? `, for ${hosts.apiHost}` : "");
|
|
387
420
|
return;
|
|
388
421
|
}
|
|
389
|
-
out.end(
|
|
422
|
+
out.end({
|
|
423
|
+
...record,
|
|
424
|
+
...hosts
|
|
425
|
+
}, {
|
|
390
426
|
fields: [
|
|
391
427
|
"name",
|
|
392
428
|
"account",
|
|
@@ -399,11 +435,12 @@ const report = (props, record) => {
|
|
|
399
435
|
title: "Profile"
|
|
400
436
|
});
|
|
401
437
|
};
|
|
402
|
-
const recordProfile = (props, name, at, identity) => {
|
|
438
|
+
const recordProfile = (props, name, at, identity, hosts) => {
|
|
403
439
|
upsertProfile(props.configDir, name, {
|
|
404
440
|
credentials: at.storage === "keyring" ? KEYRING_CREDENTIALS : at.path,
|
|
405
441
|
...identity.label ? { label: identity.label } : {},
|
|
406
|
-
...identity.userId ? { userId: identity.userId } : {}
|
|
442
|
+
...identity.userId ? { userId: identity.userId } : {},
|
|
443
|
+
...hosts
|
|
407
444
|
});
|
|
408
445
|
};
|
|
409
446
|
/**
|
|
@@ -414,7 +451,7 @@ const recordProfile = (props, name, at, identity) => {
|
|
|
414
451
|
* it, so no half-forgotten login is left behind — which also means the file holds exactly one
|
|
415
452
|
* credential, for exactly one account.
|
|
416
453
|
*/
|
|
417
|
-
const createByMinting = async (props) => {
|
|
454
|
+
const createByMinting = async (props, hosts, previousHosts) => {
|
|
418
455
|
const { name } = props;
|
|
419
456
|
if (isCi() && props.forceAuth !== true) throw new Error(`--mint needs a browser sign-in, which cannot happen in CI. Mint the key with \`neon api-keys create --name ${name}\` and pipe it in: echo "$KEY" | neon profile create ${name} --api-key -`);
|
|
420
457
|
if (locationForCreate(props.configDir, name, props.keyring).storage === "keyring") storeFor(props.configDir).assertKeyringWritable(existingLocation(props.configDir, name)?.storage === "keyring" ? name : void 0);
|
|
@@ -446,13 +483,16 @@ const createByMinting = async (props) => {
|
|
|
446
483
|
scope
|
|
447
484
|
}));
|
|
448
485
|
try {
|
|
449
|
-
recordProfile(props, name, at, identity);
|
|
486
|
+
recordProfile(props, name, at, identity, hosts);
|
|
450
487
|
} catch (err) {
|
|
451
488
|
if (at.storage === "keyring" && existing?.storage !== "keyring") warnIfKeyringRollbackUnconfirmed(storeFor(props.configDir).delete(at, { required: false }), name);
|
|
452
489
|
else keyIsReachable = true;
|
|
453
490
|
throw err instanceof Error ? err : new Error(String(err));
|
|
454
491
|
}
|
|
455
|
-
await retirePreviousCredential(
|
|
492
|
+
await retirePreviousCredential({
|
|
493
|
+
...props,
|
|
494
|
+
...previousHosts
|
|
495
|
+
}, name, previous, minted.key);
|
|
456
496
|
if (at.storage === "keyring" && existing?.storage === "file") deleteLeftoverOwnedFile(props.configDir, existing.path, name);
|
|
457
497
|
keyIsReachable = true;
|
|
458
498
|
report(props, {
|