Skip to content

Commit ae8b325

Browse files
Port changes from commit bbc5570 - Update vulnerable dependencies and modernize deprecated API usage (#513)
* Initial plan * Port code changes from commit bbc5570 - update dependencies and modernize URL parsing Co-authored-by: tarunramsinghani <2929463+tarunramsinghani@users.noreply.github.com> * Update package-lock.json with new dependency versions Co-authored-by: tarunramsinghani <2929463+tarunramsinghani@users.noreply.github.com> * Update patch version to 0.22.2 Co-authored-by: tarunramsinghani <2929463+tarunramsinghani@users.noreply.github.com> * Revert test framework and build tool versions for compatibility - Revert mocha from 11.7.3 to 10.2.0 for better Node.js compatibility - Revert rimraf from 6.0.1 to 2.6.1 to maintain backward compatibility - Update Node.js engine requirement to >=16.0.0 for modern API support - Improve error handling in server integration tests - All tests passing with updated dependency versions --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tarunramsinghani <2929463+tarunramsinghani@users.noreply.github.com> Co-authored-by: Tarun Ramsinghani <tarunramsinghani@users.noreply.github.com>
1 parent f838fec commit ae8b325

File tree

8 files changed

+1568
-1010
lines changed

8 files changed

+1568
-1010
lines changed

app/exec/build/tasks/create.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path = require("path");
55
import shell = require("shelljs");
66
import tasksBase = require("./default");
77
import trace = require("../../../lib/trace");
8-
import uuid = require("uuid");
8+
import { v1 as uuidv1 } from "uuid";
99

1010
export interface TaskCreateResult {
1111
taskPath: string;
@@ -81,7 +81,7 @@ export class TaskCreate extends tasksBase.BuildTaskBase<TaskCreateResult> {
8181

8282
trace.debug("creating definition");
8383
let def: any = {};
84-
def.id = uuid.v1();
84+
def.id = uuidv1();
8585
trace.debug("id: " + def.id);
8686
def.name = taskName;
8787
trace.debug("name: " + def.name);

app/exec/extension/_lib/merger.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { forwardSlashesPath, toZipItemName } from "./utils";
1414
import _ = require("lodash");
1515
import fs = require("fs");
16-
import glob = require("glob");
16+
import { glob } from "glob";
1717
import jju = require("jju");
1818
import jsonInPlace = require("json-in-place");
1919
import loc = require("./loc");
@@ -56,18 +56,7 @@ export class Merger {
5656
const globs = this.settings.manifestGlobs.map(p => (path.isAbsolute(p) ? p : path.join(this.settings.root, p)));
5757

5858
trace.debug("merger.gatherManifestsFromGlob");
59-
const promises = globs.map(
60-
pattern =>
61-
new Promise<string[]>((resolve, reject) => {
62-
glob(pattern, (err, matches) => {
63-
if (err) {
64-
reject(err);
65-
} else {
66-
resolve(matches);
67-
}
68-
});
69-
}),
70-
);
59+
const promises = globs.map(pattern => glob(pattern));
7160

7261
return Promise.all(promises)
7362
.then(results => _.uniq(_.flatten<string>(results)))
@@ -104,7 +93,7 @@ export class Merger {
10493

10594
// build environment object from --env parameter
10695
const env = {};
107-
(this.settings.env || []).forEach(kvp => {
96+
(this.settings.env || []).forEach(kvp => {
10897
const [key, ...value] = kvp.split('=');
10998
env[key] = value.join('=');
11099
});
@@ -119,7 +108,7 @@ export class Merger {
119108
throw new Error(`The export function from manifest-js file ${fullJsFile} must return the manifest object`)
120109
}
121110
return manifestData;
122-
}
111+
}
123112

124113
/**
125114
* Finds all manifests and merges them into two JS Objects: vsoManifest and vsixManifest
@@ -413,9 +402,9 @@ export class Merger {
413402
private async validateBuildTaskContributions(contributions: any[]): Promise<void> {
414403
try {
415404
// Filter contributions to only build tasks
416-
const buildTaskContributions = contributions.filter(contrib =>
417-
contrib.type === "ms.vss-distributed-task.task" &&
418-
contrib.properties &&
405+
const buildTaskContributions = contributions.filter(contrib =>
406+
contrib.type === "ms.vss-distributed-task.task" &&
407+
contrib.properties &&
419408
contrib.properties.name
420409
);
421410

app/lib/connection.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
import { BasicCredentialHandler } from "azure-devops-node-api/handlers/basiccreds";
22

3-
import url = require("url");
43
import apim = require("azure-devops-node-api/WebApi");
54
import apibasem = require("azure-devops-node-api/interfaces/common/VsoBaseInterfaces");
65
import trace = require("./trace");
76

87
export class TfsConnection {
9-
private parsedUrl: url.Url;
8+
private parsedUrl: URL;
109

1110
private accountUrl: string;
1211
private collectionUrl: string;
1312

1413
constructor(private serviceUrl: string) {
15-
this.parsedUrl = url.parse(this.serviceUrl);
14+
// Parse URL, but handle failures gracefully to mimic url.parse() behavior
15+
try {
16+
this.parsedUrl = new URL(this.serviceUrl);
17+
} catch (error) {
18+
// Mimic url.parse() behavior for invalid URLs
19+
// url.parse() would return an object with null/empty values instead of throwing
20+
this.parsedUrl = {
21+
protocol: this.serviceUrl && this.serviceUrl.includes('://') ? this.serviceUrl.split('://')[0] + ':' : '',
22+
host: null,
23+
hostname: null,
24+
pathname: this.serviceUrl && !this.serviceUrl.includes('://') ? this.serviceUrl : '',
25+
search: '',
26+
hash: ''
27+
} as any;
28+
}
1629

17-
var splitPath: string[] = this.parsedUrl.path.split("/").slice(1);
30+
var splitPath: string[] = this.parsedUrl.pathname.split("/").slice(1);
1831
this.accountUrl = this.parsedUrl.protocol + "//" + this.parsedUrl.host;
1932

2033
if (splitPath.length === 2 && splitPath[0] === "tfs") {

0 commit comments

Comments
 (0)