neon 4.16.0 → 4.17.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/dist/_chunks/{env-DsakkOVZ.js → env-B75xufe_.js} +57 -64
- package/dist/_chunks/{env_services-CAWrZTWa.js → env_services-CbARRnq9.js} +66 -11
- package/dist/commands/dev.js +8 -10
- package/dist/commands/env.js +6 -6
- package/dist/dev/env.js +1 -1
- package/dist/env_services.js +1 -1
- package/package.json +5 -5
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { log } from "../log.js";
|
|
2
2
|
import { getCliName } from "../utils/cli_name.js";
|
|
3
3
|
import { declaredNeonServices } from "../config_services.js";
|
|
4
|
-
import { S as
|
|
4
|
+
import { C as resolveBranchPolicy, S as policyEnvKeys, _ as defaultStorageCredential, a as envKeysForSelection, b as isFunctionBaseUrlKey, d as servicesForEnvKeys, f as NEON_ENV_VAR_KEYS, g as defaultAiGatewayCredential, h as credentialName, i as ENV_PULL_SERVICES, m as credentialEnvKeys, p as createApiFromOptions, u as serviceForEnvKey, v as fetchEnvKeysState, w as toEntries, x as isLiveCredential, y as functionBaseUrlKey } from "./env_services-CbARRnq9.js";
|
|
5
5
|
import { formatInstallCommand, resolvePackageManager } from "../utils/package_manager.js";
|
|
6
6
|
import { credentialScopesSatisfied } from "@neon/config/v1";
|
|
7
7
|
import { ErrorCode as ErrorCode$1, createNeonApiFromOptions as createNeonApiFromOptions$1, isPlatformError as isPlatformError$1, loadConfigFromFile } from "@neon/config";
|
|
8
8
|
import { plan, pullConfig } from "@neon/config-runtime";
|
|
9
9
|
//#region ../../internals/env-core/dist/reuse-secrets.js
|
|
10
10
|
/**
|
|
11
|
-
* Resolve a branch's env while keeping
|
|
11
|
+
* Resolve a branch's env while keeping secrets the caller already holds.
|
|
12
12
|
*
|
|
13
|
-
* {@link fetchEnvKeys}
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* for only the rest.
|
|
13
|
+
* {@link fetchEnvKeys} reveals the platform default credentials (or mints a fallback when a
|
|
14
|
+
* region has none). Calling it on every `neon dev` start would rewrite `.env` with freshly
|
|
15
|
+
* revealed secrets each time. This wrapper looks at what the caller already has, keeps a
|
|
16
|
+
* half when it already *is* that default (storage and gateway are independent credentials),
|
|
17
|
+
* and asks `fetchEnv` for only the rest.
|
|
19
18
|
*
|
|
20
19
|
* The check is a real verification, not a presence test. A persisted secret is kept only when
|
|
21
|
-
* it names a credential that still exists on this branch, is not revoked or expired, and
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* it names a credential that still exists on this branch, is not revoked or expired, and —
|
|
21
|
+
* when defaults exist — *is* that default. A leftover `neon-env ${branch}` credential this
|
|
22
|
+
* tool minted is replaced by the defaults and revoked. A `.env.example` placeholder, a
|
|
23
|
+
* credential revoked in the console, or one copied in from another branch fails that check.
|
|
25
24
|
*
|
|
26
25
|
* None of this needs local bookkeeping, because the secrets carry their own credential id:
|
|
27
26
|
* `AWS_ACCESS_KEY_ID` **is** the credential's `tokenId` (the storage gateway authenticates
|
|
@@ -71,47 +70,47 @@ async function fetchEnvReusingSecrets(config, options) {
|
|
|
71
70
|
const persisted = readPersistedSecrets(source);
|
|
72
71
|
const storageCredentialManaged = requested === null || storageCredentialSelected;
|
|
73
72
|
const gatewayCredentialManaged = requested === null || gatewayCredentialSelected;
|
|
74
|
-
const
|
|
75
|
-
const
|
|
73
|
+
const storageComplete = Boolean(persisted.accessKeyId && persisted.secretAccessKey);
|
|
74
|
+
const gatewayComplete = Boolean(persisted.apiToken);
|
|
75
|
+
const listed = storageCredentialManaged && persisted.accessKeyId !== "" || gatewayCredentialManaged && persisted.apiToken !== "" ? await api.listCredentials(options.projectId, branch.id) : [];
|
|
76
|
+
const named = listed.length > 0 ? namedCredentials(listed, persisted) : {
|
|
76
77
|
storage: null,
|
|
77
78
|
gateway: null
|
|
78
79
|
};
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const fetchKeys = requested === null ? null :
|
|
80
|
+
const now = Date.now();
|
|
81
|
+
const storageDefault = defaultStorageCredential(listed, now);
|
|
82
|
+
const gatewayDefault = defaultAiGatewayCredential(listed, now);
|
|
83
|
+
const keepStorage = !storageCredentialSelected || storageComplete && halfReusable(named.storage, storageDefault, ["storage:read", "storage:write"]);
|
|
84
|
+
const keepGateway = !gatewayCredentialSelected || gatewayComplete && halfReusable(named.gateway, gatewayDefault, ["ai_gateway:invoke"]);
|
|
85
|
+
const keptSecretKeys = credentialEnvKeys({
|
|
86
|
+
storage: storageCredentialSelected && keepStorage,
|
|
87
|
+
aiGateway: gatewayCredentialSelected && keepGateway
|
|
88
|
+
}).filter((key) => selected.has(key));
|
|
89
|
+
const fetchKeys = requested === null ? null : selectedPolicyKeys.filter((key) => !keptSecretKeys.includes(key));
|
|
89
90
|
const fetched = await fetchEnvKeysState(config, {
|
|
90
91
|
...fetchOptions,
|
|
91
92
|
branchId: branch.id,
|
|
92
93
|
api,
|
|
93
|
-
...
|
|
94
|
+
...keptSecretKeys.length > 0 && requested === null ? { omitKeys: keptSecretKeys } : {}
|
|
94
95
|
}, fetchKeys);
|
|
95
96
|
const vars = preferPersisted(toEntries(fetched.env), source);
|
|
96
97
|
const unavailable = fetched.functionUrlsUnavailable ? { functionUrlsUnavailable: true } : {};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (value !== void 0) vars[key] = value;
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
vars,
|
|
104
|
-
credential: {
|
|
105
|
-
issued: false,
|
|
106
|
-
keys: secretKeys,
|
|
107
|
-
revoked: [],
|
|
108
|
-
superseded: []
|
|
109
|
-
},
|
|
110
|
-
...unavailable
|
|
111
|
-
};
|
|
98
|
+
for (const key of keptSecretKeys) {
|
|
99
|
+
const value = source[key];
|
|
100
|
+
if (value !== void 0) vars[key] = value;
|
|
112
101
|
}
|
|
102
|
+
if (!(storageCredentialSelected && !keepStorage || gatewayCredentialSelected && !keepGateway)) return {
|
|
103
|
+
vars,
|
|
104
|
+
credential: {
|
|
105
|
+
issued: false,
|
|
106
|
+
keys: secretKeys,
|
|
107
|
+
revoked: [],
|
|
108
|
+
superseded: []
|
|
109
|
+
},
|
|
110
|
+
...unavailable
|
|
111
|
+
};
|
|
113
112
|
const ours = /* @__PURE__ */ new Set();
|
|
114
|
-
for (const meta of [storageCredentialManaged ? named.storage : null, gatewayCredentialManaged ? named.gateway : null]) if (meta !== null && meta.principalType === "user" && meta.name === credentialName(branch.name)) ours.add(meta.tokenId);
|
|
113
|
+
for (const meta of [storageCredentialManaged && !keepStorage ? named.storage : null, gatewayCredentialManaged && !keepGateway ? named.gateway : null]) if (meta !== null && meta.principalType === "user" && meta.name === credentialName(branch.name)) ours.add(meta.tokenId);
|
|
115
114
|
if (revokeSuperseded) for (const tokenId of ours) await api.revokeCredential(options.projectId, branch.id, tokenId);
|
|
116
115
|
return {
|
|
117
116
|
vars,
|
|
@@ -162,13 +161,6 @@ function preferPersisted(vars, source) {
|
|
|
162
161
|
function gatewayTokenIdShort(apiToken) {
|
|
163
162
|
return /^nt_live_([^_]+)_.+$/.exec(apiToken)?.[1] ?? null;
|
|
164
163
|
}
|
|
165
|
-
/** Whether an issued credential can still be used: not revoked, not past its expiry. */
|
|
166
|
-
function isLiveCredential(meta, now) {
|
|
167
|
-
if (meta.revokedAt !== void 0) return false;
|
|
168
|
-
if (meta.expiresAt === void 0) return true;
|
|
169
|
-
const expiresAt = Date.parse(meta.expiresAt);
|
|
170
|
-
return Number.isNaN(expiresAt) || expiresAt > now;
|
|
171
|
-
}
|
|
172
164
|
/**
|
|
173
165
|
* The live credentials the persisted secrets name — at most one per half. A half that names
|
|
174
166
|
* nothing contributes nothing, which is what a placeholder, a credential revoked in the
|
|
@@ -183,17 +175,17 @@ function namedCredentials(live, persisted) {
|
|
|
183
175
|
};
|
|
184
176
|
}
|
|
185
177
|
/**
|
|
186
|
-
*
|
|
178
|
+
* Whether a persisted half can be reused.
|
|
187
179
|
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
180
|
+
* When a platform default exists, only that default is reusable — a leftover
|
|
181
|
+
* `neon-env ${branch}` mint is replaced. When no default exists (mint fallback),
|
|
182
|
+
* any live credential the secrets name is reusable if it still carries the
|
|
183
|
+
* scopes that half needs.
|
|
191
184
|
*/
|
|
192
|
-
function
|
|
193
|
-
if (
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
return null;
|
|
185
|
+
function halfReusable(named, defaultMeta, requiredScopes) {
|
|
186
|
+
if (named === null) return false;
|
|
187
|
+
if (defaultMeta !== null) return named.tokenId === defaultMeta.tokenId;
|
|
188
|
+
return credentialScopesSatisfied(named.scopes, requiredScopes);
|
|
197
189
|
}
|
|
198
190
|
//#endregion
|
|
199
191
|
//#region src/dev/env.ts
|
|
@@ -437,16 +429,17 @@ const withAiGateway = (config) => ({
|
|
|
437
429
|
*
|
|
438
430
|
* So the gateway is only added once its credential endpoint has been shown to answer, by
|
|
439
431
|
* reading the branch's credentials first. A project that does not have them says so on a
|
|
440
|
-
* read, before anything is minted — which is the whole question, since the
|
|
441
|
-
* credential and nothing else.
|
|
432
|
+
* read, before anything is revealed or minted — which is the whole question, since the
|
|
433
|
+
* gateway's env is a credential and nothing else.
|
|
442
434
|
*
|
|
443
435
|
* Deciding this **before** resolving, rather than by catching and retrying, is what keeps it
|
|
444
436
|
* honest. A retry re-runs every call the first attempt made, so it would blame the gateway for
|
|
445
|
-
* a one-off failure in shared work, and — worse — a first attempt that minted a
|
|
446
|
-
* then failed would be papered over by a second that succeeds without one,
|
|
447
|
-
* error and stranding a secret nobody holds. Once the read succeeds, a later
|
|
448
|
-
* failure and propagates: the same thing already happens on a branch with
|
|
449
|
-
* whose credential is minted whether or not the
|
|
437
|
+
* a one-off failure in shared work, and — worse — a first attempt that revealed or minted a
|
|
438
|
+
* credential and then failed would be papered over by a second that succeeds without one,
|
|
439
|
+
* swallowing the error and stranding a secret nobody holds. Once the read succeeds, a later
|
|
440
|
+
* failure is a real failure and propagates: the same thing already happens on a branch with
|
|
441
|
+
* object storage, whose credential is revealed (or minted as a fallback) whether or not the
|
|
442
|
+
* gateway is involved.
|
|
450
443
|
*/
|
|
451
444
|
const resolveWithImpliedGateway = async (config, ctx, branch) => {
|
|
452
445
|
const unreachable = await credentialsUnreachable(ctx, branch);
|
|
@@ -190,7 +190,7 @@ async function fetchEnvKeysState(config, options, keys) {
|
|
|
190
190
|
branchId: branch.id
|
|
191
191
|
} });
|
|
192
192
|
}
|
|
193
|
-
const secrets = wantsCredential ? await
|
|
193
|
+
const secrets = wantsCredential ? await resolveBranchCredentialSecrets({
|
|
194
194
|
api,
|
|
195
195
|
projectId,
|
|
196
196
|
branchId: branch.id,
|
|
@@ -303,9 +303,9 @@ async function resolveBranchPolicy(config, options, api) {
|
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
305
|
/**
|
|
306
|
-
* Scopes
|
|
307
|
-
*
|
|
308
|
-
*
|
|
306
|
+
* Scopes a minted fallback credential should carry. Only object storage and the AI Gateway
|
|
307
|
+
* *require* secrets; functions never force a credential. `functions:invoke` rides along only
|
|
308
|
+
* when this path still has to mint (defaults already cover storage and the gateway).
|
|
309
309
|
*/
|
|
310
310
|
function previewCredentialScopes(preview, selected) {
|
|
311
311
|
if (!preview) return [];
|
|
@@ -348,15 +348,70 @@ function policyEnvKeys(desired) {
|
|
|
348
348
|
...desired.preview?.aiGatewayEnabled ? [K.aiGateway.apiKey, K.aiGateway.baseUrl] : []
|
|
349
349
|
];
|
|
350
350
|
}
|
|
351
|
+
/** Exact `name` values the credentials list endpoint returns for the platform defaults. */
|
|
352
|
+
const DEFAULT_AI_GATEWAY_CREDENTIAL_NAME = "Default AI gateway credential";
|
|
353
|
+
const DEFAULT_OBJECT_STORAGE_CREDENTIAL_NAME = "Default object storage credential";
|
|
354
|
+
/** Whether an issued credential can still be used: not revoked, not past its expiry. */
|
|
355
|
+
function isLiveCredential(meta, now) {
|
|
356
|
+
if (meta.revokedAt !== void 0) return false;
|
|
357
|
+
if (meta.expiresAt === void 0) return true;
|
|
358
|
+
const expiresAt = Date.parse(meta.expiresAt);
|
|
359
|
+
return Number.isNaN(expiresAt) || expiresAt > now;
|
|
360
|
+
}
|
|
361
|
+
function defaultStorageCredential(live, now) {
|
|
362
|
+
return live.find((meta) => meta.name === DEFAULT_OBJECT_STORAGE_CREDENTIAL_NAME && isLiveCredential(meta, now)) ?? null;
|
|
363
|
+
}
|
|
364
|
+
function defaultAiGatewayCredential(live, now) {
|
|
365
|
+
return live.find((meta) => meta.name === DEFAULT_AI_GATEWAY_CREDENTIAL_NAME && isLiveCredential(meta, now)) ?? null;
|
|
366
|
+
}
|
|
351
367
|
/**
|
|
352
|
-
*
|
|
368
|
+
* Resolve secrets for object storage / the AI Gateway.
|
|
353
369
|
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
370
|
+
* Regions that expose those products already have platform defaults on every branch.
|
|
371
|
+
* Reveal those by exact name instead of minting a combined `neon-env ${branch}` credential.
|
|
372
|
+
* Mint only the half (or both) that has no default — regions without the credentials
|
|
373
|
+
* endpoint still fail at list, same as before.
|
|
374
|
+
*
|
|
375
|
+
* A caller that already holds secrets for those defaults should leave the secret keys out
|
|
376
|
+
* of `keys` (see {@link fetchEnvReusingSecrets}) instead of revealing them again.
|
|
359
377
|
*/
|
|
378
|
+
async function resolveBranchCredentialSecrets(args) {
|
|
379
|
+
const needsStorage = args.scopes.includes("storage:read") || args.scopes.includes("storage:write");
|
|
380
|
+
const needsGateway = args.scopes.includes("ai_gateway:invoke");
|
|
381
|
+
const live = await args.api.listCredentials(args.projectId, args.branchId);
|
|
382
|
+
const now = Date.now();
|
|
383
|
+
const storageDefault = defaultStorageCredential(live, now);
|
|
384
|
+
const gatewayDefault = defaultAiGatewayCredential(live, now);
|
|
385
|
+
const secrets = {
|
|
386
|
+
accessKeyId: "",
|
|
387
|
+
secretAccessKey: "",
|
|
388
|
+
apiToken: ""
|
|
389
|
+
};
|
|
390
|
+
if (needsStorage && storageDefault) {
|
|
391
|
+
const revealed = await args.api.revealCredential(args.projectId, args.branchId, storageDefault.tokenId);
|
|
392
|
+
secrets.accessKeyId = revealed.tokenId;
|
|
393
|
+
secrets.secretAccessKey = revealed.s3SecretAccessKey;
|
|
394
|
+
}
|
|
395
|
+
if (needsGateway && gatewayDefault) secrets.apiToken = (await args.api.revealCredential(args.projectId, args.branchId, gatewayDefault.tokenId)).apiToken;
|
|
396
|
+
const missingStorage = needsStorage && storageDefault === null;
|
|
397
|
+
const missingGateway = needsGateway && gatewayDefault === null;
|
|
398
|
+
if (missingStorage || missingGateway) {
|
|
399
|
+
const minted = await mintBranchCredential({
|
|
400
|
+
...args,
|
|
401
|
+
scopes: deriveCredentialScopes({
|
|
402
|
+
storage: missingStorage,
|
|
403
|
+
aiGateway: missingGateway,
|
|
404
|
+
functions: args.scopes.includes("functions:invoke")
|
|
405
|
+
})
|
|
406
|
+
});
|
|
407
|
+
if (missingStorage) {
|
|
408
|
+
secrets.accessKeyId = minted.accessKeyId;
|
|
409
|
+
secrets.secretAccessKey = minted.secretAccessKey;
|
|
410
|
+
}
|
|
411
|
+
if (missingGateway) secrets.apiToken = minted.apiToken;
|
|
412
|
+
}
|
|
413
|
+
return secrets;
|
|
414
|
+
}
|
|
360
415
|
async function mintBranchCredential(args) {
|
|
361
416
|
const minted = await args.api.createCredential(args.projectId, args.branchId, {
|
|
362
417
|
scopes: args.scopes,
|
|
@@ -625,4 +680,4 @@ const editDistance = (left, right) => {
|
|
|
625
680
|
/** Narrow yargs' array option value without accepting any other runtime shape. */
|
|
626
681
|
const envPullFlagValue = (value) => Array.isArray(value) ? value.map(String) : void 0;
|
|
627
682
|
//#endregion
|
|
628
|
-
export {
|
|
683
|
+
export { resolveBranchPolicy as C, policyEnvKeys as S, defaultStorageCredential as _, envKeysForSelection as a, isFunctionBaseUrlKey as b, ownedEnvServiceKeys as c, servicesForEnvKeys as d, NEON_ENV_VAR_KEYS as f, defaultAiGatewayCredential as g, credentialName as h, ENV_PULL_SERVICES as i, parseEnvPullKeys as l, credentialEnvKeys as m, ENV_PULL_KEYS as n, envPullFlagValue as o, createApiFromOptions as p, ENV_PULL_KEY_HELP as r, envServiceKeys as s, BRANCH_ENV_KEY as t, serviceForEnvKey as u, fetchEnvKeysState as v, toEntries as w, isLiveCredential as x, functionBaseUrlKey as y };
|
package/dist/commands/dev.js
CHANGED
|
@@ -2,11 +2,11 @@ import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
|
|
|
2
2
|
import { log } from "../log.js";
|
|
3
3
|
import { getCliName } from "../utils/cli_name.js";
|
|
4
4
|
import { readEnvFile, resolveEnvFilePath } from "../env_file.js";
|
|
5
|
-
import {
|
|
5
|
+
import { y as functionBaseUrlKey } from "../_chunks/env_services-CbARRnq9.js";
|
|
6
6
|
import { isClaimableEnvTarget } from "../claimable/state.js";
|
|
7
7
|
import { branchIdResolve } from "../utils/enrichers.js";
|
|
8
8
|
import { bundleEntry } from "../utils/esbuild.js";
|
|
9
|
-
import { a as resolveDevEnv } from "../_chunks/env-
|
|
9
|
+
import { a as resolveDevEnv } from "../_chunks/env-B75xufe_.js";
|
|
10
10
|
import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
|
|
11
11
|
import { resolveWatchInputs } from "../dev/inputs.js";
|
|
12
12
|
import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -95,21 +95,19 @@ const devEnvContext = (props, branchId, cwd) => {
|
|
|
95
95
|
};
|
|
96
96
|
};
|
|
97
97
|
/**
|
|
98
|
-
* Say when
|
|
98
|
+
* Say when this run obtained credential secrets it did not already hold.
|
|
99
99
|
*
|
|
100
|
-
* `dev`
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* `NEON_AI_GATEWAY_TOKEN` reads as "fetched", not "just created, and the last one is still
|
|
104
|
-
* live". The note names the one action that stops it, so it disappears once followed.
|
|
100
|
+
* `dev` writes no file. With platform defaults, each start re-reveals the same secrets until
|
|
101
|
+
* `env pull` persists them. In a region with no defaults, each start mints another credential
|
|
102
|
+
* and cannot revoke the last one. The note names the one action that stops either loop.
|
|
105
103
|
*/
|
|
106
104
|
const reportDevCredential = (credential) => {
|
|
107
105
|
if (!credential?.issued) return;
|
|
108
106
|
if (credential.revoked.length > 0) {
|
|
109
|
-
log.info("
|
|
107
|
+
log.info("Wrote credential secrets — %s changed. Revoked the leftover it replaced (%s).", credential.keys.join(", "), credential.revoked.join(", "));
|
|
110
108
|
return;
|
|
111
109
|
}
|
|
112
|
-
log.warning(`
|
|
110
|
+
log.warning(`Resolved credential secrets for this run (%s) without writing them to a file. Run \`${getCliName()} env pull\` once so restarts reuse them instead of revealing or minting again.`, credential.keys.join(", "));
|
|
113
111
|
};
|
|
114
112
|
const handler = async (props) => {
|
|
115
113
|
if (props.source !== void 0) {
|
package/dist/commands/env.js
CHANGED
|
@@ -4,12 +4,12 @@ import { ensureGitignored } from "../context.js";
|
|
|
4
4
|
import { getCliName } from "../utils/cli_name.js";
|
|
5
5
|
import { deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOption } from "../neon_services.js";
|
|
6
6
|
import { mergeEnvFile, readEnvFile, resolveEnvFilePath } from "../env_file.js";
|
|
7
|
-
import { a as envKeysForSelection, c as ownedEnvServiceKeys, f as NEON_ENV_VAR_KEYS, i as ENV_PULL_SERVICES, l as parseEnvPullKeys, o as envPullFlagValue, r as ENV_PULL_KEY_HELP
|
|
7
|
+
import { a as envKeysForSelection, b as isFunctionBaseUrlKey, c as ownedEnvServiceKeys, f as NEON_ENV_VAR_KEYS, i as ENV_PULL_SERVICES, l as parseEnvPullKeys, o as envPullFlagValue, r as ENV_PULL_KEY_HELP } from "../_chunks/env_services-CbARRnq9.js";
|
|
8
8
|
import { isClaimableEnvTarget } from "../claimable/state.js";
|
|
9
9
|
import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
|
|
10
10
|
import { warnAiGateway } from "../utils/ai_gateway_notice.js";
|
|
11
11
|
import { announceTargetBranch } from "../utils/branch_notice.js";
|
|
12
|
-
import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "../_chunks/env-
|
|
12
|
+
import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "../_chunks/env-B75xufe_.js";
|
|
13
13
|
import { existsSync } from "node:fs";
|
|
14
14
|
import chalk from "chalk";
|
|
15
15
|
//#region src/commands/env.ts
|
|
@@ -67,7 +67,7 @@ const builder = (argv) => argv.usage("$0 env <sub-command> [options]").options({
|
|
|
67
67
|
" 2. neon.ts, when this directory has one — including derived function",
|
|
68
68
|
" URLs (the function does not have to be deployed).",
|
|
69
69
|
" 3. Otherwise everything the branch has, plus the AI Gateway —",
|
|
70
|
-
" which
|
|
70
|
+
" which pulls the default AI Gateway credential.",
|
|
71
71
|
"",
|
|
72
72
|
"On an unclaimed Claimable Neon project, neon.ts is still the source",
|
|
73
73
|
"of truth when it only declares Postgres, Auth, and the Data API.",
|
|
@@ -78,8 +78,8 @@ const builder = (argv) => argv.usage("$0 env <sub-command> [options]").options({
|
|
|
78
78
|
"and writes nothing for them.",
|
|
79
79
|
"",
|
|
80
80
|
"The pull bundled into link / checkout / config apply follows 2 and 3",
|
|
81
|
-
"without the AI Gateway, so it never
|
|
82
|
-
"for. Run `env pull` to add it."
|
|
81
|
+
"without the AI Gateway, so it never writes a gateway token you did",
|
|
82
|
+
"not ask for. Run `env pull` to add it."
|
|
83
83
|
].join("\n")).example("$0 env pull", "Write the linked branch's Neon vars into .env.local (or .env if present)").example("$0 env pull --branch preview --file .env.preview", "Pull a specific branch into a specific file").example("$0 env pull -s ai-gateway -s postgres", "Pull only the AI Gateway and Postgres variables").example("$0 env pull -e DATABASE_URL", "Pull only the pooled Postgres connection string").example("$0 env pull -s auth -e DATABASE_URL", "Pull all Auth variables plus DATABASE_URL").example("$0 env pull -s functions", "Pull NEON_FUNCTION_<SLUG>_BASE_URL for every deployed function").example("$0 env pull -e NEON_FUNCTION_HELLO_BASE_URL", "Write that function's production invocation URL (no deploy required)").strict(), async (args) => {
|
|
84
84
|
const rawServices = servicesFlagValue(args.service);
|
|
85
85
|
const rawEnvKeys = envPullFlagValue(args.env);
|
|
@@ -164,7 +164,7 @@ const pull = async (props, opts = {}) => {
|
|
|
164
164
|
log.info("Pulled %d Neon variable%s into %s: %s", written.length, written.length === 1 ? "" : "s", targetPath, written.join(", "));
|
|
165
165
|
if (removed.length > 0) log.info("Removed %d stale Neon variable%s not enabled on this branch: %s", removed.length, removed.length === 1 ? "" : "s", removed.join(", "));
|
|
166
166
|
if (credential?.issued) {
|
|
167
|
-
log.info("
|
|
167
|
+
log.info("Wrote credential secrets — these now hold fresh values: %s", credential.keys.join(", "));
|
|
168
168
|
if (credential.revoked.length > 0) log.info("Revoked the credential it replaced (%s).", credential.revoked.join(", "));
|
|
169
169
|
else if (credential.superseded.length > 0) log.info("Left the credential it replaced live (%s): an explicitly scoped pull can't tell which other variables still use it. Revoke it in the Neon Console if nothing does.", credential.superseded.join(", "));
|
|
170
170
|
}
|
package/dist/dev/env.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as resolveDevEnv, i as dropClaimableUnsupported, n as MissingBranchContextError, o as resolveNeonEnvVars, r as ServiceNotOnBranchError, t as DevEnvMismatchError } from "../_chunks/env-
|
|
1
|
+
import { a as resolveDevEnv, i as dropClaimableUnsupported, n as MissingBranchContextError, o as resolveNeonEnvVars, r as ServiceNotOnBranchError, t as DevEnvMismatchError } from "../_chunks/env-B75xufe_.js";
|
|
2
2
|
export { DevEnvMismatchError, MissingBranchContextError, ServiceNotOnBranchError, dropClaimableUnsupported, resolveDevEnv, resolveNeonEnvVars };
|
package/dist/env_services.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as envKeysForSelection, c as ownedEnvServiceKeys, d as servicesForEnvKeys, i as ENV_PULL_SERVICES, l as parseEnvPullKeys, n as ENV_PULL_KEYS, o as envPullFlagValue, r as ENV_PULL_KEY_HELP, s as envServiceKeys, t as BRANCH_ENV_KEY, u as serviceForEnvKey } from "./_chunks/env_services-
|
|
1
|
+
import { a as envKeysForSelection, c as ownedEnvServiceKeys, d as servicesForEnvKeys, i as ENV_PULL_SERVICES, l as parseEnvPullKeys, n as ENV_PULL_KEYS, o as envPullFlagValue, r as ENV_PULL_KEY_HELP, s as envServiceKeys, t as BRANCH_ENV_KEY, u as serviceForEnvKey } from "./_chunks/env_services-CbARRnq9.js";
|
|
2
2
|
export { BRANCH_ENV_KEY, ENV_PULL_KEYS, ENV_PULL_KEY_HELP, ENV_PULL_SERVICES, envKeysForSelection, envPullFlagValue, envServiceKeys, ownedEnvServiceKeys, parseEnvPullKeys, serviceForEnvKey, servicesForEnvKeys };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neon",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.0",
|
|
4
4
|
"description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"yaml": "^2.9.0",
|
|
64
64
|
"yargs": "17.7.2",
|
|
65
65
|
"yoctocolors": "^2.1.2",
|
|
66
|
-
"@neon/config": "1.3.
|
|
67
|
-
"@neon/
|
|
68
|
-
"@neon/
|
|
66
|
+
"@neon/config-runtime": "1.3.0",
|
|
67
|
+
"@neon/sdk": "4.1.0",
|
|
68
|
+
"@neon/config": "1.4.0"
|
|
69
69
|
},
|
|
70
70
|
"optionalDependencies": {
|
|
71
71
|
"@napi-rs/keyring": "1.3.0",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"typescript": "^5.9.0",
|
|
99
99
|
"vitest": "^3.0.9",
|
|
100
100
|
"@neon-internals/cli-core": "0.0.0",
|
|
101
|
-
"@neon-internals/env-core": "0.0.
|
|
101
|
+
"@neon-internals/env-core": "0.0.12",
|
|
102
102
|
"@neon/e2e-harness": "0.0.0",
|
|
103
103
|
"@neon/functions": "0.9.0"
|
|
104
104
|
},
|