@coresource/hz 0.1.4 → 0.1.6
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/hz.mjs +37 -6
- package/package.json +1 -1
package/dist/hz.mjs
CHANGED
|
@@ -642,9 +642,6 @@ function normalizeMissionMilestones(value) {
|
|
|
642
642
|
};
|
|
643
643
|
});
|
|
644
644
|
}
|
|
645
|
-
function truncateMissionId(missionId, limit = 12) {
|
|
646
|
-
return missionId.length > limit ? `${missionId.slice(0, limit)}\u2026` : missionId;
|
|
647
|
-
}
|
|
648
645
|
function formatMissionState(state) {
|
|
649
646
|
switch (state) {
|
|
650
647
|
case "completed":
|
|
@@ -740,7 +737,7 @@ function registerMissionListCommand(mission, context, dependencies = {}) {
|
|
|
740
737
|
context.stdout,
|
|
741
738
|
["Mission ID", "State", "Created", "Features", "Assertions"],
|
|
742
739
|
missions.map((missionSummary) => [
|
|
743
|
-
plainCell(
|
|
740
|
+
plainCell(missionSummary.missionId),
|
|
744
741
|
coloredCell(
|
|
745
742
|
formatMissionState(missionSummary.state),
|
|
746
743
|
missionSummary.state
|
|
@@ -2086,9 +2083,17 @@ function defaultCreateWebSocket(url, options) {
|
|
|
2086
2083
|
return new WebSocket(url, { headers: options.headers });
|
|
2087
2084
|
}
|
|
2088
2085
|
function defaultRegisterSignalHandler(signal, handler) {
|
|
2089
|
-
|
|
2086
|
+
let fired = false;
|
|
2087
|
+
const wrapper = () => {
|
|
2088
|
+
if (fired) {
|
|
2089
|
+
process.exit(130);
|
|
2090
|
+
}
|
|
2091
|
+
fired = true;
|
|
2092
|
+
handler();
|
|
2093
|
+
};
|
|
2094
|
+
process.on(signal, wrapper);
|
|
2090
2095
|
return () => {
|
|
2091
|
-
process.off(signal,
|
|
2096
|
+
process.off(signal, wrapper);
|
|
2092
2097
|
};
|
|
2093
2098
|
}
|
|
2094
2099
|
function createMissionWebSocketUrl(endpoint, missionId) {
|
|
@@ -2918,6 +2923,32 @@ function registerMissionLifecycleCommands(mission, context, dependencies = {}) {
|
|
|
2918
2923
|
dependencies
|
|
2919
2924
|
);
|
|
2920
2925
|
});
|
|
2926
|
+
mission.command("watch").description("Watch a mission's live progress").argument("[missionId]").action(async (missionId, _options, command) => {
|
|
2927
|
+
const homeDir = resolveLifecycleHomeDir(context);
|
|
2928
|
+
const resolved = await resolveMissionId(missionId, context, command, homeDir);
|
|
2929
|
+
const { apiClient, authConfig } = await createMissionClientContext(
|
|
2930
|
+
context,
|
|
2931
|
+
command,
|
|
2932
|
+
dependencies,
|
|
2933
|
+
homeDir
|
|
2934
|
+
);
|
|
2935
|
+
const monitorResult = await monitorMission({
|
|
2936
|
+
apiClient,
|
|
2937
|
+
apiKey: authConfig.apiKey,
|
|
2938
|
+
createSpinner: dependencies.createSpinner,
|
|
2939
|
+
createWebSocket: dependencies.createWebSocket,
|
|
2940
|
+
endpoint: authConfig.endpoint,
|
|
2941
|
+
missionId: resolved,
|
|
2942
|
+
promptInput: dependencies.promptInput,
|
|
2943
|
+
promptSelect: dependencies.promptSelect,
|
|
2944
|
+
registerSignalHandler: dependencies.registerSignalHandler,
|
|
2945
|
+
sleep: dependencies.sleep,
|
|
2946
|
+
stdout: context.stdout
|
|
2947
|
+
});
|
|
2948
|
+
if (monitorResult.exitCode !== 0) {
|
|
2949
|
+
throw new CommanderError(monitorResult.exitCode, "mission-monitor", "");
|
|
2950
|
+
}
|
|
2951
|
+
});
|
|
2921
2952
|
}
|
|
2922
2953
|
|
|
2923
2954
|
// src/commands/mission-run.ts
|