@solidactions/cli 0.2.3 → 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.
- package/dist/commands/logs.js +25 -16
- package/dist/commands/run.js +6 -2
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/commands/logs.js
CHANGED
|
@@ -32,8 +32,8 @@ async function logs(runId, options) {
|
|
|
32
32
|
'Accept': 'application/json',
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
displayLogs(
|
|
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
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
89
|
-
|
|
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/dist/commands/run.js
CHANGED
|
@@ -13,7 +13,11 @@ async function run(projectName, workflowName, options) {
|
|
|
13
13
|
console.error(chalk_1.default.red('Not initialized. Run "solidactions init <api-key>" first.'));
|
|
14
14
|
process.exit(1);
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
const environment = options.env || 'dev';
|
|
17
|
+
const projectSlug = environment === 'production'
|
|
18
|
+
? projectName
|
|
19
|
+
: `${projectName}-${environment}`;
|
|
20
|
+
console.log(chalk_1.default.blue(`Running workflow "${workflowName}" in project "${projectName}" (${environment})...`));
|
|
17
21
|
let inputData = {};
|
|
18
22
|
if (options.input) {
|
|
19
23
|
try {
|
|
@@ -25,7 +29,7 @@ async function run(projectName, workflowName, options) {
|
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
try {
|
|
28
|
-
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${
|
|
32
|
+
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/workflows/${workflowName}/trigger`, { input: inputData }, {
|
|
29
33
|
headers: {
|
|
30
34
|
'Authorization': `Bearer ${config.apiKey}`,
|
|
31
35
|
'Accept': 'application/json',
|
package/dist/index.js
CHANGED
|
@@ -76,6 +76,7 @@ program
|
|
|
76
76
|
.description('Trigger a workflow run')
|
|
77
77
|
.argument('<project>', 'Project name')
|
|
78
78
|
.argument('<workflow>', 'Workflow name')
|
|
79
|
+
.option('-e, --env <environment>', 'Environment (production/staging/dev)', 'dev')
|
|
79
80
|
.option('-i, --input <json>', 'JSON input for the workflow')
|
|
80
81
|
.option('-w, --wait', 'Wait for the workflow to complete')
|
|
81
82
|
.action((project, workflow, options) => {
|