Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add notarization logs to debug logging for success #202

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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