neon 4.17.4 → 4.18.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 +2 -0
- package/dist/commands/config.js +25 -6
- package/dist/utils/config_diff.js +37 -12
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -736,6 +736,8 @@ neon function domains delete docs.example.com
|
|
|
736
736
|
|
|
737
737
|
Register prints the record, then an INFO line `CNAME <domain> to <cname_target>`. The domain goes live after that CNAME resolves and a certificate is issued on the first request.
|
|
738
738
|
|
|
739
|
+
A `neon.ts` `customDomains` list is applied by `neon config plan`, `neon config apply`, and `neon checkout` only on the project's default branch. Other branches still deploy the function. Set `customDomains` in the `branch` closure to register a hostname on a child. See [`@neon/config` Default-branch-only fields](../config/README.md#default-branch-only-fields).
|
|
740
|
+
|
|
739
741
|
When a package cannot be bundled — a native addon with no esbuild loader, or an optional peer dependency a library references on an untaken code path — list it in that function's `externalPackages` and the bundler leaves the import alone. `neon dev` honours the same list. It does not make the package resolvable in the deployed archive (there is no `node_modules` next to the bundle), so it only unblocks an import that is never evaluated — a dependency the handler actually calls has to be bundled, and a natively-backed one cannot be. See [`@neon/config`](../config/README.md#unbundleable-dependencies-externalpackages).
|
|
740
742
|
|
|
741
743
|
## Scaffold a project (`bootstrap`)
|
package/dist/commands/config.js
CHANGED
|
@@ -12,7 +12,7 @@ import { loadEnvFileIntoProcess } from "../env_file.js";
|
|
|
12
12
|
import { writer } from "../writer.js";
|
|
13
13
|
import { assertAiGatewayProvisionable, warnAiGateway } from "../utils/ai_gateway_notice.js";
|
|
14
14
|
import { announceTargetBranch } from "../utils/branch_notice.js";
|
|
15
|
-
import { renderAppliedChanges, renderBranchSettingConflicts } from "../utils/config_diff.js";
|
|
15
|
+
import { renderAppliedChanges, renderBranchSettingConflicts, renderCustomDomainFollowup } from "../utils/config_diff.js";
|
|
16
16
|
import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
|
|
17
17
|
import { formatInstallCommand, installArgs, resolvePackageManager, runCommand } from "../utils/package_manager.js";
|
|
18
18
|
import { bundleEntry } from "../utils/esbuild.js";
|
|
@@ -70,6 +70,7 @@ const neonctlBundler = async (fn) => {
|
|
|
70
70
|
assertZipWithinLimits(fn.slug, zip, entries);
|
|
71
71
|
return zip;
|
|
72
72
|
};
|
|
73
|
+
const reasonAllowsUpdateExisting = (reason) => reason.includes("Pass `updateExisting: true`");
|
|
73
74
|
const INSPECT_FIELDS = [
|
|
74
75
|
"project",
|
|
75
76
|
"branch",
|
|
@@ -381,6 +382,7 @@ const planCmd = async (props) => {
|
|
|
381
382
|
});
|
|
382
383
|
const services = utilizedServices(config);
|
|
383
384
|
reportPushResult(props, result, "plan", services);
|
|
385
|
+
if (result.conflicts.some((conflict) => conflict.field === "customDomain" && !reasonAllowsUpdateExisting(conflict.reason))) process.exitCode = 1;
|
|
384
386
|
if (services.includes("AI Gateway")) await warnAiGateway({
|
|
385
387
|
apiClient: props.apiClient,
|
|
386
388
|
projectId: props.projectId,
|
|
@@ -411,7 +413,8 @@ const applyCmd = async (props) => {
|
|
|
411
413
|
} catch (err) {
|
|
412
414
|
if (err instanceof PushConflictError) {
|
|
413
415
|
reportConflicts(props, err.conflicts);
|
|
414
|
-
|
|
416
|
+
const overrideable = err.conflicts.every((c) => reasonAllowsUpdateExisting(c.reason));
|
|
417
|
+
throw new Error(overrideable ? "Branch settings conflict with the policy. Re-run with --update-existing to apply the changes shown above." : "The policy conflicts with remote state. --update-existing will not resolve every conflict shown above.");
|
|
415
418
|
}
|
|
416
419
|
throw err;
|
|
417
420
|
}
|
|
@@ -472,9 +475,16 @@ const reportPushResult = (props, result, mode, services) => {
|
|
|
472
475
|
}
|
|
473
476
|
const color = props.color !== false;
|
|
474
477
|
const out = writer(props);
|
|
475
|
-
const noChanges = appliedChanges.length === 0;
|
|
478
|
+
const noChanges = appliedChanges.length === 0 && result.conflicts.length === 0;
|
|
476
479
|
const appliedText = renderAppliedChanges(appliedChanges, mode === "plan" ? "Planned changes" : "Applied changes", { color });
|
|
477
480
|
if (appliedText) out.text(`${appliedText}\n`);
|
|
481
|
+
if (result.conflicts.length > 0) {
|
|
482
|
+
const conflictText = renderBranchSettingConflicts(result.conflicts, { color });
|
|
483
|
+
if (conflictText) out.text(`\n${conflictText}\n`);
|
|
484
|
+
for (const conflict of result.conflicts) if (!reasonAllowsUpdateExisting(conflict.reason)) out.text(` ! ${conflict.field}: ${conflict.reason}\n`);
|
|
485
|
+
}
|
|
486
|
+
const followup = renderCustomDomainFollowup(result, { color });
|
|
487
|
+
if (followup) out.text(`\n${followup}\n`);
|
|
478
488
|
if (functionUrlBySlug.size > 0) {
|
|
479
489
|
const heading = mode === "plan" ? "Function URLs (after apply)" : "Function URLs";
|
|
480
490
|
out.text(`\n${isCi() ? heading : chalk.bold(heading)}\n`);
|
|
@@ -498,7 +508,7 @@ const reportConflicts = (props, conflicts) => {
|
|
|
498
508
|
const out = writer(props);
|
|
499
509
|
const text = renderBranchSettingConflicts([...conflicts], { color: props.color !== false });
|
|
500
510
|
if (text) out.text(`${text}\n`);
|
|
501
|
-
for (const conflict of conflicts) if (
|
|
511
|
+
for (const conflict of conflicts) if (!reasonAllowsUpdateExisting(conflict.reason)) out.text(` ! ${conflict.field}: ${conflict.reason}\n`);
|
|
502
512
|
};
|
|
503
513
|
/**
|
|
504
514
|
* Block provisioning the AI Gateway on a Free plan from the `checkout` policy paths, which
|
|
@@ -565,11 +575,20 @@ const applyPolicyOnCreate = async (props) => {
|
|
|
565
575
|
*/
|
|
566
576
|
const logPolicyResult = (result, opts) => {
|
|
567
577
|
const changes = result.applied.filter((c) => c.action !== "noop");
|
|
568
|
-
if (changes.length === 0) {
|
|
578
|
+
if (changes.length === 0 && result.conflicts.length === 0) {
|
|
569
579
|
log.info("neon.ts applied — no changes were needed.");
|
|
580
|
+
const followup = renderCustomDomainFollowup(result, opts);
|
|
581
|
+
if (followup) log.info("%s", followup);
|
|
570
582
|
return;
|
|
571
583
|
}
|
|
572
|
-
log.info("%s", renderAppliedChanges(changes, `neon.ts applied — ${changes.length} change${changes.length === 1 ? "" : "s"}:`, opts));
|
|
584
|
+
if (changes.length > 0) log.info("%s", renderAppliedChanges(changes, `neon.ts applied — ${changes.length} change${changes.length === 1 ? "" : "s"}:`, opts));
|
|
585
|
+
if (result.conflicts.length > 0) {
|
|
586
|
+
const conflictText = renderBranchSettingConflicts(result.conflicts, opts);
|
|
587
|
+
if (conflictText) log.info("%s", conflictText);
|
|
588
|
+
for (const conflict of result.conflicts) if (!reasonAllowsUpdateExisting(conflict.reason)) log.info(" ! %s: %s", conflict.field, conflict.reason);
|
|
589
|
+
}
|
|
590
|
+
const followup = renderCustomDomainFollowup(result, opts);
|
|
591
|
+
if (followup) log.info("%s", followup);
|
|
573
592
|
};
|
|
574
593
|
/**
|
|
575
594
|
* Create a branch **from** the local `neon.ts` policy. Returns `null` when there is no
|
|
@@ -75,11 +75,19 @@ const renderBranchGroups = (byBranch, paint) => {
|
|
|
75
75
|
return lines;
|
|
76
76
|
};
|
|
77
77
|
/** Friendly label for a service change identifier (`bucket:x` → `bucket x`). */
|
|
78
|
-
const serviceLabel = (identifier) => {
|
|
78
|
+
const serviceLabel = (identifier, details) => {
|
|
79
79
|
if (identifier === "auth") return "Neon Auth";
|
|
80
80
|
if (identifier === "dataApi") return "Data API";
|
|
81
81
|
if (identifier.startsWith("bucket:")) return `bucket ${identifier.slice(7)}`;
|
|
82
82
|
if (identifier.startsWith("function:")) return `function ${identifier.slice(9)}`;
|
|
83
|
+
if (identifier.startsWith("domain:")) {
|
|
84
|
+
const domain = identifier.slice(7);
|
|
85
|
+
const previous = typeof details?.previousSlug === "string" ? details.previousSlug : void 0;
|
|
86
|
+
const slug = typeof details?.slug === "string" ? details.slug : void 0;
|
|
87
|
+
if (previous !== void 0 && slug !== void 0) return `domain ${domain}: ${previous} → ${slug}`;
|
|
88
|
+
if (slug !== void 0) return `domain ${domain} -> ${slug}`;
|
|
89
|
+
return `domain ${domain}`;
|
|
90
|
+
}
|
|
83
91
|
return identifier;
|
|
84
92
|
};
|
|
85
93
|
/**
|
|
@@ -110,7 +118,7 @@ const renderAppliedChanges = (changes, title, opts) => {
|
|
|
110
118
|
const lines = [paint.title(title)];
|
|
111
119
|
const services = changes.filter((c) => c.kind === "service").sort((a, b) => a.identifier.localeCompare(b.identifier));
|
|
112
120
|
for (const service of services) {
|
|
113
|
-
const label = serviceLabel(service.identifier);
|
|
121
|
+
const label = serviceLabel(service.identifier, service.details);
|
|
114
122
|
const line = service.action === "create" ? `+ ${label}` : service.action === "delete" ? `- ${label}` : `~ ${label}`;
|
|
115
123
|
lines.push(` ${service.action === "create" ? paint.added(line) : service.action === "delete" ? paint.removed(line) : paint.arrow(line)}`);
|
|
116
124
|
}
|
|
@@ -122,22 +130,39 @@ const renderAppliedChanges = (changes, title, opts) => {
|
|
|
122
130
|
lines.push(...renderBranchGroups(byBranch, paint));
|
|
123
131
|
return lines.join("\n");
|
|
124
132
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
const isOverrideableConflict = (conflict) => conflict.reason.includes("Pass `updateExisting: true`");
|
|
134
|
+
const CUSTOM_DOMAIN_REASON = /^custom domain "([^"]+)"/;
|
|
135
|
+
const labeledConflictField = (conflict) => {
|
|
136
|
+
if (conflict.field !== "customDomain") return conflict.field;
|
|
137
|
+
const match = CUSTOM_DOMAIN_REASON.exec(conflict.reason);
|
|
138
|
+
return match?.[1] !== void 0 ? `customDomain ${match[1]}` : conflict.field;
|
|
139
|
+
};
|
|
132
140
|
const renderBranchSettingConflicts = (conflicts, opts) => {
|
|
133
141
|
if (conflicts.length === 0) return "";
|
|
134
142
|
const paint = palette(opts.color);
|
|
135
143
|
const byBranch = /* @__PURE__ */ new Map();
|
|
136
144
|
for (const conflict of conflicts) {
|
|
137
145
|
const existing = byBranch.get(conflict.identifier) ?? [];
|
|
138
|
-
byBranch.set(conflict.identifier, [...existing, ...expandField(conflict
|
|
146
|
+
byBranch.set(conflict.identifier, [...existing, ...expandField(labeledConflictField(conflict), conflict.current, conflict.desired)]);
|
|
147
|
+
}
|
|
148
|
+
const heading = conflicts.every(isOverrideableConflict) ? "Branch settings differ (re-run with --update-existing to apply)" : "Branch settings differ";
|
|
149
|
+
return [paint.title(heading), ...renderBranchGroups(byBranch, paint)].join("\n");
|
|
150
|
+
};
|
|
151
|
+
const renderCustomDomainFollowup = (result, opts) => {
|
|
152
|
+
const paint = palette(opts.color);
|
|
153
|
+
const lines = [];
|
|
154
|
+
const cnames = (result.customDomains ?? []).filter((d) => d.cnameTarget !== void 0 && d.cnameTarget !== "");
|
|
155
|
+
if (cnames.length > 0) {
|
|
156
|
+
lines.push(paint.title("Custom domains"));
|
|
157
|
+
for (const d of cnames) lines.push(` CNAME ${d.domain} -> ${d.cnameTarget}`);
|
|
158
|
+
lines.push(" Point each hostname at the CNAME target. Neon does not create DNS records.");
|
|
139
159
|
}
|
|
140
|
-
|
|
160
|
+
if (result.warnings.length > 0) {
|
|
161
|
+
if (lines.length > 0) lines.push("");
|
|
162
|
+
lines.push(paint.title("Warnings"));
|
|
163
|
+
for (const warning of result.warnings) lines.push(` ${warning}`);
|
|
164
|
+
}
|
|
165
|
+
return lines.join("\n");
|
|
141
166
|
};
|
|
142
167
|
//#endregion
|
|
143
|
-
export { renderAppliedChanges, renderBranchSettingConflicts };
|
|
168
|
+
export { renderAppliedChanges, renderBranchSettingConflicts, renderCustomDomainFollowup };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neon",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.18.0",
|
|
4
4
|
"description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"yaml": "^2.9.0",
|
|
64
64
|
"yargs": "17.7.2",
|
|
65
65
|
"yoctocolors": "^2.1.2",
|
|
66
|
-
"@neon/config": "1.
|
|
66
|
+
"@neon/config": "1.5.0",
|
|
67
67
|
"@neon/sdk": "5.0.0",
|
|
68
|
-
"@neon/config-runtime": "1.
|
|
68
|
+
"@neon/config-runtime": "1.4.0"
|
|
69
69
|
},
|
|
70
70
|
"optionalDependencies": {
|
|
71
71
|
"@napi-rs/keyring": "1.3.0",
|
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
"tsx": "4.22.3",
|
|
98
98
|
"typescript": "^5.9.0",
|
|
99
99
|
"vitest": "^3.0.9",
|
|
100
|
-
"@neon-internals/env-core": "0.0.15",
|
|
101
100
|
"@neon-internals/cli-core": "0.0.0",
|
|
101
|
+
"@neon-internals/env-core": "0.0.16",
|
|
102
102
|
"@neon/e2e-harness": "0.0.0",
|
|
103
103
|
"@neon/functions": "0.10.0"
|
|
104
104
|
},
|