azdo-cli 0.25.0-azdo-grounder.960 → 0.25.0-azdo-grounder.961
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/README.md
CHANGED
|
@@ -162,7 +162,6 @@ azdo relations list 1000 --json # JSON: { workItemId, relations: [..
|
|
|
162
162
|
| Linux credential store setup | [docs/linux-credential-store.md](docs/linux-credential-store.md) |
|
|
163
163
|
| Full command reference — every command, alias and option, credential resolution order, and the `--json` output contracts | [docs/commands.md](docs/commands.md) |
|
|
164
164
|
| Development setup | [docs/development.md](docs/development.md) |
|
|
165
|
-
| Project operations and automation (Dev Container, VM, Hermes) | [instructions/README.md](instructions/README.md) |
|
|
166
165
|
|
|
167
166
|
## License
|
|
168
167
|
|
|
@@ -1047,17 +1047,6 @@ var DpapiEntry = class {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
};
|
|
1049
1049
|
|
|
1050
|
-
// src/lib/async.ts
|
|
1051
|
-
function runSequentially(items, task) {
|
|
1052
|
-
return items.reduce(
|
|
1053
|
-
(previous, item, index) => previous.then(() => task(item, index)),
|
|
1054
|
-
Promise.resolve()
|
|
1055
|
-
);
|
|
1056
|
-
}
|
|
1057
|
-
function asPromise(fn) {
|
|
1058
|
-
return Promise.resolve().then(fn);
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
1050
|
// src/services/credential-store.ts
|
|
1062
1051
|
var SERVICE = "azdo-cli";
|
|
1063
1052
|
var LEGACY_ACCOUNT = "pat";
|
|
@@ -1198,7 +1187,7 @@ function serializeCredential(cred) {
|
|
|
1198
1187
|
}
|
|
1199
1188
|
return JSON.stringify(cred);
|
|
1200
1189
|
}
|
|
1201
|
-
function maybeMigrateLegacy(targetOrg) {
|
|
1190
|
+
async function maybeMigrateLegacy(targetOrg) {
|
|
1202
1191
|
if (activeCredentialStore() === "dpapi") return null;
|
|
1203
1192
|
const config = loadConfig();
|
|
1204
1193
|
if (!config.org || config.org !== targetOrg) {
|
|
@@ -1246,31 +1235,30 @@ async function getPat(org) {
|
|
|
1246
1235
|
if (cred.kind === "pat") return cred.token;
|
|
1247
1236
|
return null;
|
|
1248
1237
|
}
|
|
1249
|
-
function getStoredCredential(org) {
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1238
|
+
async function getStoredCredential(org) {
|
|
1239
|
+
const entry = entryFor(accountFor(org));
|
|
1240
|
+
const value = wrapUnavailable(() => entry.getPassword());
|
|
1241
|
+
if (value === null) {
|
|
1242
|
+
const migrated = await maybeMigrateLegacy(org);
|
|
1243
|
+
if (migrated === null) return null;
|
|
1244
|
+
return parseStoredValue(migrated);
|
|
1245
|
+
}
|
|
1246
|
+
return parseStoredValue(value);
|
|
1255
1247
|
}
|
|
1256
|
-
function storePat(org, pat) {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
masked_pat: maskedDisplay(pat)
|
|
1266
|
-
});
|
|
1248
|
+
async function storePat(org, pat) {
|
|
1249
|
+
const cred = { kind: "pat", token: pat };
|
|
1250
|
+
const entry = entryFor(accountFor(org));
|
|
1251
|
+
wrapUnavailable(() => entry.setPassword(serializeCredential(cred)));
|
|
1252
|
+
appendAuthAuditEvent({
|
|
1253
|
+
event: "auth.store",
|
|
1254
|
+
org,
|
|
1255
|
+
backend: probeBackend(),
|
|
1256
|
+
masked_pat: maskedDisplay(pat)
|
|
1267
1257
|
});
|
|
1268
1258
|
}
|
|
1269
|
-
function storeOAuthCredential(org, cred) {
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
wrapUnavailable(() => entry.setPassword(serializeCredential(cred)));
|
|
1273
|
-
});
|
|
1259
|
+
async function storeOAuthCredential(org, cred) {
|
|
1260
|
+
const entry = entryFor(accountFor(org));
|
|
1261
|
+
wrapUnavailable(() => entry.setPassword(serializeCredential(cred)));
|
|
1274
1262
|
}
|
|
1275
1263
|
async function deletePat(org) {
|
|
1276
1264
|
const entry = entryFor(accountFor(org));
|
|
@@ -1302,16 +1290,13 @@ async function deletePat(org) {
|
|
|
1302
1290
|
}
|
|
1303
1291
|
try {
|
|
1304
1292
|
const { unlinkSync: unlinkSync2 } = await import("fs");
|
|
1305
|
-
const { lockPath: lockPath2 } = await import("./oauth-token-refresh-
|
|
1293
|
+
const { lockPath: lockPath2 } = await import("./oauth-token-refresh-RLDAAR5D.js");
|
|
1306
1294
|
unlinkSync2(lockPath2(org));
|
|
1307
1295
|
} catch {
|
|
1308
1296
|
}
|
|
1309
1297
|
return true;
|
|
1310
1298
|
}
|
|
1311
|
-
function listOrgsWithStoredPat() {
|
|
1312
|
-
return asPromise(listOrgsWithStoredPatSync);
|
|
1313
|
-
}
|
|
1314
|
-
function listOrgsWithStoredPatSync() {
|
|
1299
|
+
async function listOrgsWithStoredPat() {
|
|
1315
1300
|
const seen = /* @__PURE__ */ new Set();
|
|
1316
1301
|
for (const ev of readAuditEvents()) {
|
|
1317
1302
|
if (ev.event === "auth.store" || ev.event === "oauth-login-success") {
|
|
@@ -1402,26 +1387,25 @@ function lockPath(org) {
|
|
|
1402
1387
|
async function defaultAcquireLock(org, waitMs = DEFAULT_LOCK_WAIT_MS) {
|
|
1403
1388
|
const path4 = lockPath(org);
|
|
1404
1389
|
mkdirSync(locksDir(), { recursive: true, mode: 448 });
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1390
|
+
const deadline = Date.now() + waitMs;
|
|
1391
|
+
for (; ; ) {
|
|
1392
|
+
try {
|
|
1393
|
+
const fd = openSync2(path4, "wx");
|
|
1394
|
+
closeSync2(fd);
|
|
1395
|
+
return {
|
|
1396
|
+
release: () => {
|
|
1397
|
+
try {
|
|
1398
|
+
unlinkSync(path4);
|
|
1399
|
+
} catch {
|
|
1400
|
+
}
|
|
1416
1401
|
}
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1402
|
+
};
|
|
1403
|
+
} catch (err) {
|
|
1404
|
+
if (err.code !== "EEXIST") throw err;
|
|
1405
|
+
if (Date.now() > deadline) return null;
|
|
1406
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
1407
|
+
}
|
|
1422
1408
|
}
|
|
1423
|
-
await new Promise((r) => setTimeout(r, 100));
|
|
1424
|
-
return tryAcquireLock(path4, deadline);
|
|
1425
1409
|
}
|
|
1426
1410
|
function classifyRefreshFailure(error) {
|
|
1427
1411
|
const code = typeof error === "string" ? error : error.error ?? "";
|
|
@@ -1559,7 +1543,6 @@ export {
|
|
|
1559
1543
|
CredentialStoreUnavailableError,
|
|
1560
1544
|
CredentialMissingError,
|
|
1561
1545
|
CredentialRefreshError,
|
|
1562
|
-
runSequentially,
|
|
1563
1546
|
appendAuthAuditEvent,
|
|
1564
1547
|
readAuditEvents,
|
|
1565
1548
|
SETTINGS,
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,6 @@ import {
|
|
|
37
37
|
resolveOAuthConfig,
|
|
38
38
|
resolveScopedConfig,
|
|
39
39
|
runAuthCodeFlow,
|
|
40
|
-
runSequentially,
|
|
41
40
|
setConfigValue,
|
|
42
41
|
setOrgScopedValue,
|
|
43
42
|
storeOAuthCredential,
|
|
@@ -46,7 +45,7 @@ import {
|
|
|
46
45
|
tokenResponseToCredential,
|
|
47
46
|
unsetConfigValue,
|
|
48
47
|
unsetOrgScopedValue
|
|
49
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-DNOOZIXA.js";
|
|
50
49
|
|
|
51
50
|
// src/program.ts
|
|
52
51
|
import { Command as Command20 } from "commander";
|
|
@@ -155,14 +154,6 @@ function handleCommandError(err, id, context, scope = "write", exit = true) {
|
|
|
155
154
|
return;
|
|
156
155
|
}
|
|
157
156
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
158
|
-
writeCommandError(error, id, context, scope);
|
|
159
|
-
if (exit) {
|
|
160
|
-
process.exit(1);
|
|
161
|
-
} else {
|
|
162
|
-
process.exitCode = 1;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function writeCommandError(error, id, context, scope) {
|
|
166
157
|
const msg = error.message;
|
|
167
158
|
const scopeLabel = scope === "read" ? "Work Items (read)" : "Work Items (Read & Write)";
|
|
168
159
|
if (isSentinel(msg, "AUTH_FAILED")) {
|
|
@@ -202,6 +193,11 @@ function writeCommandError(error, id, context, scope) {
|
|
|
202
193
|
process.stderr.write(`Error: ${msg}
|
|
203
194
|
`);
|
|
204
195
|
}
|
|
196
|
+
if (exit) {
|
|
197
|
+
process.exit(1);
|
|
198
|
+
} else {
|
|
199
|
+
process.exitCode = 1;
|
|
200
|
+
}
|
|
205
201
|
}
|
|
206
202
|
var STDIN_PATH = "-";
|
|
207
203
|
function readTextSource(file) {
|
|
@@ -344,8 +340,9 @@ async function downloadImagesFromFields(fields, args, credential) {
|
|
|
344
340
|
}
|
|
345
341
|
}
|
|
346
342
|
const results = [];
|
|
347
|
-
|
|
348
|
-
|
|
343
|
+
let index = 0;
|
|
344
|
+
for (const reference of references) {
|
|
345
|
+
index += 1;
|
|
349
346
|
try {
|
|
350
347
|
const bytes = await downloadAttachment(reference.url, credential);
|
|
351
348
|
const processed = await processImageBytes(bytes, options.maxWidth);
|
|
@@ -366,7 +363,7 @@ async function downloadImagesFromFields(fields, args, credential) {
|
|
|
366
363
|
error: err instanceof Error ? err.message : String(err)
|
|
367
364
|
});
|
|
368
365
|
}
|
|
369
|
-
}
|
|
366
|
+
}
|
|
370
367
|
return results;
|
|
371
368
|
}
|
|
372
369
|
async function runImageDownload(fields, args, credential) {
|
|
@@ -849,24 +846,23 @@ async function getWorkItemFieldValue(context, id, cred, fieldName) {
|
|
|
849
846
|
}
|
|
850
847
|
return stringifyFieldValue(value);
|
|
851
848
|
}
|
|
852
|
-
async function listWorkItemCommentPages(context, id, cred, continuationToken, comments) {
|
|
853
|
-
const response = await fetchWithErrors(
|
|
854
|
-
buildWorkItemCommentsListUrl(context, id, continuationToken ?? void 0).toString(),
|
|
855
|
-
{ headers: authHeaders(cred) }
|
|
856
|
-
);
|
|
857
|
-
if (!response.ok) {
|
|
858
|
-
throw httpError(response);
|
|
859
|
-
}
|
|
860
|
-
const data = await response.json();
|
|
861
|
-
comments.push(
|
|
862
|
-
...(data.comments ?? []).map((comment) => mapWorkItemComment(comment, id)).filter((comment) => !comment.isDeleted)
|
|
863
|
-
);
|
|
864
|
-
const next = readContinuationToken(response, data);
|
|
865
|
-
if (next === null) return comments;
|
|
866
|
-
return listWorkItemCommentPages(context, id, cred, next, comments);
|
|
867
|
-
}
|
|
868
849
|
async function listWorkItemComments(context, id, cred) {
|
|
869
|
-
const comments =
|
|
850
|
+
const comments = [];
|
|
851
|
+
let continuationToken = null;
|
|
852
|
+
do {
|
|
853
|
+
const response = await fetchWithErrors(
|
|
854
|
+
buildWorkItemCommentsListUrl(context, id, continuationToken ?? void 0).toString(),
|
|
855
|
+
{ headers: authHeaders(cred) }
|
|
856
|
+
);
|
|
857
|
+
if (!response.ok) {
|
|
858
|
+
throw httpError(response);
|
|
859
|
+
}
|
|
860
|
+
const data = await response.json();
|
|
861
|
+
comments.push(
|
|
862
|
+
...(data.comments ?? []).map((comment) => mapWorkItemComment(comment, id)).filter((comment) => !comment.isDeleted)
|
|
863
|
+
);
|
|
864
|
+
continuationToken = readContinuationToken(response, data);
|
|
865
|
+
} while (continuationToken !== null);
|
|
870
866
|
return {
|
|
871
867
|
workItemId: id,
|
|
872
868
|
count: comments.length,
|
|
@@ -1446,31 +1442,29 @@ async function loginWithOAuth(org, opts = {}) {
|
|
|
1446
1442
|
async function logout(opts = {}) {
|
|
1447
1443
|
if (opts.all) {
|
|
1448
1444
|
const orgs = await listOrgsWithStoredPat();
|
|
1449
|
-
|
|
1445
|
+
const removed = [];
|
|
1446
|
+
for (const o of orgs) {
|
|
1447
|
+
const cred2 = await getStoredCredential(o);
|
|
1448
|
+
const ok2 = await deletePat(o);
|
|
1449
|
+
if (ok2 && cred2 !== null) {
|
|
1450
|
+
removed.push({ org: o, kind: cred2.kind });
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
return { removed };
|
|
1450
1454
|
}
|
|
1451
1455
|
if (!opts.org) {
|
|
1452
1456
|
throw new Error("logout requires an org or --all");
|
|
1453
1457
|
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
const org = orgs[index];
|
|
1458
|
-
if (org === void 0) return removed;
|
|
1459
|
-
removed.push(...await logoutOrg(org));
|
|
1460
|
-
return logoutOrgsInOrder(orgs, index + 1, removed);
|
|
1461
|
-
}
|
|
1462
|
-
async function logoutOrg(org) {
|
|
1463
|
-
const cred = await getStoredCredential(org);
|
|
1464
|
-
const ok = await deletePat(org);
|
|
1465
|
-
return ok && cred !== null ? [{ org, kind: cred.kind }] : [];
|
|
1458
|
+
const cred = await getStoredCredential(opts.org);
|
|
1459
|
+
const ok = await deletePat(opts.org);
|
|
1460
|
+
return { removed: ok && cred !== null ? [{ org: opts.org, kind: cred.kind }] : [] };
|
|
1466
1461
|
}
|
|
1467
1462
|
async function status() {
|
|
1468
1463
|
const orgs = await listOrgsWithStoredPat();
|
|
1469
|
-
const creds = await Promise.all(orgs.map((org) => getStoredCredential(org)));
|
|
1470
1464
|
const out = [];
|
|
1471
|
-
|
|
1472
|
-
const cred =
|
|
1473
|
-
if (cred === null)
|
|
1465
|
+
for (const org of orgs) {
|
|
1466
|
+
const cred = await getStoredCredential(org);
|
|
1467
|
+
if (cred === null) continue;
|
|
1474
1468
|
if (cred.kind === "pat") {
|
|
1475
1469
|
out.push({ org, kind: "pat", backend: probeBackend() });
|
|
1476
1470
|
} else {
|
|
@@ -1483,7 +1477,7 @@ async function status() {
|
|
|
1483
1477
|
backend: probeBackend()
|
|
1484
1478
|
});
|
|
1485
1479
|
}
|
|
1486
|
-
}
|
|
1480
|
+
}
|
|
1487
1481
|
return { orgs: out };
|
|
1488
1482
|
}
|
|
1489
1483
|
async function exportCredential(org) {
|
|
@@ -3134,8 +3128,10 @@ ${renderSettingsHelp()}`);
|
|
|
3134
3128
|
const ask = createAsk(rl);
|
|
3135
3129
|
process.stderr.write("Azure DevOps CLI - Configuration Wizard\n");
|
|
3136
3130
|
process.stderr.write("=======================================\n\n");
|
|
3137
|
-
const
|
|
3138
|
-
|
|
3131
|
+
for (const setting of SETTINGS) {
|
|
3132
|
+
if (setting.key === "credentialStore") continue;
|
|
3133
|
+
await promptForSetting(cfg, setting, ask);
|
|
3134
|
+
}
|
|
3139
3135
|
rl.close();
|
|
3140
3136
|
process.stderr.write("Configuration complete!\n");
|
|
3141
3137
|
});
|
|
@@ -3775,8 +3771,7 @@ function stringifyValue(value) {
|
|
|
3775
3771
|
if (value === null || value === void 0) return "";
|
|
3776
3772
|
if (typeof value === "string") return value;
|
|
3777
3773
|
if (typeof value === "object") return JSON.stringify(value);
|
|
3778
|
-
if (typeof value === "symbol") return value.toString();
|
|
3779
|
-
if (typeof value === "function") return `[function ${value.name || "anonymous"}]`;
|
|
3774
|
+
if (typeof value === "symbol" || typeof value === "function") return value.toString();
|
|
3780
3775
|
return String(value);
|
|
3781
3776
|
}
|
|
3782
3777
|
function formatRichValue(raw) {
|
|
@@ -6876,27 +6871,26 @@ async function getTestSummary(context, cred, buildId) {
|
|
|
6876
6871
|
var MAX_FAILED_TESTS = 50;
|
|
6877
6872
|
async function getFailedTests(context, cred, buildId) {
|
|
6878
6873
|
const testRuns = await listTestRuns(context, cred, buildId);
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
const resultsResponse = await fetchWithErrors(resultsUrl.toString(), {
|
|
6890
|
-
headers: authHeaders(cred)
|
|
6891
|
-
});
|
|
6892
|
-
const resultsData = await readJsonResponse2(resultsResponse);
|
|
6893
|
-
for (const result of resultsData.value) {
|
|
6894
|
-
failed.push({
|
|
6895
|
-
name: result.testCaseTitle ?? result.automatedTestName ?? "(unnamed test)",
|
|
6896
|
-
errorMessage: result.errorMessage ?? null
|
|
6874
|
+
const failed = [];
|
|
6875
|
+
for (const testRun of testRuns) {
|
|
6876
|
+
if (failed.length >= MAX_FAILED_TESTS) break;
|
|
6877
|
+
const resultsUrl = withApiVersion(
|
|
6878
|
+
new URL(`${orgProjectBase(context)}/_apis/test/runs/${testRun.id}/results`)
|
|
6879
|
+
);
|
|
6880
|
+
resultsUrl.searchParams.set("outcomes", "Failed");
|
|
6881
|
+
resultsUrl.searchParams.set("$top", String(MAX_FAILED_TESTS - failed.length));
|
|
6882
|
+
const resultsResponse = await fetchWithErrors(resultsUrl.toString(), {
|
|
6883
|
+
headers: authHeaders(cred)
|
|
6897
6884
|
});
|
|
6885
|
+
const resultsData = await readJsonResponse2(resultsResponse);
|
|
6886
|
+
for (const result of resultsData.value) {
|
|
6887
|
+
failed.push({
|
|
6888
|
+
name: result.testCaseTitle ?? result.automatedTestName ?? "(unnamed test)",
|
|
6889
|
+
errorMessage: result.errorMessage ?? null
|
|
6890
|
+
});
|
|
6891
|
+
}
|
|
6898
6892
|
}
|
|
6899
|
-
return
|
|
6893
|
+
return failed;
|
|
6900
6894
|
}
|
|
6901
6895
|
function secondsBetween(start, finish) {
|
|
6902
6896
|
if (!start || !finish) return null;
|
|
@@ -7169,17 +7163,6 @@ function sleep(ms) {
|
|
|
7169
7163
|
setTimeout(resolve2, ms);
|
|
7170
7164
|
});
|
|
7171
7165
|
}
|
|
7172
|
-
async function pollRunUntilDone(context, cred, runId, timing) {
|
|
7173
|
-
const status2 = await getBuildStatus(context, cred, runId);
|
|
7174
|
-
if (status2.state === "completed") {
|
|
7175
|
-
return { id: runId, state: status2.state, result: status2.result, timedOut: false };
|
|
7176
|
-
}
|
|
7177
|
-
if (Date.now() >= timing.deadline) {
|
|
7178
|
-
return { id: runId, state: status2.state, result: status2.result, timedOut: true };
|
|
7179
|
-
}
|
|
7180
|
-
await sleep(timing.pollMs);
|
|
7181
|
-
return pollRunUntilDone(context, cred, runId, timing);
|
|
7182
|
-
}
|
|
7183
7166
|
function formatTable(rows, rightAlign = /* @__PURE__ */ new Set()) {
|
|
7184
7167
|
const widths = [];
|
|
7185
7168
|
for (const row of rows) {
|
|
@@ -7342,10 +7325,19 @@ function createPipelineWaitCommand() {
|
|
|
7342
7325
|
const resolved = await resolvePipelineContext(options);
|
|
7343
7326
|
context = resolved.context;
|
|
7344
7327
|
const deadline = Date.now() + timeoutSec * 1e3;
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7328
|
+
let waitResult = null;
|
|
7329
|
+
for (; ; ) {
|
|
7330
|
+
const status2 = await getBuildStatus(resolved.context, resolved.cred, runId);
|
|
7331
|
+
if (status2.state === "completed") {
|
|
7332
|
+
waitResult = { id: runId, state: status2.state, result: status2.result, timedOut: false };
|
|
7333
|
+
break;
|
|
7334
|
+
}
|
|
7335
|
+
if (Date.now() >= deadline) {
|
|
7336
|
+
waitResult = { id: runId, state: status2.state, result: status2.result, timedOut: true };
|
|
7337
|
+
break;
|
|
7338
|
+
}
|
|
7339
|
+
await sleep(pollSec * 1e3);
|
|
7340
|
+
}
|
|
7349
7341
|
applyWaitExitCode(waitResult);
|
|
7350
7342
|
if (options.json) {
|
|
7351
7343
|
process.stdout.write(`${JSON.stringify(waitResult, null, 2)}
|