|
|
@ -13,21 +13,34 @@ exports.default = async function notarizing(context) { |
|
|
|
const appName = context.packager.appInfo.productFilename |
|
|
|
const appName = context.packager.appInfo.productFilename |
|
|
|
const appPath = `${appOutDir}/${appName}.app` |
|
|
|
const appPath = `${appOutDir}/${appName}.app` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Function to promisify the exec command
|
|
|
|
|
|
|
|
function execShellCommand(cmd) { |
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
exec(cmd, (error, stdout, stderr) => { |
|
|
|
|
|
|
|
if (error) { |
|
|
|
|
|
|
|
reject(new Error(`Error: ${error.message}`)); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (stderr) { |
|
|
|
|
|
|
|
reject(new Error(`Stderr: ${stderr}`)); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
resolve(stdout); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Function to check if the app is stapled
|
|
|
|
// Function to check if the app is stapled
|
|
|
|
function checkStapleStatus() { |
|
|
|
// Async function to check the stapling status
|
|
|
|
exec(`xcrun stapler validate "${appPath}"`, async (error, stdout, stderr) => { |
|
|
|
async function checkStapleStatus(appPath) { |
|
|
|
if (error) { |
|
|
|
try { |
|
|
|
console.log(`App is not stapled: ${error.message}`) |
|
|
|
await execShellCommand(`xcrun stapler validate "${appPath}"`); |
|
|
|
await runNotarize() |
|
|
|
console.log('App is already stapled. No action needed.'); |
|
|
|
return |
|
|
|
return true |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
if (stderr) { |
|
|
|
console.log(`App is not stapled: ${error.message}`); |
|
|
|
console.log(`App is not stapled: ${stderr}`) |
|
|
|
return false |
|
|
|
await runNotarize() |
|
|
|
} |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log('App is already stapled. No action needed.') |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -57,19 +70,18 @@ exports.default = async function notarizing(context) { |
|
|
|
// Stapling the app
|
|
|
|
// Stapling the app
|
|
|
|
console.log('STAPLING') |
|
|
|
console.log('STAPLING') |
|
|
|
|
|
|
|
|
|
|
|
exec(`xcrun stapler staple "${appPath}"`, (error, stdout, stderr) => { |
|
|
|
await execShellCommand(`xcrun stapler staple "${appPath}"`) |
|
|
|
if (error) { |
|
|
|
|
|
|
|
console.error(`exec error: ${error}`) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log(`Stapling output: ${stdout}`) |
|
|
|
|
|
|
|
console.error(`Stapling errors: ${stderr}`) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
console.error('Error during notarization:', error) |
|
|
|
console.error('Error during notarization:', error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
checkStapleStatus() |
|
|
|
if(!await checkStapleStatus()){ |
|
|
|
|
|
|
|
await runNotarize() |
|
|
|
|
|
|
|
await checkStapleStatus() |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|