@standards/cli 1.0.0-alpha.421 → 1.0.0-alpha.425
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/bin.mjs +18 -6
- package/package.json +4 -4
package/dist/bin.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { createWriteStream } from "node:fs";
|
|
|
10
10
|
import { chmod, lstat, mkdir, readFile, readdir, readlink, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
11
11
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
12
12
|
import Table from "cli-table3";
|
|
13
|
-
import { StandardsRequestError as StandardsRequestError$1, TURN_END_TYPES, createAppClient, openAgentStream } from "@standards/client/app";
|
|
13
|
+
import { StandardsRequestError as StandardsRequestError$1, TURN_END_TYPES, createAppClient, openAgentStream, schemaApiErrorCode } from "@standards/client/app";
|
|
14
14
|
import { homedir, hostname } from "node:os";
|
|
15
15
|
import { Readable } from "node:stream";
|
|
16
16
|
import { pipeline } from "node:stream/promises";
|
|
@@ -165,6 +165,21 @@ async function readAllPages(read) {
|
|
|
165
165
|
} while (cursor);
|
|
166
166
|
return items;
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Every machine `GET /machines` lists for `query`, every page. A host with no
|
|
170
|
+
* machines answers `CONFIGURATION_REQUIRED`, which reads as none.
|
|
171
|
+
*/
|
|
172
|
+
async function readAllMachines(client, query = {}) {
|
|
173
|
+
try {
|
|
174
|
+
return await readAllPages((cursor) => client.machines.list({
|
|
175
|
+
...query,
|
|
176
|
+
...cursor && { cursor }
|
|
177
|
+
}));
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (schemaApiErrorCode(error) === SchemaErrorCode.CONFIGURATION_REQUIRED) return [];
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
168
183
|
function getClientFromCommand(cmd) {
|
|
169
184
|
const root = getGlobalOptions(cmd);
|
|
170
185
|
if (!(root.apiUrl && root.apiKey)) throw new ValidationError("No Standards instance configured. Run \"standards login\" or pass --api-key.", []);
|
|
@@ -1071,10 +1086,7 @@ function registerMachinesCommand(program) {
|
|
|
1071
1086
|
machines.command("list").description("List the machines you can read, every page").option("--env <env>", "only one environment's machines (name or id)").action(async (opts, cmd) => {
|
|
1072
1087
|
const client = getAppClientFromCommand(cmd);
|
|
1073
1088
|
const environmentId = opts.env ? await resolveEnvironmentId(client, opts.env) : void 0;
|
|
1074
|
-
formatOutput(await
|
|
1075
|
-
...environmentId && { environmentId },
|
|
1076
|
-
...cursor && { cursor }
|
|
1077
|
-
})), getFormat(cmd));
|
|
1089
|
+
formatOutput(await readAllMachines(client, environmentId ? { environmentId } : {}), getFormat(cmd));
|
|
1078
1090
|
});
|
|
1079
1091
|
machines.command("get").description("Show a machine: its lease, pilot and links").argument("<id>", "machine id").action(async (id, _opts, cmd) => {
|
|
1080
1092
|
formatOutput(await getAppClientFromCommand(cmd).machines.get({ id }), getFormat(cmd));
|
|
@@ -2661,7 +2673,7 @@ async function readSessionsAndDecisions(client) {
|
|
|
2661
2673
|
}
|
|
2662
2674
|
/** The running machines with their links, every page (the provider's listing, read sparingly). */
|
|
2663
2675
|
async function readRunningMachines(client) {
|
|
2664
|
-
return (await
|
|
2676
|
+
return (await readAllMachines(client)).filter((item) => item.machine.status === "running").map(summarizeMachine);
|
|
2665
2677
|
}
|
|
2666
2678
|
function quoted(text) {
|
|
2667
2679
|
return JSON.stringify(text);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standards/cli",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.425",
|
|
4
4
|
"description": "CLI tool to interact with Standards API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"node": ">=22"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@standards/client": "1.0.0-alpha.
|
|
28
|
-
"@standards/constants": "1.0.0-alpha.
|
|
29
|
-
"@standards/schema": "1.0.0-alpha.
|
|
27
|
+
"@standards/client": "1.0.0-alpha.425",
|
|
28
|
+
"@standards/constants": "1.0.0-alpha.425",
|
|
29
|
+
"@standards/schema": "1.0.0-alpha.425",
|
|
30
30
|
"cli-table3": "^0.6.5",
|
|
31
31
|
"commander": "^13.1.0",
|
|
32
32
|
"jiti": "2.7.0",
|