azdo-cli 0.25.0-develop.938 → 0.25.0-feature-devcontainer-caddy-proxy.939
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 +17 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -406,6 +406,19 @@ var DEFAULT_FIELDS = [
|
|
|
406
406
|
"System.AreaPath",
|
|
407
407
|
"System.IterationPath"
|
|
408
408
|
];
|
|
409
|
+
function routeAzureDevOpsApiUrl(url) {
|
|
410
|
+
const proxyBase = process.env.AZDO_API_BASE_URL?.trim();
|
|
411
|
+
if (!proxyBase) return url;
|
|
412
|
+
const original = new URL(url);
|
|
413
|
+
if (original.hostname !== "dev.azure.com" || !original.pathname.includes("/_apis/")) return url;
|
|
414
|
+
const base = new URL(proxyBase);
|
|
415
|
+
const basePath = base.pathname.replace(/\/$/, "");
|
|
416
|
+
original.protocol = base.protocol;
|
|
417
|
+
original.hostname = base.hostname;
|
|
418
|
+
original.port = base.port;
|
|
419
|
+
original.pathname = `${basePath}${original.pathname}`;
|
|
420
|
+
return original.toString();
|
|
421
|
+
}
|
|
409
422
|
function authHeaders(credentialOrPat) {
|
|
410
423
|
if (typeof credentialOrPat === "string") {
|
|
411
424
|
const token2 = Buffer.from(`:${credentialOrPat}`).toString("base64");
|
|
@@ -420,7 +433,7 @@ function authHeaders(credentialOrPat) {
|
|
|
420
433
|
async function fetchRaw(url, init) {
|
|
421
434
|
let response;
|
|
422
435
|
try {
|
|
423
|
-
response = await fetch(url, init);
|
|
436
|
+
response = await fetch(routeAzureDevOpsApiUrl(url), init);
|
|
424
437
|
} catch (err) {
|
|
425
438
|
throw new Error(`NETWORK_ERROR: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
426
439
|
}
|
|
@@ -519,7 +532,7 @@ async function traceResponse(url, init, response) {
|
|
|
519
532
|
async function fetchWithErrors(url, init) {
|
|
520
533
|
let response;
|
|
521
534
|
try {
|
|
522
|
-
response = await fetch(url, init);
|
|
535
|
+
response = await fetch(routeAzureDevOpsApiUrl(url), init);
|
|
523
536
|
} catch (err) {
|
|
524
537
|
throw new Error("NETWORK_ERROR", { cause: err });
|
|
525
538
|
}
|
|
@@ -1280,7 +1293,7 @@ function patFromEnvFile(envFile) {
|
|
|
1280
1293
|
if (!existsSync3(envFile)) return null;
|
|
1281
1294
|
const contents = readFileSync3(envFile, "utf8");
|
|
1282
1295
|
for (const line of contents.split("\n")) {
|
|
1283
|
-
const match =
|
|
1296
|
+
const match = /^AZDO_PAT\s*=([^\n\r]+)$/.exec(line);
|
|
1284
1297
|
if (match === null) continue;
|
|
1285
1298
|
const value = match[1].trim().replace(/^["']|["']$/g, "");
|
|
1286
1299
|
if (value.length > 0) return value;
|
|
@@ -1347,7 +1360,7 @@ function describeResolvedCredential() {
|
|
|
1347
1360
|
async function validatePatAgainstAzdo(pat, org) {
|
|
1348
1361
|
const url = `https://dev.azure.com/${encodeURIComponent(org)}/_apis/projects?$top=1&api-version=7.1`;
|
|
1349
1362
|
const auth = Buffer.from(`:${pat}`).toString("base64");
|
|
1350
|
-
const response = await fetch(url, {
|
|
1363
|
+
const response = await fetch(routeAzureDevOpsApiUrl(url), {
|
|
1351
1364
|
headers: {
|
|
1352
1365
|
Authorization: `Basic ${auth}`,
|
|
1353
1366
|
Accept: "application/json"
|