neon 5.0.1 → 6.1.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 +34 -27
- package/dist/commands/bootstrap.js +19 -17
- package/dist/commands/config.js +38 -17
- package/dist/commands/dev.js +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/init.js +45 -302
- package/dist/commands/mcp.js +68 -41
- package/dist/commands/plugins.js +56 -35
- package/dist/commands/skills.js +56 -35
- package/dist/commands/snapshots.js +23 -7
- package/dist/index.js +8 -0
- package/dist/init/auth.js +84 -0
- package/dist/init/cancelled.js +41 -0
- package/dist/init/choices.js +10 -21
- package/dist/init/chrome.js +59 -24
- package/dist/init/copy.js +133 -0
- package/dist/init/detect.js +58 -0
- package/dist/init/funnel.js +115 -0
- package/dist/init/mode.js +30 -0
- package/dist/init/plan.js +135 -32
- package/dist/init/run.js +645 -0
- package/dist/init/tooling.js +104 -22
- package/dist/init/wizard.js +207 -48
- package/dist/mcp/plan.js +1 -1
- package/dist/mcp/wizard.js +1 -27
- package/dist/plugins/plan.js +1 -1
- package/dist/skills/plan.js +1 -1
- package/dist/skills/wizard.js +1 -25
- package/dist/test_utils/npm_env.js +26 -0
- package/dist/update_check_worker.js +47 -0
- package/dist/update_notifier.js +145 -0
- package/dist/utils/package_manager.js +8 -1
- package/dist/utils/service_picker.js +34 -8
- package/package.json +7 -5
- package/dist/init/child.js +0 -37
- package/dist/plugins/wizard.js +0 -36
package/README.md
CHANGED
|
@@ -46,6 +46,11 @@ brew upgrade neonctl
|
|
|
46
46
|
|
|
47
47
|
To upgrade a binary version, download the latest binary file, as described above, and replace your old binary with the new one.
|
|
48
48
|
|
|
49
|
+
Global npm, pnpm, Bun, and Homebrew installs check for updates once per day.
|
|
50
|
+
When an update is available, terminal commands periodically print the matching
|
|
51
|
+
upgrade command. Set `NO_UPDATE_NOTIFIER=1` to disable these checks. The notifier
|
|
52
|
+
does not run in CI, for machine-readable output, or from standalone binaries.
|
|
53
|
+
|
|
49
54
|
## Connect
|
|
50
55
|
|
|
51
56
|
Run the following command to authenticate a connection to Neon:
|
|
@@ -613,6 +618,8 @@ export default defineConfig({
|
|
|
613
618
|
|
|
614
619
|
```
|
|
615
620
|
? Which Neon services should neon.ts declare? (space to toggle, enter to confirm) ›
|
|
621
|
+
◉ Postgres (always included)
|
|
622
|
+
Every Neon project includes a Postgres database.
|
|
616
623
|
◯ Managed Better Auth
|
|
617
624
|
Authentication with users and sessions stored in Postgres.
|
|
618
625
|
◯ Data API
|
|
@@ -625,7 +632,7 @@ export default defineConfig({
|
|
|
625
632
|
All models, one API, one bill. Powered by Databricks. Not available on the Neon free plan.
|
|
626
633
|
```
|
|
627
634
|
|
|
628
|
-
Selecting nothing is a valid answer: you get the starter policy, which is also what a non-interactive run (CI, no TTY) writes. Pass `--services` to skip the prompt anywhere:
|
|
635
|
+
Postgres cannot be unselected. Selecting nothing else is a valid answer: you get the starter policy, which is also what a non-interactive run (CI, no TTY) writes. Pass `--services` to skip the prompt anywhere:
|
|
629
636
|
|
|
630
637
|
```bash
|
|
631
638
|
# Pick interactively (TTY) or take the starter policy (CI)
|
|
@@ -779,46 +786,42 @@ The target directory must be empty unless you pass `--force` (a lone `.git` is i
|
|
|
779
786
|
|
|
780
787
|
## Set up a project (`init`)
|
|
781
788
|
|
|
782
|
-
`neon init` sets up this directory for Neon
|
|
789
|
+
`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.
|
|
783
790
|
|
|
784
|
-
|
|
791
|
+
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 a default `neon.ts` (Postgres only) using the package manager already in the directory.
|
|
785
792
|
|
|
786
|
-
`-y`
|
|
793
|
+
Unauthenticated `-y` skips linking and prints the next step: sign up at https://neon.com/signup, then `neon auth`, `neon link`, or `neon claim create` (no account, expires in 72 hours unless claimed). `-y` never opens a browser. `-y` with `--project-id` or other account flags links when the CLI is already signed in; otherwise it errors and names `neon auth` or `--claimable`.
|
|
787
794
|
|
|
788
|
-
|
|
795
|
+
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. 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.
|
|
789
796
|
|
|
790
|
-
|
|
797
|
+
Empty directories are set up in place. `neon init` does not scaffold starter files.
|
|
791
798
|
|
|
792
799
|
```bash
|
|
793
800
|
$ neon init
|
|
794
|
-
$ neon init --skip-template
|
|
795
|
-
$ neon init --skip-template --no-link
|
|
796
801
|
$ neon init -y
|
|
797
|
-
$ neon init --agent cursor --agent claude-code
|
|
802
|
+
$ neon init --agent cursor --agent claude-code --no-link
|
|
803
|
+
$ neon init --no-agent-setup --claimable
|
|
804
|
+
$ neon init -y --skill neon --mcp-auth oauth --mcp-config-location project
|
|
805
|
+
$ neon init -y --agent cursor --project-id <project-id> \
|
|
806
|
+
--mcp-auth oauth --mcp-config-location project --mcp-project-scoped
|
|
798
807
|
```
|
|
799
808
|
|
|
800
|
-
Without a TTY, pass `-y
|
|
801
|
-
|
|
802
|
-
`-y` skips the template picker and the agent-setup offer. Empty dir: `bootstrap --default`. `--skip-template` or an existing app: plugin when Cursor, Claude Code, or Codex is in project folders, else the host CLI agent; otherwise skills and MCP. If none are found, it exits: pass `--agent <name>`, run from a supported agent, or omit `-y` in a terminal to pick. VS Code, GitHub Copilot CLI, and Grok only take the plugin user-level (`neon plugins --global`), so `-y` uses skills and MCP for those.
|
|
803
|
-
|
|
804
|
-
`--agent` / `-a` (repeatable) names coding agents and skips agent selection, interactive or with `-y`. Init forwards those names to `plugins`, or to `skills` and `mcp`, not both.
|
|
809
|
+
Without a TTY, pass `-y` or enough flags to answer every question. `-y` alone is Recommended. `-y` with `--skill`, MCP flags, `--no-agent-setup`, or `--claimable` is Custom: those flags, Recommended defaults for the rest. `--skill` selects skills (not the plugin). MCP flags select skills and MCP. `--agent` skips agent selection and, without `-y`, selects Custom. `--no-link` skips project linking without asking. `--no-config` skips `neon.ts`. `--services` implies creating `neon.ts`. `--org-id`, `--project-id`, `--project-name`, `--region-id`, and `--branch` select linking.
|
|
805
810
|
|
|
806
|
-
`--project-id`, `--org-id`, `--project-name`, `--region-id`, and `--branch` are forwarded to `link
|
|
811
|
+
`--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.
|
|
807
812
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
`-y` forwards `-y` to `plugins` or `skills`/`mcp`, uses `link -y` (auto-select or print IDs and exit), passes `--default` to nested bootstrap, and forwards `--services none` to `config init`. `--agent` is forwarded to agent setup. `mcp -y` is the global install. Default linking skips the "already linked" confirmation.
|
|
813
|
+
After a new default `neon.ts` on a pinned branch, init runs `env pull` unless link already pulled env or the file declares extra services (those still need `neon config plan` / `neon deploy`).
|
|
811
814
|
|
|
812
815
|
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.
|
|
813
816
|
|
|
814
|
-
`skills` needs Node.js 22.20 or newer. See [`
|
|
817
|
+
`skills` needs Node.js 22.20 or newer. See [`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.
|
|
815
818
|
|
|
816
819
|
## Install the Neon MCP server (`mcp`)
|
|
817
820
|
|
|
818
821
|
`neon mcp` writes the hosted Neon MCP server (`https://mcp.neon.tech/mcp`) into coding-agent config files.
|
|
819
822
|
|
|
820
823
|
```bash
|
|
821
|
-
# Interactive: global or project, then agents, then API key or OAuth
|
|
824
|
+
# Interactive: global or project, then agents, then API key or OAuth.
|
|
822
825
|
$ neon mcp
|
|
823
826
|
|
|
824
827
|
# Skip prompts. Global config, installed apps else the host CLI agent, reuse or mint an API key.
|
|
@@ -843,7 +846,7 @@ $ neon mcp --project-id <project-id>
|
|
|
843
846
|
$ neon mcp --category querying --category schema
|
|
844
847
|
```
|
|
845
848
|
|
|
846
|
-
On a TTY the command asks for config location (global is the default), then agents, then API key vs OAuth, then
|
|
849
|
+
On a TTY the command asks for config location (global is the default), then agents, then API key vs OAuth, then writes. Detected agents start selected: globally installed agents or project-folder markers such as `.cursor` when the install is project.
|
|
847
850
|
|
|
848
851
|
`-y` skips those questions. `neon mcp -y` writes `https://mcp.neon.tech/mcp` into global config for globally installed apps, else the host CLI agent, reuses an existing Neon MCP API key or mints an account-wide key, leaves write tools enabled, exposes every tool category, and does not pin a project (including from `.neon`). `--agent`, `--project`, `--oauth`, `--read-only`, `--project-id` and `--category` still apply with `-y`. `--read-only` and `--category` are flags only and are never prompted. A linked project-folder install asks whether to pin MCP tools to that `.neon` project (`?projectId=`). If you pin and selected API-key auth, the minted key is limited to that project too. An unlinked project folder does not ask. Global installs never add that param unless you pass `--project-id`. Without a TTY, pass `-y` to mint into every detected agent, `--agent <name>` to name them, or `--oauth` to write the URL only. If `-y` finds no agent, it exits: pass `--agent <name>`, run from a supported agent, or omit `-y` in a terminal to pick. `neon mcp --help` lists the server URL, those `-y` defaults, the supported agent names, and the `--category` values.
|
|
849
852
|
|
|
@@ -856,7 +859,7 @@ The default mints an account-wide API key (or reuses the Bearer already configur
|
|
|
856
859
|
`neon skills` installs Neon agent skills by running `npx skills add`. It does not call the Neon API. This command needs Node.js 22.20 or newer. The rest of the CLI supports Node.js 20.19 or newer.
|
|
857
860
|
|
|
858
861
|
```bash
|
|
859
|
-
# Interactive: this directory, then agents, then skills
|
|
862
|
+
# Interactive: this directory, then agents, then skills.
|
|
860
863
|
$ neon skills
|
|
861
864
|
|
|
862
865
|
# Skip prompts. This directory, detected agents (project folders, else the host CLI agent), the default skills.
|
|
@@ -880,7 +883,7 @@ $ neon skills update -y
|
|
|
880
883
|
$ neon skills update --global -y
|
|
881
884
|
```
|
|
882
885
|
|
|
883
|
-
On a TTY the command asks which agents and which skills, then
|
|
886
|
+
On a TTY the command asks which agents and which skills, then installs. Detected agents start selected from project-folder markers such as `.cursor`. Default skills start selected. `neon-postgres-agent-platforms` is offered and starts unselected.
|
|
884
887
|
|
|
885
888
|
`-y` skips those questions and installs the default skills into detected agents: project-folder markers such as `.cursor`, else the agent driving the CLI. `--agent` / `-a` names coding agents and skips the agent picker. `--skill` / `-s` names specific skills and skips the skill picker; it does not select agents. `--global -y` uses installed apps, else the host CLI agent. Without a TTY, pass `-y`, or `--skill <name>` (add `--agent <name>` to name agents). If `-y` finds no agent, it exits: pass `--agent <name>`, run from a supported agent, or omit `-y` in a terminal to pick.
|
|
886
889
|
|
|
@@ -904,7 +907,7 @@ Default table output is the assistant's text. On a TTY that is a spinner, then t
|
|
|
904
907
|
`neon plugins` installs the Neon agent plugin (`neon-postgres`) by running `npx plugins add`. It does not call the Neon API.
|
|
905
908
|
|
|
906
909
|
```bash
|
|
907
|
-
# Interactive: agents, then
|
|
910
|
+
# Interactive: pick agents, then install.
|
|
908
911
|
$ neon plugins
|
|
909
912
|
|
|
910
913
|
# Skip prompts. Detected agents (project folders, else the host CLI agent).
|
|
@@ -917,7 +920,7 @@ $ neon plugins --agent cursor --agent claude-code
|
|
|
917
920
|
$ neon plugins --global
|
|
918
921
|
```
|
|
919
922
|
|
|
920
|
-
On a TTY the command asks which agents, then
|
|
923
|
+
On a TTY the command asks which agents, then installs. Detected agents start selected from project-folder markers such as `.cursor`. There is one plugin (`neon-postgres`); there is no plugin picker and no `update` subcommand.
|
|
921
924
|
|
|
922
925
|
`-y` skips those questions and installs into detected agents: project-folder markers such as `.cursor`, else the agent driving the CLI. `--agent` / `-a` names coding agents and skips the agent picker. `--global -y` uses installed apps, else the host CLI agent. Without a TTY, pass `-y` or `--agent <name>`. If `-y` finds no agent, it exits: pass `--agent <name>`, run from a supported agent, or omit `-y` in a terminal to pick.
|
|
923
926
|
|
|
@@ -933,12 +936,15 @@ The plugins CLI installs every plugin it finds in the Neon plugin package. Today
|
|
|
933
936
|
|
|
934
937
|
`neon snapshots` (alias `neon snapshot`) manages **snapshots** — point-in-time backups of a branch that you can list, rename, expire, restore into a branch, or schedule automatically. Snapshots are a Beta Neon feature and were previously only available in the Console and REST API; this command group brings them to the CLI.
|
|
935
938
|
|
|
936
|
-
Every sub-command resolves the project through the standard chain (`--project-id`, then the `.neon` context file, then a single-project auto-detect). Branch-scoped sub-commands (`create`, `schedule`) default to the branch pinned in `.neon`, falling back to the project's default branch, and accept `--branch <id|name>`. The `get`, `update`, `delete`, and `restore` sub-commands take a snapshot **id or
|
|
939
|
+
Every sub-command resolves the project through the standard chain (`--project-id`, then the `.neon` context file, then a single-project auto-detect). Branch-scoped sub-commands (`create`, `schedule`) default to the branch pinned in `.neon`, falling back to the project's default branch, and accept `--branch <id|name>`. The `get`, `update`, `delete`, and `restore` sub-commands take a snapshot **id, unique name, or slug** as their positional argument. An id wins. A unique name still wins over another snapshot's matching slug, so a name you already use keeps targeting that snapshot. Slug is used when no name matches. An ambiguous name errors and asks you to use the id.
|
|
937
940
|
|
|
938
941
|
```bash
|
|
939
942
|
# Snapshot the head of the current/default branch
|
|
940
943
|
neon snapshots create --name pre-migration
|
|
941
944
|
|
|
945
|
+
# Give the snapshot a slug (unique in the project; omit to let the API generate one)
|
|
946
|
+
neon snapshots create --branch main --name "Before migration" --slug before-migration
|
|
947
|
+
|
|
942
948
|
# Snapshot a specific branch at a point in time (RFC 3339 timestamp OR LSN — mutually exclusive)
|
|
943
949
|
neon snapshots create --branch main --timestamp 2025-01-01T00:00:00Z
|
|
944
950
|
neon snapshots create --branch main --lsn 0/1F3C8A0 --expires-at 2025-12-31T23:59:59Z
|
|
@@ -946,6 +952,7 @@ neon snapshots create --branch main --lsn 0/1F3C8A0 --expires-at 2025-12-31T23:5
|
|
|
946
952
|
# List / inspect
|
|
947
953
|
neon snapshots list
|
|
948
954
|
neon snapshots get pre-migration
|
|
955
|
+
neon snapshots get before-migration
|
|
949
956
|
|
|
950
957
|
# Rename or change expiration (omit both to error; --expires-at and --clear-expiration conflict)
|
|
951
958
|
neon snapshots update snap-1234 --name nightly
|
|
@@ -1361,7 +1368,7 @@ Id Name Project Created At Last Used At Last
|
|
|
1361
1368
|
| config | `init`, `status`, `plan`, `apply` | Drive a branch from `neon.ts` |
|
|
1362
1369
|
| deploy | | Alias for `config apply` |
|
|
1363
1370
|
| bootstrap | | Scaffold a template, then agent tooling and link |
|
|
1364
|
-
| init | |
|
|
1371
|
+
| init | | In place: agents, link, neon.ts |
|
|
1365
1372
|
| mcp | | Install the Neon MCP server |
|
|
1366
1373
|
| plugins | | Install the Neon plugin |
|
|
1367
1374
|
| skills | `update` | Install Neon agent skills |
|
|
@@ -2,12 +2,10 @@ 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 { recordCommandSuccessExtras, recordScaffoldedTemplate } from "../analytics.js";
|
|
5
|
-
import { t as credentialInputs } from "../_chunks/auth_selection-pitMFzDe.js";
|
|
6
5
|
import { getCliName } from "../utils/cli_name.js";
|
|
7
6
|
import { helpCsv, helpEpilogue } from "../utils/help_text.js";
|
|
8
7
|
import { writer } from "../writer.js";
|
|
9
8
|
import { FALLBACK_TEMPLATES, ensureTargetUsable, fetchTemplates, findTemplate, scaffoldTemplate, templateIds } from "../init/bootstrap.js";
|
|
10
|
-
import { spawnCliChild } from "../init/child.js";
|
|
11
9
|
import { agentSetupDoneLabel, formatInitDone, printInitBanner, printInitDone, shouldPrintInitBanner } from "../init/chrome.js";
|
|
12
10
|
import { formatInstallCommand, inferPackageManager, installArgs, installedPackageManagers, resolvePackageManager, runCommand } from "../utils/package_manager.js";
|
|
13
11
|
import { runAuthenticatedLink } from "../init/link.js";
|
|
@@ -271,7 +269,9 @@ const runDefaultSteps = async (props, targetDir, pm, neonConfig, template, named
|
|
|
271
269
|
};
|
|
272
270
|
const executePostScaffold = async (props, targetDir, choices) => {
|
|
273
271
|
const kids = {
|
|
274
|
-
|
|
272
|
+
output: "table",
|
|
273
|
+
auth: bootstrapAuth(props, targetDir),
|
|
274
|
+
operations: props.operations,
|
|
275
275
|
...props.narrate ? { narrate: props.narrate } : {}
|
|
276
276
|
};
|
|
277
277
|
let installed = false;
|
|
@@ -370,20 +370,22 @@ const hasNeonConfig = (dir) => NEON_CONFIG_FILENAMES.some((name) => existsSync(j
|
|
|
370
370
|
const logSkippedLink = (pm) => {
|
|
371
371
|
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\`.`);
|
|
372
372
|
};
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
}
|
|
373
|
+
/**
|
|
374
|
+
* plugins/skills need no Neon auth at all; mcp resolves it itself, in-process, exactly as
|
|
375
|
+
* the standalone `neon mcp` does (see `init/auth.ts`) — this is that shared context.
|
|
376
|
+
*/
|
|
377
|
+
const bootstrapAuth = (props, targetDir) => ({
|
|
378
|
+
apiClient: props.apiClient,
|
|
379
|
+
apiKey: props.apiKey,
|
|
380
|
+
apiHost: props.apiHost,
|
|
381
|
+
contextFile: projectContextFile(targetDir, props.contextFile),
|
|
382
|
+
...props.configDir ? { configDir: props.configDir } : {},
|
|
383
|
+
...props.profile ? { profile: props.profile } : {},
|
|
384
|
+
...props.oauthHost ? { oauthHost: props.oauthHost } : {},
|
|
385
|
+
...props.clientId ? { clientId: props.clientId } : {},
|
|
386
|
+
...props.forceAuth !== void 0 ? { forceAuth: props.forceAuth } : {},
|
|
387
|
+
...props.allowUnsafeTls !== void 0 ? { allowUnsafeTls: props.allowUnsafeTls } : {}
|
|
388
|
+
});
|
|
387
389
|
/**
|
|
388
390
|
* Initialize a git repository in the scaffolded directory. Just `git init` — we
|
|
389
391
|
* deliberately don't auto-commit, both to avoid failing on a machine with no
|
package/dist/commands/config.js
CHANGED
|
@@ -26,6 +26,7 @@ import { packagesToStage, previewGaWarningForConfig, resolveConfig } from "@neon
|
|
|
26
26
|
import { PushConflictError, apply, assertZipWithinLimits, bundleAsIs, createBranch, describeNativeFinding, enforceLimits, findUndeclaredNativePackages, inspect, isPartialBranchCreateError, loadConfigFromFile as loadConfigFromFile$1, plan, resolveEsbuildEntry, traceNativePackages, zipFunctionBundle } from "@neon/config-runtime";
|
|
27
27
|
//#region src/commands/config.ts
|
|
28
28
|
var config_exports = /* @__PURE__ */ __exportAll({
|
|
29
|
+
ConfigInstallFailed: () => ConfigInstallFailed,
|
|
29
30
|
applyCmd: () => applyCmd,
|
|
30
31
|
applyFlags: () => applyFlags,
|
|
31
32
|
applyPolicyOnCreate: () => applyPolicyOnCreate,
|
|
@@ -38,6 +39,7 @@ var config_exports = /* @__PURE__ */ __exportAll({
|
|
|
38
39
|
handler: () => handler,
|
|
39
40
|
hasNeonConfigFile: () => hasNeonConfigFile,
|
|
40
41
|
initCmd: () => initCmd,
|
|
42
|
+
neonConfigFilename: () => neonConfigFilename,
|
|
41
43
|
planCmd: () => planCmd,
|
|
42
44
|
status: () => status
|
|
43
45
|
});
|
|
@@ -117,8 +119,16 @@ const NEON_CONFIG_FILENAMES = [
|
|
|
117
119
|
"neon.js",
|
|
118
120
|
"neon.mjs"
|
|
119
121
|
];
|
|
122
|
+
const neonConfigFilename = (dir) => NEON_CONFIG_FILENAMES.find((name) => existsSync(join(dir, name)));
|
|
120
123
|
/** Whether `dir` already has a Neon config file the runtime would load. */
|
|
121
|
-
const hasNeonConfigFile = (dir) =>
|
|
124
|
+
const hasNeonConfigFile = (dir) => neonConfigFilename(dir) !== void 0;
|
|
125
|
+
var ConfigInstallFailed = class extends Error {
|
|
126
|
+
constructor(command) {
|
|
127
|
+
super("Could not install the Neon dependencies.");
|
|
128
|
+
this.name = "ConfigInstallFailed";
|
|
129
|
+
this.command = command;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
122
132
|
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
123
133
|
/**
|
|
124
134
|
* The {@link REQUIRED_PACKAGES} not already declared in the project's package.json
|
|
@@ -209,33 +219,44 @@ const seedFromBranch = async (props) => {
|
|
|
209
219
|
const initCmd = async (props) => {
|
|
210
220
|
const cwd = props.cwd ?? process.cwd();
|
|
211
221
|
const run = props.run ?? runCommand;
|
|
212
|
-
const existing =
|
|
213
|
-
if (existing)
|
|
214
|
-
|
|
222
|
+
const existing = neonConfigFilename(cwd);
|
|
223
|
+
if (existing) {
|
|
224
|
+
if (!props.silent) log.info("Found an existing %s — leaving it untouched.", existing);
|
|
225
|
+
} else if (props.fromBranch) {
|
|
215
226
|
const { source, seeded, branchName } = await seedFromBranch(props);
|
|
216
227
|
writeFileSync(join(cwd, "neon.ts"), source);
|
|
217
|
-
if (
|
|
218
|
-
|
|
228
|
+
if (!props.silent) {
|
|
229
|
+
if (seeded) log.info("Created neon.ts from the live state of %s.", branchName);
|
|
230
|
+
else log.info("%s declares no services and no branch settings — created neon.ts with the starter policy instead.", branchName);
|
|
231
|
+
}
|
|
219
232
|
} else {
|
|
220
233
|
const services = await resolveServices(props);
|
|
221
234
|
writeFileSync(join(cwd, "neon.ts"), renderNeonConfig(services));
|
|
222
|
-
if (
|
|
223
|
-
|
|
235
|
+
if (!props.silent) {
|
|
236
|
+
if (services.length === 0) log.info("Created neon.ts with a starter policy.");
|
|
237
|
+
else log.info("Created neon.ts declaring %s.", services.join(", "));
|
|
238
|
+
}
|
|
224
239
|
if (services.includes("functions")) scaffoldFunction(cwd);
|
|
225
240
|
}
|
|
226
241
|
const missing = missingDependencies(cwd);
|
|
227
|
-
if (missing.length === 0)
|
|
228
|
-
|
|
229
|
-
|
|
242
|
+
if (missing.length === 0) {
|
|
243
|
+
if (!props.silent) log.info("%s are already installed.", REQUIRED_PACKAGES.join(" and "));
|
|
244
|
+
} else {
|
|
245
|
+
const pm = props.packageManager ?? resolvePackageManager(cwd);
|
|
230
246
|
const args = installArgs(pm, missing);
|
|
231
|
-
if (props.install === false)
|
|
232
|
-
|
|
247
|
+
if (props.install === false) {
|
|
248
|
+
if (!props.silent) log.info("Install the Neon config packages to use neon.ts: %s", formatInstallCommand(pm, missing));
|
|
249
|
+
} else {
|
|
233
250
|
ensureDirectoryGitignored(join(cwd, "node_modules"));
|
|
234
|
-
log.info("Installing %s with %s…", missing.join(", "), pm);
|
|
235
|
-
if (!await run(pm, args, cwd))
|
|
251
|
+
if (!props.silent) log.info("Installing %s with %s…", missing.join(", "), pm);
|
|
252
|
+
if (!await run(pm, args, cwd)) {
|
|
253
|
+
const command = formatInstallCommand(pm, missing);
|
|
254
|
+
if (props.requireInstall) throw new ConfigInstallFailed(command);
|
|
255
|
+
log.warning("Could not install the config packages automatically. Run by hand: %s", command);
|
|
256
|
+
}
|
|
236
257
|
}
|
|
237
258
|
}
|
|
238
|
-
log.info("Next: edit neon.ts, then run `neon config plan` to preview and `neon config apply`.");
|
|
259
|
+
if (!props.silent) log.info("Next: edit neon.ts, then run `neon config plan` to preview and `neon config apply`.");
|
|
239
260
|
};
|
|
240
261
|
const command = "config";
|
|
241
262
|
const describe = "Manage a branch with a neon.ts policy";
|
|
@@ -741,4 +762,4 @@ const createBranchFromPolicyOnCheckout = async (props) => {
|
|
|
741
762
|
}
|
|
742
763
|
};
|
|
743
764
|
//#endregion
|
|
744
|
-
export { applyCmd, applyFlags, applyPolicyOnCreate, builder, command, createBranchFromPolicyOnCheckout, describe, envFlag, envPullFlag, handler, hasNeonConfigFile, initCmd, planCmd, status, config_exports as t };
|
|
765
|
+
export { ConfigInstallFailed, applyCmd, applyFlags, applyPolicyOnCreate, builder, command, createBranchFromPolicyOnCheckout, describe, envFlag, envPullFlag, handler, hasNeonConfigFile, initCmd, neonConfigFilename, planCmd, status, config_exports as t };
|
package/dist/commands/dev.js
CHANGED
|
@@ -13,8 +13,8 @@ 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";
|
|
15
15
|
import chalk from "chalk";
|
|
16
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
17
16
|
import { bundleAsIs, describeNativeFinding, findUndeclaredNativePackages, resolveEsbuildEntry } from "@neon/config-runtime";
|
|
17
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
18
18
|
import { once } from "node:events";
|
|
19
19
|
import { createServer } from "node:net";
|
|
20
20
|
//#region src/commands/dev.ts
|
package/dist/commands/index.js
CHANGED
|
@@ -6,6 +6,9 @@ import { t as env_exports } from "./env.js";
|
|
|
6
6
|
import { t as config_exports } from "./config.js";
|
|
7
7
|
import { t as projects_exports } from "./projects.js";
|
|
8
8
|
import { t as link_exports } from "./link.js";
|
|
9
|
+
import { t as mcp_exports } from "./mcp.js";
|
|
10
|
+
import { t as plugins_exports } from "./plugins.js";
|
|
11
|
+
import { t as skills_exports } from "./skills.js";
|
|
9
12
|
import { t as bootstrap_exports } from "./bootstrap.js";
|
|
10
13
|
import { t as branches_exports } from "./branches.js";
|
|
11
14
|
import { t as bucket_exports } from "./bucket.js";
|
|
@@ -23,17 +26,14 @@ import { t as init_exports } from "./init.js";
|
|
|
23
26
|
import { t as inspect_exports } from "./inspect.js";
|
|
24
27
|
import { t as ip_allow_exports } from "./ip_allow.js";
|
|
25
28
|
import { t as logs_exports } from "./logs.js";
|
|
26
|
-
import { t as mcp_exports } from "./mcp.js";
|
|
27
29
|
import { t as neon_auth_exports } from "./neon_auth.js";
|
|
28
30
|
import { t as open_exports } from "./open.js";
|
|
29
31
|
import { t as operations_exports } from "./operations.js";
|
|
30
32
|
import { t as orgs_exports } from "./orgs.js";
|
|
31
|
-
import { t as plugins_exports } from "./plugins.js";
|
|
32
33
|
import { t as profile_exports } from "./profile.js";
|
|
33
34
|
import { t as psql_exports } from "./psql.js";
|
|
34
35
|
import { t as roles_exports } from "./roles.js";
|
|
35
36
|
import { t as set_context_exports } from "./set_context.js";
|
|
36
|
-
import { t as skills_exports } from "./skills.js";
|
|
37
37
|
import { t as snapshots_exports } from "./snapshots.js";
|
|
38
38
|
import { t as status_exports } from "./status.js";
|
|
39
39
|
import { t as triggers_exports } from "./triggers.js";
|