Skip to content

Commit

Permalink
feat: add notarization logs to debug logging for success (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao authored Aug 13, 2024
1 parent a38ba02 commit dfbdcd8
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/notarytool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ function authorizationArgs(rawOpts: NotaryToolCredentials): string[] {
}
}

async function getNotarizationLogs(opts: NotaryToolStartOptions, id: string) {
try {
const logResult = await spawn('xcrun', ['notarytool', 'log', id, ...authorizationArgs(opts)]);
d('notarization log', logResult.output);
return logResult.output;
} catch (e) {
d('failed to pull notarization logs', e);
}
}

export async function isNotaryToolAvailable() {
const result = await spawn('xcrun', ['--find', 'notarytool']);
return result.code === 0;
Expand Down Expand Up @@ -94,25 +104,14 @@ export async function notarizeAndWaitForNotaryTool(opts: NotaryToolStartOptions)
);
}

if (result.code === 0 && parsed.status === 'Accepted') {
d('notarization success');
return;
let logOutput: undefined | string;
if (typeof parsed.id === 'string') {
logOutput = await getNotarizationLogs(opts, parsed.id);
}

let logOutput: undefined | string;
if (parsed.id) {
try {
const logResult = await spawn('xcrun', [
'notarytool',
'log',
parsed.id,
...authorizationArgs(opts),
]);
d('notarization log', logResult.output);
logOutput = logResult.output;
} catch (e) {
d('failed to pull notarization logs', e);
}
if (result.code === 0 && parsed.status === 'Accepted') {
d(`notarization success (id: ${parsed.id})`);
return;
}

let message = `Failed to notarize via notarytool\n\n${result.output}`;
Expand Down

0 comments on commit dfbdcd8

Please sign in to comment.