本文整理汇总了TypeScript中azure-pipelines-task-lib/toolrunner.ToolRunner.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ToolRunner.on方法的具体用法?TypeScript ToolRunner.on怎么用?TypeScript ToolRunner.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure-pipelines-task-lib/toolrunner.ToolRunner
的用法示例。
在下文中一共展示了ToolRunner.on方法的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: 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;
}
示例3: 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;
}
示例4: getCloudEntitlement
export async function getCloudEntitlement(provisioningProfilePath: string, exportMethod: string): Promise<string> {
//find the provisioning profile details
let provProfileDetails: string;
const getProvProfileDetailsCmd: ToolRunner = tl.tool(tl.which('security', true));
getProvProfileDetailsCmd.arg(['cms', '-D', '-i', provisioningProfilePath]);
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', provisioningProfilePath);
}
//use PlistBuddy to figure out if cloud entitlement exists.
const cloudEntitlement: string = await printFromPlist('Entitlements:com.apple.developer.icloud-container-environment', tmpPlist);
//delete the temporary plist file
const deletePlistCommand: ToolRunner = tl.tool(tl.which('rm', true));
deletePlistCommand.arg(['-f', tmpPlist]);
await deletePlistCommand.exec();
if (!cloudEntitlement) {
return null;
}
tl.debug('Provisioning Profile contains cloud entitlement');
return (exportMethod === 'app-store' || exportMethod === 'enterprise' || exportMethod === 'developer-id')
? "Production"
: "Development";
}
示例5: getP12PrivateKeyName
export async function getP12PrivateKeyName(p12Path: string, p12Pwd: string): Promise<string> {
//openssl pkcs12 -in <p12Path> -nocerts -passin pass:"<p12Pwd>" -passout pass:"<p12Pwd>" | grep 'friendlyName'
tl.debug('getting the P12 private key name');
const opensslPath: string = tl.which('openssl', true);
const openssl: ToolRunner = tl.tool(opensslPath);
if (!p12Pwd) {
// if password is null or not defined, set it to empty
p12Pwd = '';
}
// since we can't suppress the private key bytes, encrypt them before we pass them to grep.
const privateKeyPassword = p12Pwd ? p12Pwd : generatePassword();
openssl.arg(['pkcs12', '-in', p12Path, '-nocerts', '-passin', 'pass:' + p12Pwd, '-passout', 'pass:' + privateKeyPassword]);
//we pipe through grep so we we don't log the private key to the console.
//even if it's encrypted, it's noise and could cause concern for some users.
const grepPath: string = tl.which('grep', true);
const grep: ToolRunner = tl.tool(grepPath);
grep.arg(['friendlyName']);
openssl.pipeExecOutputToTool(grep);
let privateKeyName: string;
openssl.on('stdout', function (data) {
if (data) {
// find the private key name
data = data.toString().trim();
const match = data.match(/friendlyName: (.*)/);
if (match && match[1]) {
privateKeyName = match[1].trim();
}
}
});
await openssl.exec();
tl.debug('P12 private key name = ' + privateKeyName);
if (!privateKeyName) {
throw new Error(tl.loc('P12PrivateKeyNameNotFound', p12Path));
}
return privateKeyName;
}
示例6: 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;
}
示例7: 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'));
}
}
}
}
示例8: 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');
}
}
示例9: getProvisioningProfileName
export async function getProvisioningProfileName(provProfilePath: string) {
//find the provisioning profile UUID
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);
}
//use PlistBuddy to figure out the Name
let provProfileName: string = await printFromPlist('Name', tmpPlist);
//delete the temporary plist file
let deletePlistCommand: ToolRunner = tl.tool(tl.which('rm', true));
deletePlistCommand.arg(['-f', tmpPlist]);
await deletePlistCommand.exec();
tl.debug('getProvisioningProfileName: profile name = ' + provProfileName);
return provProfileName;
}
示例10: getP12Properties
export async function getP12Properties(p12Path: string, p12Pwd: string): Promise<{ fingerprint: string, commonName: string, notBefore: Date, notAfter: Date}> {
//openssl pkcs12 -in <p12Path> -nokeys -passin pass:"<p12Pwd>" | openssl x509 -noout -fingerprint âsubject -dates
let opensslPath: string = tl.which('openssl', true);
let openssl1: ToolRunner = tl.tool(opensslPath);
if (!p12Pwd) {
// if password is null or not defined, set it to empty
p12Pwd = '';
}
openssl1.arg(['pkcs12', '-in', p12Path, '-nokeys', '-passin', 'pass:' + p12Pwd]);
let openssl2: ToolRunner = tl.tool(opensslPath);
openssl2.arg(['x509', '-noout', '-fingerprint', '-subject', '-dates']);
openssl1.pipeExecOutputToTool(openssl2);
let fingerprint: string;
let commonName: string;
let notBefore: Date;
let notAfter: Date;
function onLine(line: string) {
if (line) {
const tuple = splitIntoKeyValue(line);
const key: string = tuple.key;
const value: string = tuple.value;
if (key === 'SHA1 Fingerprint') {
// Example value: "BB:26:83:C6:AA:88:35:DE:36:94:F2:CF:37:0A:D4:60:BB:AE:87:0C"
// Remove colons separating each octet.
fingerprint = value.replace(/:/g, '').trim();
} else if (key === 'subject') {
// Example value: "/UID=E848ASUQZY/CN=iPhone Developer: Chris Sidi (7RZ3N927YF)/OU=DJ8T2973U7/O=Chris Sidi/C=US"
// Extract the common name.
const matches: string[] = value.match(/\/CN=([^/]+)/);
if (matches && matches[1]) {
commonName = matches[1].trim();
}
} else if (key === 'notBefore') {
// Example value: "Nov 13 03:37:42 2018 GMT"
notBefore = new Date(value);
} else if (key === 'notAfter') {
notAfter = new Date(value);
}
}
}
// Concat all of stdout to avoid shearing. This can be updated to `openssl1.on('stdline', onLine)` once stdline mocking is available.
let output = '';
openssl1.on('stdout', (data) => {
output = output + data.toString();
});
try {
await openssl1.exec();
// process the collected stdout.
let line: string;
for (line of output.split('\n')) {
onLine(line);
}
} catch (err) {
if (!p12Pwd) {
tl.warning(tl.loc('NoP12PwdWarning'));
}
throw err;
}
tl.debug(`P12 fingerprint: ${fingerprint}`);
tl.debug(`P12 common name (CN): ${commonName}`);
tl.debug(`NotBefore: ${notBefore}`);
tl.debug(`NotAfter: ${notAfter}`);
return { fingerprint, commonName, notBefore, notAfter };
}