本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
})
示例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);
}
}
示例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());
}
示例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`);
}
示例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;
}
示例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;
}