Example #1
0
		coreApi.restClient.get(packageUrl, ApiVersion, null, { responseIsCollection: false }, async function (error, status, result) {
			if (!!error && status != 200) {
				reject(tl.loc("FailedToGetPackageMetadata", error));
			}

			var packageType = result.protocolType.toLowerCase();
			var packageName = result.name;

			if (packageType == "nuget") {
				var downloadUrl = await getDownloadUrl(coreApi.vsoClient, feedId, packageName, version);
				
				if (!tl.exist(downloadPath)) {
					tl.mkdirP(downloadPath);
				}

				var zipLocation = path.resolve(downloadPath, "/../", packageName) + ".zip";
				var unzipLocation = path.join(downloadPath, "");

				console.log(tl.loc("StartingDownloadOfPackage", packageName, zipLocation));
				await downloadNugetPackage(coreApi, downloadUrl, zipLocation);
				console.log(tl.loc("ExtractingNugetPackage", packageName, unzipLocation));
				await unzip(zipLocation, unzipLocation);
				
				if (tl.exist(zipLocation)) {
					tl.rmRF(zipLocation, false);
				}

				resolve();
			}
			else {
				reject(tl.loc("PackageTypeNotSupported"));
			}
		});
Example #2
0
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
// In this case, there will be two files located at:
//      /dist/v5.10.1/win-x64/node.exe
//      /dist/v5.10.1/win-x64/node.lib
// If this is not the structure, there may also be two files located at:
//      /dist/v0.12.18/node.exe
//      /dist/v0.12.18/node.lib
// This method attempts to download and cache the resources from these alternative locations.
// Note also that the files are normally zipped but in this case they are just an exe
// and lib file in a folder, not zipped.
async function acquireNodeFromFallbackLocation(version: string): Promise<string> {
    // Create temporary folder to download in to
    let tempDownloadFolder: string = 'temp_' + Math.floor(Math.random() * 2000000000);
    let tempDir: string = path.join(taskLib.getVariable('agent.tempDirectory'), tempDownloadFolder);
    taskLib.mkdirP(tempDir);
    let exeUrl: string;
    let libUrl: string;
    try {
        exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
        libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;

        await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
        await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
    }
    catch (err) {
        if (err['httpStatusCode'] && 
            err['httpStatusCode'] == 404)
        {
            exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
            libUrl = `https://nodejs.org/dist/v${version}/node.lib`;

            await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
            await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
        }
        else {
            throw err;
        }
    }
    return await toolLib.cacheDir(tempDir, 'node', version);
}
 private ensureDirExists(dirPath : string) : void
 {
     if (!fs.existsSync(dirPath)) {
         fs.mkdirSync(dirPath);
         var privateKeyDir= path.join(dirPath, "trust", "private");
         tl.mkdirP(privateKeyDir);
     }
 }
Example #4
0
    constructor(packageType: string, installationPath: string) {
        try {
            tl.exist(installationPath) || tl.mkdirP(installationPath);
        }
        catch (ex) {
            throw tl.loc("UnableToAccessPath", installationPath, JSON.stringify(ex));
        }

        this.packageType = packageType;
        this.installationPath = installationPath;
    }
Example #5
0
export function getTempPath(): string {
    let tempNpmrcDir
        = tl.getVariable("Agent.BuildDirectory")
        || tl.getVariable("Agent.ReleaseDirectory")
        || process.cwd();
    let tempPath = path.join(tempNpmrcDir, "yarn");
    if (tl.exist(tempPath) === false) {
        tl.mkdirP(tempPath);
    }

    return tempPath;
}
Example #6
0
export function getTempPath(): string {
    const tempNpmrcDir
        = tl.getVariable('Agent.BuildDirectory')
        || tl.getVariable('Agent.ReleaseDirectory')
        || process.cwd();
        const tempPath = path.join(tempNpmrcDir, 'npm');
    if (tl.exist(tempPath) === false) {
        tl.mkdirP(tempPath);
    }

    return tempPath;
}
Example #7
0
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
// In this case, there will be two files located at:
//      /dist/v5.10.1/win-x64/node.exe
//      /dist/v5.10.1/win-x64/node.lib
// This method attempts to download and cache the resources from this alternative location.
// Note also that the files are normally zipped but in this case they are just an exe
// and lib file in a folder, not zipped.
async function acquireNodeFromFallbackLocation(version: string): Promise<string> {
    let exeUrl: string = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
    let libUrl: string = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;

    // Create temporary folder to download in to
    let tempDownloadFolder: string = 'temp_' + Math.floor(Math.random() * 2000000000);
    let tempDir: string = path.join(taskLib.getVariable('agent.tempDirectory'), tempDownloadFolder);
    taskLib.mkdirP(tempDir);

    let exeDownloadPath: string = await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
    let libDownloadPath: string = await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));

    return await toolLib.cacheDir(tempDir, 'node', version);
}
Example #8
0
export function getPypircPath(): string {
    let pypircPath: string;
    if (tl.getVariable("PYPIRC_PATH")) {
        pypircPath = tl.getVariable("PYPIRC_PATH");
    }
    else {
       // tslint:disable-next-line:max-line-length
       let tempPath = tl.getVariable("Agent.BuildDirectory") || tl.getVariable("Agent.ReleaseDirectory") || process.cwd();
       tempPath = path.join(tempPath, "twineAuthenticate");
       tl.mkdirP(tempPath);
       let savePypircPath = fs.mkdtempSync(tempPath + path.sep);
       pypircPath = savePypircPath + path.sep + ".pypirc";
    }
    return pypircPath;
}
function addDotNetCoreToolPath() {
    try {
        let globalToolPath: string = "";
        if (tl.osType().match(/^Win/)) {
            globalToolPath = path.join(process.env.USERPROFILE, Constants.relativeGlobalToolPath);
        } else {
            globalToolPath = path.join(process.env.HOME, Constants.relativeGlobalToolPath);
        }

        console.log(tl.loc("PrependGlobalToolPath"));
        tl.mkdirP(globalToolPath);
        toolLib.prependPath(globalToolPath);
    } catch (error) {
        //nop
        console.log(tl.loc("ErrorWhileSettingDotNetToolPath", JSON.stringify(error)));
    }
}
    public async install() {
        // Check cache
        let toolPath: string;
        let osSuffixes = this.detectMachineOS();
        let parts = osSuffixes[0].split("-");
        this.arch = parts.length > 1 ? parts[1] : "x64";
        toolPath = this.getLocalTool();

        if (!toolPath) {
            // download, extract, cache
            console.log(tl.loc("InstallingAfresh"));
            console.log(tl.loc("GettingDownloadUrl", this.packageType, this.version));
            let downloadUrls = await DotNetCoreReleaseFetcher.getDownloadUrls(osSuffixes, this.version, this.packageType);
            toolPath = await this.downloadAndInstall(downloadUrls);
        } else {
            console.log(tl.loc("UsingCachedTool", toolPath));
        }

        // Prepend the tools path. instructs the agent to prepend for future tasks
        toolLib.prependPath(toolPath);

        try {
            let globalToolPath: string = "";
            if (tl.osType().match(/^Win/)) {
                globalToolPath = path.join(process.env.USERPROFILE, ".dotnet\\tools");
            } else {
                globalToolPath = path.join(process.env.HOME, ".dotnet/tools");
            }

            console.log(tl.loc("PrependGlobalToolPath"));
            tl.mkdirP(globalToolPath);
            toolLib.prependPath(globalToolPath);
        } catch (error) {
            //nop
        }

        // Set DOTNET_ROOT for dotnet core Apphost to find runtime since it is installed to a non well-known location.
        tl.setVariable('DOTNET_ROOT', toolPath);
    }