neon 3.2.0 → 3.2.2
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 +1 -1
- package/dist/init/auth.js +3 -3
- package/dist/init/neonctl.js +27 -18
- package/dist/init/phases/setup.js +5 -5
- package/dist/init/resolve_context.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -673,7 +673,7 @@ $ neon init
|
|
|
673
673
|
|
|
674
674
|
Run in a terminal it prompts you through those steps. This is what the retired `neon-init` package used to do; `npx neon init` replaces it.
|
|
675
675
|
|
|
676
|
-
Two side effects worth knowing before you run it. It **installs or upgrades `
|
|
676
|
+
Two side effects worth knowing before you run it. It **installs or upgrades `neon` globally**, with whichever package manager invoked it — the flow drives Neon by shelling out to the CLI rather than calling the API in-process. And it **writes `.neon`** in the project directory, the same context file `neon link` and `neon checkout` use.
|
|
677
677
|
|
|
678
678
|
### Agent mode
|
|
679
679
|
|
package/dist/init/auth.js
CHANGED
|
@@ -5,7 +5,7 @@ import { log } from "@clack/prompts";
|
|
|
5
5
|
import { execa } from "execa";
|
|
6
6
|
//#region src/init/auth.ts
|
|
7
7
|
/**
|
|
8
|
-
* Ensures
|
|
8
|
+
* Ensures the Neon CLI is authenticated by running a command that triggers auth if needed
|
|
9
9
|
* This will automatically start the OAuth flow if the user isn't already authenticated
|
|
10
10
|
*/
|
|
11
11
|
async function ensureNeonctlAuth(options) {
|
|
@@ -14,7 +14,7 @@ async function ensureNeonctlAuth(options) {
|
|
|
14
14
|
try {
|
|
15
15
|
await execa("npx", [
|
|
16
16
|
"-y",
|
|
17
|
-
"
|
|
17
|
+
"neon",
|
|
18
18
|
"me"
|
|
19
19
|
], {
|
|
20
20
|
stdio: "inherit",
|
|
@@ -32,7 +32,7 @@ async function ensureNeonctlAuth(options) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Checks whether
|
|
35
|
+
* Checks whether the Neon CLI has stored OAuth credentials.
|
|
36
36
|
*/
|
|
37
37
|
async function isAuthenticated() {
|
|
38
38
|
return await getNeonctlAccessToken() !== null;
|
package/dist/init/neonctl.js
CHANGED
|
@@ -3,12 +3,14 @@ import { lstatSync } from "node:fs";
|
|
|
3
3
|
import { execa } from "execa";
|
|
4
4
|
//#region src/init/neonctl.ts
|
|
5
5
|
/**
|
|
6
|
-
* Returns the Neon CLI command prefix
|
|
6
|
+
* Returns the Neon CLI command prefix emitted to users and agents:
|
|
7
|
+
* `CI= npx -y neon`.
|
|
7
8
|
*
|
|
8
9
|
* The CLI reads NEON_API_HOST and NEON_OAUTH_HOST from the environment
|
|
9
|
-
* directly, so no extra flags are needed. The
|
|
10
|
-
* `neon
|
|
11
|
-
*
|
|
10
|
+
* directly, so no extra flags are needed. The published package is `neon`
|
|
11
|
+
* (its binary is `neon`; the older `neonctl` alias is no longer shipped). `npx`
|
|
12
|
+
* runs it with zero global-install assumptions, and the leading `CI=` keeps the
|
|
13
|
+
* CLI non-interactive.
|
|
12
14
|
*
|
|
13
15
|
* Usage: `${neonctlCmd()} orgs list --output json`
|
|
14
16
|
*/
|
|
@@ -16,12 +18,19 @@ function neonctlCmd() {
|
|
|
16
18
|
return "CI= npx -y neon";
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
+
* The global binaries that indicate the Neon CLI is installed. The current
|
|
22
|
+
* package ships `neon`; `neonctl` is the legacy alias, kept in the probe so an
|
|
23
|
+
* older global install still counts as "installed" (and isn't reinstalled).
|
|
21
24
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
const NEON_CLI_BINARIES = ["neon", "neonctl"];
|
|
26
|
+
/**
|
|
27
|
+
* Gets the currently installed Neon CLI version, probing the `neon` binary
|
|
28
|
+
* first and falling back to the legacy `neonctl` alias. Returns null when the
|
|
29
|
+
* CLI isn't on PATH.
|
|
30
|
+
*/
|
|
31
|
+
async function getNeonCliVersion() {
|
|
32
|
+
for (const bin of NEON_CLI_BINARIES) try {
|
|
33
|
+
const match = (await execa(bin, ["--version"], {
|
|
25
34
|
stdio: "pipe",
|
|
26
35
|
timeout: 5e3
|
|
27
36
|
})).stdout.trim().match(/(\d+\.\d+\.\d+)/);
|
|
@@ -30,10 +39,10 @@ async function getNeonctlVersion() {
|
|
|
30
39
|
return null;
|
|
31
40
|
}
|
|
32
41
|
/**
|
|
33
|
-
* Checks whether the
|
|
42
|
+
* Checks whether the Neon CLI is globally installed and whether it's up to date.
|
|
34
43
|
*/
|
|
35
44
|
async function checkNeonctl() {
|
|
36
|
-
const currentVersion = await
|
|
45
|
+
const currentVersion = await getNeonCliVersion();
|
|
37
46
|
if (!currentVersion) return {
|
|
38
47
|
installed: false,
|
|
39
48
|
currentVersion: null,
|
|
@@ -44,7 +53,7 @@ async function checkNeonctl() {
|
|
|
44
53
|
try {
|
|
45
54
|
latestVersion = (await execa("npm", [
|
|
46
55
|
"view",
|
|
47
|
-
"
|
|
56
|
+
"neon",
|
|
48
57
|
"version"
|
|
49
58
|
], {
|
|
50
59
|
stdio: "pipe",
|
|
@@ -82,9 +91,9 @@ function isOlderVersion(current, latest) {
|
|
|
82
91
|
function isLocalDevSymlink() {
|
|
83
92
|
try {
|
|
84
93
|
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
85
|
-
const
|
|
86
|
-
for (const
|
|
87
|
-
if (lstatSync(
|
|
94
|
+
const roots = [`${process.env.NVM_DIR || `${home}/.nvm`}/versions/node/${process.version}/lib/node_modules`, `${home}/.nvm/versions/node/${process.version}/lib/node_modules`];
|
|
95
|
+
for (const root of roots) for (const pkg of NEON_CLI_BINARIES) try {
|
|
96
|
+
if (lstatSync(`${root}/${pkg}`).isSymbolicLink()) return true;
|
|
88
97
|
} catch {}
|
|
89
98
|
return false;
|
|
90
99
|
} catch {
|
|
@@ -98,7 +107,7 @@ function isLocalDevSymlink() {
|
|
|
98
107
|
async function ensureNeonctl() {
|
|
99
108
|
if (isLocalDevSymlink()) return {
|
|
100
109
|
status: "already_current",
|
|
101
|
-
version: await
|
|
110
|
+
version: await getNeonCliVersion() ?? "dev"
|
|
102
111
|
};
|
|
103
112
|
const check = await checkNeonctl();
|
|
104
113
|
if (check.installed && !check.needsUpdate) return {
|
|
@@ -106,7 +115,7 @@ async function ensureNeonctl() {
|
|
|
106
115
|
version: check.currentVersion ?? void 0
|
|
107
116
|
};
|
|
108
117
|
const pm = resolveInvokingPackageManager();
|
|
109
|
-
const install = globalInstallCommand(pm, "
|
|
118
|
+
const install = globalInstallCommand(pm, "neon");
|
|
110
119
|
if (!install) return {
|
|
111
120
|
status: "failed",
|
|
112
121
|
error: "Could not install the Neon CLI: this machine has no package manager that can perform a global install. npm, pnpm and bun are not on PATH (yarn Berry has no global install). Install npm, pnpm or bun, then run this again."
|
|
@@ -117,7 +126,7 @@ async function ensureNeonctl() {
|
|
|
117
126
|
stdio: "pipe",
|
|
118
127
|
timeout: 6e4
|
|
119
128
|
});
|
|
120
|
-
const version = await
|
|
129
|
+
const version = await getNeonCliVersion();
|
|
121
130
|
return {
|
|
122
131
|
status: check.installed ? "updated" : "installed",
|
|
123
132
|
version: version ?? void 0
|
|
@@ -111,7 +111,7 @@ async function buildBulkInspection(options) {
|
|
|
111
111
|
].join("\n"),
|
|
112
112
|
checks: [
|
|
113
113
|
{
|
|
114
|
-
id: "
|
|
114
|
+
id: "neon",
|
|
115
115
|
description: "The Neon CLI will be installed or updated automatically (no action needed from the agent)",
|
|
116
116
|
lookFor: []
|
|
117
117
|
},
|
|
@@ -294,27 +294,27 @@ async function executeBatchedInstallation(options) {
|
|
|
294
294
|
switch (neonctlResult.status) {
|
|
295
295
|
case "already_current":
|
|
296
296
|
results.push({
|
|
297
|
-
id: "
|
|
297
|
+
id: "neon",
|
|
298
298
|
description: `Neon CLI is up to date (v${neonctlResult.version})`,
|
|
299
299
|
status: "success"
|
|
300
300
|
});
|
|
301
301
|
break;
|
|
302
302
|
case "installed":
|
|
303
303
|
results.push({
|
|
304
|
-
id: "
|
|
304
|
+
id: "neon",
|
|
305
305
|
description: `Installed Neon CLI (v${neonctlResult.version})`,
|
|
306
306
|
status: "success"
|
|
307
307
|
});
|
|
308
308
|
break;
|
|
309
309
|
case "updated":
|
|
310
310
|
results.push({
|
|
311
|
-
id: "
|
|
311
|
+
id: "neon",
|
|
312
312
|
description: `Updated Neon CLI to v${neonctlResult.version}`,
|
|
313
313
|
status: "success"
|
|
314
314
|
});
|
|
315
315
|
break;
|
|
316
316
|
case "failed": results.push({
|
|
317
|
-
id: "
|
|
317
|
+
id: "neon",
|
|
318
318
|
description: "Failed to install Neon CLI",
|
|
319
319
|
status: "failed",
|
|
320
320
|
error: neonctlResult.error
|
|
@@ -30,7 +30,7 @@ function extractNeonHost(cwd) {
|
|
|
30
30
|
*
|
|
31
31
|
* Strategy:
|
|
32
32
|
* 1. Extract endpoint hostname from .env
|
|
33
|
-
* 2. List orgs via
|
|
33
|
+
* 2. List orgs via the Neon CLI
|
|
34
34
|
* 3. For each org, list projects
|
|
35
35
|
* 4. For each project, get connection string and compare hostnames
|
|
36
36
|
* 5. Return the matching org/project
|
|
@@ -42,7 +42,7 @@ async function resolveNeonContext(cwd) {
|
|
|
42
42
|
try {
|
|
43
43
|
const result = await execa("npx", [
|
|
44
44
|
"-y",
|
|
45
|
-
"
|
|
45
|
+
"neon",
|
|
46
46
|
"orgs",
|
|
47
47
|
"list",
|
|
48
48
|
"--output",
|
|
@@ -65,7 +65,7 @@ async function resolveNeonContext(cwd) {
|
|
|
65
65
|
try {
|
|
66
66
|
const result = await execa("npx", [
|
|
67
67
|
"-y",
|
|
68
|
-
"
|
|
68
|
+
"neon",
|
|
69
69
|
"projects",
|
|
70
70
|
"list",
|
|
71
71
|
"--org-id",
|
|
@@ -87,7 +87,7 @@ async function resolveNeonContext(cwd) {
|
|
|
87
87
|
for (const project of projects) try {
|
|
88
88
|
if ((await execa("npx", [
|
|
89
89
|
"-y",
|
|
90
|
-
"
|
|
90
|
+
"neon",
|
|
91
91
|
"connection-string",
|
|
92
92
|
"--project-id",
|
|
93
93
|
project.id
|