当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript locationUtilities.getFeedUriFromBaseServiceUri函数代码示例

本文整理汇总了TypeScript中packaging-common/locationUtilities.getFeedUriFromBaseServiceUri函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getFeedUriFromBaseServiceUri函数的具体用法?TypeScript getFeedUriFromBaseServiceUri怎么用?TypeScript getFeedUriFromBaseServiceUri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getFeedUriFromBaseServiceUri函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: downloadUniversalPackage

export async function downloadUniversalPackage(
    downloadPath: string,
    feedId: string,
    packageId: string,
    version: string,
    filterPattern: string
): Promise<void> {
    try {
        const accessToken = pkgLocationUtils.getSystemAccessToken();
        let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
        const blobUri = await pkgLocationUtils.getBlobstoreUriFromBaseServiceUri(serviceUri, accessToken);

        // Finding the artifact tool directory
        var artifactToolPath = await artifactToolUtilities.getArtifactToolFromService(
            blobUri,
            accessToken,
            "artifacttool"
        );

        const feedUri = await pkgLocationUtils.getFeedUriFromBaseServiceUri(serviceUri, accessToken);
        let packageName: string = await artifactToolUtilities.getPackageNameFromId(
            feedUri,
            accessToken,
            feedId,
            packageId
        );

        tl.debug(tl.loc("Info_UsingArtifactToolDownload"));

        const downloadOptions = {
            artifactToolPath,
            feedId,
            accountUrl: serviceUri,
            packageName,
            packageVersion: version
        } as artifactToolRunner.IArtifactToolOptions;

        let toolRunnerOptions = artifactToolRunner.getOptions();
        toolRunnerOptions.env.UNIVERSAL_DOWNLOAD_PAT = accessToken;
        downloadPackageUsingArtifactTool(downloadPath, downloadOptions, toolRunnerOptions, filterPattern);
    } catch (error) {
        tl.setResult(tl.TaskResult.Failed, error.message);
        return;
    } finally {
        _logUniversalStartupVariables({
            ArtifactToolPath: artifactToolPath,
            PackageType: "Universal",
            FeedId : feedId,
            PackageId: packageId,
            Version: version,
            IsTriggeringArtifact: tl.getInput("isTriggeringArtifact")
        });
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:54,代码来源:universal.ts

示例2: run

export async function run(artifactToolPath: string): Promise<void> {
    const buildIdentityDisplayName: string = null;
    const buildIdentityAccount: string = null;
    try {
        // Get directory to publish
        const publishDir: string = tl.getInput("publishDirectory");
        if (publishDir.length < 1)
        {
            tl.debug(tl.loc("Info_PublishDirectoryNotFound"));
            return;
        }

        let serviceUri: string;
        let feedId: string;
        let packageName: string;
        let version: string;
        let accessToken: string;
        let feedUri: string;
        const publishedPackageVar: string = tl.getInput("publishedPackageVar");
        const versionRadio = tl.getInput("versionPublishSelector");

        // Feed Auth
        let feedType = tl.getInput("internalOrExternalPublish") || "internal";

        const normalizedFeedType = ["internal", "external"].find((x) =>
            feedType.toUpperCase() === x.toUpperCase());
        if (!normalizedFeedType) {
            throw new Error(tl.loc("UnknownFeedType", feedType));
        }
        feedType = normalizedFeedType;

        let internalAuthInfo: auth.InternalAuthInfo;

        const toolRunnerOptions = artifactToolRunner.getOptions();

        let sessionId: string;

        if (feedType === "internal")
        {
            // getting inputs
            serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);

            packageName = tl.getInput("packageListPublish");
            feedId = tl.getInput("feedListPublish");

            // Setting up auth info
            accessToken = pkgLocationUtils.getSystemAccessToken();
            internalAuthInfo = new auth.InternalAuthInfo([], accessToken);

            toolRunnerOptions.env.UNIVERSAL_PUBLISH_PAT = internalAuthInfo.accessToken;

            let packagingLocation: string;
            try {
                // This call is to get the packaging URI(abc.pkgs.vs.com) which is same for all protocols.
                packagingLocation = await pkgLocationUtils.getNuGetUriFromBaseServiceUri(
                    serviceUri,
                    accessToken);
            } catch (error) {
                tl.debug(JSON.stringify(error));
                packagingLocation = serviceUri;
            }

            const pkgConn = pkgLocationUtils.getWebApiWithProxy(packagingLocation, accessToken);
            sessionId = await ProvenanceHelper.GetSessionId(
                feedId,
                null,
                "upack", /* must match protocol name on the server */
                pkgConn.serverUrl,
                [pkgConn.authHandler],
                pkgConn.options);
        }
        else {
            const externalAuthInfo = auth.GetExternalAuthInfo("externalEndpoints");
            if (!externalAuthInfo)
            {
                tl.setResult(tl.TaskResult.Failed, tl.loc("Error_NoSourceSpecifiedForPublish"));
                return;
            }

            serviceUri = externalAuthInfo.packageSource.accountUrl;

            feedId = tl.getInput("feedPublishExternal");
            packageName = tl.getInput("packagePublishExternal");

            // Assuming only auth via PAT works for now
            accessToken = (externalAuthInfo as auth.TokenExternalAuthInfo).token;
            toolRunnerOptions.env.UNIVERSAL_PUBLISH_PAT = accessToken;
        }

        if (versionRadio === "custom"){
            version = tl.getInput("versionPublish");
        }
        else{
            feedUri = await pkgLocationUtils.getFeedUriFromBaseServiceUri(serviceUri, accessToken);

            const highestVersion = await artifactToolUtilities.getHighestPackageVersionFromFeed(
                feedUri,
                accessToken,
                feedId,
                packageName);
//.........这里部分代码省略.........
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:101,代码来源:universalpublish.ts

示例3: downloadPackage

export async function downloadPackage(collectionUrl: string, accessToken, credentialHandler: bearm.BearerCredentialHandler, feedId: string, packageId: string, version: string, downloadPath: string) {
	
	var feedsUrl = await locationUtility.getFeedUriFromBaseServiceUri(collectionUrl, accessToken);
	var feedConnection = new vsts.WebApi(feedsUrl, credentialHandler);
	
	var packagesUrl = await locationUtility.getNuGetUriFromBaseServiceUri(collectionUrl, accessToken);
	var packageConnection = new vsts.WebApi(packagesUrl, credentialHandler);
	
	var packageUrl = await getNuGetPackageUrl(feedConnection.getCoreApi().vsoClient, feedId, packageId);
	
	await new Promise((resolve, reject) => {
		feedConnection.getCoreApi().restClient.get(packageUrl, ApiVersion, null, { responseIsCollection: false }, async function (error, status, result) {
			if (!!error || status != 200) {
				return reject(tl.loc("FailedToGetPackageMetadata", error));
			}

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

			if (packageType == "nuget") {
				
				var getDownloadUrlPromise = getDownloadUrl(packageConnection.getCoreApi().vsoClient, feedId, packageName, version)
				getDownloadUrlPromise.catch((error) => {
					return reject(error)
				});
				var downloadUrl = await getDownloadUrlPromise;
				
				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));
				
				var downloadNugetPackagePromise = downloadNugetPackage(packageConnection.getCoreApi(), downloadUrl, zipLocation);
				downloadNugetPackagePromise.catch((error) => {
					return reject(error)
				});
				await downloadNugetPackagePromise;

				console.log(tl.loc("ExtractingNugetPackage", packageName, unzipLocation));

				var unzipPromise = unzip(zipLocation, unzipLocation);
				unzipPromise.catch((error) => {
					return reject(error)
				});
				await unzipPromise;
				
				if (tl.exist(zipLocation)) {
					tl.rmRF(zipLocation);
				}

				return resolve();
			}
			else {
				return reject(tl.loc("PackageTypeNotSupported"));
			}
		});
	});
}
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:62,代码来源:download.ts

示例4: run

export async function run(artifactToolPath: string): Promise<void> {
    let buildIdentityDisplayName: string = null;
    let buildIdentityAccount: string = null;
    try {
        // Get directory to publish
        let downloadDir: string = tl.getInput("downloadDirectory");
        if (downloadDir.length < 1)
        {
            tl.warning(tl.loc("Info_DownloadDirectoryNotFound"));
            return;
        }

        let serviceUri: string;
        let feedId: string;
        let packageName: string;
        let version: string;

        // Feed Auth
        let feedType = tl.getInput("internalOrExternalDownload") || "internal";

        const normalizedFeedType = ["internal", "external"].find((x) =>
            feedType.toUpperCase() === x.toUpperCase());
        if (!normalizedFeedType) {
            throw new Error(tl.loc("UnknownFeedType", feedType));
        }
        feedType = normalizedFeedType;

        let internalAuthInfo: auth.InternalAuthInfo;

        let toolRunnerOptions = artifactToolRunner.getOptions();

        if (feedType === "internal")
        {
            // getting inputs
            serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);

            feedId = tl.getInput("feedListDownload");

            // Getting package name from package Id
            const packageId = tl.getInput("packageListDownload");
            const accessToken = pkgLocationUtils.getSystemAccessToken();

            internalAuthInfo = new auth.InternalAuthInfo([], accessToken);

            const feedUri = await pkgLocationUtils.getFeedUriFromBaseServiceUri(serviceUri, accessToken);
            packageName = await artifactToolUtilities.getPackageNameFromId(feedUri, accessToken, feedId, packageId);

            version = tl.getInput("versionListDownload");

            toolRunnerOptions.env.UNIVERSAL_DOWNLOAD_PAT = internalAuthInfo.accessToken;
        }
        else {
            let externalAuthInfo = auth.GetExternalAuthInfo("externalEndpoint");

            if (!externalAuthInfo)
            {
                tl.setResult(tl.TaskResult.Failed, tl.loc("Error_NoSourceSpecifiedForDownload"));
                return;
            }

            serviceUri = externalAuthInfo.packageSource.accountUrl;
            feedId = tl.getInput("feedDownloadExternal");
            packageName = tl.getInput("packageDownloadExternal");
            version = tl.getInput("versionDownloadExternal");

            // Assuming only auth via PAT works for now
            const tokenAuth = externalAuthInfo as auth.TokenExternalAuthInfo;
            toolRunnerOptions.env.UNIVERSAL_DOWNLOAD_PAT = tokenAuth.token;
        }

        tl.debug(tl.loc("Info_UsingArtifactToolDownload"));

        const downloadOptions = {
            artifactToolPath,
            feedId,
            accountUrl: serviceUri,
            packageName,
            packageVersion: version,
        } as artifactToolRunner.IArtifactToolOptions;

        downloadPackageUsingArtifactTool(downloadDir, downloadOptions, toolRunnerOptions);

        tl.setResult(tl.TaskResult.Succeeded, tl.loc("PackagesDownloadedSuccessfully"));

    } catch (err) {
        tl.error(err);

        if (buildIdentityDisplayName || buildIdentityAccount) {
            tl.warning(tl.loc("BuildIdentityPermissionsHint", buildIdentityDisplayName, buildIdentityAccount));
        }

        tl.setResult(tl.TaskResult.Failed, tl.loc("PackagesFailedToDownload"));
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:94,代码来源:universaldownload.ts


注:本文中的packaging-common/locationUtilities.getFeedUriFromBaseServiceUri函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。