• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript task.loc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getAdvinst

async function getAdvinst(version: string, license: string): Promise<void> {

  if (!semvish.valid(version))
    throw Error(taskLib.loc("AI_InvalidVersionFormat", version));

  let cachedToolRoot: string;
  //Verify if this version of advinst was already installed.
  cachedToolRoot = _getLocalTool(semvish.clean(version));

  if (!cachedToolRoot) {
    console.log(taskLib.loc("AI_InstallNewTool"));
    //Extract advinst.msi and cache the content.
    cachedToolRoot = await acquireAdvinst(version);
  }
  else {
    console.log(taskLib.loc("AI_UseCachedTool", cachedToolRoot));
  }

  let msBuildTargetsPath: string = path.join(cachedToolRoot, advinstMSBuildTargetsSubPath);
  //Compute the actual AdvancedInstaller.com folder
  let advinstBinRoot: string = path.join(cachedToolRoot, advinstToolSubPath);
  //Debug traces
  taskLib.debug('cachedToolRoot = ' + cachedToolRoot);
  taskLib.debug('advinstBinRoot = ' + advinstBinRoot);
  taskLib.debug('msBuildTargetsPath = ' + msBuildTargetsPath);

  //Register advinst if a license key was provided
  await registerAdvinst(advinstBinRoot, license);
  //Add the advinst folder to PATH
  toolLib.prependPath(advinstBinRoot);

  //Set the environment variables that will be used by Advanced Installer tasks later on.
  taskLib.setVariable(advinstMSBuildTargetsVar, msBuildTargetsPath);
  taskLib.setVariable(advinstToolRootVar, cachedToolRoot);
}
开发者ID:Caphyon,项目名称:advinst-vsts-task,代码行数:35,代码来源:AdvinstTool.ts


示例2: compareChannelVersion

export function compareChannelVersion(channelVersionA: string, channelVersionB: string): number {
    if (!channelVersionA || !channelVersionB) {
        throw "One channel version is missing"
    }

    let channelVersionAParts = channelVersionA.split(".");
    let channelVersionBParts = channelVersionB.split(".");
    if (channelVersionAParts.length != 2 || channelVersionBParts.length != 2) {
        throw tl.loc("ChannelVersionsNotComparable", channelVersionA, channelVersionB)
    }

    let channelAMajorVersion = Number.parseInt(channelVersionAParts[0]);
    let channelAMinorVersion = Number.parseInt(channelVersionAParts[1]);
    let channelBMajorVersion = Number.parseInt(channelVersionBParts[0]);
    let channelBMinorVersion = Number.parseInt(channelVersionBParts[1]);

    if (Number.isNaN(channelAMajorVersion) || Number.isNaN(channelAMinorVersion) || Number.isNaN(channelBMajorVersion) || Number.isNaN(channelBMinorVersion)) {
        throw tl.loc("ChannelVersionsNotComparable", channelVersionA, channelVersionB);
    }

    if (channelAMajorVersion != channelBMajorVersion) {
        return channelAMajorVersion > channelBMajorVersion ? 1 : -1;
    }
    else if (channelAMinorVersion != channelBMinorVersion) {
        return channelAMinorVersion > channelBMinorVersion ? 1 : -1;
    }

    return 0;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:29,代码来源:versionutilities.ts


示例3: isLatestInstalledVersion

    private isLatestInstalledVersion(version: string): boolean {
        var pathTobeChecked = this.packageType == utils.Constants.sdk ? path.join(this.installationPath, utils.Constants.relativeSdkPath) : path.join(this.installationPath, utils.Constants.relativeRuntimePath);
        if (!tl.exist(pathTobeChecked)) {
            throw tl.loc("PathNotFoundException", pathTobeChecked);
        }

        var allEnteries: string[] = tl.ls("", [pathTobeChecked]).map(name => path.join(pathTobeChecked, name));
        var folderPaths: string[] = allEnteries.filter(element => fs.lstatSync(element).isDirectory());
        var isLatest: boolean = folderPaths.findIndex(folderPath => {
            try {
                let versionFolderName = path.basename(folderPath);
                tl.debug(tl.loc("ComparingInstalledFolderVersions", version, versionFolderName));
                return utils.versionCompareFunction(versionFolderName, version) > 0;
            }
            catch (ex) {
                // no op, folder name might not be in version format
            }
        }) < 0;

        var filePaths: string[] = allEnteries.filter(element => !fs.lstatSync(element).isDirectory());
        isLatest = isLatest && filePaths.findIndex(filePath => {
            try {
                var versionCompleteFileName = this.getVersionCompleteFileName(path.basename(filePath));
                tl.debug(tl.loc("ComparingInstalledFileVersions", version, versionCompleteFileName));
                return utils.versionCompareFunction(versionCompleteFileName, version) > 0
            }
            catch (ex) {
                // no op, file name might not be in version format
            }
        }) < 0;

        isLatest ? tl.debug(tl.loc("VersionIsLocalLatest", version, this.installationPath)) : tl.debug(tl.loc("VersionIsNotLocalLatest", version, this.installationPath));
        return isLatest;
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:34,代码来源:versioninstaller.ts


示例4: _extractAdvinst

async function _extractAdvinst(sourceMsi: string): Promise<string> {
  console.log(taskLib.loc("AI_ExtractTool"));

  // Ensure the c:\windows\installer folder exists. MSIEXEC will fail on some clients (E.g. Hosted VS2017)
  // due to the lack of this folder.

  let windowsInstallerFolder = path.join(taskLib.getVariable('windir'), 'Installer');
  if (!taskLib.exist(windowsInstallerFolder)) {
    taskLib.debug(taskLib.loc("AI_CreateInstallerFolder"))
    taskLib.mkdirP(windowsInstallerFolder);
  }

  let advinstWorkFolder = path.join(_getAgentTemp(), 'AdvancedInstaller');
  let msiExtractionPath: string = path.join(advinstWorkFolder, 'resources');
  // Create the work folder, otherwise msiexec will fail because of the log path.
  if (!taskLib.exist(advinstWorkFolder))
    taskLib.mkdirP(advinstWorkFolder);
  let msiLogPath: string = path.join(advinstWorkFolder, 'advinst_install.log');

  let msiexecArguments: string[] = ['/a', sourceMsi, 'TARGETDIR=' + msiExtractionPath, '/qn', '/l*v', msiLogPath];

  let exitCode = taskLib.execSync('msiexec.exe', msiexecArguments).code;
  if (exitCode != 0) {
    taskLib.command('task.uploadfile', {}, msiLogPath);
    return null;
  }
  return msiExtractionPath;
}
开发者ID:Caphyon,项目名称:advinst-vsts-task,代码行数:28,代码来源:AdvinstTool.ts


示例5: VersionInfo

                .then((body: string) => {
                    var channelReleases = JSON.parse(body).releases;

                    let versionInfoList: VersionInfo[] = [];
                    channelReleases.forEach((release) => {
                        if (release && release[packageType] && release[packageType].version) {
                            try {
                                let versionInfo: VersionInfo = new VersionInfo(release[packageType], packageType);
                                versionInfoList.push(versionInfo);
                            }
                            catch (err) {
                                tl.debug(tl.loc("VersionInformationNotComplete", release[packageType].version, err));
                            }
                        }
                    });

                    let matchedVersionInfo = utils.getMatchingVersionFromList(versionInfoList, versionSpec, includePreviewVersions);
                    if (!matchedVersionInfo) {
                        console.log(tl.loc("MatchingVersionNotFound", packageType, versionSpec));
                        return null;
                    }

                    console.log(tl.loc("MatchingVersionForUserInputVersion", matchedVersionInfo.getVersion(), channelInformation.channelVersion, versionSpec))
                    return matchedVersionInfo;
                })
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:25,代码来源:versionfetcher.ts


示例6: run

async function run() {
    tl.setResourcePath(path.join( __dirname, 'task.json'));

    let taskInputs =  new OptimizelyTaskParameter();
    let taskOperation = new TaskOperation(taskInputs);

    let optimizelyClient = taskOperation.getOptimizelyClientInstance();

    let projectId: string = taskInputs.getProjectId();
    console.log(tl.loc("ProjectId", projectId));
    let project = await optimizelyClient.getProject(projectId);

    taskInputs.setProjectType(project.platform);

    let experimentId: string = taskInputs.getExperimentId();
    let experiment: IOptimizelyAlphaBetaTest = await optimizelyClient.getExperiment(projectId, experimentId);

    experiment = taskOperation.updateTrafficVariation(experiment);
    experiment.audience_conditions = await taskOperation.getAudienceCondition(projectId);

    let action: string = taskInputs.getAction();
    if (action.toLowerCase() === 'startabtest') {
        await taskOperation.startABTest(experiment);
    } else if (action.toLowerCase() === 'pauseabtest') {
        await taskOperation.pauseABTest(experiment);
    } else {
        throw tl.loc("InvalidAction", action);
    }
}
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:29,代码来源:Main.ts


示例7: getDownloadUrl

    public getDownloadUrl(versionInfo: VersionInfo): string {
        console.log(tl.loc("GettingDownloadUrl", versionInfo.getPackageType(), versionInfo.getVersion()));

        let osSuffixes = this.detectMachineOS();
        let downloadPackageInfoObject: VersionFilesData = null;
        osSuffixes.find((osSuffix) => {
            downloadPackageInfoObject = versionInfo.getFiles().find((downloadPackageInfo: VersionFilesData) => {
                if (downloadPackageInfo.rid && osSuffix && downloadPackageInfo.rid.toLowerCase() == osSuffix.toLowerCase()) {
                    if ((osSuffix.split("-")[0] == "win" && downloadPackageInfo.name.endsWith(".zip")) || (osSuffix.split("-")[0] != "win" && downloadPackageInfo.name.endsWith("tar.gz"))) {
                        return true;
                    }
                }

                return false;
            });

            return !!downloadPackageInfoObject;
        });

        if (!!downloadPackageInfoObject && downloadPackageInfoObject.url) {
            tl.debug("Got download URL for platform with rid: " + downloadPackageInfoObject.rid);
            return downloadPackageInfoObject.url;
        }

        throw tl.loc("DownloadUrlForMatchingOsNotFound", versionInfo.getPackageType(), versionInfo.getVersion(), osSuffixes.toString());
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:26,代码来源:versionfetcher.ts


示例8: startABTest

  public async startABTest(experiment: IOptimizelyAlphaBetaTest): Promise<void> {
      let environmentName: string = this.taskInputs.getEnvironmentName();
      let projectId: string = this.taskInputs.getProjectId();

      if(this.taskInputs.isWebProject()) {
          experiment.status = OptimizelyExperimentStatus.Running;
      } else {
          let environment: IOptimizelyEnvironment = await this.optimizelyClient.getEnvironment(projectId, environmentName);
          if (environment == null) {
              throw tl.loc("EnvironmentNotFound", environmentName);
          }

          Object.keys(experiment.environments).forEach((value) => {
              if (value.toLowerCase() == environmentName.toLowerCase()) {
                  experiment.environments[value].status = OptimizelyExperimentStatus.Running;
              }
          });
      }

      let experimentName = experiment.name;
      await this.optimizelyClient.updateExperiment(experiment.id, experiment);

      let counter: number = 6;
      while (counter > 0) {
          console.log(tl.loc("WaitingForExperimentToStart", experimentName));
          await this.sleep(10000);
          counter--;
      }

      console.log(tl.loc("ABTestStartedSuccessfully", experimentName));
      console.log(tl.loc("VisitOptimizelyPage") + ` https://app.optimizely.com/v2/projects/${projectId}/experiments`);
  }
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:32,代码来源:TaskOperation.ts


示例9: getVSTestConsolePath

export function getVSTestConsolePath(versionLowerLimit : string, versionUpperLimit : string): string {
    let vswhereTool = tl.tool(path.join(__dirname, 'vswhere.exe'));

    console.log(tl.loc('LookingForVsInstalltion'));
    vswhereTool.line(`-version [${versionLowerLimit},${versionUpperLimit}) -latest -products * -requires Microsoft.VisualStudio.PackageGroup.TestTools.Core -property installationPath`);
    let vsPath = vswhereTool.execSync({ silent: true } as tr.IExecSyncOptions).stdout;
    vsPath = utils.Helper.trimString(vsPath);
    if (!utils.Helper.isNullOrWhitespace(vsPath)) {
        tl.debug('Visual Studio 15.0 or higher installed path: ' + vsPath);
        return vsPath;
    }

    // look for build tool installation if full VS not present
    console.log(tl.loc('LookingForBuildToolsInstalltion'));
    vswhereTool = tl.tool(path.join(__dirname, 'vswhere.exe'));
    vswhereTool.line(`-version [${versionLowerLimit},${versionUpperLimit}) -latest -products * -requires Microsoft.VisualStudio.Component.TestTools.BuildTools -property installationPath`);
    vsPath = vswhereTool.execSync({ silent: true } as tr.IExecSyncOptions).stdout;
    vsPath = utils.Helper.trimString(vsPath);
    if (!utils.Helper.isNullOrWhitespace(vsPath)) {
        tl.debug('Build tools installed path: ' + vsPath);
        return vsPath;
    }

    return null;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:25,代码来源:versionfinder.ts


示例10: updateTrafficVariation

  public updateTrafficVariation(experiment: IOptimizelyAlphaBetaTest): IOptimizelyAlphaBetaTest {
      let totalTrafficParameter : string = this.taskInputs.getTotalTraffic();
      let totalTraffic: number = Number.parseInt(totalTrafficParameter);

      if (Number.isNaN(totalTraffic)) {
          throw tl.loc("TrafficValueNotValid", totalTrafficParameter);
      }

      if (totalTraffic > 100) {
          throw tl.loc("TrafficValueCantExceed", totalTraffic);
      }

      let holdBack: number = 10000 - (totalTraffic * 100);
      experiment.holdback = holdBack;
      let trafficByVariationKeyInput = this.taskInputs.getTrafficByVariation();
      let trafficVariations = this.parseTrafficByVariation(trafficByVariationKeyInput);

      for (let i: number = 0; i < experiment.variations.length; i++) {
          let variationKey: string = (this.taskInputs.isWebProject()) ? experiment.variations[i].name : experiment.variations[i].key;
          variationKey = variationKey.toLowerCase();
          if (!trafficVariations.has(variationKey)) {
              throw tl.loc("TrafficVariationKeyNotDefined", variationKey);
          }
          experiment.variations[i].weight = trafficVariations.get(variationKey);
      }

      return experiment;
  }
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:28,代码来源:TaskOperation.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript task.ls函数代码示例发布时间:2022-05-25
下一篇:
TypeScript task.getVariable函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap