neon 2.38.2 → 2.38.4
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/index.js +8 -2
- package/dist/utils/middlewares.js +15 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { isNetworkError, matchErrorCode, NETWORK_ERROR_MESSAGE, } from "./errors
|
|
|
13
13
|
import { showHelp } from "./help.js";
|
|
14
14
|
import { log } from "./log.js";
|
|
15
15
|
import pkg from "./pkg.js";
|
|
16
|
-
import { fillInArgs } from "./utils/middlewares.js";
|
|
16
|
+
import { fillInArgs, resolveApiKeyFromEnv } from "./utils/middlewares.js";
|
|
17
17
|
const NO_SUBCOMMANDS_VERBS = [
|
|
18
18
|
// `api <path>` has a handler but no subcommands (like `status`), so the
|
|
19
19
|
// help-fallback middleware must not intercept a bare `neon api /projects`.
|
|
@@ -91,7 +91,12 @@ builder = builder
|
|
|
91
91
|
describe: "API key",
|
|
92
92
|
group: "Global options:",
|
|
93
93
|
type: "string",
|
|
94
|
-
default
|
|
94
|
+
// The default must never be the value of NEON_API_KEY: yargs renders an
|
|
95
|
+
// option's default into every help screen, so that printed the user's key
|
|
96
|
+
// verbatim on `neon --help`. `resolveApiKeyFromEnv` reads the env var
|
|
97
|
+
// instead, and `defaultDescription` names it in help without its value.
|
|
98
|
+
default: "",
|
|
99
|
+
defaultDescription: "NEON_API_KEY",
|
|
95
100
|
},
|
|
96
101
|
apiClient: {
|
|
97
102
|
hidden: true,
|
|
@@ -119,6 +124,7 @@ builder = builder
|
|
|
119
124
|
.middleware((args) => {
|
|
120
125
|
fillInArgs(args);
|
|
121
126
|
}, true)
|
|
127
|
+
.middleware(resolveApiKeyFromEnv, true)
|
|
122
128
|
.middleware(initAnalyticsClientMiddleware, true)
|
|
123
129
|
.help(false)
|
|
124
130
|
.group("help", "Global options:")
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves `--api-key` from `NEON_API_KEY` when the flag is absent, leaving it an
|
|
3
|
+
* empty string when neither is set.
|
|
4
|
+
*
|
|
5
|
+
* This cannot be expressed as the option's yargs `default`, because yargs prints
|
|
6
|
+
* defaults in help output and would print the key itself.
|
|
7
|
+
*/
|
|
8
|
+
export const resolveApiKeyFromEnv = (args) => {
|
|
9
|
+
if (typeof args.apiKey === "string" && args.apiKey !== "") {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const fromEnv = process.env.NEON_API_KEY ?? "";
|
|
13
|
+
args.apiKey = fromEnv;
|
|
14
|
+
args["api-key"] = fromEnv;
|
|
15
|
+
};
|
|
1
16
|
/**
|
|
2
17
|
* This middleware is needed to fill in the args for nested objects,
|
|
3
18
|
* so that required arguments would work
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neon",
|
|
3
|
-
"version": "2.38.
|
|
3
|
+
"version": "2.38.4",
|
|
4
4
|
"description": "CLI tool for Neon Serverless Postgres",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"which": "3.0.1",
|
|
57
57
|
"yaml": "^2.9.0",
|
|
58
58
|
"yargs": "17.7.2",
|
|
59
|
-
"@neon/
|
|
60
|
-
"@neon/config": "0.10.
|
|
61
|
-
"@neon/
|
|
62
|
-
"@neon/
|
|
59
|
+
"@neon/config": "0.10.1",
|
|
60
|
+
"@neon/config-runtime": "0.10.1",
|
|
61
|
+
"@neon/env": "0.12.1",
|
|
62
|
+
"@neon/sdk": "1.4.0"
|
|
63
63
|
},
|
|
64
64
|
"optionalDependencies": {
|
|
65
65
|
"esbuild": "0.28.1"
|