neon 8.0.7 → 8.0.8

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.
@@ -113,10 +113,14 @@ function requiredValue(value, description) {
113
113
  async function fetchEnvKeys(config, options, keys) {
114
114
  return (await fetchEnvKeysState(config, options, keys)).env;
115
115
  }
116
- async function fetchEnvKeysState(config, options, keys) {
116
+ /**
117
+ * `policy` is the {@link resolveBranchPolicy} result for this same `config` and branch, when
118
+ * the caller already has it.
119
+ */
120
+ async function fetchEnvKeysState(config, options, keys, policy) {
117
121
  const api = options.api ?? createApiFromOptions(options);
118
122
  const projectId = options.projectId;
119
- const { branch, desired } = await resolveBranchPolicy(config, options, api);
123
+ const { branch, desired } = policy ?? await resolveBranchPolicy(config, options, api);
120
124
  const selection = keys ? new Set(keys) : null;
121
125
  const omitted = new Set(options.omitKeys ?? []);
122
126
  const wants = (key) => !omitted.has(key) && (selection === null || selection.has(key));
@@ -2,7 +2,7 @@ import { log } from "../log.js";
2
2
  import { getCliName } from "../utils/cli_name.js";
3
3
  import { declaredNeonServices } from "../config_services.js";
4
4
  import { loadProjectConfig } from "../project.js";
5
- import { a as defaultAiGatewayCredential, c as fetchEnvKeysState, d as isLiveCredential, h as toEntries, i as credentialName, l as functionBaseUrlKey, m as resolveBranchPolicy, n as createApiFromOptions, o as defaultStorageCredential, p as policyEnvKeys, r as credentialEnvKeys, t as NEON_ENV_VAR_KEYS, u as isFunctionBaseUrlKey } from "./env-N19A7qND.js";
5
+ import { a as defaultAiGatewayCredential, c as fetchEnvKeysState, d as isLiveCredential, h as toEntries, i as credentialName, l as functionBaseUrlKey, m as resolveBranchPolicy, n as createApiFromOptions, o as defaultStorageCredential, p as policyEnvKeys, r as credentialEnvKeys, t as NEON_ENV_VAR_KEYS, u as isFunctionBaseUrlKey } from "./env-Dkl0TY44.js";
6
6
  import { ENV_PULL_SERVICES, envKeysForSelection, serviceForEnvKey, servicesForEnvKeys } from "../env_services.js";
7
7
  import { formatInstallCommand, resolvePackageManager } from "../utils/package_manager.js";
8
8
  import { ErrorCode, createNeonApiFromOptions, isPlatformError } from "@neon/config";
@@ -57,7 +57,10 @@ async function fetchEnvReusingSecrets(config, options) {
57
57
  aiGateway: gatewayCredentialSelected
58
58
  }).filter((key) => selected.has(key));
59
59
  if (secretKeys.length === 0) {
60
- const fetched = await fetchEnvKeysState(config, fetchOptions, requested === null ? null : selectedPolicyKeys);
60
+ const fetched = await fetchEnvKeysState(config, fetchOptions, requested === null ? null : selectedPolicyKeys, {
61
+ branch,
62
+ desired
63
+ });
61
64
  return {
62
65
  vars: preferPersisted(toEntries(fetched.env), source),
63
66
  credential: {
@@ -91,10 +94,12 @@ async function fetchEnvReusingSecrets(config, options) {
91
94
  const fetchKeys = requested === null ? null : selectedPolicyKeys.filter((key) => !keptSecretKeys.includes(key));
92
95
  const fetched = await fetchEnvKeysState(config, {
93
96
  ...fetchOptions,
94
- branchId: branch.id,
95
97
  api,
96
98
  ...keptSecretKeys.length > 0 && requested === null ? { omitKeys: keptSecretKeys } : {}
97
- }, fetchKeys);
99
+ }, fetchKeys, {
100
+ branch,
101
+ desired
102
+ });
98
103
  const vars = preferPersisted(toEntries(fetched.env), source);
99
104
  const unavailable = fetched.functionUrlsUnavailable ? { functionUrlsUnavailable: true } : {};
100
105
  for (const key of keptSecretKeys) {
@@ -791,7 +791,7 @@ const applyCmd = async (props) => {
791
791
  await autoPullEnvAfterPin({
792
792
  ...props,
793
793
  envPull: props.envPull !== false
794
- });
794
+ }, branch);
795
795
  if (hooks?.deploy?.after) {
796
796
  const env = await resolveHookEnv(config, {
797
797
  projectId: props.projectId,
@@ -3,12 +3,12 @@ import { log } from "../log.js";
3
3
  import { isClaimableEnvTarget } from "../claimable/state.js";
4
4
  import { getCliName } from "../utils/cli_name.js";
5
5
  import { readEnvFile, resolveEnvFilePath } from "../env_file.js";
6
- import { l as functionBaseUrlKey } from "../_chunks/env-N19A7qND.js";
7
- import { branchIdResolve } from "../utils/enrichers.js";
8
- import { bundleEntry } from "../utils/esbuild.js";
9
- import { a as resolveDevEnv } from "../_chunks/env-BgiaRNT1.js";
6
+ import { l as functionBaseUrlKey } from "../_chunks/env-Dkl0TY44.js";
7
+ import { a as resolveDevEnv } from "../_chunks/env-HVRMArlT.js";
10
8
  import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
11
9
  import { resolveWatchInputs } from "../dev/inputs.js";
10
+ import { branchIdResolve } from "../utils/enrichers.js";
11
+ import { bundleEntry } from "../utils/esbuild.js";
12
12
  import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
13
13
  import { basename, dirname, join, relative, resolve } from "node:path";
14
14
  import { fileURLToPath } from "node:url";
@@ -5,12 +5,12 @@ import { isClaimableEnvTarget } from "../claimable/state.js";
5
5
  import { getCliName } from "../utils/cli_name.js";
6
6
  import { deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOption } from "../neon_services.js";
7
7
  import { mergeEnvFile, readEnvFile, resolveEnvFilePath } from "../env_file.js";
8
- import { t as NEON_ENV_VAR_KEYS, u as isFunctionBaseUrlKey } from "../_chunks/env-N19A7qND.js";
8
+ import { t as NEON_ENV_VAR_KEYS, u as isFunctionBaseUrlKey } from "../_chunks/env-Dkl0TY44.js";
9
9
  import { ENV_PULL_KEY_HELP, ENV_PULL_SERVICES, envKeysForSelection, envPullFlagValue, ownedEnvServiceKeys, parseEnvPullKeys } from "../env_services.js";
10
+ import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "../_chunks/env-HVRMArlT.js";
10
11
  import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
11
12
  import { warnAiGateway } from "../utils/ai_gateway_notice.js";
12
13
  import { announceTargetBranch } from "../utils/branch_notice.js";
13
- import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "../_chunks/env-BgiaRNT1.js";
14
14
  import { existsSync } from "node:fs";
15
15
  import chalk from "chalk";
16
16
  //#region src/commands/env.ts
@@ -133,7 +133,7 @@ const pull = async (props, opts = {}) => {
133
133
  const selectionServices = dropped ? dropped.services : props.services ?? [];
134
134
  const selectionEnvKeys = dropped ? dropped.envKeys : props.envKeys ?? [];
135
135
  const selectedKeys = props.services !== void 0 || props.envKeys !== void 0 ? envKeysForSelection(selectionServices, selectionEnvKeys) : void 0;
136
- const branch = await resolveBranchRef(props);
136
+ const branch = opts.branch ?? await resolveBranchRef(props);
137
137
  if (opts.announce) announceTargetBranch(props, branch, "Pulling env from branch");
138
138
  const branchId = branch.branchId;
139
139
  const location = {
@@ -251,13 +251,13 @@ const pickSelectedVars = (vars, selectedKeys, services) => {
251
251
  * command's primary effect and has already succeeded by the time this runs, so a pull failure
252
252
  * degrades to a warning rather than failing the command.
253
253
  */
254
- const autoPullEnvAfterPin = async (props) => {
254
+ const autoPullEnvAfterPin = async (props, branch) => {
255
255
  if (!props.envPull) {
256
256
  log.info(chalk.dim(ENV_PULL_SKIPPED_HINT));
257
257
  return { status: "skipped" };
258
258
  }
259
259
  try {
260
- return await pull(props);
260
+ return await pull(props, branch ? { branch } : {});
261
261
  } catch (err) {
262
262
  const message = err instanceof Error ? err.message : String(err);
263
263
  log.warning(`Branch pinned, but pulling its Neon env vars failed: %s
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-BgiaRNT1.js";
1
+ import { a as resolveDevEnv, i as dropClaimableUnsupported, n as MissingBranchContextError, o as resolveNeonEnvVars, r as ServiceNotOnBranchError, t as DevEnvMismatchError } from "../_chunks/env-HVRMArlT.js";
2
2
  export { DevEnvMismatchError, MissingBranchContextError, ServiceNotOnBranchError, dropClaimableUnsupported, resolveDevEnv, resolveNeonEnvVars };
@@ -1,5 +1,5 @@
1
1
  import { NEON_SERVICES } from "./neon_services.js";
2
- import { f as parseFunctionBaseUrlKey, t as NEON_ENV_VAR_KEYS, u as isFunctionBaseUrlKey } from "./_chunks/env-N19A7qND.js";
2
+ import { f as parseFunctionBaseUrlKey, t as NEON_ENV_VAR_KEYS, u as isFunctionBaseUrlKey } from "./_chunks/env-Dkl0TY44.js";
3
3
  //#region src/env_services.ts
4
4
  const ENV_PULL_SERVICES = NEON_SERVICES;
5
5
  const ENV_PULL_KEYS = [
@@ -1,6 +1,6 @@
1
1
  import { log } from "../log.js";
2
2
  import { loadProjectConfig } from "../project.js";
3
- import { s as fetchEnvKeys } from "../_chunks/env-N19A7qND.js";
3
+ import { s as fetchEnvKeys } from "../_chunks/env-Dkl0TY44.js";
4
4
  import { runHook } from "@neon/config-runtime";
5
5
  //#region src/utils/hooks.ts
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "8.0.7",
3
+ "version": "8.0.8",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -64,8 +64,8 @@
64
64
  "yaml": "^2.9.0",
65
65
  "yargs": "17.7.2",
66
66
  "yoctocolors": "^2.1.2",
67
- "@neon/config-runtime": "1.7.4",
68
67
  "@neon/sdk": "7.0.0",
68
+ "@neon/config-runtime": "1.7.5",
69
69
  "@neon/config": "1.8.3"
70
70
  },
71
71
  "optionalDependencies": {