@solidactions/cli 0.7.3 → 1.0.0

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.
@@ -1,202 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.steps = steps;
7
- const axios_1 = __importDefault(require("axios"));
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const api_1 = require("../utils/api");
10
- async function steps(runId, options) {
11
- const config = await (0, api_1.requireConfigWithWorkspace)();
12
- // Flag validation: --follow and --step are incompatible
13
- if (options.follow && options.step) {
14
- console.error(chalk_1.default.red('Cannot use --follow with --step.'));
15
- process.exit(1);
16
- }
17
- try {
18
- const response = await axios_1.default.get(`${config.host}/api/v1/runs/${runId}/steps`, {
19
- headers: (0, api_1.getApiHeaders)(config),
20
- });
21
- const data = response.data;
22
- // --json mode: output raw JSON and exit
23
- if (options.json) {
24
- if (options.step) {
25
- const allSteps = flattenSteps(data.workers);
26
- const found = allSteps.find(s => s.name === options.step);
27
- if (!found) {
28
- console.log(JSON.stringify({
29
- error: 'Step not found',
30
- available: allSteps.map(s => s.name),
31
- }, null, 2));
32
- process.exit(1);
33
- }
34
- console.log(JSON.stringify(found, null, 2));
35
- }
36
- else {
37
- console.log(JSON.stringify(data, null, 2));
38
- }
39
- return;
40
- }
41
- // --step mode: show single step detail
42
- if (options.step) {
43
- const allSteps = flattenSteps(data.workers);
44
- const found = allSteps.find(s => s.name === options.step);
45
- if (!found) {
46
- console.error(chalk_1.default.red(`Step "${options.step}" not found.`));
47
- console.log(chalk_1.default.gray('Available steps:'));
48
- for (const s of allSteps) {
49
- console.log(chalk_1.default.gray(` - ${s.name}`));
50
- }
51
- process.exit(1);
52
- }
53
- displaySingleStep(found);
54
- return;
55
- }
56
- // Default mode: show all steps
57
- displayAllSteps(runId, data);
58
- // --follow mode
59
- if (options.follow) {
60
- console.log(chalk_1.default.gray('\n--- Following steps (Ctrl+C to stop) ---\n'));
61
- const pollInterval = setInterval(async () => {
62
- try {
63
- const refreshResponse = await axios_1.default.get(`${config.host}/api/v1/runs/${runId}/steps`, {
64
- headers: (0, api_1.getApiHeaders)(config),
65
- });
66
- const runStatus = await axios_1.default.get(`${config.host}/api/v1/runs/${runId}`, {
67
- headers: (0, api_1.getApiHeaders)(config),
68
- });
69
- console.clear();
70
- displayAllSteps(runId, refreshResponse.data);
71
- if (['completed', 'failed', 'acknowledged'].includes(runStatus.data.status)) {
72
- clearInterval(pollInterval);
73
- console.log(chalk_1.default.gray(`\n--- Run ${runStatus.data.status} ---`));
74
- process.exit(runStatus.data.status === 'completed' ? 0 : 1);
75
- }
76
- }
77
- catch {
78
- // Ignore transient errors during follow
79
- }
80
- }, 2000);
81
- }
82
- }
83
- catch (error) {
84
- if (error.response) {
85
- if (error.response.status === 401) {
86
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions init <api-key>" to re-configure.'));
87
- }
88
- else if (error.response.status === 404) {
89
- console.error(chalk_1.default.red('Run not found.'));
90
- }
91
- else {
92
- console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
93
- }
94
- }
95
- else {
96
- console.error(chalk_1.default.red('Connection failed:'), error.message);
97
- }
98
- process.exit(1);
99
- }
100
- }
101
- function flattenSteps(workers) {
102
- const allSteps = [];
103
- for (const worker of workers) {
104
- for (const step of worker.steps || []) {
105
- allSteps.push(step);
106
- }
107
- }
108
- return allSteps;
109
- }
110
- function displaySingleStep(step) {
111
- const statusColor = getStatusColor(step.status);
112
- console.log(chalk_1.default.blue(`Step: ${step.name}`));
113
- console.log(` Status: ${statusColor(step.status)}`);
114
- console.log(` Type: ${step.type}`);
115
- console.log(` Duration: ${formatDuration(step.duration_ms)}`);
116
- console.log(` Started: ${step.started_at || '-'}`);
117
- console.log(` Completed: ${step.completed_at || '-'}`);
118
- if (step.output !== null && step.output !== undefined) {
119
- console.log(` Output:`);
120
- console.log(JSON.stringify(step.output, null, 2));
121
- }
122
- else {
123
- console.log(` Output: ${chalk_1.default.gray('(no output)')}`);
124
- }
125
- if (step.error) {
126
- console.log(chalk_1.default.red(` Error:`));
127
- console.log(chalk_1.default.red(JSON.stringify(step.error, null, 2)));
128
- }
129
- }
130
- function displayAllSteps(runId, data) {
131
- const workers = data.workers || [];
132
- const signalWaits = data.signal_waits || [];
133
- console.log(chalk_1.default.blue(`Steps for run: ${runId}`));
134
- console.log('');
135
- for (let i = 0; i < workers.length; i++) {
136
- const worker = workers[i];
137
- const workerStatus = getStatusColor(worker.status || 'unknown');
138
- const workerDuration = calculateDuration(worker.started_at, worker.completed_at);
139
- console.log(chalk_1.default.white.bold(`Worker ${i + 1}`) + ' ' + workerStatus(worker.status || 'unknown') + chalk_1.default.gray(` (${workerDuration})`));
140
- for (const step of worker.steps || []) {
141
- const statusColor = getStatusColor(step.status);
142
- const name = (step.name || '?').padEnd(30);
143
- const status = statusColor((step.status || '?').padEnd(10));
144
- const type = (step.type || '?').padEnd(10);
145
- const duration = formatDuration(step.duration_ms);
146
- console.log(` ${name} ${status} ${type} ${chalk_1.default.gray(duration)}`);
147
- if (step.output !== null && step.output !== undefined) {
148
- const outputStr = JSON.stringify(step.output, null, 2);
149
- for (const line of outputStr.split('\n')) {
150
- console.log(chalk_1.default.gray(` ${line}`));
151
- }
152
- }
153
- else {
154
- console.log(chalk_1.default.gray(' (no output)'));
155
- }
156
- if (step.error) {
157
- console.log(chalk_1.default.red(` Error: ${JSON.stringify(step.error, null, 2)}`));
158
- }
159
- }
160
- // Show signal waits between workers
161
- if (i < workers.length - 1) {
162
- const wait = signalWaits[i];
163
- if (wait) {
164
- console.log(chalk_1.default.yellow(` ⏳ ${wait.signal_name} (${formatDuration(wait.duration_ms)})`));
165
- }
166
- }
167
- console.log('');
168
- }
169
- }
170
- function formatDuration(ms) {
171
- if (ms === null || ms === undefined)
172
- return '-';
173
- if (ms < 1000)
174
- return `${ms}ms`;
175
- if (ms < 60000)
176
- return `${Math.round(ms / 1000)}s`;
177
- if (ms < 3600000)
178
- return `${Math.round(ms / 60000)}m`;
179
- return `${Math.round(ms / 3600000)}h`;
180
- }
181
- function calculateDuration(startedAt, completedAt) {
182
- if (!startedAt)
183
- return '-';
184
- const start = new Date(startedAt).getTime();
185
- const end = completedAt ? new Date(completedAt).getTime() : Date.now();
186
- return formatDuration(end - start);
187
- }
188
- function getStatusColor(status) {
189
- switch (status.toLowerCase()) {
190
- case 'completed':
191
- return chalk_1.default.green;
192
- case 'running':
193
- return chalk_1.default.blue;
194
- case 'pending':
195
- case 'queued':
196
- return chalk_1.default.yellow;
197
- case 'failed':
198
- return chalk_1.default.red;
199
- default:
200
- return chalk_1.default.gray;
201
- }
202
- }
File without changes