neon 8.18.1 → 8.20.1
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 +6 -1
- package/dist/_chunks/{bootstrap-vAtWRZXa.js → bootstrap-Dh7-KDmw.js} +73 -7
- package/dist/_chunks/{neon_auth-Dw-ucM5Y.js → neon_auth-C1CgNTGP.js} +10 -3
- package/dist/_chunks/{operations-CzaR_uqx.js → operations-D7qGkKo3.js} +26 -2
- package/dist/commands/bootstrap.js +1 -1
- package/dist/commands/index.js +3 -3
- package/dist/commands/neon_auth.js +1 -1
- package/dist/commands/operations.js +1 -1
- package/dist/init/auth.js +1 -1
- package/dist/init/deploy.js +70 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -866,6 +866,8 @@ When a package cannot be bundled — a native addon with no esbuild loader, or a
|
|
|
866
866
|
|
|
867
867
|
After scaffolding, an interactive terminal asks about dependency install and git, then finishes agent setup before asking whether to link a Neon project. Dependency install is last, except when the template has a `neon.ts` and you chose to link — then install runs first so the link flow can pull env. `--default` / `-y` skips the template, install, git, and agent pickers, then installs agent tooling for project folders, else the host CLI agent. If none are found, it exits: pass `--agent <name>`, run from a supported agent, or omit `--default` / `-y` in a terminal to pick. `--agent` / `-a` names coding agents, skips agent selection, and is forwarded to `plugins`, or to `skills` and `mcp`, not both. Linking uses `neon link -y`: the only organization and project are selected, or their IDs are printed and the command exits. `--no-agent-setup` and `--no-link` skip those steps. Non-interactive without `--default` prints next steps and does not install, set up agents, or link.
|
|
868
868
|
|
|
869
|
+
When the template has a `neon.ts` and its dependencies are installed and the project is linked, bootstrap checks the env vars its functions read against the env file link pulled into (`.env.local`). If all are set, a terminal asks `Deploy this project to Neon now?` and runs `neon deploy --env .env.local`; `--default` leaves that command under `Next:`. If some are unset, `Next:` names them. `--deploy` installs, links, and deploys without asking, and fails with `neon deploy`'s error when an env var is unset. It refuses `--no-install` and `--no-link`, and needs `--default` outside a terminal.
|
|
870
|
+
|
|
869
871
|
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>`.
|
|
870
872
|
|
|
871
873
|
```bash
|
|
@@ -878,6 +880,9 @@ $ neon bootstrap . --template hono
|
|
|
878
880
|
# Skip agent selection; install the plugin for those agents
|
|
879
881
|
$ neon bootstrap my-app --agent cursor --agent claude-code
|
|
880
882
|
|
|
883
|
+
# Scaffold, install, link, and deploy without prompting
|
|
884
|
+
$ neon bootstrap my-app --template hono --default --deploy
|
|
885
|
+
|
|
881
886
|
# List templates
|
|
882
887
|
$ neon bootstrap --list-templates
|
|
883
888
|
|
|
@@ -1509,7 +1514,7 @@ Id Name Project Created At Last Used At Last
|
|
|
1509
1514
|
| [databases](https://neon.com/docs/reference/cli-databases) | `list`, `create`, `delete` | Manage databases |
|
|
1510
1515
|
| function | `deploy`, `list`, `get`, `delete`, `domains list`, `domains register`, `domains delete` | Manage Neon Functions |
|
|
1511
1516
|
| [roles](https://neon.com/docs/reference/cli-roles) | `list`, `create`, `delete` | Manage roles |
|
|
1512
|
-
| [operations](https://neon.com/docs/reference/cli-operations) | `list`
|
|
1517
|
+
| [operations](https://neon.com/docs/reference/cli-operations) | `list`, `get` | Manage operations |
|
|
1513
1518
|
| logs | `query`, `fields`, `field-values` | Query branch logs (Beta) |
|
|
1514
1519
|
| inspect | `db stalled-queries` | Inspect Postgres diagnostics |
|
|
1515
1520
|
| snapshots | `list`, `get`, `create`, `update`, `delete`, `restore`, `finalize`, `schedule get`, `schedule set` | Manage snapshots |
|
|
@@ -4,9 +4,10 @@ import { log } from "../log.js";
|
|
|
4
4
|
import { recordCommandSuccessExtras, recordScaffoldedTemplate } from "../analytics.js";
|
|
5
5
|
import { getCliName } from "../utils/cli_name.js";
|
|
6
6
|
import { helpCsv, helpEpilogue } from "../utils/help_text.js";
|
|
7
|
+
import { resolveEnvFilePath } from "../env_file.js";
|
|
7
8
|
import { formatInstallCommand, inferPackageManager, installArgs, installedPackageManagers, resolvePackageManager, runCommand } from "../utils/package_manager.js";
|
|
8
9
|
import { writer } from "../writer.js";
|
|
9
|
-
import { FALLBACK_TEMPLATES, ensureTargetUsable, fetchTemplates, findTemplate, scaffoldTemplate, templateIds } from "../init/bootstrap.js";
|
|
10
|
+
import { BootstrapInputError, FALLBACK_TEMPLATES, ensureTargetUsable, fetchTemplates, findTemplate, scaffoldTemplate, templateIds } from "../init/bootstrap.js";
|
|
10
11
|
import { agentSetupDoneLabel, formatInitDone, printInitBanner, printInitDone, shouldPrintInitBanner } from "../init/chrome.js";
|
|
11
12
|
import { runAuthenticatedLink } from "../init/link.js";
|
|
12
13
|
import { coerceAgentFlag } from "../utils/agent_flag.js";
|
|
@@ -77,8 +78,13 @@ const builder = (argv) => argv.usage("$0 bootstrap [directory] [options]").posit
|
|
|
77
78
|
string: true,
|
|
78
79
|
describe: "Coding agent to install into (repeatable). Forwarded to plugins, or to skills and mcp. Skips agent selection. Values listed below",
|
|
79
80
|
coerce: coerceAgentFlag
|
|
81
|
+
},
|
|
82
|
+
deploy: {
|
|
83
|
+
describe: "Run `neon deploy` once dependencies are installed and the project is linked, without asking. Fails if neon.ts reads an env var that is not set yet",
|
|
84
|
+
type: "boolean",
|
|
85
|
+
default: false
|
|
80
86
|
}
|
|
81
|
-
}).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; if several orgs or projects exist, link prints IDs and exits").example("$0 bootstrap --list-templates --output json", "Print the template catalog as JSON").example("$0 bootstrap my-app --agent cursor --agent claude-code", "Skip agent selection; install the plugin for those agents").epilogue(helpEpilogue("--agent / -a is forwarded to plugins, or to skills and mcp, not both. It skips agent selection, including with --default.", helpCsv("Plugin agents", initPluginAgents()), helpCsv("Skills and MCP agents", initSkillsMcpAgents()))).strict();
|
|
87
|
+
}).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; if several orgs or projects exist, link prints IDs and exits").example("$0 bootstrap my-app --template hono --default --deploy", "Scaffold, install, link, and deploy without prompting").example("$0 bootstrap --list-templates --output json", "Print the template catalog as JSON").example("$0 bootstrap my-app --agent cursor --agent claude-code", "Skip agent selection; install the plugin for those agents").epilogue(helpEpilogue("--agent / -a is forwarded to plugins, or to skills and mcp, not both. It skips agent selection, including with --default.", helpCsv("Plugin agents", initPluginAgents()), helpCsv("Skills and MCP agents", initSkillsMcpAgents()))).strict();
|
|
82
88
|
const handler = async (props) => {
|
|
83
89
|
if (props.listTemplates) {
|
|
84
90
|
const templates = await fetchTemplates();
|
|
@@ -109,12 +115,14 @@ const handler = async (props) => {
|
|
|
109
115
|
...props.default ? { yes: true } : {}
|
|
110
116
|
});
|
|
111
117
|
const interactive = !props.default && Boolean(process.stdout.isTTY) && !isCi();
|
|
118
|
+
if (props.deploy) assertDeployable(props, interactive);
|
|
112
119
|
const template = props.selectedTemplate ?? await resolveSelectedTemplate(props, interactive, await resolveTemplateList(props));
|
|
113
120
|
const targetDir = await resolveTargetDir(props, interactive, template);
|
|
114
121
|
ensureTargetUsable(targetDir, props.force);
|
|
115
122
|
await scaffold(template, targetDir);
|
|
116
123
|
recordScaffoldedTemplate(template.id);
|
|
117
124
|
printScaffolded(template, targetDir);
|
|
125
|
+
if (props.deploy && !hasNeonConfig(targetDir)) throw new BootstrapInputError(`Template "${template.id}" has no neon.ts, so there is nothing to deploy. Re-run without --deploy.`, "TEMPLATE_NOT_DEPLOYABLE");
|
|
118
126
|
const result = await runPostScaffoldSteps(props, targetDir, interactive, template, named);
|
|
119
127
|
recordCommandSuccessExtras({ agent_setup: result.agentSetup });
|
|
120
128
|
return result;
|
|
@@ -198,7 +206,8 @@ const runPostScaffoldSteps = async (props, targetDir, interactive, template, nam
|
|
|
198
206
|
agentSetup: "skip",
|
|
199
207
|
linked: false,
|
|
200
208
|
skippedLinkForDeps: false,
|
|
201
|
-
agentsRan: false
|
|
209
|
+
agentsRan: false,
|
|
210
|
+
deployed: false
|
|
202
211
|
};
|
|
203
212
|
finishPostScaffold({
|
|
204
213
|
heading: "Project scaffolded.",
|
|
@@ -206,13 +215,14 @@ const runPostScaffoldSteps = async (props, targetDir, interactive, template, nam
|
|
|
206
215
|
targetDir,
|
|
207
216
|
pm: defaultPm,
|
|
208
217
|
...outcome,
|
|
218
|
+
hasNeonConfig: neonConfig,
|
|
209
219
|
suggestLink: true,
|
|
210
220
|
skipPrint: props.skipDoneSummary === true
|
|
211
221
|
});
|
|
212
222
|
return nestedResult(template, targetDir, neonConfig, outcome);
|
|
213
223
|
}
|
|
214
224
|
let pm = defaultPm;
|
|
215
|
-
const wantInstall = props.install && await confirm(installPrompt(inferred));
|
|
225
|
+
const wantInstall = props.install && (props.deploy === true || await confirm(installPrompt(inferred)));
|
|
216
226
|
if (wantInstall) pm = inferred ?? await selectPackageManager();
|
|
217
227
|
const wantGit = props.git && !isGitRepo(targetDir) && await confirm("Initialize a git repository?");
|
|
218
228
|
const agentSetup = props.agentSetup === false ? "skip" : named.length > 0 ? chooseYesAgentTooling(named).setup : await (props.pickAgentSetup ?? pickAgentSetupInteractively)();
|
|
@@ -235,6 +245,7 @@ const runPostScaffoldSteps = async (props, targetDir, interactive, template, nam
|
|
|
235
245
|
targetDir,
|
|
236
246
|
pm,
|
|
237
247
|
...outcome,
|
|
248
|
+
hasNeonConfig: neonConfig,
|
|
238
249
|
suggestLink: !outcome.linked,
|
|
239
250
|
skipPrint: props.skipDoneSummary === true
|
|
240
251
|
});
|
|
@@ -262,6 +273,7 @@ const runDefaultSteps = async (props, targetDir, pm, neonConfig, template, named
|
|
|
262
273
|
targetDir,
|
|
263
274
|
pm,
|
|
264
275
|
...outcome,
|
|
276
|
+
hasNeonConfig: neonConfig,
|
|
265
277
|
suggestLink: !outcome.linked,
|
|
266
278
|
skipPrint: props.skipDoneSummary === true
|
|
267
279
|
});
|
|
@@ -326,7 +338,7 @@ const executePostScaffold = async (props, targetDir, choices) => {
|
|
|
326
338
|
logSkippedLink(choices.pm);
|
|
327
339
|
continue;
|
|
328
340
|
}
|
|
329
|
-
if (!(choices.yes || await (props.pickLink ?? pickInitLinkInteractively)())) continue;
|
|
341
|
+
if (!(choices.yes || props.deploy === true || await (props.pickLink ?? pickInitLinkInteractively)())) continue;
|
|
330
342
|
await (props.linkProject ?? runAuthenticatedLink)({
|
|
331
343
|
apiClient: props.apiClient,
|
|
332
344
|
apiKey: props.apiKey,
|
|
@@ -349,6 +361,11 @@ const executePostScaffold = async (props, targetDir, choices) => {
|
|
|
349
361
|
});
|
|
350
362
|
linked = true;
|
|
351
363
|
}
|
|
364
|
+
const deploy = installFailed || gitFailed ? { deployed: false } : await runDeployStep(props, targetDir, {
|
|
365
|
+
interactive: !choices.yes,
|
|
366
|
+
ready: choices.hasNeonConfig && installed && linked,
|
|
367
|
+
auth: kids.auth
|
|
368
|
+
});
|
|
352
369
|
return {
|
|
353
370
|
installed,
|
|
354
371
|
installFailed,
|
|
@@ -357,9 +374,53 @@ const executePostScaffold = async (props, targetDir, choices) => {
|
|
|
357
374
|
linked,
|
|
358
375
|
skippedLinkForDeps,
|
|
359
376
|
agentSetup,
|
|
360
|
-
agentsRan
|
|
377
|
+
agentsRan,
|
|
378
|
+
...deploy
|
|
361
379
|
};
|
|
362
380
|
};
|
|
381
|
+
/**
|
|
382
|
+
* `--deploy` installs and links without asking, so flags that skip those steps contradict
|
|
383
|
+
* it. Outside a terminal, only `-y` runs the post-scaffold steps at all.
|
|
384
|
+
*/
|
|
385
|
+
const assertDeployable = (props, interactive) => {
|
|
386
|
+
if (props.install === false || props.link === false) throw new BootstrapInputError("--deploy needs installed dependencies and a linked project. Remove --no-install and --no-link.", "DEPLOY_NEEDS_INSTALL_AND_LINK");
|
|
387
|
+
if (!interactive && !props.default) throw new BootstrapInputError("--deploy outside an interactive terminal needs --default (-y).", "DEPLOY_NEEDS_DEFAULT");
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* The last step. `--deploy` always deploys and lets `neon deploy` report unset env. Otherwise
|
|
391
|
+
* a linked, installed template with neon.ts is offered a deploy in a terminal once every
|
|
392
|
+
* function env var it reads is set; when some are not, the done summary names them.
|
|
393
|
+
*/
|
|
394
|
+
const runDeployStep = async (props, targetDir, input) => {
|
|
395
|
+
if (!props.deploy && !input.ready) return { deployed: false };
|
|
396
|
+
const envFile = resolveEnvFilePath({
|
|
397
|
+
cwd: targetDir,
|
|
398
|
+
contextFile: input.auth.contextFile
|
|
399
|
+
});
|
|
400
|
+
const envFileName = relative(targetDir, envFile);
|
|
401
|
+
const deployWithEnv = `${getCliName()} deploy --env ${envFileName}`;
|
|
402
|
+
const deployCommand = existsSync(envFile) ? deployWithEnv : `${getCliName()} deploy`;
|
|
403
|
+
const { deployInitProject, missingDeployEnv } = await import("../init/deploy.js");
|
|
404
|
+
const options = {
|
|
405
|
+
...input.auth,
|
|
406
|
+
cwd: targetDir,
|
|
407
|
+
envFile
|
|
408
|
+
};
|
|
409
|
+
if (!props.deploy) {
|
|
410
|
+
const missing = await missingDeployEnv(options);
|
|
411
|
+
if (missing.length > 0) return {
|
|
412
|
+
deployed: false,
|
|
413
|
+
deployNext: `Set ${missing.join(", ")} in ${envFileName}, then run \`${deployWithEnv}\``
|
|
414
|
+
};
|
|
415
|
+
if (!input.interactive || !await confirm("Deploy this project to Neon now?")) return {
|
|
416
|
+
deployed: false,
|
|
417
|
+
deployNext: deployCommand
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
log.info("Deploying with `%s`…", deployCommand);
|
|
421
|
+
await (props.deployProject ?? deployInitProject)(options);
|
|
422
|
+
return { deployed: true };
|
|
423
|
+
};
|
|
363
424
|
const isGitRepo = (dir) => existsSync(join(dir, ".git"));
|
|
364
425
|
const NEON_CONFIG_FILENAMES = [
|
|
365
426
|
"neon.ts",
|
|
@@ -438,6 +499,7 @@ const printDoneSummary = (input) => {
|
|
|
438
499
|
if (!isCurrentDir(input.targetDir)) next.push(`cd ${displayDir(input.targetDir)}`);
|
|
439
500
|
if (!input.installed) next.push(formatInstallCommand(input.pm));
|
|
440
501
|
if (input.suggestLink) next.push(`${getCliName()} link`);
|
|
502
|
+
if (input.deployNext) next.push(input.deployNext);
|
|
441
503
|
if (!unfinished) next.push("See the README to run it.");
|
|
442
504
|
printInitDone(formatInitDone({
|
|
443
505
|
heading,
|
|
@@ -468,7 +530,11 @@ const printDoneSummary = (input) => {
|
|
|
468
530
|
{
|
|
469
531
|
label: "Project",
|
|
470
532
|
value: project
|
|
471
|
-
}
|
|
533
|
+
},
|
|
534
|
+
...input.hasNeonConfig ? [{
|
|
535
|
+
label: "Deploy",
|
|
536
|
+
value: input.deployed ? "deployed" : "not deployed"
|
|
537
|
+
}] : []
|
|
472
538
|
],
|
|
473
539
|
next
|
|
474
540
|
}));
|
|
@@ -101,7 +101,8 @@ const EMAIL_PASSWORD_FIELDS = [
|
|
|
101
101
|
"auto_sign_in_after_verification",
|
|
102
102
|
"send_verification_email_on_sign_up",
|
|
103
103
|
"send_verification_email_on_sign_in",
|
|
104
|
-
"disable_sign_up"
|
|
104
|
+
"disable_sign_up",
|
|
105
|
+
"revoke_sessions_on_password_reset"
|
|
105
106
|
];
|
|
106
107
|
const EMAIL_PROVIDER_FIELDS = [
|
|
107
108
|
"type",
|
|
@@ -333,6 +334,10 @@ const builder = (argv) => {
|
|
|
333
334
|
"disable-sign-up": {
|
|
334
335
|
describe: "Disable new user sign ups",
|
|
335
336
|
type: "boolean"
|
|
337
|
+
},
|
|
338
|
+
"revoke-sessions-on-password-reset": {
|
|
339
|
+
describe: "Revoke all of a user's sessions when their password is reset",
|
|
340
|
+
type: "boolean"
|
|
336
341
|
}
|
|
337
342
|
}), async (args) => {
|
|
338
343
|
await emailPasswordUpdate(args);
|
|
@@ -825,7 +830,8 @@ const printEmailPasswordEntries = (data) => [
|
|
|
825
830
|
["Auto Sign In After Verify: ", String(data.auto_sign_in_after_verification)],
|
|
826
831
|
["Send Email On Sign Up: ", String(data.send_verification_email_on_sign_up)],
|
|
827
832
|
["Send Email On Sign In: ", String(data.send_verification_email_on_sign_in)],
|
|
828
|
-
["Disable Sign Up:", String(data.disable_sign_up)]
|
|
833
|
+
["Disable Sign Up:", String(data.disable_sign_up)],
|
|
834
|
+
["Revoke Sessions On Reset:", String(data.revoke_sessions_on_password_reset)]
|
|
829
835
|
];
|
|
830
836
|
const emailPasswordGet = async (props) => {
|
|
831
837
|
const branchId = await resolveBranch(props);
|
|
@@ -845,7 +851,8 @@ const emailPasswordUpdate = async (props) => {
|
|
|
845
851
|
auto_sign_in_after_verification: props.autoSignInAfterVerification,
|
|
846
852
|
send_verification_email_on_sign_up: props.sendVerificationEmailOnSignUp,
|
|
847
853
|
send_verification_email_on_sign_in: props.sendVerificationEmailOnSignIn,
|
|
848
|
-
disable_sign_up: props.disableSignUp
|
|
854
|
+
disable_sign_up: props.disableSignUp,
|
|
855
|
+
revoke_sessions_on_password_reset: props.revokeSessionsOnPasswordReset
|
|
849
856
|
});
|
|
850
857
|
if (props.output === "json" || props.output === "yaml") {
|
|
851
858
|
writer(props).end(data, { fields: EMAIL_PASSWORD_FIELDS });
|
|
@@ -7,6 +7,7 @@ var operations_exports = /* @__PURE__ */ __exportAll({
|
|
|
7
7
|
builder: () => builder,
|
|
8
8
|
command: () => command,
|
|
9
9
|
describe: () => describe,
|
|
10
|
+
get: () => get,
|
|
10
11
|
handler: () => handler,
|
|
11
12
|
list: () => list
|
|
12
13
|
});
|
|
@@ -16,13 +17,26 @@ const OPERATIONS_FIELDS = [
|
|
|
16
17
|
"status",
|
|
17
18
|
"created_at"
|
|
18
19
|
];
|
|
20
|
+
const OPERATION_DETAIL_FIELDS = [
|
|
21
|
+
"id",
|
|
22
|
+
"action",
|
|
23
|
+
"status",
|
|
24
|
+
"branch_id",
|
|
25
|
+
"endpoint_id",
|
|
26
|
+
"error",
|
|
27
|
+
"failures_count",
|
|
28
|
+
"retry_at",
|
|
29
|
+
"total_duration_ms",
|
|
30
|
+
"created_at",
|
|
31
|
+
"updated_at"
|
|
32
|
+
];
|
|
19
33
|
const command = "operations";
|
|
20
34
|
const describe = "Manage operations";
|
|
21
35
|
const aliases = ["operation"];
|
|
22
36
|
const builder = (argv) => argv.usage("$0 operations <sub-command> [options]").options({ "project-id": {
|
|
23
37
|
describe: "Project ID",
|
|
24
38
|
type: "string"
|
|
25
|
-
} }).middleware(fillSingleProject).command("list", "List operations", (yargs) => yargs, (args) => list(args));
|
|
39
|
+
} }).middleware(fillSingleProject).command("list", "List operations", (yargs) => yargs, (args) => list(args)).command("get <id>", "Get an operation", (yargs) => yargs, (args) => get(args));
|
|
26
40
|
const handler = (args) => {
|
|
27
41
|
return args;
|
|
28
42
|
};
|
|
@@ -33,4 +47,14 @@ const list = async (props) => {
|
|
|
33
47
|
});
|
|
34
48
|
writer(props).end(data.operations, { fields: OPERATIONS_FIELDS });
|
|
35
49
|
};
|
|
36
|
-
|
|
50
|
+
const get = async (props) => {
|
|
51
|
+
const { fromSdkError, getNeonClient } = await import("../neon_client.js");
|
|
52
|
+
const operation = await getNeonClient(props).operations.get({
|
|
53
|
+
projectId: props.projectId,
|
|
54
|
+
operationId: props.id
|
|
55
|
+
}).catch((error) => {
|
|
56
|
+
throw fromSdkError(error, props.apiHost);
|
|
57
|
+
});
|
|
58
|
+
writer(props).end(operation, { fields: OPERATION_DETAIL_FIELDS });
|
|
59
|
+
};
|
|
60
|
+
export { get as a, operations_exports as c, describe as i, builder as n, handler as o, command as r, list as s, aliases as t };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as builder, r as command, i as describe, a as handler } from "../_chunks/bootstrap-
|
|
1
|
+
export { n as builder, r as command, i as describe, a as handler } from "../_chunks/bootstrap-Dh7-KDmw.js";
|
package/dist/commands/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { a as link_exports } from "../_chunks/link-CNO-HxHN.js";
|
|
|
9
9
|
import { o as mcp_exports } from "../_chunks/mcp-SvqWzHnT.js";
|
|
10
10
|
import { c as plugins_exports } from "../_chunks/plugins-7cxVcgay.js";
|
|
11
11
|
import { l as skills_exports } from "../_chunks/skills-Bv8oKKwE.js";
|
|
12
|
-
import { t as bootstrap_exports } from "../_chunks/bootstrap-
|
|
12
|
+
import { t as bootstrap_exports } from "../_chunks/bootstrap-Dh7-KDmw.js";
|
|
13
13
|
import { r as branches_exports } from "../_chunks/branches-Bp-5z1lM.js";
|
|
14
14
|
import { n as bucket_exports } from "../_chunks/bucket-D06bvDSa.js";
|
|
15
15
|
import { n as checkout_exports } from "../_chunks/checkout-CNBIS3gA.js";
|
|
@@ -29,9 +29,9 @@ import { a as init_exports } from "../_chunks/init-D2fClHtC.js";
|
|
|
29
29
|
import { o as inspect_exports } from "../_chunks/inspect-yFAb61qo.js";
|
|
30
30
|
import { a as ip_allow_exports } from "../_chunks/ip_allow-DBdxNEUa.js";
|
|
31
31
|
import { l as logs_exports } from "../_chunks/logs-BB4uvblR.js";
|
|
32
|
-
import { a as neon_auth_exports } from "../_chunks/neon_auth-
|
|
32
|
+
import { a as neon_auth_exports } from "../_chunks/neon_auth-C1CgNTGP.js";
|
|
33
33
|
import { a as open_exports } from "../_chunks/open-T2nI89Oh.js";
|
|
34
|
-
import {
|
|
34
|
+
import { c as operations_exports } from "../_chunks/operations-D7qGkKo3.js";
|
|
35
35
|
import { o as orgs_exports } from "../_chunks/orgs-Dpbr-K0A.js";
|
|
36
36
|
import { o as profile_exports } from "../_chunks/profile-BAlM625e.js";
|
|
37
37
|
import { a as psql_exports } from "../_chunks/psql-Bce4X0NG.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as builder, n as command, r as describe, i as handler } from "../_chunks/neon_auth-
|
|
1
|
+
export { t as builder, n as command, r as describe, i as handler } from "../_chunks/neon_auth-C1CgNTGP.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as aliases, n as builder, r as command, i as describe, a as
|
|
1
|
+
export { t as aliases, n as builder, r as command, i as describe, a as get, o as handler, s as list } from "../_chunks/operations-D7qGkKo3.js";
|
package/dist/init/auth.js
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { isNeonApiError } from "../api.js";
|
|
2
|
+
import { contextBranch, readContextFile } from "../context.js";
|
|
3
|
+
import { c as ensureAuth } from "../_chunks/auth-rup6nemJ.js";
|
|
4
|
+
import { recoverFrom401 } from "../auth_recovery.js";
|
|
5
|
+
import { loadProjectConfig } from "../project.js";
|
|
6
|
+
import { loadEnvFileIntoProcess } from "../env_file.js";
|
|
7
|
+
import { r as applyCmd } from "../_chunks/config-CgtJH8xE.js";
|
|
8
|
+
import { authContext } from "./auth.js";
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
// src/init/deploy.ts
|
|
11
|
+
/**
|
|
12
|
+
* The function env keys neon.ts reads that neither `envFile` nor the environment sets.
|
|
13
|
+
* `neon deploy --env <envFile>` refuses to run until this is empty.
|
|
14
|
+
*/
|
|
15
|
+
const missingDeployEnv = async (options) => {
|
|
16
|
+
const applied = existsSync(options.envFile) ? loadEnvFileIntoProcess(options.envFile) : [];
|
|
17
|
+
try {
|
|
18
|
+
const { omittedFunctionEnv } = await loadProjectConfig({
|
|
19
|
+
cwd: options.cwd,
|
|
20
|
+
contextFile: options.contextFile,
|
|
21
|
+
unsetFunctionEnv: "omit"
|
|
22
|
+
});
|
|
23
|
+
return omittedFunctionEnv;
|
|
24
|
+
} finally {
|
|
25
|
+
for (const key of applied) delete process.env[key];
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Runs `neon deploy --env <envFile>` in process against the branch `link` pinned, resolving
|
|
30
|
+
* auth the way the standalone command does.
|
|
31
|
+
*/
|
|
32
|
+
const deployInitProject = async (options) => {
|
|
33
|
+
const context = readContextFile(options.contextFile);
|
|
34
|
+
const branch = contextBranch(context);
|
|
35
|
+
const projectId = context.projectId;
|
|
36
|
+
if (!projectId || !branch) throw new Error("Can't deploy: the directory isn't linked to a Neon project. Run `neon link`, then `neon deploy`.");
|
|
37
|
+
const authenticated = authContext(options, ["deploy"]);
|
|
38
|
+
const apply = () => inDirectory(options.cwd, () => applyCmd({
|
|
39
|
+
...authenticated,
|
|
40
|
+
output: "table",
|
|
41
|
+
projectId,
|
|
42
|
+
branch,
|
|
43
|
+
cwd: options.cwd,
|
|
44
|
+
...existsSync(options.envFile) ? { env: options.envFile } : {}
|
|
45
|
+
}));
|
|
46
|
+
await ensureAuth(authenticated);
|
|
47
|
+
try {
|
|
48
|
+
await apply();
|
|
49
|
+
return;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (!isNeonApiError(error) || error.status !== 401) throw error;
|
|
52
|
+
if (!await recoverFrom401(true)) throw new Error("Authentication failed.");
|
|
53
|
+
}
|
|
54
|
+
await ensureAuth(authenticated);
|
|
55
|
+
await apply();
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* `config apply` resolves function sources, bundles, and runs hooks relative to
|
|
59
|
+
* `process.cwd()`, so the deploy runs from the project directory.
|
|
60
|
+
*/
|
|
61
|
+
const inDirectory = async (dir, run) => {
|
|
62
|
+
const previous = process.cwd();
|
|
63
|
+
process.chdir(dir);
|
|
64
|
+
try {
|
|
65
|
+
return await run();
|
|
66
|
+
} finally {
|
|
67
|
+
process.chdir(previous);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export { deployInitProject, missingDeployEnv };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neon",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.20.1",
|
|
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/
|
|
77
|
-
"@neon/
|
|
78
|
-
"@neon/
|
|
79
|
-
"@neon/
|
|
76
|
+
"@neon/realtime": "0.2.0",
|
|
77
|
+
"@neon/config-runtime": "1.11.4",
|
|
78
|
+
"@neon/config": "1.11.0",
|
|
79
|
+
"@neon/sdk": "7.8.1"
|
|
80
80
|
},
|
|
81
81
|
"optionalDependencies": {
|
|
82
82
|
"@napi-rs/keyring": "1.3.0",
|
|
@@ -113,9 +113,9 @@
|
|
|
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.
|
|
116
|
+
"@neon-internals/env-core": "0.0.42",
|
|
117
117
|
"@neon/e2e-harness": "0.0.0",
|
|
118
|
-
"@neon/env": "1.6.
|
|
118
|
+
"@neon/env": "1.6.12",
|
|
119
119
|
"@neon/functions": "0.11.0"
|
|
120
120
|
},
|
|
121
121
|
"publishConfig": {
|