azdo-cli 0.22.0-develop.807 → 0.22.0-develop.822
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/index.js +32 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6669,6 +6669,26 @@ async function listBuildArtifacts(context, cred, buildId) {
|
|
|
6669
6669
|
};
|
|
6670
6670
|
});
|
|
6671
6671
|
}
|
|
6672
|
+
var INITIAL_BUFFER_BYTES = 8 * 1024 * 1024;
|
|
6673
|
+
async function collectBody(body, declared, onProgress, initialBytes = INITIAL_BUFFER_BYTES) {
|
|
6674
|
+
const hint = Number.isSafeInteger(declared) && declared > 0 ? declared : Infinity;
|
|
6675
|
+
let buffer = new Uint8Array(Math.min(hint, initialBytes));
|
|
6676
|
+
let received = 0;
|
|
6677
|
+
for await (const chunk of body) {
|
|
6678
|
+
const needed = received + chunk.length;
|
|
6679
|
+
if (needed > buffer.length) {
|
|
6680
|
+
let capacity = Math.max(buffer.length * 2, needed);
|
|
6681
|
+
if (hint >= needed) capacity = Math.min(capacity, hint);
|
|
6682
|
+
const grown = new Uint8Array(capacity);
|
|
6683
|
+
grown.set(buffer.subarray(0, received));
|
|
6684
|
+
buffer = grown;
|
|
6685
|
+
}
|
|
6686
|
+
buffer.set(chunk, received);
|
|
6687
|
+
received = needed;
|
|
6688
|
+
onProgress?.(received);
|
|
6689
|
+
}
|
|
6690
|
+
return buffer.subarray(0, received);
|
|
6691
|
+
}
|
|
6672
6692
|
async function downloadArtifactZip(cred, artifact, onProgress) {
|
|
6673
6693
|
if (!artifact.downloadUrl) {
|
|
6674
6694
|
throw new Error(`Artifact "${artifact.name}" (${artifact.type ?? "unknown type"}) has no download URL.`);
|
|
@@ -6682,14 +6702,8 @@ async function downloadArtifactZip(cred, artifact, onProgress) {
|
|
|
6682
6702
|
if (!response.body) {
|
|
6683
6703
|
return new Uint8Array(await response.arrayBuffer());
|
|
6684
6704
|
}
|
|
6685
|
-
const
|
|
6686
|
-
|
|
6687
|
-
for await (const chunk of response.body) {
|
|
6688
|
-
chunks.push(chunk);
|
|
6689
|
-
received += chunk.length;
|
|
6690
|
-
onProgress?.(received);
|
|
6691
|
-
}
|
|
6692
|
-
return Buffer.concat(chunks);
|
|
6705
|
+
const declared = Number.parseInt(response.headers.get("content-length") ?? "", 10);
|
|
6706
|
+
return collectBody(response.body, declared, onProgress);
|
|
6693
6707
|
}
|
|
6694
6708
|
|
|
6695
6709
|
// src/services/artifact-extract.ts
|
|
@@ -7142,10 +7156,18 @@ function grepWithContext(lines, grep, context) {
|
|
|
7142
7156
|
}
|
|
7143
7157
|
return selected;
|
|
7144
7158
|
}
|
|
7159
|
+
var PROGRESS_BAR = /(?<![\d.])\d+(?:\.\d+)? [KMGT]?i?B \/ \d+(?:\.\d+)? [KMGT]?i?B \[/g;
|
|
7160
|
+
var LOG_TIMESTAMP = /^\d{4}-\d{2}-\d{2}T[\d:.]+Z /;
|
|
7161
|
+
function collapseGluedBars(line) {
|
|
7162
|
+
const starts = [...line.matchAll(PROGRESS_BAR)].map((m) => m.index ?? 0);
|
|
7163
|
+
if (starts.length < 2) return line;
|
|
7164
|
+
const prefix = LOG_TIMESTAMP.exec(line)?.[0] ?? "";
|
|
7165
|
+
return prefix + line.slice(starts.at(-1));
|
|
7166
|
+
}
|
|
7145
7167
|
function collapseProgress(line) {
|
|
7146
7168
|
let end = line.length;
|
|
7147
7169
|
while (end > 0 && line[end - 1] === "\r") end--;
|
|
7148
|
-
return line.slice(line.lastIndexOf("\r", end - 1) + 1, end);
|
|
7170
|
+
return collapseGluedBars(line.slice(line.lastIndexOf("\r", end - 1) + 1, end));
|
|
7149
7171
|
}
|
|
7150
7172
|
function filterLogLines(content, filters) {
|
|
7151
7173
|
const { grep, tail, head, contextLines: context } = filters;
|
|
@@ -7255,7 +7277,7 @@ function printSingleLog(content, filters) {
|
|
|
7255
7277
|
}
|
|
7256
7278
|
function createPipelineLogsCommand() {
|
|
7257
7279
|
const command = new Command14("logs");
|
|
7258
|
-
command.description("List a pipeline run's logs, or print a specific log with --log-id").argument("<run_id>", "pipeline run id").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--log-id <id>", "print the content of this log id").option("--step <name>", "print the log of the step/job matching this name (case-insensitive substring)").option("--tail <n>", "with --log-id/--step, print only the last N lines").option("--head <n>", "with --log-id/--step, print only the first N lines").option("--grep <pattern>", "with --log-id/--step, print only lines matching this regular expression").option("--context <n>", "with --grep, also print N lines around each match (grep -C)").option("--no-progress", "with --log-id/--step, collapse carriage-return
|
|
7280
|
+
command.description("List a pipeline run's logs, or print a specific log with --log-id").argument("<run_id>", "pipeline run id").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--log-id <id>", "print the content of this log id").option("--step <name>", "print the log of the step/job matching this name (case-insensitive substring)").option("--tail <n>", "with --log-id/--step, print only the last N lines").option("--head <n>", "with --log-id/--step, print only the first N lines").option("--grep <pattern>", "with --log-id/--step, print only lines matching this regular expression").option("--context <n>", "with --grep, also print N lines around each match (grep -C)").option("--no-progress", "with --log-id/--step, collapse progress-bar redraws (carriage-return or glued into one line) to their final state").option("--json", "output JSON").action(async (runIdRaw, options) => {
|
|
7259
7281
|
validateOrgProjectPair(options);
|
|
7260
7282
|
const runId = parsePositiveId(runIdRaw);
|
|
7261
7283
|
if (runId === null) {
|