neon 4.7.0 → 4.8.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 +37 -59
- package/dist/_chunks/{auth_selection-ktL6uoEe.js → auth_selection-pitMFzDe.js} +1 -1
- package/dist/_chunks/{credential_io-B1JxWELN.js → credential_io-YeAxg9Xn.js} +2 -2
- package/dist/_chunks/{paths-g3DRqJiD.js → paths-DMq0Lt7a.js} +1 -1
- package/dist/_chunks/{profiles-D95AeZ5v.js → profiles-CvnFEQyd.js} +1 -1
- package/dist/analytics.js +2 -2
- package/dist/auth_context.js +1 -1
- package/dist/commands/auth.js +12 -9
- package/dist/commands/bootstrap.js +72 -43
- package/dist/commands/claim.js +1 -1
- package/dist/commands/init.js +80 -79
- package/dist/commands/link.js +78 -63
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/plugins.js +4 -4
- package/dist/commands/profile.js +4 -4
- package/dist/commands/skills.js +1 -1
- package/dist/config.js +1 -1
- package/dist/credential_io.js +1 -1
- package/dist/index.js +1 -1
- package/dist/init/child.js +36 -0
- package/dist/init/plan.js +47 -0
- package/dist/init/tooling.js +43 -0
- package/dist/init/wizard.js +42 -0
- package/dist/mcp/targets.js +1 -1
- package/dist/plugins/plan.js +1 -1
- package/dist/plugins/targets.js +5 -1
- package/dist/retire_credential.js +1 -1
- package/dist/utils/middlewares.js +1 -1
- package/dist/utils/package_manager.js +10 -5
- package/package.json +13 -14
- package/dist/init/auth.js +0 -53
- package/dist/init/build_config.js +0 -4
- package/dist/init/detect_agent.js +0 -63
- package/dist/init/editors.js +0 -19
- package/dist/init/enrich_output.js +0 -61
- package/dist/init/extension.js +0 -154
- package/dist/init/inspect.js +0 -249
- package/dist/init/interactive.js +0 -529
- package/dist/init/neonctl.js +0 -139
- package/dist/init/orchestrate.js +0 -189
- package/dist/init/phases/auth.js +0 -195
- package/dist/init/phases/cleanup.js +0 -27
- package/dist/init/phases/db.js +0 -257
- package/dist/init/phases/getting_started.js +0 -218
- package/dist/init/phases/mcp.js +0 -219
- package/dist/init/phases/migrations.js +0 -250
- package/dist/init/phases/neon_auth.js +0 -116
- package/dist/init/phases/setup.js +0 -582
- package/dist/init/phases/skills.js +0 -86
- package/dist/init/phases/status.js +0 -82
- package/dist/init/profile_cli.js +0 -56
- package/dist/init/resolve_context.js +0 -105
- package/dist/init/route_command.js +0 -93
- package/dist/init/skills.js +0 -206
- package/dist/init/types.js +0 -1
- package/dist/init/vsix.js +0 -89
package/README.md
CHANGED
|
@@ -257,7 +257,7 @@ The Neon CLI supports autocompletion, which you can configure in a few easy step
|
|
|
257
257
|
|
|
258
258
|
- **org** is inferred from the project (so `--project-id` alone is enough); it's omitted only when the project has no organization (personal account).
|
|
259
259
|
- **project** is taken from `--project-id` (or chosen interactively).
|
|
260
|
-
- **branch** is
|
|
260
|
+
- **branch** is taken from `--branch`, an existing pin for the same project, or the project's branch list: one branch is pinned automatically; several prompt in a TTY, pin the default with `-y`, or stay unpinned for [`neon checkout <branch>`](#checkout). A project with no branches is linked without a pin and says so.
|
|
261
261
|
|
|
262
262
|
When a branch ends up pinned, `link` also runs [`env pull`](#env-pull) so the branch's Neon env vars (`DATABASE_URL`, …) land in a local `.env`. With no branch pinned there is nothing to pull, so `link` instead nudges you to run `neon checkout`. Pass `--no-env-pull` to skip the pull (for example when injecting env at runtime with `neon-env run` or `neon dev`).
|
|
263
263
|
|
|
@@ -282,22 +282,34 @@ Linked .neon:
|
|
|
282
282
|
|
|
283
283
|
When you link an **existing** project that has more than one branch, the interactive flow adds a
|
|
284
284
|
final step to pick which branch to pin — the same `+ Create a new branch…` + list selector used by
|
|
285
|
-
`neon checkout` (a single-branch project is pinned automatically, no prompt)
|
|
286
|
-
`link --project-id …` does **not** prompt or default a branch; it links org + project and leaves
|
|
287
|
-
branch selection to `neon checkout`:
|
|
285
|
+
`neon checkout` (a single-branch project is pinned automatically, no prompt):
|
|
288
286
|
|
|
289
287
|
```bash
|
|
288
|
+
$ neon link
|
|
290
289
|
? Which organization would you like to link? › Personal Org (org-abc123)
|
|
291
290
|
? Which project would you like to link? › my-app (polished-snowflake-12345678)
|
|
292
291
|
? Which branch would you like to link? › [default] main (br-main-branch-87654321)
|
|
293
292
|
```
|
|
294
293
|
|
|
294
|
+
`link --project-id …` skips org and project. One branch is pinned with no prompt. Several branches
|
|
295
|
+
in a TTY show the branch prompt; `-y` pins the default; no TTY leaves the pin empty for
|
|
296
|
+
`neon checkout`:
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
$ neon link --project-id polished-snowflake-12345678
|
|
300
|
+
? Which branch would you like to link? › [default] main (br-main-branch-87654321)
|
|
301
|
+
```
|
|
302
|
+
|
|
295
303
|
**Non-interactive (flags or `--params` JSON)** — for scripts and CI:
|
|
296
304
|
|
|
297
305
|
```bash
|
|
298
|
-
# Link to an existing project (org is inferred
|
|
306
|
+
# Link to an existing project (org is inferred). Pins the only branch;
|
|
307
|
+
# several branches prompt in a TTY, or stay unpinned without one.
|
|
299
308
|
neon link --project-id polished-snowflake-12345678
|
|
300
309
|
|
|
310
|
+
# Same, pin the project's default branch when several exist
|
|
311
|
+
neon link --project-id polished-snowflake-12345678 -y
|
|
312
|
+
|
|
301
313
|
# Same, but also pin a branch (name or id — resolved and stored as its name)
|
|
302
314
|
neon link --project-id polished-snowflake-12345678 --branch main
|
|
303
315
|
|
|
@@ -327,7 +339,7 @@ Every supplied identifier is checked before anything is written, with actionable
|
|
|
327
339
|
```bash
|
|
328
340
|
neon orgs list --output json
|
|
329
341
|
neon projects list --org-id <org-id> --output json
|
|
330
|
-
neon link --project-id <project-id>
|
|
342
|
+
neon link --project-id <project-id> [--branch <name> | -y]
|
|
331
343
|
neon link --org-id <org-id> --project-name <name> --region-id aws-us-east-2
|
|
332
344
|
```
|
|
333
345
|
|
|
@@ -352,7 +364,7 @@ How today's `set-context` uses map onto `link`:
|
|
|
352
364
|
|
|
353
365
|
| `set-context` (deprecated) | Recommended `link` equivalent |
|
|
354
366
|
| --------------------------------------- | ----------------------------------------------------------------------------- |
|
|
355
|
-
| `neon set-context --project-id <id>` | `neon link --project-id <id>` (infers org + verifies;
|
|
367
|
+
| `neon set-context --project-id <id>` | `neon link --project-id <id>` (infers org + verifies; pins the only branch) |
|
|
356
368
|
| `neon set-context --org-id <id>` | `neon link --org-id <id>` |
|
|
357
369
|
| `neon set-context --branch-id <id>` | `neon link --branch <name\|id>` |
|
|
358
370
|
| `neon set-context` (clear) | `neon link --clear` |
|
|
@@ -657,7 +669,9 @@ When a package cannot be bundled — a native addon with no esbuild loader, or a
|
|
|
657
669
|
|
|
658
670
|
## Scaffold a project (`bootstrap`)
|
|
659
671
|
|
|
660
|
-
`neon bootstrap` copies a Neon starter template into a new (or current) directory — conceptually like `degit`, but it only pulls from a small set of templates we maintain in the public [`neondatabase/examples`](https://github.com/neondatabase/examples) repo.
|
|
672
|
+
`neon bootstrap` copies a Neon starter template into a new (or current) directory — conceptually like `degit`, but it only pulls from a small set of templates we maintain in the public [`neondatabase/examples`](https://github.com/neondatabase/examples) repo. The template copy needs no Neon login: it downloads files from GitHub.
|
|
673
|
+
|
|
674
|
+
After scaffolding, an interactive terminal offers agent tooling (the Neon plugin, or skills and MCP separately — never both) and then `neon link`. `--default` / `-y` skips the template, install, git, and agent pickers, then runs `link --yes`. `link --yes` still asks for a project unless one is already linked. `--no-agent-setup` and `--no-link` skip those. Non-interactive without `--default` prints next steps and does not install, set up agents, or link.
|
|
661
675
|
|
|
662
676
|
Pass a target directory (or `.` for the current one). In an interactive terminal you pick the template from a list; in CI / non-interactive contexts pass `--template <id>`.
|
|
663
677
|
|
|
@@ -665,7 +679,7 @@ Pass a target directory (or `.` for the current one). In an interactive terminal
|
|
|
665
679
|
# Pick a template interactively and scaffold it into ./my-app
|
|
666
680
|
$ neon bootstrap my-app
|
|
667
681
|
|
|
668
|
-
# Scaffold a specific template into the current directory (
|
|
682
|
+
# Scaffold a specific template into the current directory (skips the template picker)
|
|
669
683
|
$ neon bootstrap . --template hono
|
|
670
684
|
|
|
671
685
|
# List templates
|
|
@@ -677,64 +691,28 @@ $ neon bootstrap --list-templates --output json
|
|
|
677
691
|
|
|
678
692
|
The target directory must be empty unless you pass `--force` (a lone `.git` is ignored, so a freshly `git init`ed folder is fine). Symlinks and executable bits in the template are preserved.
|
|
679
693
|
|
|
680
|
-
## Set up a project
|
|
681
|
-
|
|
682
|
-
`neon init` wires an existing project up to Neon: it signs you in, installs the Neon MCP server and agent skills into your editor, adds the Neon Local Connect extension for VS Code and Cursor, creates or picks a project, writes `DATABASE_URL` into `.env`, and offers to scaffold migrations.
|
|
683
|
-
|
|
684
|
-
```bash
|
|
685
|
-
$ neon init
|
|
686
|
-
```
|
|
694
|
+
## Set up a project (`init`)
|
|
687
695
|
|
|
688
|
-
|
|
696
|
+
`neon init` sets up this directory for Neon.
|
|
689
697
|
|
|
690
|
-
|
|
698
|
+
An empty directory (nothing except `.git`) runs `neon bootstrap .` and stops. With `-y` that is `neon bootstrap . --default`. Bootstrap handles scaffolding, agent tooling, and linking.
|
|
691
699
|
|
|
692
|
-
|
|
700
|
+
An existing app installs agent tooling, then `neon link` unless `.neon` already has a projectId, then `neon config init`. Interactive `config init` opens the services picker; `-y` uses `--services none` (starter policy).
|
|
693
701
|
|
|
694
|
-
|
|
702
|
+
In an interactive terminal it offers one of: the Neon plugin (`neon plugins`), skills and MCP separately (`neon skills`, then `neon mcp`), or skip agent setup. It never runs plugin and skills+MCP together.
|
|
695
703
|
|
|
696
704
|
```bash
|
|
697
|
-
$ neon init
|
|
698
|
-
|
|
699
|
-
"auth": { "authenticated": true },
|
|
700
|
-
"tooling": { "mcpServer": { "configured": true, "scope": "global" }, "skills": { "installed": false, "scope": null } },
|
|
701
|
-
"project": { "databaseUrl": false },
|
|
702
|
-
"migrations": { "tool": "prisma", "hasMigrations": false },
|
|
703
|
-
"recommendations": [
|
|
704
|
-
{ "priority": "high", "message": "No DATABASE_URL found in .env", "command": "neon init --agent --data '{\"step\":\"db\"}'" },
|
|
705
|
-
{ "priority": "medium", "message": "Neon agent skills not detected in this project", "command": "neon init --agent --data '{\"step\":\"skills\",\"install\":true}'" },
|
|
706
|
-
{ "priority": "medium", "message": "prisma detected but no migrations found", "command": "neon init --agent --data '{\"step\":\"migrations\"}'" }
|
|
707
|
-
]
|
|
708
|
-
}
|
|
705
|
+
$ neon init
|
|
706
|
+
$ neon init -y
|
|
709
707
|
```
|
|
710
708
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
`--data` takes a JSON object whose `step` selects the phase: `auth`, `db`, `setup`, `getting-started`, `mcp`, `skills`, `migrations`, `neon-auth`, `status`, or `finalize`. Remaining keys are that phase's options. Without `--data`, the orchestrator picks the next phase itself. An unrecognised `step` is refused with the full list.
|
|
714
|
-
|
|
715
|
-
**Failures are JSON too**, so an agent never has to distinguish "it broke" from "it returned nothing":
|
|
709
|
+
`-y` skips the template picker and the agent-setup offer. Empty dir: `bootstrap --default`. Existing app: plugin when a project-level plugin agent is detected (Cursor, Claude Code, Codex); otherwise skills and MCP. VS Code, GitHub Copilot CLI, and Grok only take the plugin user-level (`neon plugins --global`), so `-y` uses skills and MCP for those.
|
|
716
710
|
|
|
717
|
-
|
|
718
|
-
$ neon init --agent --data '{not json'
|
|
719
|
-
{
|
|
720
|
-
"success": false,
|
|
721
|
-
"error": "Invalid JSON in --data flag at position 1. Expected a JSON object."
|
|
722
|
-
}
|
|
723
|
-
$ echo $?
|
|
724
|
-
1
|
|
725
|
-
```
|
|
726
|
-
|
|
727
|
-
That message reports where parsing stopped and nothing more. `--data` carries whatever you put in it, and the JSON parser's own message quotes a window of the input, so echoing either would put a connection string or an API key on stdout.
|
|
711
|
+
`-y` forwards `-y` to `plugins` or `skills`/`mcp`, `--default` to `bootstrap`, `--yes` to `link`, and `--services none` to `config init`. `link --yes` only skips the "already linked" confirmation; it still asks for a project unless one is already linked.
|
|
728
712
|
|
|
729
|
-
|
|
713
|
+
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.
|
|
730
714
|
|
|
731
|
-
|
|
732
|
-
| --- | --- |
|
|
733
|
-
| `--agent`, `-a` | Emit the JSON state machine instead of prompting |
|
|
734
|
-
| `--data <json>` | Route to one phase, with that phase's options |
|
|
735
|
-
| `--skip-migrations` | Leave the migrations phase out of the flow |
|
|
736
|
-
| `--preview` | Enable preview features (scaffolding a project from a template) |
|
|
737
|
-
| `--profile <name>` | Run as that stored account. See [Which credential an invocation uses](#which-credential-an-invocation-uses). |
|
|
715
|
+
`skills` needs Node.js 22.20 or newer. See [`bootstrap`](#scaffold-a-project-bootstrap), [`plugins`](#install-the-neon-plugin-plugins), [`skills`](#install-neon-agent-skills-skills), [`link`](#linking-a-project), and [`mcp`](#install-the-neon-mcp-server-mcp) for what those commands write.
|
|
738
716
|
|
|
739
717
|
## Install the Neon MCP server (`mcp`)
|
|
740
718
|
|
|
@@ -1116,7 +1094,7 @@ When both are only environment variables the key wins, which keeps a CI pipeline
|
|
|
1116
1094
|
|
|
1117
1095
|
`neon auth` and the `profile` subcommands are outside all of this, because they read the same flags to mean something else: `neon auth --profile work` names where to write a credential, and `neon profile create work --api-key …` names one to store.
|
|
1118
1096
|
|
|
1119
|
-
`neon init`
|
|
1097
|
+
`neon init` forwards `--profile` and `--config-dir` to the commands it runs. An explicit `--api-key` is passed to those children through `NEON_API_KEY`, not argv.
|
|
1120
1098
|
|
|
1121
1099
|
## API keys (`api-keys`)
|
|
1122
1100
|
|
|
@@ -1213,8 +1191,8 @@ Id Name Project Created At Last Used At Last
|
|
|
1213
1191
|
| open | | Open the linked project in Console |
|
|
1214
1192
|
| config | `init`, `status`, `plan`, `apply` | Drive a branch from `neon.ts` |
|
|
1215
1193
|
| deploy | | Alias for `config apply` |
|
|
1216
|
-
| bootstrap | | Scaffold a
|
|
1217
|
-
| init | |
|
|
1194
|
+
| bootstrap | | Scaffold a template, then agent tooling and link |
|
|
1195
|
+
| init | | Empty dir: bootstrap. Existing: agents, link, neon.ts |
|
|
1218
1196
|
| mcp | | Install the Neon MCP server |
|
|
1219
1197
|
| plugins | | Install the Neon plugin |
|
|
1220
1198
|
| skills | `update` | Install Neon agent skills |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as writeSecretFile } from "./secure_file-BucZj4yQ.js";
|
|
2
|
-
import {
|
|
3
|
-
import { f as profilesFilePath, v as CRED_STORAGE_FILE, y as CRED_STORAGE_KEYRING } from "./profiles-
|
|
2
|
+
import { a as isOwnedCredentialPath } from "./paths-DMq0Lt7a.js";
|
|
3
|
+
import { f as profilesFilePath, v as CRED_STORAGE_FILE, y as CRED_STORAGE_KEYRING } from "./profiles-CvnFEQyd.js";
|
|
4
4
|
import { tryLoadKeyring } from "../keyring.js";
|
|
5
5
|
import { existsSync, readFileSync, rmSync } from "node:fs";
|
|
6
6
|
import { dirname } from "node:path";
|
|
@@ -148,4 +148,4 @@ const isOwnedCredentialPath = (configDirectory, file) => {
|
|
|
148
148
|
return legacy !== void 0 && isInsideConfigDir(legacy, file);
|
|
149
149
|
};
|
|
150
150
|
//#endregion
|
|
151
|
-
export {
|
|
151
|
+
export { isOwnedCredentialPath as a, isInsideConfigDir as i, credentialsPath as n, resolveConfigFile as o, defaultDir as r, CREDENTIALS_FILE as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as writeSecretFile } from "./secure_file-BucZj4yQ.js";
|
|
2
|
-
import {
|
|
2
|
+
import { n as credentialsPath, o as resolveConfigFile, r as defaultDir } from "./paths-DMq0Lt7a.js";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
5
5
|
//#region ../../internals/cli-core/dist/cli_config.js
|
package/dist/analytics.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as OAUTH, t as storeFor } from "./_chunks/credential_io-
|
|
1
|
+
import { a as OAUTH, t as storeFor } from "./_chunks/credential_io-YeAxg9Xn.js";
|
|
2
2
|
import { getCliAgent, getGithubEnvVars, isCi } from "./env.js";
|
|
3
3
|
import { log } from "./log.js";
|
|
4
4
|
import pkg_default from "./pkg.js";
|
|
5
5
|
import { getApiClient, isNeonApiError } from "./api.js";
|
|
6
|
-
import {
|
|
6
|
+
import { n as credentialsPath } from "./_chunks/paths-DMq0Lt7a.js";
|
|
7
7
|
import "./config.js";
|
|
8
8
|
import { getAuthContext } from "./auth_context.js";
|
|
9
9
|
import { isCurrentBranchProbe } from "./context.js";
|
package/dist/auth_context.js
CHANGED
package/dist/commands/auth.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { a as OAUTH, i as API_KEY, l as interpretCredentials, s as credentialLabel, t as storeFor } from "../_chunks/credential_io-
|
|
2
|
+
import { a as OAUTH, i as API_KEY, l as interpretCredentials, s as credentialLabel, t as storeFor } from "../_chunks/credential_io-YeAxg9Xn.js";
|
|
3
3
|
import { isCi } from "../env.js";
|
|
4
4
|
import { log } from "../log.js";
|
|
5
5
|
import { getApiClient } from "../api.js";
|
|
6
|
-
import {
|
|
6
|
+
import { a as isOwnedCredentialPath } from "../_chunks/paths-DMq0Lt7a.js";
|
|
7
7
|
import { setAuthContext } from "../auth_context.js";
|
|
8
8
|
import { currentContextFile, isClaimCommand, isConfigInit, isCurrentBranchProbe, isMcpCommand, isMcpOauth, isPluginsCommand, isProfileCommand, isSkillsCommand, readContextFile } from "../context.js";
|
|
9
|
-
import { _ as upsertProfile, d as newProfileLocation, g as selectProfileName, h as resolveProfile, i as assertValidProfileName, l as locationForName, m as readProfiles, n as KEYRING_CREDENTIALS, p as profilesUsingPath, r as assertProfilesUsable, s as isKeyringPointer, t as DEFAULT_PROFILE, u as locationOf } from "../_chunks/profiles-
|
|
9
|
+
import { _ as upsertProfile, d as newProfileLocation, g as selectProfileName, h as resolveProfile, i as assertValidProfileName, l as locationForName, m as readProfiles, n as KEYRING_CREDENTIALS, p as profilesUsingPath, r as assertProfilesUsable, s as isKeyringPointer, t as DEFAULT_PROFILE, u as locationOf } from "../_chunks/profiles-CvnFEQyd.js";
|
|
10
10
|
import { extendTokenSet } from "../utils/auth.js";
|
|
11
11
|
import { auth, refreshToken } from "../auth.js";
|
|
12
|
-
import { i as selectCredential, n as displacedProfileWarning, t as credentialInputs } from "../_chunks/auth_selection-
|
|
12
|
+
import { i as selectCredential, n as displacedProfileWarning, t as credentialInputs } from "../_chunks/auth_selection-pitMFzDe.js";
|
|
13
13
|
import { ClaimableClient, ClaimableServiceError } from "../claimable/api.js";
|
|
14
14
|
import { assertionHasExpired, claimableCredentialsPath, readClaimableCredentials, resolveClaimableContext, shouldUseClaimableCredentials } from "../claimable/state.js";
|
|
15
15
|
import { readOutgoingCredential, retirePreviousCredential } from "../retire_credential.js";
|
|
@@ -220,10 +220,17 @@ const ensureAuth = async (props) => {
|
|
|
220
220
|
if (isMcpOauth(props)) return;
|
|
221
221
|
if (props._[0] === "open") return;
|
|
222
222
|
if (isSkillsCommand(props) || isPluginsCommand(props)) return;
|
|
223
|
+
if (props._[0] === "init") {
|
|
224
|
+
selectCredential({
|
|
225
|
+
...credentialInputs(),
|
|
226
|
+
profileFlag: props.profile
|
|
227
|
+
});
|
|
228
|
+
log.debug("init: skipping global auth; child commands authenticate");
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
223
231
|
if (isClaimCommand(props)) return;
|
|
224
232
|
const isLocalDev = props._[0] === "dev";
|
|
225
233
|
const isBootstrap = props._[0] === "bootstrap";
|
|
226
|
-
const isInit = props._[0] === "init";
|
|
227
234
|
const isMcp = isMcpCommand(props);
|
|
228
235
|
if (props._[0] === "auth") {
|
|
229
236
|
props.apiClient = getApiClient({
|
|
@@ -334,10 +341,6 @@ const ensureAuth = async (props) => {
|
|
|
334
341
|
log.debug("bootstrap: no usable credentials; continuing without auth");
|
|
335
342
|
return;
|
|
336
343
|
}
|
|
337
|
-
if (isInit) {
|
|
338
|
-
log.debug("init: skipping global auth; init manages its own auth flow");
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
344
|
if (isMcp) {
|
|
342
345
|
log.debug("mcp: no usable credentials; minting requires auth or --oauth");
|
|
343
346
|
return;
|
|
@@ -2,9 +2,12 @@ import { t as __exportAll } from "../_chunks/rolldown-runtime-8H4AJuhK.js";
|
|
|
2
2
|
import { isCi } from "../env.js";
|
|
3
3
|
import { log } from "../log.js";
|
|
4
4
|
import { getCliName } from "../utils/cli_name.js";
|
|
5
|
-
import { t as credentialInputs } from "../_chunks/auth_selection-
|
|
5
|
+
import { t as credentialInputs } from "../_chunks/auth_selection-pitMFzDe.js";
|
|
6
6
|
import { writer } from "../writer.js";
|
|
7
7
|
import { FALLBACK_TEMPLATES, ensureTargetUsable, fetchTemplates, findTemplate, scaffoldTemplate, templateIds } from "../init/bootstrap.js";
|
|
8
|
+
import { spawnCliChild } from "../init/child.js";
|
|
9
|
+
import { projectContextFile } from "../init/plan.js";
|
|
10
|
+
import { runScaffoldFollowUp } from "../init/tooling.js";
|
|
8
11
|
import { formatInstallCommand, inferPackageManager, installArgs, installedPackageManagers, resolvePackageManager, runCommand } from "../utils/package_manager.js";
|
|
9
12
|
import { existsSync } from "node:fs";
|
|
10
13
|
import { join, relative, resolve } from "node:path";
|
|
@@ -19,7 +22,7 @@ var bootstrap_exports = /* @__PURE__ */ __exportAll({
|
|
|
19
22
|
});
|
|
20
23
|
const removedAgent = () => `\`${getCliName()} bootstrap --agent\` was removed. List templates with \`${getCliName()} bootstrap --list-templates --output json\`. Scaffold with \`${getCliName()} bootstrap <directory> --template <id>\` or \`${getCliName()} bootstrap <directory> --default\`.`;
|
|
21
24
|
const command = "bootstrap [directory]";
|
|
22
|
-
const describe = "Scaffold a new project from a Neon starter template";
|
|
25
|
+
const describe = "Scaffold a new project from a Neon starter template, then install agent tooling and link a Neon project";
|
|
23
26
|
const builder = (argv) => argv.usage("$0 bootstrap [directory] [options]").positional("directory", {
|
|
24
27
|
describe: "Directory to scaffold into. Use \".\" for the current directory. Omit to be prompted.",
|
|
25
28
|
type: "string"
|
|
@@ -45,7 +48,7 @@ const builder = (argv) => argv.usage("$0 bootstrap [directory] [options]").posit
|
|
|
45
48
|
},
|
|
46
49
|
default: {
|
|
47
50
|
alias: "y",
|
|
48
|
-
describe: "Quick start: scaffold the default template (or --template)
|
|
51
|
+
describe: "Quick start: scaffold the default template (or --template), then install, git, agent tooling, and link --yes. Skips those pickers; link --yes still asks for a project unless one is already linked",
|
|
49
52
|
type: "boolean",
|
|
50
53
|
default: false
|
|
51
54
|
},
|
|
@@ -63,8 +66,13 @@ const builder = (argv) => argv.usage("$0 bootstrap [directory] [options]").posit
|
|
|
63
66
|
describe: `Run \`${getCliName()} link\` in the scaffolded directory after installing. In interactive mode this is offered as a prompt; use --no-link to skip without being asked.`,
|
|
64
67
|
type: "boolean",
|
|
65
68
|
default: true
|
|
69
|
+
},
|
|
70
|
+
"agent-setup": {
|
|
71
|
+
type: "boolean",
|
|
72
|
+
default: true,
|
|
73
|
+
describe: "After scaffolding, install the Neon plugin or skills and MCP. Use --no-agent-setup to skip"
|
|
66
74
|
}
|
|
67
|
-
}).example("$0 bootstrap my-app", "Create ./my-app from an interactively chosen template").example("$0 bootstrap . --template hono", "Scaffold the Hono template into the current directory").example("$0 bootstrap my-app --default", "
|
|
75
|
+
}).example("$0 bootstrap my-app", "Create ./my-app from an interactively chosen template").example("$0 bootstrap . --template hono", "Scaffold the Hono template into the current directory").example("$0 bootstrap my-app --default", "Skip the pickers; link --yes still asks for a project unless one is already linked").example("$0 bootstrap --list-templates --output json", "Print the template catalog as JSON").check((argv) => {
|
|
68
76
|
if (argv.agent === true) throw new Error(removedAgent());
|
|
69
77
|
return true;
|
|
70
78
|
}).strict();
|
|
@@ -163,12 +171,6 @@ const resolveTargetDir = async (props, interactive, template) => {
|
|
|
163
171
|
return resolve(process.cwd(), dir === "." ? "" : dir);
|
|
164
172
|
};
|
|
165
173
|
const defaultDirName = (template) => template.source.subdir.split("/").pop() || template.id;
|
|
166
|
-
/**
|
|
167
|
-
* Download and materialize the template into `targetDir`. The actual
|
|
168
|
-
* download/extract/write lives in `src/init/bootstrap.ts`, shared with `neon init`
|
|
169
|
-
* (exec-bit and symlink fidelity, graceful symlink fallback); here we just
|
|
170
|
-
* frame it with progress logging. Returns the number of files written.
|
|
171
|
-
*/
|
|
172
174
|
const scaffold = async (template, targetDir) => {
|
|
173
175
|
log.info("Fetching template \"%s\" from GitHub…", template.id);
|
|
174
176
|
const filesWritten = await scaffoldTemplate(template, targetDir, { onWarn: (message) => {
|
|
@@ -198,16 +200,33 @@ const runPostScaffoldSteps = async (props, targetDir, interactive) => {
|
|
|
198
200
|
installed = await runCommand(pm, installArgs(pm), targetDir);
|
|
199
201
|
}
|
|
200
202
|
if (props.git && !isGitRepo(targetDir) && await confirm("Initialize a git repository?")) await initGitRepo(targetDir);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
203
|
+
const skipLink = shouldSkipLinkForDeps(targetDir, installed);
|
|
204
|
+
if (props.link && skipLink) logSkippedLink(pm);
|
|
205
|
+
const kids = bootstrapChildren(props, targetDir);
|
|
206
|
+
await runScaffoldFollowUp({
|
|
207
|
+
cwd: targetDir,
|
|
208
|
+
yes: false,
|
|
209
|
+
skipAgentSetup: props.agentSetup === false,
|
|
210
|
+
shouldLink: false,
|
|
211
|
+
linkYes: false,
|
|
212
|
+
...kids,
|
|
213
|
+
...props.pickAgentSetup ? { pickAgentSetup: props.pickAgentSetup } : {},
|
|
214
|
+
...props.hasProjectPlugins ? { hasProjectPlugins: props.hasProjectPlugins } : {}
|
|
215
|
+
});
|
|
216
|
+
if (props.link && !skipLink && await confirm(`Link this project to a Neon project now? (runs ${getCliName()} link)`)) {
|
|
217
|
+
await runScaffoldFollowUp({
|
|
218
|
+
cwd: targetDir,
|
|
219
|
+
yes: false,
|
|
220
|
+
skipAgentSetup: true,
|
|
221
|
+
shouldLink: true,
|
|
222
|
+
linkYes: false,
|
|
223
|
+
...kids
|
|
224
|
+
});
|
|
225
|
+
printNextSteps(targetDir, pm, {
|
|
226
|
+
installed,
|
|
227
|
+
suggestLink: false
|
|
228
|
+
});
|
|
229
|
+
return;
|
|
211
230
|
}
|
|
212
231
|
printNextSteps(targetDir, pm, {
|
|
213
232
|
installed,
|
|
@@ -215,20 +234,27 @@ const runPostScaffoldSteps = async (props, targetDir, interactive) => {
|
|
|
215
234
|
});
|
|
216
235
|
};
|
|
217
236
|
const installPrompt = (inferred) => inferred ? `Install dependencies with ${inferred}?` : "Install dependencies?";
|
|
218
|
-
/**
|
|
219
|
-
* `--default` quick start: run install + git init without prompting, honoring
|
|
220
|
-
* --no-install / --no-git. Linking is intentionally skipped — it needs an
|
|
221
|
-
* org/project choice we can't make non-interactively — so we point at it in the
|
|
222
|
-
* closing hint instead.
|
|
223
|
-
*/
|
|
237
|
+
/** `link --yes` still asks for a project unless one is already linked. */
|
|
224
238
|
const runDefaultSteps = async (props, targetDir, pm) => {
|
|
225
|
-
log.info("Quick start (--default):
|
|
239
|
+
log.info("Quick start (--default): skipping the template, install, git, and agent pickers. link --yes still asks for a project unless one is already linked.");
|
|
226
240
|
let installed = false;
|
|
227
241
|
if (props.install) installed = await runCommand(pm, installArgs(pm), targetDir);
|
|
228
242
|
if (props.git && !isGitRepo(targetDir)) await initGitRepo(targetDir);
|
|
243
|
+
const skipLink = shouldSkipLinkForDeps(targetDir, installed);
|
|
244
|
+
if (props.link && skipLink) logSkippedLink(pm);
|
|
245
|
+
await runScaffoldFollowUp({
|
|
246
|
+
cwd: targetDir,
|
|
247
|
+
yes: true,
|
|
248
|
+
skipAgentSetup: props.agentSetup === false,
|
|
249
|
+
shouldLink: props.link && !skipLink,
|
|
250
|
+
linkYes: true,
|
|
251
|
+
...bootstrapChildren(props, targetDir),
|
|
252
|
+
...props.pickAgentSetup ? { pickAgentSetup: props.pickAgentSetup } : {},
|
|
253
|
+
...props.hasProjectPlugins ? { hasProjectPlugins: props.hasProjectPlugins } : {}
|
|
254
|
+
});
|
|
229
255
|
printNextSteps(targetDir, pm, {
|
|
230
256
|
installed,
|
|
231
|
-
suggestLink:
|
|
257
|
+
suggestLink: !(props.link && !skipLink)
|
|
232
258
|
});
|
|
233
259
|
};
|
|
234
260
|
const isGitRepo = (dir) => existsSync(join(dir, ".git"));
|
|
@@ -239,6 +265,24 @@ const NEON_CONFIG_FILENAMES = [
|
|
|
239
265
|
"neon.mjs"
|
|
240
266
|
];
|
|
241
267
|
const hasNeonConfig = (dir) => NEON_CONFIG_FILENAMES.some((name) => existsSync(join(dir, name)));
|
|
268
|
+
const shouldSkipLinkForDeps = (dir, installed) => !installed && hasNeonConfig(dir);
|
|
269
|
+
const logSkippedLink = (pm) => {
|
|
270
|
+
log.info(`Skipping the Neon link step: \`${getCliName()} link\` reads this project's neon.ts to pull env vars, which needs its dependencies. Run \`${formatInstallCommand(pm)}\`, then \`${getCliName()} link\`.`);
|
|
271
|
+
};
|
|
272
|
+
const bootstrapChildren = (props, targetDir) => {
|
|
273
|
+
const explicitKey = props.profile ? "" : credentialInputs().apiKeyFlag;
|
|
274
|
+
return {
|
|
275
|
+
run: props.run ?? spawnCliChild,
|
|
276
|
+
forward: {
|
|
277
|
+
...props.configDir ? { configDir: props.configDir } : {},
|
|
278
|
+
...props.profile ? { profile: props.profile } : {},
|
|
279
|
+
apiHost: props.apiHost,
|
|
280
|
+
contextFile: projectContextFile(targetDir, props.contextFile),
|
|
281
|
+
...props.analytics === false ? { analytics: false } : {}
|
|
282
|
+
},
|
|
283
|
+
...explicitKey ? { authEnv: { NEON_API_KEY: explicitKey } } : {}
|
|
284
|
+
};
|
|
285
|
+
};
|
|
242
286
|
/**
|
|
243
287
|
* Initialize a git repository in the scaffolded directory. Just `git init` — we
|
|
244
288
|
* deliberately don't auto-commit, both to avoid failing on a machine with no
|
|
@@ -279,21 +323,6 @@ const selectPackageManager = async () => {
|
|
|
279
323
|
});
|
|
280
324
|
return pm ?? "npm";
|
|
281
325
|
};
|
|
282
|
-
/**
|
|
283
|
-
* Re-invoke this same CLI as `neon link` inside the scaffolded directory, so the
|
|
284
|
-
* new project's `.neon` context (and pulled `.env`) land in the right place and
|
|
285
|
-
* link's own interactive picker drives org/project/branch selection. Re-execing
|
|
286
|
-
* (rather than calling the handler in-process) keeps link running with `cwd` set
|
|
287
|
-
* to the target dir, which is where its env pull writes.
|
|
288
|
-
*/
|
|
289
|
-
const runNeonLink = async (props, targetDir) => {
|
|
290
|
-
const args = [process.argv[1], "link"];
|
|
291
|
-
if (props.configDir) args.push("--config-dir", props.configDir);
|
|
292
|
-
if (props.profile) args.push("--profile", props.profile);
|
|
293
|
-
args.push("--api-host", props.apiHost, "--output", props.output);
|
|
294
|
-
const explicitKey = props.profile ? "" : credentialInputs().apiKeyFlag;
|
|
295
|
-
await runCommand(process.execPath, args, targetDir, explicitKey ? { NEON_API_KEY: explicitKey } : void 0);
|
|
296
|
-
};
|
|
297
326
|
const printScaffolded = (template, targetDir) => {
|
|
298
327
|
log.info("");
|
|
299
328
|
log.info("Done. Scaffolded \"%s\" into %s.", template.title, isCurrentDir(targetDir) ? "the current directory" : displayDir(targetDir));
|
package/dist/commands/claim.js
CHANGED
|
@@ -5,7 +5,7 @@ import { applyContext, contextBranch, ensureGitignored, readContextFile } from "
|
|
|
5
5
|
import { declaredNeonServices } from "../config_services.js";
|
|
6
6
|
import { NEON_SERVICES, deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOption } from "../neon_services.js";
|
|
7
7
|
import { mergeEnvFile, resolveEnvFilePath } from "../env_file.js";
|
|
8
|
-
import { t as credentialInputs } from "../_chunks/auth_selection-
|
|
8
|
+
import { t as credentialInputs } from "../_chunks/auth_selection-pitMFzDe.js";
|
|
9
9
|
import { ClaimableClient, ClaimableServiceError } from "../claimable/api.js";
|
|
10
10
|
import { assertionHasExpired, listClaimableCredentials, readClaimableCredentials, removeClaimableCredentials, resolveClaimableContext, writeClaimableCredentials } from "../claimable/state.js";
|
|
11
11
|
import { writer } from "../writer.js";
|