Skip to content

Commit f09deeb

Browse files
committed
feat(cli): fix run logs interruption
1 parent 8a51b6d commit f09deeb

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

.changeset/twelve-chairs-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cartesi/cli": patch
3+
---
4+
5+
fix run logs interruption

apps/cli/src/base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import fs from "node:fs";
44
import path from "node:path";
55
import {
66
type Address,
7-
type Hash,
87
getAddress,
8+
type Hash,
99
isAddress,
1010
isHash,
1111
zeroHash,
@@ -101,7 +101,7 @@ export const getAddressBook = async (options: {
101101
return contracts;
102102
};
103103

104-
const getServiceInfo = async (options: {
104+
export const getServiceInfo = async (options: {
105105
projectName: string;
106106
service: string;
107107
}): Promise<PsResponse | undefined> => {

apps/cli/src/commands/logs.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Command } from "@commander-js/extra-typings";
22
import { execa } from "execa";
3-
import { getProjectName } from "../base.js";
3+
import { getProjectName, getServiceInfo } from "../base.js";
44

55
export const createLogsCommand = () => {
66
return new Command("logs")
@@ -10,7 +10,6 @@ export const createLogsCommand = () => {
1010
"name of project (used by docker compose and cartesi-rollups-node)",
1111
)
1212
.option("-f, --follow", "Follow log output")
13-
.option("--no-color", "Produce monochrome output")
1413
.option(
1514
"--since <string>",
1615
"Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)",
@@ -26,24 +25,25 @@ export const createLogsCommand = () => {
2625
)
2726
.configureHelp({ showGlobalOptions: true })
2827
.action(async (options) => {
29-
const { follow, color, since, tail, until } = options;
28+
const { follow, since, tail, until } = options;
3029
const projectName = getProjectName(options);
31-
const logOptions: string[] = ["--no-log-prefix"];
30+
const logOptions: string[] = [];
3231
if (follow) logOptions.push("--follow");
33-
if (color === false) logOptions.push("--no-color");
3432
if (since) logOptions.push("--since", since);
3533
if (tail) logOptions.push("--tail", tail);
3634
if (until) logOptions.push("--until", until);
35+
36+
const serviceInfo = await getServiceInfo({
37+
projectName,
38+
service: "rollups-node",
39+
});
40+
if (!serviceInfo) {
41+
throw new Error(`service rollups-node not found`);
42+
}
43+
3744
await execa(
3845
"docker",
39-
[
40-
"compose",
41-
"--project-name",
42-
projectName,
43-
"logs",
44-
...logOptions,
45-
"rollups-node",
46-
],
46+
["container", "logs", ...logOptions, serviceInfo.ID],
4747
{ stdio: "inherit" },
4848
);
4949
});

0 commit comments

Comments
 (0)