@solidactions/cli 0.2.4 → 0.2.5

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.
@@ -32,8 +32,8 @@ async function logs(runId, options) {
32
32
  'Accept': 'application/json',
33
33
  },
34
34
  });
35
- let logEntries = logsResponse.data.logs || [];
36
- displayLogs(logEntries);
35
+ const logData = logsResponse.data.logs || '';
36
+ let printed = displayLogs(logData);
37
37
  if (options.follow && runData.status === 'running') {
38
38
  console.log(chalk_1.default.gray('\n--- Following logs (Ctrl+C to stop) ---\n'));
39
39
  const pollInterval = setInterval(async () => {
@@ -44,10 +44,11 @@ async function logs(runId, options) {
44
44
  'Accept': 'application/json',
45
45
  },
46
46
  });
47
- const newLogs = refreshResponse.data.logs || [];
48
- const newEntries = newLogs.slice(logEntries.length);
49
- displayLogs(newEntries);
50
- logEntries = newLogs;
47
+ const newLogData = refreshResponse.data.logs || '';
48
+ if (newLogData.length > printed) {
49
+ const newContent = newLogData.substring(printed);
50
+ printed += displayLogs(newContent);
51
+ }
51
52
  // Check if run is complete
52
53
  const runStatus = await axios_1.default.get(`${config.host}/api/v1/runs/${runId}`, {
53
54
  headers: {
@@ -85,19 +86,27 @@ async function logs(runId, options) {
85
86
  process.exit(1);
86
87
  }
87
88
  }
88
- function displayLogs(entries) {
89
- for (const entry of entries) {
89
+ /**
90
+ * Display log content. Handles both string logs and array-of-entry logs.
91
+ * Returns the number of characters printed (for follow-mode diffing).
92
+ */
93
+ function displayLogs(logData) {
94
+ if (typeof logData === 'string') {
95
+ if (logData.trim()) {
96
+ console.log(logData);
97
+ }
98
+ return logData.length;
99
+ }
100
+ // Handle array format in case the API changes
101
+ for (const entry of logData) {
102
+ const message = entry.message || entry.content || '';
103
+ if (!message.trim())
104
+ continue;
90
105
  const timestamp = entry.timestamp ? new Date(entry.timestamp).toLocaleTimeString() : '??:??:??';
91
106
  const stream = entry.stream || 'stdout';
92
- const message = entry.message || entry.content || '';
93
- let coloredMessage;
94
- if (stream === 'stderr') {
95
- coloredMessage = chalk_1.default.red(message);
96
- }
97
- else {
98
- coloredMessage = chalk_1.default.white(message);
99
- }
100
107
  const streamIndicator = stream === 'stderr' ? chalk_1.default.red('[err]') : chalk_1.default.gray('[out]');
108
+ const coloredMessage = stream === 'stderr' ? chalk_1.default.red(message) : chalk_1.default.white(message);
101
109
  console.log(`${chalk_1.default.gray(`[${timestamp}]`)} ${streamIndicator} ${coloredMessage}`);
102
110
  }
111
+ return logData.length;
103
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidactions/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "SolidActions CLI - Deploy and manage workflow automation",
5
5
  "main": "dist/index.js",
6
6
  "bin": {