@tdk-landscape/tdk-cli-core 1.3.105 → 1.3.106
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/CHANGELOG.md +1 -0
- package/cli/dist/cli.js +4 -0
- package/cli/dist/commands/doctor.js +2 -1
- package/cli/dist/commands/logs.js +85 -0
- package/cli/dist/commands/mcp.js +24 -0
- package/cli/dist/commands/projects.js +37 -6
- package/cli/dist/commands/resources.js +3 -2
- package/cli/dist/commands/stacks.js +30 -3
- package/cli/dist/commands/status.js +18 -0
- package/cli/dist/commands/up.js +84 -17
- package/cli/dist/mcp/server.js +100 -0
- package/cli/dist/mcp/tools.js +273 -0
- package/cli/dist/utils/discovery-context.js +9 -3
- package/cli/dist/utils/doctor-wiring.js +88 -0
- package/cli/dist/utils/services.js +65 -7
- package/cli/dist/utils/tilt-logs.js +62 -0
- package/cli/dist/utils/up-only.js +29 -0
- package/cli/dist/utils/up-readiness.js +82 -15
- package/cli/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,82 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { getDeferredResourceNames, parseTiltResourceFailures } from "./doctor-runtime.js";
|
|
3
3
|
import { findOnPath } from "./which.js";
|
|
4
|
-
function tiltGetUiResources(port) {
|
|
4
|
+
export function tiltGetUiResources(port) {
|
|
5
5
|
return new Promise((resolve) => {
|
|
6
6
|
execFile(findOnPath("tilt") ?? "tilt", ["get", "uiresources", "-o", "json", "--port", String(port)], { timeout: 15_000, maxBuffer: 16 * 1024 * 1024 }, (error, stdout) => resolve(error ? null : stdout));
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Tilt lists resources outside the current focus (the other release phases, or everything but a `--only` selection) with
|
|
11
|
+
* `disableStatus.state: Disabled` and both statuses `none`, which would read as pending forever. A resource whose update
|
|
12
|
+
* status is `not_applicable` (a serve-only local resource) has nothing to build, so it counts as built.
|
|
13
|
+
*/
|
|
14
|
+
export function onlyEnabledResources(jsonText) {
|
|
15
|
+
const parsed = JSON.parse(jsonText);
|
|
16
|
+
const items = (parsed.items ?? [])
|
|
17
|
+
.filter((item) => item.status?.disableStatus?.state !== "Disabled")
|
|
18
|
+
.map((item) => item.status?.updateStatus === "not_applicable"
|
|
19
|
+
? { ...item, status: { ...item.status, updateStatus: "ok" } }
|
|
20
|
+
: item);
|
|
21
|
+
return JSON.stringify({ items });
|
|
22
|
+
}
|
|
23
|
+
function enabledNames(jsonText) {
|
|
24
|
+
return (JSON.parse(jsonText).items ?? [])
|
|
25
|
+
.filter((item) => item.status?.disableStatus?.state !== "Disabled")
|
|
26
|
+
.flatMap((item) => (item.metadata?.name ? [item.metadata.name] : []));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Services the caller asked for must not vanish into the disabled filter: one that Tilt lists as disabled (it can be
|
|
30
|
+
* disabled while running) is a failure, and one Tilt does not list yet is still pending.
|
|
31
|
+
*/
|
|
32
|
+
export function checkExpectedResources(jsonText, expected) {
|
|
33
|
+
const items = JSON.parse(jsonText).items ?? [];
|
|
34
|
+
const byName = new Map(items.map((item) => [item.metadata?.name, item]));
|
|
35
|
+
return {
|
|
36
|
+
missing: expected.filter((name) => !byName.has(name)),
|
|
37
|
+
disabled: expected.filter((name) => byName.get(name)?.status?.disableStatus?.state === "Disabled"),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* One look at `tilt get uiresources -o json`. `settled` means polling can stop: everything is ready, or the rest has
|
|
42
|
+
* finished with a failure (an errored resource, or an expected service Tilt has disabled).
|
|
43
|
+
*/
|
|
44
|
+
export function evaluateTiltReadiness(jsonText, deferred, expected) {
|
|
45
|
+
const parsed = parseTiltResourceFailures(onlyEnabledResources(jsonText), deferred);
|
|
46
|
+
let result = {
|
|
47
|
+
ready: parsed.failures.length === 0 && parsed.pendingCount === 0 && parsed.okCount > 0,
|
|
48
|
+
failures: parsed.failures.map((failure) => ({
|
|
49
|
+
name: failure.name,
|
|
50
|
+
message: failure.error || `${failure.updateStatus}/${failure.runtimeStatus}`,
|
|
51
|
+
})),
|
|
52
|
+
pending: parsed.pendingCount,
|
|
53
|
+
timedOut: false,
|
|
54
|
+
enabled: enabledNames(jsonText),
|
|
55
|
+
};
|
|
56
|
+
if (expected && expected.length > 0) {
|
|
57
|
+
const { missing, disabled } = checkExpectedResources(jsonText, expected);
|
|
58
|
+
if (missing.length > 0) {
|
|
59
|
+
result = { ...result, ready: false, pending: result.pending + missing.length };
|
|
60
|
+
}
|
|
61
|
+
if (disabled.length > 0) {
|
|
62
|
+
return {
|
|
63
|
+
settled: true,
|
|
64
|
+
result: {
|
|
65
|
+
...result,
|
|
66
|
+
ready: false,
|
|
67
|
+
failures: [
|
|
68
|
+
...result.failures,
|
|
69
|
+
...disabled.map((name) => ({ name, message: "disabled in Tilt" })),
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
result,
|
|
77
|
+
settled: result.ready || (result.failures.length > 0 && result.pending === 0),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
9
80
|
/**
|
|
10
81
|
* Waits until every non-deferred Tilt resource is built and running. Resolves not-ready as soon as the rest has settled
|
|
11
82
|
* with an errored resource, or at the deadline. Sablier-deferred resources are excluded: they stay idle by design.
|
|
@@ -16,24 +87,20 @@ export async function waitForTiltResourcesReady(port, options = {}) {
|
|
|
16
87
|
const fetchJson = options.fetchJson ?? tiltGetUiResources;
|
|
17
88
|
const deferred = options.deferred ?? getDeferredResourceNames();
|
|
18
89
|
const deadline = Date.now() + timeoutMs;
|
|
19
|
-
let last = {
|
|
90
|
+
let last = {
|
|
91
|
+
ready: false,
|
|
92
|
+
failures: [],
|
|
93
|
+
pending: 0,
|
|
94
|
+
timedOut: false,
|
|
95
|
+
enabled: [],
|
|
96
|
+
};
|
|
20
97
|
for (;;) {
|
|
21
98
|
const text = await fetchJson(port);
|
|
22
99
|
if (text) {
|
|
23
100
|
try {
|
|
24
|
-
const
|
|
25
|
-
last =
|
|
26
|
-
|
|
27
|
-
failures: parsed.failures.map((failure) => ({
|
|
28
|
-
name: failure.name,
|
|
29
|
-
message: failure.error || `${failure.updateStatus}/${failure.runtimeStatus}`,
|
|
30
|
-
})),
|
|
31
|
-
pending: parsed.pendingCount,
|
|
32
|
-
timedOut: false,
|
|
33
|
-
};
|
|
34
|
-
if (last.ready)
|
|
35
|
-
return last;
|
|
36
|
-
if (last.failures.length > 0 && last.pending === 0)
|
|
101
|
+
const evaluation = evaluateTiltReadiness(text, deferred, options.expected);
|
|
102
|
+
last = evaluation.result;
|
|
103
|
+
if (evaluation.settled)
|
|
37
104
|
return last;
|
|
38
105
|
}
|
|
39
106
|
catch {
|
package/cli/package.json
CHANGED