本文整理汇总了TypeScript中azure-pipelines-task-lib/toolrunner.ToolRunner类的典型用法代码示例。如果您正苦于以下问题:TypeScript ToolRunner类的具体用法?TypeScript ToolRunner怎么用?TypeScript ToolRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ToolRunner类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getWorkspaceSchemes
export async function getWorkspaceSchemes(xcbuild: string, workspace: string) : Promise<string[]> {
let xcv: ToolRunner = tl.tool(xcbuild);
xcv.arg(['-workspace', workspace]);
xcv.arg('-list');
let schemes: string[] = [];
let inSchemesSection = false;
let output = '';
xcv.on('stdout', (data) => {
output = output + data.toString();
});
await xcv.exec();
output.split('\n').forEach((line: string) => {
tl.debug(`Line: ${line}`);
line = line.trim();
if (inSchemesSection) {
if (line !== '') {
tl.debug(`Scheme: ${line}`);
schemes.push(line);
}
else {
inSchemesSection = false;
}
}
else if (line === 'Schemes:') {
inSchemesSection = true;
}
});
return schemes;
}
示例2: deleteKeychain
export async function deleteKeychain(keychainPath: string): Promise<void> {
if (tl.exist(keychainPath)) {
let deleteKeychainCommand: ToolRunner = tl.tool(tl.which('security', true));
deleteKeychainCommand.arg(['delete-keychain', keychainPath]);
await deleteKeychainCommand.exec();
}
}
示例3: acquireTfx
async function acquireTfx(version: string): Promise<string> {
try{
version = toolLib.cleanVersion(version);
let extPath: string;
taskLib.assertAgent('2.115.0');
extPath = taskLib.getVariable('Agent.TempDirectory');
if (!extPath) {
throw new Error('Expected Agent.TempDirectory to be set');
}
extPath = path.join(extPath, 'tfx'); // use as short a path as possible due to nested node_modules folders
taskLib.mkdirP(path.join(extPath));
const npmRunner = new tr.ToolRunner("npm");
npmRunner.arg(["install", "tfx-cli@" + version, "--prefix", extPath]);
const result = npmRunner.execSync({ failOnStdErr: false, silent: true, ignoreReturnCode: false} as tr.IExecOptions);
if (result.code === 0)
{
if (os.platform() === "win32")
{
fs.unlinkSync(path.join(extPath, "/tfx"));
}
return await toolLib.cacheDir(extPath, 'tfx', version);
}
}
catch {
return Promise.reject(new Error("Failed to install tfx"));
}
}
示例4: getDefaultKeychainPath
export async function getDefaultKeychainPath() {
let defaultKeychainPath: string;
let getKeychainCmd: ToolRunner = tl.tool(tl.which('security', true));
getKeychainCmd.arg('default-keychain');
getKeychainCmd.on('stdout', function (data) {
if (data) {
defaultKeychainPath = data.toString().trim().replace(/[",\n\r\f\v]/gm, '');
}
})
await getKeychainCmd.exec();
return defaultKeychainPath;
}
示例5: queryLatestMatch
function queryLatestMatch(versionSpec: string): string {
const npmRunner = new tr.ToolRunner("npm");
npmRunner.arg(["show", "tfx-cli", "versions", "--json"]);
const result = npmRunner.execSync({ failOnStdErr: false, silent: true, ignoreReturnCode: false} as tr.IExecOptions);
if (result.code === 0)
{
let versions: string[] = JSON.parse(result.stdout.trim());
let version: string = toolLib.evaluateVersions(versions, versionSpec);
return version;
}
return "";
}
示例6: deleteProvisioningProfile
export async function deleteProvisioningProfile(uuid: string): Promise<void> {
if (uuid && uuid.trim()) {
const provProfiles: string[] = tl.findMatch(getUserProvisioningProfilesPath(), uuid.trim() + '*');
if (provProfiles) {
for (const provProfilePath of provProfiles) {
console.log('Deleting provisioning profile: ' + provProfilePath);
if (tl.exist(provProfilePath)) {
const deleteProfileCommand: ToolRunner = tl.tool(tl.which('rm', true));
deleteProfileCommand.arg(['-f', provProfilePath]);
await deleteProfileCommand.exec();
}
}
}
}
}
示例7: printFromPlist
async function printFromPlist(itemToPrint: string, plistPath: string) {
let plist = tl.which('/usr/libexec/PlistBuddy', true);
let plistTool: ToolRunner = tl.tool(plist);
plistTool.arg(['-c', 'Print ' + itemToPrint, plistPath]);
let printedValue: string;
plistTool.on('stdout', function (data) {
if (data) {
printedValue = data.toString().trim();
}
});
try {
await plistTool.exec();
} catch (err) {
tl.debug('Exception when looking for ' + itemToPrint + ' in plist.');
printedValue = null;
}
return printedValue;
}
示例8: getmacOSProvisioningProfileType
export async function getmacOSProvisioningProfileType(provProfilePath: string) {
let provProfileType: string;
try {
//find the provisioning profile details
let provProfileDetails: string;
let getProvProfileDetailsCmd: ToolRunner = tl.tool(tl.which('security', true));
getProvProfileDetailsCmd.arg(['cms', '-D', '-i', provProfilePath]);
getProvProfileDetailsCmd.on('stdout', function (data) {
if (data) {
if (provProfileDetails) {
provProfileDetails = provProfileDetails.concat(data.toString().trim().replace(/[,\n\r\f\v]/gm, ''));
} else {
provProfileDetails = data.toString().trim().replace(/[,\n\r\f\v]/gm, '');
}
}
})
await getProvProfileDetailsCmd.exec();
let tmpPlist: string;
if (provProfileDetails) {
//write the provisioning profile to a plist
tmpPlist = '_xcodetasktmp.plist';
tl.writeFile(tmpPlist, provProfileDetails);
} else {
throw tl.loc('ProvProfileDetailsNotFound', provProfilePath);
}
//get ProvisionsAllDevices - this will exist for developer-id profiles
let provisionsAllDevices: string = await printFromPlist('ProvisionsAllDevices', tmpPlist);
tl.debug('provisionsAllDevices = ' + provisionsAllDevices);
if (provisionsAllDevices && provisionsAllDevices.trim().toLowerCase() === 'true') {
//ProvisionsAllDevices = true in developer-id profiles
provProfileType = 'developer-id';
} else {
let provisionedDevices: string = await printFromPlist('ProvisionedDevices', tmpPlist);
if (!provisionedDevices) {
// no provisioned devices means it is an app-store profile
provProfileType = 'app-store';
} else {
// profile with provisioned devices - use development
provProfileType = 'development';
}
}
//delete the temporary plist file
let deletePlistCommand: ToolRunner = tl.tool(tl.which('rm', true));
deletePlistCommand.arg(['-f', tmpPlist]);
await deletePlistCommand.exec();
} catch (err) {
tl.debug(err);
}
return provProfileType;
}
示例9: setKeyPartitionList
/**
* Set the partition_id ACL so codesign has permission to use the signing key.
*/
async function setKeyPartitionList(keychainPath: string, keychainPwd: string, privateKeyName: string) {
// security set-key-partition-list -S apple-tool:,apple: -s -l <privateKeyName> -k <keychainPwd> <keychainPath>
// n.b. This command could update multiple keys (e.g. an expired signing key and a newer signing key.)
if (privateKeyName) {
tl.debug(`Setting the partition_id ACL for ${privateKeyName}`);
// "If you'd like to run /usr/bin/codesign with the key, "apple:" must be an element of the partition list." - security(1) man page.
// When you sign into your developer account in Xcode on a new machine, you get a private key with partition list "apple:". However
// "security import a.p12 -k login.keychain" results in the private key with partition list "apple-tool:". I'm preserving import's
// "apple-tool:" and adding the "apple:" codesign needs.
const partitionList = 'apple-tool:,apple:';
let setKeyCommand: ToolRunner = tl.tool(tl.which('security', true));
setKeyCommand.arg(['set-key-partition-list', '-S', partitionList, '-s', '-l', privateKeyName, '-k', keychainPwd, keychainPath]);
// Watch for "unknown command". set-key-partition-list was added in Sierra (macOS v10.12)
let unknownCommandErrorFound: boolean;
let incorrectPasswordErrorFound: boolean;
setKeyCommand.on('errline', (line: string) => {
if (!unknownCommandErrorFound && line.includes('security: unknown command')) {
unknownCommandErrorFound = true;
}
});
try {
await setKeyCommand.exec();
} catch (err) {
if (unknownCommandErrorFound) {
// If we're on an older OS, we don't need to run set-key-partition-list.
console.log(tl.loc('SetKeyPartitionListCommandNotFound'));
} else {
tl.error(err);
throw new Error(tl.loc('SetKeyPartitionListCommandFailed'));
}
}
}
}
示例10: findSigningIdentity
export async function findSigningIdentity(keychainPath: string) {
let signIdentity: string;
let findIdentityCmd: ToolRunner = tl.tool(tl.which('security', true));
findIdentityCmd.arg(['find-identity', '-v', '-p', 'codesigning', keychainPath]);
findIdentityCmd.on('stdout', function (data) {
if (data) {
let matches = data.toString().trim().match(/"(.+)"/g);
tl.debug('signing identity data = ' + matches);
if (matches && matches[0]) {
signIdentity = matches[0].replace(/"/gm, '');
tl.debug('signing identity data trimmed = ' + signIdentity);
}
}
})
await findIdentityCmd.exec();
if (signIdentity) {
tl.debug('findSigningIdentity = ' + signIdentity);
return signIdentity;
} else {
throw tl.loc('SignIdNotFound');
}
}