@nurix/nustack 0.26.5 → 0.26.7
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/commands/api.js +10 -1
- package/package.json +4 -4
package/dist/commands/api.js
CHANGED
|
@@ -2,6 +2,8 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { ensureAuthWithRecovery, lastAuthFailure } from "../lib/auth_recovery.js";
|
|
3
3
|
import { assertSafeApiPath } from "../lib/guards.js";
|
|
4
4
|
import { authorizedFetch, resolveNuStackUrl } from "../lib/nustack_client.js";
|
|
5
|
+
const DEFAULT_TIMEOUT_SECONDS = 30;
|
|
6
|
+
const MAX_TIMEOUT_SECONDS = 300;
|
|
5
7
|
function collect(value, previous = []) {
|
|
6
8
|
return [...previous, value];
|
|
7
9
|
}
|
|
@@ -74,8 +76,14 @@ export async function runApi(path, options, globals) {
|
|
|
74
76
|
}
|
|
75
77
|
headers.set("Authorization", `Bearer ${auth.accessToken}`);
|
|
76
78
|
const method = (options.method ?? (body === undefined ? "GET" : "POST")).toUpperCase();
|
|
79
|
+
const seconds = options.timeout === undefined ? DEFAULT_TIMEOUT_SECONDS : Number(options.timeout);
|
|
80
|
+
if (!Number.isFinite(seconds) || seconds <= 0 || seconds > MAX_TIMEOUT_SECONDS) {
|
|
81
|
+
console.error(`--timeout takes a number of seconds above 0 and at most ${MAX_TIMEOUT_SECONDS} (got ${options.timeout})`);
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
77
85
|
try {
|
|
78
|
-
const response = await authorizedFetch(url, { method, headers, body, signal: AbortSignal.timeout(
|
|
86
|
+
const response = await authorizedFetch(url, { method, headers, body, signal: AbortSignal.timeout(seconds * 1000) });
|
|
79
87
|
if (options.include) {
|
|
80
88
|
console.error(`HTTP ${response.status} ${response.statusText}`);
|
|
81
89
|
response.headers.forEach((value, name) => console.error(`${name}: ${value}`));
|
|
@@ -102,5 +110,6 @@ export function registerApiCommand(program, getGlobalOptions) {
|
|
|
102
110
|
.option("--input <file>", "send a file as the body, or - for stdin")
|
|
103
111
|
.option("-H, --header <header>", "an extra request header, 'Name: value' (repeatable)", collect)
|
|
104
112
|
.option("-i, --include", "print the status line and response headers on stderr")
|
|
113
|
+
.option("--timeout <seconds>", `how long to wait for the answer (default ${DEFAULT_TIMEOUT_SECONDS})`)
|
|
105
114
|
.action(async (path, options) => runApi(path, options, getGlobalOptions()));
|
|
106
115
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nurix/nustack",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.7",
|
|
4
4
|
"description": "The nustack CLI — bootstrap NuStack services into a repo via the NuStack discovery plane.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"@types/node": "^22.19.20",
|
|
35
35
|
"typescript": "^5.7.2",
|
|
36
36
|
"vitest": "^4.1.11",
|
|
37
|
-
"@nurix/contracts": "3.0.2",
|
|
38
|
-
"@nurix/harness": "0.0.0",
|
|
39
37
|
"@nurix/nustack.studio": "0.0.0",
|
|
40
|
-
"@nurix/nustack.ui": "0.0.0"
|
|
38
|
+
"@nurix/nustack.ui": "0.0.0",
|
|
39
|
+
"@nurix/harness": "0.0.0",
|
|
40
|
+
"@nurix/contracts": "3.0.2"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|