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.
Files changed (53) hide show
  1. package/README.md +4 -4
  2. package/dist/_chunks/{auth-DY5Bm7Ym.js → auth-CEb642X3.js} +20 -9
  3. package/dist/_chunks/{auth_selection-CwGLN9Qz.js → auth_selection-D81EvEz9.js} +1 -1
  4. package/dist/_chunks/{checkout-B_hB_ELY.js → checkout-9zUY4N8W.js} +2 -2
  5. package/dist/_chunks/{claim-Dv5wARrN.js → claim-D7fATGLw.js} +1 -1
  6. package/dist/_chunks/{config-DFj1Btk-.js → config-CUWOp44_.js} +1 -1
  7. package/dist/_chunks/{credential_io-DbeSh3Pl.js → credential_io-BHwacMdt.js} +1 -1
  8. package/dist/_chunks/{credentials-BMBNmW0t.js → credentials-KV1jlK-n.js} +13 -2
  9. package/dist/_chunks/{data_api-CHDwvMTG.js → data_api-BpSGbdZf.js} +1 -1
  10. package/dist/_chunks/{deploy-CVJIahZE.js → deploy-BUkXtacE.js} +1 -1
  11. package/dist/_chunks/{dev-CtIzg7vq.js → dev-Dp6LuAe2.js} +1 -1
  12. package/dist/_chunks/{git-CIBowi6T.js → git-BISnX9MB.js} +2 -2
  13. package/dist/_chunks/{incidents-D6rDn1g2.js → incidents-BSFkUu1P.js} +5 -1
  14. package/dist/_chunks/{init-AKhj0lHa.js → init-BSwLzxjX.js} +3 -3
  15. package/dist/_chunks/{link-mdFXf8dW.js → link-CfbTC-or.js} +11 -13
  16. package/dist/_chunks/{profile-Qoyql0AR.js → profile-BVkmMwHO.js} +68 -28
  17. package/dist/_chunks/{profiles-DTazQtjK.js → profiles-kpRUx7gU.js} +32 -2
  18. package/dist/_chunks/{status-DRWS1u6H.js → status-BM42rYe1.js} +1 -1
  19. package/dist/analytics.js +1 -1
  20. package/dist/auth_recovery.js +2 -2
  21. package/dist/commands/auth.js +1 -1
  22. package/dist/commands/checkout.js +1 -1
  23. package/dist/commands/claim.js +1 -1
  24. package/dist/commands/config.js +1 -1
  25. package/dist/commands/credentials.js +1 -1
  26. package/dist/commands/data_api.js +1 -1
  27. package/dist/commands/deploy.js +1 -1
  28. package/dist/commands/dev.js +1 -1
  29. package/dist/commands/functions_new.js +1 -1
  30. package/dist/commands/git.js +1 -1
  31. package/dist/commands/incidents.js +1 -1
  32. package/dist/commands/index.js +14 -14
  33. package/dist/commands/init.js +1 -1
  34. package/dist/commands/link.js +1 -1
  35. package/dist/commands/profile.js +1 -1
  36. package/dist/commands/status.js +1 -1
  37. package/dist/credential_io.js +1 -1
  38. package/dist/dev/runtime.js +1 -1
  39. package/dist/functions/scaffold.js +3 -1
  40. package/dist/hosts.js +130 -0
  41. package/dist/index.js +8 -6
  42. package/dist/init/auth.js +1 -1
  43. package/dist/init/chrome.js +1 -0
  44. package/dist/init/copy.js +1 -1
  45. package/dist/init/deploy.js +2 -2
  46. package/dist/init/detect.js +3 -3
  47. package/dist/init/link.js +4 -5
  48. package/dist/init/run.js +16 -10
  49. package/dist/retire_credential.js +1 -1
  50. package/dist/utils/middlewares.js +1 -1
  51. package/dist/utils/package_manager.js +30 -3
  52. package/dist/utils/staging.js +6 -16
  53. package/package.json +9 -9
package/dist/init/run.js CHANGED
@@ -14,8 +14,8 @@ import { getAgentDisplayName } from "../mcp/agents.js";
14
14
  import { missingPluginsCommands, pluginsCommandProblemText, pluginsInstallableAgents, unusablePluginsCommands } from "../plugins/targets.js";
15
15
  import { AGENTS_NOT_INSTALLED, CANCELLED_BODY, CLAIMABLE_ACCOUNT_FLAGS, CLAIMABLE_ALREADY_LINKED, CLAIMABLE_MCP_API_KEY, CLAIMABLE_NO_LINK, MCP_API_KEY_NEEDS_AUTH, MCP_SCOPED_NEEDS_PROJECT, NON_TTY_LINK_NEEDS_AUTH, NO_AGENTS_FALLBACK_STATUS, PROGRESS, PROJECT_PINNED_OFFLINE, claimableNext, claimableThenServicesNext, configInitNext, envPullFailedNext, existingConfigNext, installFailedNext, mcpAfterLinkNext, mcpConfigLocationSkipped, mcpConfigLocationUnavailable, mcpKeyFailedNext, namedAgentsUnavailable, newConfigNext, offlinePinNext, skippedLinkNext, toolingFailedNext, unattendedUnauthedNext } from "./copy.js";
16
16
  import { agentsRowValue, configRowValue, formatInitDone, headingForKind, printInitBanner, printInitDone, printInitProgress, projectRowValue, shouldPrintInitBanner } from "./chrome.js";
17
- import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-DFj1Btk-.js";
18
- import { o as quoteFlagValue, s as runLink } from "../_chunks/link-mdFXf8dW.js";
17
+ import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-CUWOp44_.js";
18
+ import { o as quoteFlagValue, s as runLink } from "../_chunks/link-CfbTC-or.js";
19
19
  import { runAuthenticatedLink } from "./link.js";
20
20
  import { mcpInstallableAgents } from "../mcp/targets.js";
21
21
  import { skillsInstallableAgents } from "../skills/targets.js";
@@ -25,7 +25,7 @@ import { pullInitEnv, resolveInitConfigApi } from "./auth.js";
25
25
  import { InitCancelled, raceSigint, restoreCursor } from "./cancelled.js";
26
26
  import { pickAgentSetupInteractively, pickInitAgentsInteractively, pickInitConfigInteractively, pickInitMcpAuthInteractively, pickInitMcpConfigLocationInteractively, pickInitModeInteractively, pickInitPackageManagerInteractively, pickInitProjectSetupInteractively, pickInitServicesInteractively, pickInitSkillsInteractively } from "./wizard.js";
27
27
  import { runToolingSteps, toolingStepCommandText } from "./tooling.js";
28
- import { l as create } from "../_chunks/claim-Dv5wARrN.js";
28
+ import { l as create } from "../_chunks/claim-D7fATGLw.js";
29
29
  import { INIT_CONFIG_SERVICES_CONFLICT, configPlanFromResolution, initEnvPullAfterConfig, resolveInitConfigChoice } from "./choices.js";
30
30
  import { detectInitEnvironment } from "./detect.js";
31
31
  import { createInitFunnel, emitInitStart, finishInitFunnel, initStartProperties, recordInitError, recordInitExit } from "./funnel.js";
@@ -137,6 +137,7 @@ const defaultInitConfig = async (input) => {
137
137
  ...input.project.auth.clientId !== void 0 ? { clientId: input.project.auth.clientId } : {}
138
138
  };
139
139
  } catch (error) {
140
+ if (input.fromBranch) throw error;
140
141
  log.warning("Couldn't authenticate to read the Data API on the linked branch (%s); declaring it with Neon Auth.", error instanceof Error ? error.message : String(error));
141
142
  }
142
143
  await initCmd({
@@ -144,6 +145,7 @@ const defaultInitConfig = async (input) => {
144
145
  install: input.install,
145
146
  silent: true,
146
147
  requireInstall: true,
148
+ ...input.fromBranch ? { fromBranch: true } : {},
147
149
  ...input.services !== void 0 ? { services: input.services } : {},
148
150
  ...input.packageManager !== void 0 ? { packageManager: input.packageManager } : {},
149
151
  ...project
@@ -415,6 +417,7 @@ const runInit = async (props) => {
415
417
  step = "link";
416
418
  let projectSetup = "skip";
417
419
  let claimExpiresAt;
420
+ let linkedExisting = false;
418
421
  const noLink = props.link === false;
419
422
  const linkByDefault = detection.authenticated || hasExplicitLinkInputs && !yes;
420
423
  if (noLink) {
@@ -479,7 +482,7 @@ const runInit = async (props) => {
479
482
  } else if (projectSetup === "link") {
480
483
  step = "link";
481
484
  printInitProgress(detection.authenticated ? PROGRESS.link : PROGRESS.auth);
482
- await (props.linkProject ?? runAuthenticatedLink)(linkProps);
485
+ linkedExisting = (await (props.linkProject ?? runAuthenticatedLink)(linkProps))?.created === false;
483
486
  funnel.link = "linked";
484
487
  }
485
488
  const pinnedOffline = funnel.link === "skipped" && !noLink && linkInputs.orgId !== void 0 && linkInputs.projectId !== void 0 && linkInputs.branch !== void 0 && linkInputs.projectName === void 0 && linkInputs.regionId === void 0;
@@ -538,14 +541,15 @@ const runInit = async (props) => {
538
541
  });
539
542
  const accepted = configResolution.kind === "ask" ? await (props.pickConfig ?? pickInitConfigInteractively)() : void 0;
540
543
  let configPlan = configPlanFromResolution(configResolution, accepted);
541
- if (configPlan.kind === "write" && !existingConfig && configPlan.services === void 0 && !recommended && servicesFlag === void 0 && (detection.interactive || props.pickServices !== void 0)) {
544
+ const seedFromBranch = configPlan.kind === "write" && !existingConfig && linkedExisting && servicesFlag === void 0;
545
+ if (configPlan.kind === "write" && !existingConfig && !seedFromBranch && configPlan.services === void 0 && !recommended && servicesFlag === void 0 && (detection.interactive || props.pickServices !== void 0)) {
542
546
  const picked = await (props.pickServices ?? pickInitServicesInteractively)();
543
547
  configPlan = {
544
548
  kind: "write",
545
549
  services: picked.length === 0 ? ["postgres"] : picked
546
550
  };
547
551
  }
548
- if (recommended && configPlan.kind === "write" && !existingConfig) configPlan = {
552
+ if (recommended && configPlan.kind === "write" && !existingConfig && !seedFromBranch) configPlan = {
549
553
  kind: "write",
550
554
  services: servicesFlag ?? ["postgres"]
551
555
  };
@@ -555,8 +559,9 @@ const runInit = async (props) => {
555
559
  let selectedServices = null;
556
560
  const linkDeferredPull = deferLinkPull && projectSetup === "link" && funnel.link === "linked";
557
561
  if (configPlan.kind === "write") {
558
- const planned = existingConfig ? void 0 : configPlan.services ?? ["postgres"];
559
- if (planned !== void 0) {
562
+ const planned = existingConfig || seedFromBranch ? void 0 : configPlan.services ?? ["postgres"];
563
+ if (seedFromBranch) wroteNewFile = true;
564
+ else if (planned !== void 0) {
560
565
  declared = parseConfigInitServices(planned);
561
566
  extraServices = declared.length > 0;
562
567
  selectedServices = expandTelemetryServices(declared);
@@ -571,7 +576,7 @@ const runInit = async (props) => {
571
576
  }
572
577
  if (!existingConfig) printInitProgress(PROGRESS.config);
573
578
  printInitProgress(PROGRESS.install(pm));
574
- const readableProject = funnel.link !== "skipped" && !pinnedOffline && declared.includes("data-api") ? readContextFile(contextFile) : void 0;
579
+ const readableProject = funnel.link !== "skipped" && !pinnedOffline && (seedFromBranch || declared.includes("data-api")) ? readContextFile(contextFile) : void 0;
575
580
  const readableBranch = readableProject !== void 0 ? contextBranch(readableProject) : void 0;
576
581
  try {
577
582
  await (props.initConfig ?? defaultInitConfig)({
@@ -579,6 +584,7 @@ const runInit = async (props) => {
579
584
  install: true,
580
585
  packageManager: pm,
581
586
  ...planned !== void 0 ? { services: planned } : {},
587
+ ...seedFromBranch ? { fromBranch: true } : {},
582
588
  ...typeof readableProject?.projectId === "string" ? { project: {
583
589
  projectId: readableProject.projectId,
584
590
  ...readableBranch !== void 0 ? { branch: readableBranch } : {},
@@ -600,7 +606,7 @@ const runInit = async (props) => {
600
606
  }
601
607
  throw error;
602
608
  }
603
- funnel.config = existingConfig ? "existing" : "created";
609
+ funnel.config = existingConfig ? "existing" : seedFromBranch ? "seeded" : "created";
604
610
  } else funnel.config = "skipped";
605
611
  const context = readContextFile(contextFile);
606
612
  const branch = contextBranch(context);
@@ -1,4 +1,4 @@
1
- import { a as OAUTH, d as scopeOf, i as API_KEY, l as interpretCredentials, t as storeFor, u as isSameCredential } from "./_chunks/credential_io-DbeSh3Pl.js";
1
+ import { a as OAUTH, d as scopeOf, i as API_KEY, l as interpretCredentials, t as storeFor, u as isSameCredential } from "./_chunks/credential_io-BHwacMdt.js";
2
2
  import { log } from "./log.js";
3
3
  import { getApiClient } from "./api.js";
4
4
  import { revokeToken } from "./auth.js";
@@ -1,4 +1,4 @@
1
- import { r as recordCredentialInputs } from "../_chunks/auth_selection-CwGLN9Qz.js";
1
+ import { r as recordCredentialInputs } from "../_chunks/auth_selection-D81EvEz9.js";
2
2
  // src/utils/middlewares.ts
3
3
  /**
4
4
  * Forwarding Yargs's default would turn ambient configuration into an explicit child override.
@@ -14,7 +14,9 @@ import which from "which";
14
14
  * **`detect*` may return undefined, `resolve*` never does**, and `inferPackageManager` is the
15
15
  * composed detector for callers that can prompt rather than guess.
16
16
  *
17
- * - {@link detectProjectPackageManager} — lockfile walk from `cwd` up to the repo root
17
+ * - {@link detectProjectPackageManager} — lockfile walk from `cwd` up to the repo root; the
18
+ * project's pin or pnpm layout, then PATH, breaks the tie when one directory has lockfiles
19
+ * from several managers
18
20
  * - {@link detectInvokingPackageManager} — the tool that launched us (`npx`, `pnpm dlx`, …)
19
21
  * - {@link inferPackageManager} — project, then invocation, or nothing (when there is
20
22
  * something to ask the user, an unanswerable guess is worse than a prompt)
@@ -42,7 +44,8 @@ const PACKAGE_MANAGERS = [
42
44
  /**
43
45
  * Lockfiles, and the package manager each one belongs to. npm is last on
44
46
  * purpose: a repo with both a pnpm lockfile and a leftover `package-lock.json`
45
- * (which a failed run like the one this fixes can leave behind) is a pnpm repo.
47
+ * (which running npm in a pnpm repo leaves behind) is a pnpm repo, unless pnpm
48
+ * is not installed and nothing binds the repo to it.
46
49
  */
47
50
  const LOCKFILES = [
48
51
  ["pnpm-lock.yaml", "pnpm"],
@@ -52,8 +55,32 @@ const LOCKFILES = [
52
55
  ["package-lock.json", "npm"],
53
56
  ["npm-shrinkwrap.json", "npm"]
54
57
  ];
58
+ /**
59
+ * The package manager `dir` is already bound to: its `packageManager` pin, or pnpm for a
60
+ * pnpm workspace or a `node_modules` in pnpm's layout, which npm must never run against.
61
+ */
62
+ const boundPackageManager = (dir) => {
63
+ const pinned = readManifest(dir)?.packageManager;
64
+ if (typeof pinned === "string") {
65
+ const name = pinned.split("@")[0];
66
+ const pm = PACKAGE_MANAGERS.find((candidate) => candidate === name);
67
+ if (pm !== void 0) return pm;
68
+ }
69
+ return existsSync(join(dir, "pnpm-workspace.yaml")) || existsSync(join(dir, "node_modules", ".pnpm")) ? "pnpm" : void 0;
70
+ };
71
+ /**
72
+ * The package manager behind `dir`'s lockfiles. Lockfiles from several managers are common
73
+ * in app-builder exports (`bun.lockb` beside `package-lock.json`), which are then installed
74
+ * with whichever one the machine has, so the first one on PATH wins unless the project is
75
+ * bound to one. With none of them installed, the first stays the answer and the install
76
+ * fails naming it.
77
+ */
55
78
  const lockfileIn = (dir) => {
56
- for (const [file, pm] of LOCKFILES) if (existsSync(join(dir, file))) return pm;
79
+ const candidates = [...new Set(LOCKFILES.filter(([file]) => existsSync(join(dir, file))).map(([, pm]) => pm))];
80
+ if (candidates.length <= 1) return candidates[0];
81
+ const bound = boundPackageManager(dir);
82
+ if (bound !== void 0 && candidates.includes(bound)) return bound;
83
+ return candidates.find((pm) => which.sync(pm, { nothrow: true }) !== null) ?? candidates[0];
57
84
  };
58
85
  /** `.git` is a file rather than a directory in a worktree or a submodule. */
59
86
  const isRepoRoot = (dir) => existsSync(join(dir, ".git"));
@@ -1,28 +1,18 @@
1
- import { Parser, hideBin } from "yargs/helpers";
1
+ import { invocationHosts } from "../hosts.js";
2
+ import { hideBin } from "yargs/helpers";
2
3
  // src/utils/staging.ts
3
4
  /**
4
5
  * Staging-only features ship in a release before their API reaches production. The CLI
5
- * exposes them only when the API host it sends requests to (`--api-host`, else
6
- * `NEON_API_HOST`) is Neon's staging console; with production or no host set, they are
7
- * hidden from help and fail with a "coming soon" message.
6
+ * exposes them only when the API host it sends requests to (`--api-host`, else the selected
7
+ * profile's recorded host, else `NEON_API_HOST`) is Neon's staging console; with production or
8
+ * no host set, they are hidden from help and fail with a "coming soon" message.
8
9
  */
9
10
  const STAGING_API_HOST = "https://console-stage.neon.build/api/v2";
10
11
  /** `NEON_STAGING_API_HOST` lets the CLI's tests treat their local mock API as staging. */
11
12
  const stagingHostname = () => new URL(process.env.NEON_STAGING_API_HOST ?? "https://console-stage.neon.build/api/v2").hostname;
12
13
  const isStagingApiHost = (apiHost) => apiHost !== void 0 && URL.canParse(apiHost) && new URL(apiHost).hostname === stagingHostname();
13
14
  /** The API host this process was invoked with, read before or without yargs. */
14
- const stagingFeaturesEnabledForArgv = (args = hideBin(process.argv)) => {
15
- const { argv } = Parser.detailed([...args], {
16
- string: ["api-host"],
17
- alias: { "api-host": ["apiHost"] },
18
- configuration: {
19
- "populate--": true,
20
- "parse-positional-numbers": false
21
- }
22
- });
23
- const flag = argv["api-host"];
24
- return isStagingApiHost(typeof flag === "string" ? flag : process.env.NEON_API_HOST);
25
- };
15
+ const stagingFeaturesEnabledForArgv = (args = hideBin(process.argv)) => isStagingApiHost(invocationHosts(args).apiHost);
26
16
  /** `apiHost` is a command's resolved host; without one, the host this process was invoked with. */
27
17
  const stagingFeaturesEnabled = (apiHost) => apiHost === void 0 ? stagingFeaturesEnabledForArgv() : isStagingApiHost(apiHost);
28
18
  /** A hard stop: callers that degrade other failures to warnings let this one through. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "9.7.2",
3
+ "version": "9.9.0",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -73,10 +73,10 @@
73
73
  "yaml": "^2.9.0",
74
74
  "yargs": "17.7.2",
75
75
  "yoctocolors": "^2.1.2",
76
- "@neon/config": "1.14.4",
77
- "@neon/config-runtime": "1.12.7",
78
- "@neon/realtime": "0.2.1",
79
- "@neon/sdk": "7.14.2"
76
+ "@neon/sdk": "7.14.3",
77
+ "@neon/config": "1.14.5",
78
+ "@neon/config-runtime": "1.12.8",
79
+ "@neon/realtime": "0.2.1"
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@napi-rs/keyring": "1.3.0",
@@ -113,10 +113,10 @@
113
113
  "typescript": "^5.9.0",
114
114
  "vitest": "^3.0.9",
115
115
  "@neon-internals/cli-core": "0.0.0",
116
- "@neon-internals/env-core": "0.0.55",
117
- "@neon/env": "2.1.7",
118
- "@neon/functions": "0.11.0",
119
- "@neon/e2e-harness": "0.0.0"
116
+ "@neon-internals/env-core": "0.0.56",
117
+ "@neon/e2e-harness": "0.0.0",
118
+ "@neon/env": "2.1.8",
119
+ "@neon/functions": "0.11.0"
120
120
  },
121
121
  "publishConfig": {
122
122
  "access": "public",