neon 3.2.0 → 3.2.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/dist/init/auth.js +3 -3
- package/dist/init/neonctl.js +27 -18
- package/dist/init/resolve_context.js +4 -4
- package/package.json +5 -5
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
|
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neon",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
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/sdk": "2.0.0",
|
|
67
66
|
"@neon/config": "1.0.0",
|
|
68
|
-
"@neon/config-runtime": "1.0.0"
|
|
67
|
+
"@neon/config-runtime": "1.0.0",
|
|
68
|
+
"@neon/sdk": "2.0.0"
|
|
69
69
|
},
|
|
70
70
|
"optionalDependencies": {
|
|
71
71
|
"esbuild": "0.28.1"
|
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
"typescript": "^5.9.0",
|
|
98
98
|
"vitest": "^3.0.9",
|
|
99
99
|
"@neon-internals/cli-core": "0.0.0",
|
|
100
|
-
"@neon/
|
|
101
|
-
"@neon
|
|
100
|
+
"@neon-internals/env-core": "0.0.0",
|
|
101
|
+
"@neon/e2e-harness": "0.0.0"
|
|
102
102
|
},
|
|
103
103
|
"publishConfig": {
|
|
104
104
|
"access": "public",
|