bdy 1.25.23-dev-vt-suite-pkg-869b1fwwu → 1.25.24-dev
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/distTs/package.json +1 -1
- package/distTs/src/api/client.js +25 -125
- package/distTs/src/command/artifact/download.js +87 -4
- package/distTs/src/command/sandbox/exec/command.js +5 -5
- package/distTs/src/command/sandbox/exec/kill.js +7 -3
- package/distTs/src/command/sandbox/exec/list.js +18 -13
- package/distTs/src/command/sandbox/exec/logs.js +8 -1
- package/distTs/src/command/sandbox/exec/status.js +13 -8
- package/distTs/src/command/sandbox/finishExec.js +29 -11
- package/distTs/src/command/target/exec/command.js +9 -24
- package/distTs/src/command/target/exec/logs.js +2 -3
- package/distTs/src/command/target/scope.js +1 -36
- package/distTs/src/command/tests/capture.js +6 -8
- package/distTs/src/command/tests/visual/session/close.js +5 -4
- package/distTs/src/command/tests/visual/session/create.js +7 -9
- package/distTs/src/command/tests/visual/session.js +0 -15
- package/distTs/src/command/tests/visual/upload.js +6 -8
- package/distTs/src/command/tests/visual.js +1 -13
- package/distTs/src/execLog.js +77 -0
- package/distTs/src/input.js +19 -0
- package/distTs/src/output.js +0 -30
- package/distTs/src/texts.js +50 -465
- package/distTs/src/utils.js +5 -38
- package/distTs/src/visualTest/requests.js +2 -10
- package/distTs/src/visualTest/snapshots.js +5 -3
- package/package.json +1 -1
- package/distTs/src/autocomplete.js +0 -90
- package/distTs/src/command/artifact/downloadDir.js +0 -110
- package/distTs/src/command/autocomplete/install.js +0 -16
- package/distTs/src/command/autocomplete/uninstall.js +0 -16
- package/distTs/src/command/autocomplete.js +0 -14
- package/distTs/src/command/environment/resolve.js +0 -39
- package/distTs/src/command/package/create.js +0 -64
- package/distTs/src/command/package/delete.js +0 -38
- package/distTs/src/command/package/docker/login.js +0 -26
- package/distTs/src/command/package/docker.js +0 -11
- package/distTs/src/command/package/download.js +0 -138
- package/distTs/src/command/package/get.js +0 -36
- package/distTs/src/command/package/list.js +0 -31
- package/distTs/src/command/package/publish.js +0 -241
- package/distTs/src/command/package/version/delete.js +0 -39
- package/distTs/src/command/package/version/get.js +0 -45
- package/distTs/src/command/package/version/list.js +0 -47
- package/distTs/src/command/package/version.js +0 -16
- package/distTs/src/command/package.js +0 -26
- package/distTs/src/command/pipeline/run/apply.js +0 -62
- package/distTs/src/command/scrape/validation.js +0 -154
- package/distTs/src/command/scrape.js +0 -144
- package/distTs/src/command/tests/visual/result/download.js +0 -31
- package/distTs/src/command/tests/visual/result/get.js +0 -52
- package/distTs/src/command/tests/visual/result/list.js +0 -49
- package/distTs/src/command/tests/visual/result.js +0 -23
- package/distTs/src/command/tests/visual/session/get.js +0 -49
- package/distTs/src/command/tests/visual/session/list.js +0 -69
- package/distTs/src/command/tests/visual/session/reviewUrl.js +0 -37
- package/distTs/src/command/tests/visual/session/update.js +0 -26
- package/distTs/src/command/tests/visual/shared/context.js +0 -172
- package/distTs/src/command/tests/visual/shared/format.js +0 -21
- package/distTs/src/command/tests/visual/shared/lookup.js +0 -107
- package/distTs/src/command/tests/visual/shared/options.js +0 -92
- package/distTs/src/command/tests/visual/shared/review.js +0 -146
- package/distTs/src/command/tests/visual/shared/reviewUrl.js +0 -62
- package/distTs/src/command/tests/visual/shared/session.js +0 -31
- package/distTs/src/command/tests/visual/snapshot/get.js +0 -46
- package/distTs/src/command/tests/visual/snapshot/list.js +0 -68
- package/distTs/src/command/tests/visual/snapshot/reviewUrl.js +0 -48
- package/distTs/src/command/tests/visual/snapshot.js +0 -25
- package/distTs/src/command/tests/visual/suite/create.js +0 -38
- package/distTs/src/command/tests/visual/suite/delete.js +0 -29
- package/distTs/src/command/tests/visual/suite/get.js +0 -43
- package/distTs/src/command/tests/visual/suite/list.js +0 -35
- package/distTs/src/command/tests/visual/suite/update.js +0 -47
- package/distTs/src/command/tests/visual/suite.js +0 -27
- package/distTs/src/command/ut/upload.js +0 -86
- package/distTs/src/command/ut.js +0 -12
- package/distTs/src/command/vt/close.js +0 -27
- package/distTs/src/command/vt/compare/validation.js +0 -46
- package/distTs/src/command/vt/compare.js +0 -100
- package/distTs/src/command/vt/exec.js +0 -82
- package/distTs/src/command/vt/installBrowser.js +0 -20
- package/distTs/src/command/vt/shared/validation.js +0 -145
- package/distTs/src/command/vt/storybook.js +0 -138
- package/distTs/src/command/vt.js +0 -20
- package/distTs/src/command/yaml/agents.js +0 -88
- package/distTs/src/command/yaml/init.js +0 -110
- package/distTs/src/main.js +0 -190
- package/distTs/src/types/options.js +0 -2
- package/distTs/src/types/scrape.js +0 -2
- package/distTs/src/types/visualTests.js +0 -2
package/distTs/package.json
CHANGED
package/distTs/src/api/client.js
CHANGED
|
@@ -1133,41 +1133,50 @@ class ApiClient {
|
|
|
1133
1133
|
async executeSandboxCommand(workspace, sandboxId, body) {
|
|
1134
1134
|
return await this.request({
|
|
1135
1135
|
method: 'POST',
|
|
1136
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/
|
|
1136
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/execs`,
|
|
1137
1137
|
body,
|
|
1138
1138
|
parseResponseBody: true,
|
|
1139
1139
|
});
|
|
1140
1140
|
}
|
|
1141
|
-
async
|
|
1141
|
+
async getSandboxExecs(workspace, sandboxId, limit) {
|
|
1142
|
+
const query = {};
|
|
1143
|
+
if (limit)
|
|
1144
|
+
query.limit = limit.toString();
|
|
1142
1145
|
return await this.request({
|
|
1143
1146
|
method: 'GET',
|
|
1144
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/
|
|
1147
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/execs`,
|
|
1148
|
+
query,
|
|
1145
1149
|
parseResponseBody: true,
|
|
1146
1150
|
});
|
|
1147
1151
|
}
|
|
1148
|
-
async
|
|
1152
|
+
async getSandboxExec(workspace, sandboxId, execId, wait) {
|
|
1153
|
+
const query = {};
|
|
1154
|
+
if (wait)
|
|
1155
|
+
query.wait = wait.toString();
|
|
1149
1156
|
return await this.request({
|
|
1150
1157
|
method: 'GET',
|
|
1151
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/
|
|
1158
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/execs/${encodeURIComponent(execId)}`,
|
|
1159
|
+
query,
|
|
1152
1160
|
parseResponseBody: true,
|
|
1153
1161
|
});
|
|
1154
1162
|
}
|
|
1155
|
-
async
|
|
1156
|
-
let q = '';
|
|
1157
|
-
if (follow)
|
|
1158
|
-
q = '?follow=true';
|
|
1163
|
+
async cancelSandboxExec(workspace, sandboxId, execId) {
|
|
1159
1164
|
return await this.request({
|
|
1160
|
-
method: '
|
|
1161
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/
|
|
1165
|
+
method: 'DELETE',
|
|
1166
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/execs/${encodeURIComponent(execId)}`,
|
|
1162
1167
|
parseResponseBody: false,
|
|
1163
|
-
rawResponseBody: true,
|
|
1164
1168
|
});
|
|
1165
1169
|
}
|
|
1166
|
-
async
|
|
1170
|
+
async getSandboxExecLog(workspace, sandboxId, execId, offset, limit) {
|
|
1171
|
+
const query = {};
|
|
1172
|
+
if (offset)
|
|
1173
|
+
query.offset = offset.toString();
|
|
1174
|
+
if (limit)
|
|
1175
|
+
query.limit = limit.toString();
|
|
1167
1176
|
return await this.request({
|
|
1168
|
-
method: '
|
|
1169
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/
|
|
1170
|
-
|
|
1177
|
+
method: 'GET',
|
|
1178
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/execs/${encodeURIComponent(execId)}/log`,
|
|
1179
|
+
query,
|
|
1171
1180
|
parseResponseBody: true,
|
|
1172
1181
|
});
|
|
1173
1182
|
}
|
|
@@ -1576,114 +1585,5 @@ class ApiClient {
|
|
|
1576
1585
|
path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}`,
|
|
1577
1586
|
});
|
|
1578
1587
|
}
|
|
1579
|
-
// Artifact paths keep their slashes; only the segments are escaped.
|
|
1580
|
-
artifactContentPath(path) {
|
|
1581
|
-
return path
|
|
1582
|
-
.split('/')
|
|
1583
|
-
.filter(Boolean)
|
|
1584
|
-
.map((segment) => encodeURIComponent(segment))
|
|
1585
|
-
.join('/');
|
|
1586
|
-
}
|
|
1587
|
-
async getArtifactVersionContent(workspace, artifactId, versionId, path) {
|
|
1588
|
-
const base = `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions/${encodeURIComponent(versionId)}/content`;
|
|
1589
|
-
const contentPath = path ? this.artifactContentPath(path) : '';
|
|
1590
|
-
return await this.request({
|
|
1591
|
-
method: 'GET',
|
|
1592
|
-
path: contentPath ? `${base}/${contentPath}` : base,
|
|
1593
|
-
parseResponseBody: true,
|
|
1594
|
-
});
|
|
1595
|
-
}
|
|
1596
|
-
async downloadArtifactVersionFile(workspace, artifactId, versionId, path) {
|
|
1597
|
-
return await this.request({
|
|
1598
|
-
method: 'GET',
|
|
1599
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions/${encodeURIComponent(versionId)}/content/download/${this.artifactContentPath(path)}`,
|
|
1600
|
-
rawResponseBody: true,
|
|
1601
|
-
});
|
|
1602
|
-
}
|
|
1603
|
-
async getVtSuiteContext() {
|
|
1604
|
-
return await this.request({
|
|
1605
|
-
method: 'GET',
|
|
1606
|
-
path: '/visual-tests/suite',
|
|
1607
|
-
parseResponseBody: true,
|
|
1608
|
-
});
|
|
1609
|
-
}
|
|
1610
|
-
vtSuitePath(workspace, project, suiteId) {
|
|
1611
|
-
return `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/visual-tests/suites/${encodeURIComponent(suiteId)}`;
|
|
1612
|
-
}
|
|
1613
|
-
async getVtSuite(workspace, project, suiteId) {
|
|
1614
|
-
return await this.request({
|
|
1615
|
-
method: 'GET',
|
|
1616
|
-
path: this.vtSuitePath(workspace, project, suiteId),
|
|
1617
|
-
parseResponseBody: true,
|
|
1618
|
-
});
|
|
1619
|
-
}
|
|
1620
|
-
async updateVtSuite(workspace, project, suiteId, body) {
|
|
1621
|
-
return await this.request({
|
|
1622
|
-
method: 'PATCH',
|
|
1623
|
-
path: this.vtSuitePath(workspace, project, suiteId),
|
|
1624
|
-
body,
|
|
1625
|
-
parseResponseBody: true,
|
|
1626
|
-
});
|
|
1627
|
-
}
|
|
1628
|
-
async deleteVtSuite(workspace, project, suiteId) {
|
|
1629
|
-
return await this.request({
|
|
1630
|
-
method: 'DELETE',
|
|
1631
|
-
path: this.vtSuitePath(workspace, project, suiteId),
|
|
1632
|
-
});
|
|
1633
|
-
}
|
|
1634
|
-
queryOf(filter) {
|
|
1635
|
-
const query = {};
|
|
1636
|
-
Object.entries(filter).forEach(([key, value]) => {
|
|
1637
|
-
if (value !== undefined && value !== null)
|
|
1638
|
-
query[key] = String(value);
|
|
1639
|
-
});
|
|
1640
|
-
return query;
|
|
1641
|
-
}
|
|
1642
|
-
async getVtSessions(workspace, project, suiteId, filter) {
|
|
1643
|
-
return await this.request({
|
|
1644
|
-
method: 'GET',
|
|
1645
|
-
path: `${this.vtSuitePath(workspace, project, suiteId)}/sessions`,
|
|
1646
|
-
query: this.queryOf(filter),
|
|
1647
|
-
parseResponseBody: true,
|
|
1648
|
-
});
|
|
1649
|
-
}
|
|
1650
|
-
async getVtSession(workspace, project, suiteId, sessionId) {
|
|
1651
|
-
return await this.request({
|
|
1652
|
-
method: 'GET',
|
|
1653
|
-
path: `${this.vtSuitePath(workspace, project, suiteId)}/sessions/${encodeURIComponent(sessionId)}`,
|
|
1654
|
-
parseResponseBody: true,
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
async updateVtSession(workspace, project, suiteId, sessionId, body) {
|
|
1658
|
-
return await this.request({
|
|
1659
|
-
method: 'PATCH',
|
|
1660
|
-
path: `${this.vtSuitePath(workspace, project, suiteId)}/sessions/${encodeURIComponent(sessionId)}`,
|
|
1661
|
-
body,
|
|
1662
|
-
parseResponseBody: true,
|
|
1663
|
-
});
|
|
1664
|
-
}
|
|
1665
|
-
async getVtSnapshots(workspace, project, suiteId, sessionId, filter) {
|
|
1666
|
-
return await this.request({
|
|
1667
|
-
method: 'GET',
|
|
1668
|
-
path: `${this.vtSuitePath(workspace, project, suiteId)}/sessions/${encodeURIComponent(sessionId)}/snapshots`,
|
|
1669
|
-
query: this.queryOf(filter),
|
|
1670
|
-
parseResponseBody: true,
|
|
1671
|
-
});
|
|
1672
|
-
}
|
|
1673
|
-
async getVtSnapshot(workspace, project, suiteId, sessionId, snapshotId) {
|
|
1674
|
-
return await this.request({
|
|
1675
|
-
method: 'GET',
|
|
1676
|
-
path: `${this.vtSuitePath(workspace, project, suiteId)}/sessions/${encodeURIComponent(sessionId)}/snapshots/${encodeURIComponent(snapshotId)}`,
|
|
1677
|
-
parseResponseBody: true,
|
|
1678
|
-
});
|
|
1679
|
-
}
|
|
1680
|
-
async updateVtSnapshotsStatuses(workspace, project, suiteId, sessionId, body) {
|
|
1681
|
-
return await this.request({
|
|
1682
|
-
method: 'PATCH',
|
|
1683
|
-
path: `${this.vtSuitePath(workspace, project, suiteId)}/sessions/${encodeURIComponent(sessionId)}/snapshots`,
|
|
1684
|
-
body,
|
|
1685
|
-
parseResponseBody: true,
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
1588
|
}
|
|
1689
1589
|
exports.default = ApiClient;
|
|
@@ -8,8 +8,11 @@ const utils_1 = require("../../utils");
|
|
|
8
8
|
const texts_1 = require("../../texts");
|
|
9
9
|
const input_1 = __importDefault(require("../../input"));
|
|
10
10
|
const output_1 = __importDefault(require("../../output"));
|
|
11
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
14
|
+
const promises_1 = __importDefault(require("node:stream/promises"));
|
|
11
15
|
const distro_1 = require("../../types/distro");
|
|
12
|
-
const downloadDir_1 = require("./downloadDir");
|
|
13
16
|
const commandArtifactDownload = (0, utils_1.newCommand)('download', texts_1.DESC_COMMAND_ARTIFACT_DOWNLOAD, {
|
|
14
17
|
requiredScopes: [utils_1.REST_API_SCOPE.ARTIFACT_READ],
|
|
15
18
|
examples: texts_1.EXAMPLE_ARTIFACT_DOWNLOAD,
|
|
@@ -24,7 +27,11 @@ commandArtifactDownload.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
|
24
27
|
commandArtifactDownload.argument('<identifier>', texts_1.OPTION_ARTIFACT_ID);
|
|
25
28
|
commandArtifactDownload.argument('<directory>', texts_1.OPTION_ARTIFACT_DOWNLOAD_PATH);
|
|
26
29
|
commandArtifactDownload.action(async (id, path, options) => {
|
|
30
|
+
const { v4 } = require('uuid');
|
|
31
|
+
const ArchiverExtract = require('../../unzipper').default;
|
|
32
|
+
const { UNZIPPER_FORMAT } = require('../../unzipper');
|
|
27
33
|
const json = options.format === 'json';
|
|
34
|
+
const say = output_1.default.progress(json);
|
|
28
35
|
const client = input_1.default.restApiTokenClient();
|
|
29
36
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
30
37
|
const project = input_1.default.restApiProject(options.project, true);
|
|
@@ -54,8 +61,84 @@ commandArtifactDownload.action(async (id, path, options) => {
|
|
|
54
61
|
version = v.version;
|
|
55
62
|
versionId = v.id;
|
|
56
63
|
}
|
|
57
|
-
const dirPath = (0,
|
|
58
|
-
const
|
|
59
|
-
|
|
64
|
+
const dirPath = (0, path_1.resolve)(path);
|
|
65
|
+
const exists = fs_1.default.existsSync(dirPath);
|
|
66
|
+
if (!exists) {
|
|
67
|
+
try {
|
|
68
|
+
fs_1.default.mkdirSync(dirPath, {
|
|
69
|
+
recursive: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
logger_1.default.error(err);
|
|
74
|
+
output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_MKDIR)(dirPath));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (options.replace) {
|
|
78
|
+
try {
|
|
79
|
+
fs_1.default.rmSync(dirPath, {
|
|
80
|
+
recursive: true,
|
|
81
|
+
force: true,
|
|
82
|
+
});
|
|
83
|
+
fs_1.default.mkdirSync(dirPath, {
|
|
84
|
+
recursive: true,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
logger_1.default.error(err);
|
|
89
|
+
output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_REPLACE)(dirPath));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const stat = fs_1.default.statSync(dirPath);
|
|
94
|
+
if (!stat.isDirectory()) {
|
|
95
|
+
output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_IS_FILE)(dirPath));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
logger_1.default.error(err);
|
|
100
|
+
output_1.default.exitError(texts_1.ERR_SWW);
|
|
101
|
+
}
|
|
102
|
+
let empty = true;
|
|
103
|
+
try {
|
|
104
|
+
const entries = fs_1.default.readdirSync(dirPath);
|
|
105
|
+
empty = !entries.length;
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
logger_1.default.error(err);
|
|
109
|
+
output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_READDIR)(dirPath));
|
|
110
|
+
}
|
|
111
|
+
if (!empty && !options.merge) {
|
|
112
|
+
output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_NOT_EMPTY_DIR)(dirPath));
|
|
113
|
+
}
|
|
114
|
+
const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${v4()}.zip`);
|
|
115
|
+
const clearZip = () => {
|
|
116
|
+
try {
|
|
117
|
+
fs_1.default.rmSync(zipPath);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// do nothing
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
say(texts_1.TXT_ARTIFACT_DOWNLOADING_ZIP);
|
|
124
|
+
const body = await client.downloadArtifactVersion(workspace, artifactId, versionId);
|
|
125
|
+
let count = 0;
|
|
126
|
+
try {
|
|
127
|
+
await promises_1.default.pipeline(body, fs_1.default.createWriteStream(zipPath));
|
|
128
|
+
say(texts_1.TXT_ARTIFACT_DOWNLOADED_ZIP, true, true);
|
|
129
|
+
say(texts_1.TXT_ARTIFACT_UNZIPPING);
|
|
130
|
+
await ArchiverExtract.extract(UNZIPPER_FORMAT.ZIP, zipPath, dirPath, async () => {
|
|
131
|
+
count += 1;
|
|
132
|
+
say((0, texts_1.TXT_ARTIFACT_UNZIPPING_COUNT)(count), true, true);
|
|
133
|
+
});
|
|
134
|
+
clearZip();
|
|
135
|
+
say(texts_1.TXT_ARTIFACT_UNZIPPED, true, true);
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
logger_1.default.error(err);
|
|
139
|
+
clearZip();
|
|
140
|
+
output_1.default.exitError(texts_1.ERR_SWW);
|
|
141
|
+
}
|
|
142
|
+
output_1.default.exitResult(json, { identifier, version, path: dirPath, files: count }, (0, texts_1.TXT_ARTIFACT_DOWNLOADED)(version, dirPath));
|
|
60
143
|
});
|
|
61
144
|
exports.default = commandArtifactDownload;
|
|
@@ -9,7 +9,7 @@ const output_1 = __importDefault(require("../../../output"));
|
|
|
9
9
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
10
|
const finishExec_1 = require("../finishExec");
|
|
11
11
|
const commandSandboxExecCommand = (0, utils_1.newCommand)('command', texts_1.DESC_COMMAND_SANDBOX_EXEC_COMMAND, {
|
|
12
|
-
requiredScopes: [utils_1.REST_API_SCOPE.
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_USE],
|
|
13
13
|
helpText: texts_1.HELP_SANDBOX_EXEC_COMMAND_JSONL,
|
|
14
14
|
examples: texts_1.EXAMPLE_SANDBOX_EXEC_COMMAND,
|
|
15
15
|
});
|
|
@@ -35,19 +35,19 @@ commandSandboxExecCommand.action(async (identifier, command, options) => {
|
|
|
35
35
|
output_1.default.json({ type: 'command', command: cmdResult });
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
|
-
output_1.default.gray((0, texts_1.TXT_SANDBOX_EXEC_ID)(cmdResult.
|
|
38
|
+
output_1.default.gray((0, texts_1.TXT_SANDBOX_EXEC_ID)(cmdResult.execution_id));
|
|
39
39
|
}
|
|
40
40
|
if (options.exitCode)
|
|
41
41
|
(0, utils_1.executionExitCode)(cmdResult.status);
|
|
42
42
|
if (!options.wait) {
|
|
43
43
|
if (options.exitCode)
|
|
44
|
-
(0, finishExec_1.finishSandboxCommand)(cmdResult, identifier, cmdResult.
|
|
44
|
+
(0, finishExec_1.finishSandboxCommand)(cmdResult, identifier, cmdResult.execution_id, options.format === 'jsonl', true, true);
|
|
45
45
|
if (options.format === 'jsonl')
|
|
46
46
|
output_1.default.exitNormal();
|
|
47
|
-
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_BACKGROUND)(identifier, cmdResult.
|
|
47
|
+
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_BACKGROUND)(identifier, cmdResult.execution_id));
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, cmdResult.
|
|
50
|
+
await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, cmdResult.execution_id, true, options.format === 'jsonl', !!options.exitCode);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
exports.default = commandSandboxExecCommand;
|
|
@@ -7,7 +7,7 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const input_1 = __importDefault(require("../../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
-
const commandSandboxExecKill = (0, utils_1.newCommand)('kill', texts_1.DESC_COMMAND_SANDBOX_EXEC_KILL, { requiredScopes: [utils_1.REST_API_SCOPE.
|
|
10
|
+
const commandSandboxExecKill = (0, utils_1.newCommand)('kill', texts_1.DESC_COMMAND_SANDBOX_EXEC_KILL, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_USE], examples: texts_1.EXAMPLE_SANDBOX_EXEC_KILL });
|
|
11
11
|
(0, utils_1.sandboxScopeOptions)(commandSandboxExecKill);
|
|
12
12
|
commandSandboxExecKill.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
13
13
|
commandSandboxExecKill.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
@@ -17,11 +17,15 @@ commandSandboxExecKill.action(async (identifier, commandId, options) => {
|
|
|
17
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
18
|
const client = input_1.default.restApiTokenClient();
|
|
19
19
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
20
|
+
// A bad id fails as not found before the prompt, as in target exec kill;
|
|
21
|
+
// with --force the DELETE itself reports it.
|
|
22
|
+
if (!options.force)
|
|
23
|
+
await client.getSandboxExec(workspace, sandboxId, commandId);
|
|
20
24
|
const json = options.format === 'json';
|
|
21
25
|
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.OPTION_SANDBOX_COMMAND_KILL_CONFIRM)(identifier, commandId), json);
|
|
22
26
|
if (!confirmed)
|
|
23
27
|
output_1.default.exitResult(json, { killed: null });
|
|
24
|
-
|
|
25
|
-
output_1.default.exitResult(json,
|
|
28
|
+
await client.cancelSandboxExec(workspace, sandboxId, commandId);
|
|
29
|
+
output_1.default.exitResult(json, { killed: commandId }, (0, texts_1.TXT_SANDBOX_COMMAND_KILLED)(commandId));
|
|
26
30
|
});
|
|
27
31
|
exports.default = commandSandboxExecKill;
|
|
@@ -10,33 +10,38 @@ const output_1 = __importDefault(require("../../../output"));
|
|
|
10
10
|
const commandSandboxExecList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_SANDBOX_EXEC_LIST, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_READ], examples: texts_1.EXAMPLE_SANDBOX_EXEC_LIST });
|
|
11
11
|
commandSandboxExecList.alias('ls');
|
|
12
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxExecList);
|
|
13
|
+
commandSandboxExecList.option('--limit <n>', texts_1.OPTION_SANDBOX_EXEC_LIMIT);
|
|
13
14
|
commandSandboxExecList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
14
15
|
commandSandboxExecList.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
15
16
|
commandSandboxExecList.action(async (identifier, options) => {
|
|
16
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
17
18
|
const client = input_1.default.restApiTokenClient();
|
|
18
19
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
commands.sort((a, b) => (b.id || '').localeCompare(a.id || ''));
|
|
20
|
+
const limit = options.limit ? parseInt(options.limit, 10) : undefined;
|
|
21
|
+
const execs = await client.getSandboxExecs(workspace, sandboxId, limit);
|
|
22
22
|
if (options.format === 'json') {
|
|
23
|
-
output_1.default.json(
|
|
23
|
+
output_1.default.json(execs);
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
|
-
if (
|
|
26
|
+
if (execs.length === 0) {
|
|
27
27
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NO_COMMANDS);
|
|
28
28
|
}
|
|
29
29
|
const data = [
|
|
30
|
-
['ID', 'COMMAND', '
|
|
30
|
+
['EXEC ID', 'STATUS', 'COMMAND', 'RUNTIME', 'STARTED', 'FINISHED', 'EXIT CODE'],
|
|
31
31
|
];
|
|
32
|
-
for (const
|
|
32
|
+
for (const exec of execs) {
|
|
33
33
|
data.push([
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
exec.execution_id || '-',
|
|
35
|
+
exec.failure_reason
|
|
36
|
+
? `${exec.status} (${exec.failure_reason})`
|
|
37
|
+
: exec.status || '-',
|
|
38
|
+
(0, utils_1.truncate)(exec.command || '-', 40),
|
|
39
|
+
exec.runtime || '-',
|
|
40
|
+
exec.started_at || '-',
|
|
41
|
+
exec.finished_at || '-',
|
|
42
|
+
exec.exit_code !== undefined && exec.exit_code !== null
|
|
43
|
+
? String(exec.exit_code)
|
|
44
|
+
: '-',
|
|
40
45
|
]);
|
|
41
46
|
}
|
|
42
47
|
output_1.default.table(data);
|
|
@@ -11,15 +11,22 @@ const finishExec_1 = require("../finishExec");
|
|
|
11
11
|
const commandSandboxExecLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_SANDBOX_EXEC_LOGS, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_READ], helpText: texts_1.HELP_SANDBOX_EXEC_JSONL, examples: texts_1.EXAMPLE_SANDBOX_EXEC_LOGS });
|
|
12
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxExecLogs);
|
|
13
13
|
commandSandboxExecLogs.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
|
|
14
|
+
commandSandboxExecLogs.option('--offset <n>', texts_1.OPTION_TARGET_EXEC_LOG_OFFSET);
|
|
15
|
+
commandSandboxExecLogs.option('--limit <n>', texts_1.OPTION_TARGET_EXEC_LOG_LIMIT);
|
|
14
16
|
commandSandboxExecLogs.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
15
17
|
commandSandboxExecLogs.argument('<command-id>', texts_1.OPTION_SANDBOX_COMMAND_ID);
|
|
16
18
|
commandSandboxExecLogs.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
|
|
17
19
|
commandSandboxExecLogs.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
|
|
18
20
|
commandSandboxExecLogs.action(async (identifier, commandId, options) => {
|
|
19
21
|
output_1.default.handleSignals();
|
|
22
|
+
// --wait reads the log until the command ends, so a line cap would
|
|
23
|
+
// stop it from following.
|
|
24
|
+
if (options.wait && options.limit) {
|
|
25
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_EXEC_LOGS_LIMIT_WAIT);
|
|
26
|
+
}
|
|
20
27
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
21
28
|
const client = input_1.default.restApiTokenClient();
|
|
22
29
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
23
|
-
await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, commandId, !!options.wait, options.format === 'jsonl', !!options.exitCode);
|
|
30
|
+
await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, commandId, !!options.wait, options.format === 'jsonl', !!options.exitCode, options.offset ? parseInt(options.offset, 10) : 0, options.limit ? parseInt(options.limit, 10) : undefined);
|
|
24
31
|
});
|
|
25
32
|
exports.default = commandSandboxExecLogs;
|
|
@@ -17,22 +17,27 @@ commandSandboxExecStatus.action(async (identifier, commandId, options) => {
|
|
|
17
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
18
|
const client = input_1.default.restApiTokenClient();
|
|
19
19
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
20
|
-
const
|
|
21
|
-
const code = options.exitCode ? (0, utils_1.executionExitCode)(
|
|
20
|
+
const exec = await client.getSandboxExec(workspace, sandboxId, commandId);
|
|
21
|
+
const code = options.exitCode ? (0, utils_1.executionExitCode)(exec.status) : undefined;
|
|
22
22
|
if (options.format === 'json') {
|
|
23
|
-
output_1.default.json(
|
|
23
|
+
output_1.default.json(exec);
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
26
|
const data = [
|
|
27
27
|
['Property', 'Value'],
|
|
28
|
-
['
|
|
29
|
-
['Command',
|
|
30
|
-
['Runtime',
|
|
31
|
-
['Status',
|
|
28
|
+
['Execution ID', exec.execution_id || '-'],
|
|
29
|
+
['Command', (0, utils_1.truncate)(exec.command || '-', 100)],
|
|
30
|
+
['Runtime', exec.runtime || '-'],
|
|
31
|
+
['Status', exec.status || '-'],
|
|
32
32
|
[
|
|
33
33
|
'Exit Code',
|
|
34
|
-
|
|
34
|
+
exec.exit_code !== undefined && exec.exit_code !== null
|
|
35
|
+
? String(exec.exit_code)
|
|
36
|
+
: '-',
|
|
35
37
|
],
|
|
38
|
+
['Failure Reason', exec.failure_reason || '-'],
|
|
39
|
+
['Started', exec.started_at || '-'],
|
|
40
|
+
['Finished', exec.finished_at || '-'],
|
|
36
41
|
];
|
|
37
42
|
output_1.default.table(data);
|
|
38
43
|
}
|
|
@@ -7,21 +7,36 @@ exports.finishExec = finishExec;
|
|
|
7
7
|
exports.finishSandboxCommand = finishSandboxCommand;
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
|
+
const execLog_1 = require("../../execLog");
|
|
10
11
|
const texts_1 = require("../../texts");
|
|
11
|
-
async function finishExec(client, workspace, sandboxId, identifier,
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
async function finishExec(client, workspace, sandboxId, identifier, execId, follow, jsonl, semanticExitCode = false, offset = 0, limit) {
|
|
13
|
+
const fetchLog = (from, pageLimit) => client.getSandboxExecLog(workspace, sandboxId, execId, from, pageLimit);
|
|
14
|
+
const emit = jsonl ? execLog_1.emitExecLogJsonl : execLog_1.emitExecLogText;
|
|
15
|
+
let exec;
|
|
16
|
+
let truncated;
|
|
17
|
+
if (follow) {
|
|
18
|
+
// The log endpoint pages instead of streaming, so following is polling
|
|
19
|
+
// the status and reading the log on from where the last page ended.
|
|
20
|
+
({ exec, truncated } = await (0, execLog_1.followExec)(await client.getSandboxExec(workspace, sandboxId, execId), (wait) => client.getSandboxExec(workspace, sandboxId, execId, wait), fetchLog, emit, undefined, offset));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
({ truncated } = await (0, execLog_1.forwardExecLog)(fetchLog, offset, emit, limit));
|
|
24
|
+
exec = await client.getSandboxExec(workspace, sandboxId, execId);
|
|
25
|
+
}
|
|
26
|
+
truncated = truncated || !!exec.truncated;
|
|
27
|
+
if (truncated)
|
|
28
|
+
output_1.default.noteWarning(texts_1.WARN_TARGET_EXEC_TRUNCATED);
|
|
29
|
+
finishSandboxCommand({ ...exec, truncated }, identifier, execId, jsonl, semanticExitCode);
|
|
16
30
|
}
|
|
17
31
|
/** Shared final record and process status, including commands started without --wait. */
|
|
18
|
-
function finishSandboxCommand(cmdExit, identifier,
|
|
32
|
+
function finishSandboxCommand(cmdExit, identifier, execId, jsonl, semanticExitCode, background = false) {
|
|
19
33
|
const code = semanticExitCode ? (0, utils_1.executionExitCode)(cmdExit.status) : undefined;
|
|
20
34
|
if (jsonl) {
|
|
21
35
|
output_1.default.json({
|
|
22
36
|
type: 'exit',
|
|
23
37
|
status: cmdExit.status,
|
|
24
38
|
exit_code: cmdExit.exit_code ?? null,
|
|
39
|
+
truncated: !!cmdExit.truncated,
|
|
25
40
|
...(semanticExitCode ? { code } : {}),
|
|
26
41
|
});
|
|
27
42
|
if (code !== undefined)
|
|
@@ -32,20 +47,23 @@ function finishSandboxCommand(cmdExit, identifier, commandId, jsonl, semanticExi
|
|
|
32
47
|
output_1.default.exitCode(1);
|
|
33
48
|
}
|
|
34
49
|
if (background) {
|
|
35
|
-
output_1.default.normal(output_1.default.getGreenColor((0, texts_1.TXT_SANDBOX_EXEC_BACKGROUND)(identifier,
|
|
50
|
+
output_1.default.normal(output_1.default.getGreenColor((0, texts_1.TXT_SANDBOX_EXEC_BACKGROUND)(identifier, execId)));
|
|
36
51
|
output_1.default.exitCode(code ?? 0);
|
|
37
52
|
}
|
|
38
53
|
if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.SUCCESSFUL) {
|
|
39
|
-
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_SUCCESS)(identifier,
|
|
54
|
+
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_SUCCESS)(identifier, execId));
|
|
40
55
|
}
|
|
41
56
|
else if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.INPROGRESS) {
|
|
42
57
|
if (code !== undefined) {
|
|
43
|
-
output_1.default.normal((0, texts_1.TXT_SANDBOX_EXEC_INPROGRESS)(identifier,
|
|
58
|
+
output_1.default.normal((0, texts_1.TXT_SANDBOX_EXEC_INPROGRESS)(identifier, execId));
|
|
44
59
|
output_1.default.exitCode(code);
|
|
45
60
|
}
|
|
46
|
-
output_1.default.exitNormal((0, texts_1.TXT_SANDBOX_EXEC_INPROGRESS)(identifier,
|
|
61
|
+
output_1.default.exitNormal((0, texts_1.TXT_SANDBOX_EXEC_INPROGRESS)(identifier, execId));
|
|
62
|
+
}
|
|
63
|
+
else if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.CANCELLED) {
|
|
64
|
+
output_1.default.exitError((0, texts_1.TXT_SANDBOX_EXEC_CANCELLED)(identifier, execId), 1);
|
|
47
65
|
}
|
|
48
66
|
else {
|
|
49
|
-
output_1.default.exitError((0, texts_1.TXT_SANDBOX_EXEC_FAILED)(identifier,
|
|
67
|
+
output_1.default.exitError((0, texts_1.TXT_SANDBOX_EXEC_FAILED)(identifier, execId), 1);
|
|
50
68
|
}
|
|
51
69
|
}
|
|
@@ -8,8 +8,8 @@ const utils_1 = require("../../../utils");
|
|
|
8
8
|
const texts_1 = require("../../../texts");
|
|
9
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
10
10
|
const input_1 = __importDefault(require("../../../input"));
|
|
11
|
+
const execLog_1 = require("../../../execLog");
|
|
11
12
|
const scope_1 = require("../scope");
|
|
12
|
-
const EXEC_WAIT_MS = 10000;
|
|
13
13
|
const commandTargetExecCommand = (0, utils_1.newCommand)('command', texts_1.DESC_COMMAND_TARGET_EXEC_COMMAND, { requiredScopes: [utils_1.REST_API_SCOPE.TARGET_USE], examples: texts_1.EXAMPLE_TARGET_EXEC_COMMAND, helpText: texts_1.HELP_TARGET_EXEC_COMMAND });
|
|
14
14
|
commandTargetExecCommand.alias('cmd');
|
|
15
15
|
commandTargetExecCommand.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
@@ -47,6 +47,7 @@ commandTargetExecCommand.action(async (identifier, command, options) => {
|
|
|
47
47
|
command: cmd,
|
|
48
48
|
});
|
|
49
49
|
const execId = exec.execution_id;
|
|
50
|
+
const fetchLog = (offset, limit) => client.getTargetExecLog(workspace, target_id, execId, offset, limit);
|
|
50
51
|
const target = (0, scope_1.targetExecRef)(identifier, options);
|
|
51
52
|
const json = options.format === 'json';
|
|
52
53
|
// Preserve the execution id before status validation can fail.
|
|
@@ -72,37 +73,21 @@ commandTargetExecCommand.action(async (identifier, command, options) => {
|
|
|
72
73
|
}
|
|
73
74
|
if (json) {
|
|
74
75
|
while (exec.status === utils_1.TARGET_EXEC_STATUS.INPROGRESS) {
|
|
75
|
-
exec = await client.getTargetExec(workspace, target_id, execId, EXEC_WAIT_MS);
|
|
76
|
+
exec = await client.getTargetExec(workspace, target_id, execId, execLog_1.EXEC_WAIT_MS);
|
|
76
77
|
if (options.exitCode)
|
|
77
78
|
code = (0, utils_1.executionExitCode)(exec.status, recoveryHint);
|
|
78
79
|
}
|
|
79
80
|
const log = [];
|
|
80
|
-
await (0,
|
|
81
|
+
await (0, execLog_1.forwardExecLog)(fetchLog, 0, (lines) => log.push(...lines));
|
|
81
82
|
output_1.default.json({ ...exec, log });
|
|
82
83
|
output_1.default.exitCode(code ?? (exec.status === utils_1.TARGET_EXEC_STATUS.SUCCESSFUL ? 0 : 1));
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
-
let truncated = false;
|
|
86
|
-
// bytes_out from the status long-poll tells whether there is anything
|
|
87
|
-
// new to fetch, saving a log request per quiet poll cycle.
|
|
88
|
-
let loggedBytes;
|
|
89
|
-
const drainLog = async () => {
|
|
90
|
-
loggedBytes = exec.bytes_out;
|
|
91
|
-
const log = await (0, scope_1.forwardExecLog)(client, workspace, target_id, execId, offset);
|
|
92
|
-
offset = log.offset;
|
|
93
|
-
truncated = truncated || log.truncated;
|
|
94
|
-
};
|
|
95
|
-
while (exec.status === utils_1.TARGET_EXEC_STATUS.INPROGRESS) {
|
|
96
|
-
exec = await client.getTargetExec(workspace, target_id, execId, EXEC_WAIT_MS);
|
|
85
|
+
const followed = await (0, execLog_1.followExec)(exec, (wait) => client.getTargetExec(workspace, target_id, execId, wait), fetchLog, undefined, (polled) => {
|
|
97
86
|
if (options.exitCode)
|
|
98
|
-
(0, utils_1.executionExitCode)(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (loggedBytes === undefined || exec.bytes_out !== loggedBytes) {
|
|
103
|
-
await drainLog();
|
|
104
|
-
}
|
|
105
|
-
if (exec.truncated || truncated) {
|
|
87
|
+
(0, utils_1.executionExitCode)(polled.status, recoveryHint);
|
|
88
|
+
});
|
|
89
|
+
exec = followed.exec;
|
|
90
|
+
if (exec.truncated || followed.truncated) {
|
|
106
91
|
output_1.default.noteWarning(texts_1.WARN_TARGET_EXEC_TRUNCATED);
|
|
107
92
|
}
|
|
108
93
|
if (exec.status === utils_1.TARGET_EXEC_STATUS.SUCCESSFUL) {
|
|
@@ -7,6 +7,7 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const input_1 = __importDefault(require("../../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const execLog_1 = require("../../../execLog");
|
|
10
11
|
const scope_1 = require("../scope");
|
|
11
12
|
const commandTargetExecLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_TARGET_EXEC_LOGS, { requiredScopes: [utils_1.REST_API_SCOPE.TARGET_READ], helpText: texts_1.HELP_TARGET_EXEC_LOGS_JSONL, examples: texts_1.EXAMPLE_TARGET_EXEC_LOGS });
|
|
12
13
|
commandTargetExecLogs.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
@@ -25,9 +26,7 @@ commandTargetExecLogs.action(async (identifier, execId, options) => {
|
|
|
25
26
|
const target_id = await (0, scope_1.resolveTargetId)(client, workspace, identifier, options);
|
|
26
27
|
const offset = options.offset ? parseInt(options.offset, 10) : 0;
|
|
27
28
|
const limit = options.limit ? parseInt(options.limit, 10) : undefined;
|
|
28
|
-
const { truncated } = await (0,
|
|
29
|
-
? (lines) => lines.forEach((data) => output_1.default.json({ type: 'log', data }))
|
|
30
|
-
: undefined, limit);
|
|
29
|
+
const { truncated } = await (0, execLog_1.forwardExecLog)((from, pageLimit) => client.getTargetExecLog(workspace, target_id, execId, from, pageLimit), offset, options.format === 'jsonl' ? execLog_1.emitExecLogJsonl : undefined, limit);
|
|
31
30
|
if (truncated)
|
|
32
31
|
output_1.default.noteWarning(texts_1.WARN_TARGET_EXEC_TRUNCATED);
|
|
33
32
|
if (options.format === 'jsonl' || options.exitCode) {
|