Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/exec/build/tasks/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path = require("path");
import shell = require("shelljs");
import tasksBase = require("./default");
import trace = require("../../../lib/trace");
import uuid = require("uuid");
import { v1 as uuidv1 } from "uuid";

export interface TaskCreateResult {
taskPath: string;
Expand Down Expand Up @@ -81,7 +81,7 @@ export class TaskCreate extends tasksBase.BuildTaskBase<TaskCreateResult> {

trace.debug("creating definition");
let def: any = {};
def.id = uuid.v1();
def.id = uuidv1();
trace.debug("id: " + def.id);
def.name = taskName;
trace.debug("name: " + def.name);
Expand Down
25 changes: 7 additions & 18 deletions app/exec/extension/_lib/merger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { forwardSlashesPath, toZipItemName } from "./utils";
import _ = require("lodash");
import fs = require("fs");
import glob = require("glob");
import { glob } from "glob";
import jju = require("jju");
import jsonInPlace = require("json-in-place");
import loc = require("./loc");
Expand Down Expand Up @@ -56,18 +56,7 @@ export class Merger {
const globs = this.settings.manifestGlobs.map(p => (path.isAbsolute(p) ? p : path.join(this.settings.root, p)));

trace.debug("merger.gatherManifestsFromGlob");
const promises = globs.map(
pattern =>
new Promise<string[]>((resolve, reject) => {
glob(pattern, (err, matches) => {
if (err) {
reject(err);
} else {
resolve(matches);
}
});
}),
);
const promises = globs.map(pattern => glob(pattern));

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

// build environment object from --env parameter
const env = {};
(this.settings.env || []).forEach(kvp => {
(this.settings.env || []).forEach(kvp => {
const [key, ...value] = kvp.split('=');
env[key] = value.join('=');
});
Expand All @@ -119,7 +108,7 @@ export class Merger {
throw new Error(`The export function from manifest-js file ${fullJsFile} must return the manifest object`)
}
return manifestData;
}
}

/**
* Finds all manifests and merges them into two JS Objects: vsoManifest and vsixManifest
Expand Down Expand Up @@ -413,9 +402,9 @@ export class Merger {
private async validateBuildTaskContributions(contributions: any[]): Promise<void> {
try {
// Filter contributions to only build tasks
const buildTaskContributions = contributions.filter(contrib =>
contrib.type === "ms.vss-distributed-task.task" &&
contrib.properties &&
const buildTaskContributions = contributions.filter(contrib =>
contrib.type === "ms.vss-distributed-task.task" &&
contrib.properties &&
contrib.properties.name
);

Expand Down
21 changes: 17 additions & 4 deletions app/lib/connection.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
import { BasicCredentialHandler } from "azure-devops-node-api/handlers/basiccreds";

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

export class TfsConnection {
private parsedUrl: url.Url;
private parsedUrl: URL;

private accountUrl: string;
private collectionUrl: string;

constructor(private serviceUrl: string) {
this.parsedUrl = url.parse(this.serviceUrl);
// Parse URL, but handle failures gracefully to mimic url.parse() behavior
try {
this.parsedUrl = new URL(this.serviceUrl);
} catch (error) {
// Mimic url.parse() behavior for invalid URLs
// url.parse() would return an object with null/empty values instead of throwing
this.parsedUrl = {
protocol: this.serviceUrl && this.serviceUrl.includes('://') ? this.serviceUrl.split('://')[0] + ':' : '',
host: null,
hostname: null,
pathname: this.serviceUrl && !this.serviceUrl.includes('://') ? this.serviceUrl : '',
search: '',
hash: ''
} as any;
}

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

if (splitPath.length === 2 && splitPath[0] === "tfs") {
Expand Down
Loading
Loading