staple only once

signmacosdesktop
bunsenstraat 9 months ago
parent 1f57c3aa05
commit efa1f9bed1
  1. 91
      apps/remixdesktop/aftersign.js

@ -1,54 +1,75 @@
const { notarize } = require('@electron/notarize');
const fs = require('fs');
const { exec } = require('child_process'); // Import the exec function
const { notarize } = require('@electron/notarize')
const fs = require('fs')
const { exec } = require('child_process') // Import the exec function
exports.default = async function notarizing(context) {
const { electronPlatformName, appOutDir } = context; // Provided by electron-builder
const { electronPlatformName, appOutDir } = context // Provided by electron-builder
console.log('NOTARIZING');
console.log('NOTARIZING')
if (electronPlatformName !== 'darwin' || !process.env.CIRCLE_BRANCH) {
return;
return
}
const appName = context.packager.appInfo.productFilename;
const appName = context.packager.appInfo.productFilename
const appPath = `${appOutDir}/${appName}.app`
// Function to check if the app is stapled
function checkStapleStatus() {
exec(`xcrun stapler validate "${appPath}"`, async (error, stdout, stderr) => {
if (error) {
console.log(`App is not stapled: ${error.message}`)
await runNotarize()
return
}
if (stderr) {
console.log(`App is not stapled: ${stderr}`)
await runNotarize()
return
}
console.log('App is already stapled. No action needed.')
})
}
const files = fs.readdirSync(appOutDir, 'utf8')
console.log(files);
console.log({
appBundleId: 'org.ethereum.remix-ide', // Your app's bundle ID
appPath: `${appOutDir}/${appName}.app`, // Path to your .app
appleId: process.env.APPLE_ID, // Your Apple ID
appleIdPassword: process.env.APPLE_ID_PASSWORD, // App-specific password
teamId: process.env.APPLE_TEAM_ID, // Your Apple Developer team ID (optional)
})
async function runNotarize() {
try {
const r = await notarize({
console.log({
appBundleId: 'org.ethereum.remix-ide', // Your app's bundle ID
appPath: `${appOutDir}/${appName}.app`, // Path to your .app
appleId: process.env.APPLE_ID, // Your Apple ID
appleIdPassword: process.env.APPLE_ID_PASSWORD, // App-specific password
teamId: process.env.APPLE_TEAM_ID, // Your Apple Developer team ID (optional)
});
})
console.log(r);
try {
const r = await notarize({
appBundleId: 'org.ethereum.remix-ide', // Your app's bundle ID
appPath: `${appOutDir}/${appName}.app`, // Path to your .app
appleId: process.env.APPLE_ID, // Your Apple ID
appleIdPassword: process.env.APPLE_ID_PASSWORD, // App-specific password
teamId: process.env.APPLE_TEAM_ID, // Your Apple Developer team ID (optional)
})
console.log(r)
// Stapling the app
console.log('STAPLING')
exec(`xcrun stapler staple "${appPath}"`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`)
return
}
console.log(`Stapling output: ${stdout}`)
console.error(`Stapling errors: ${stderr}`)
})
} catch (error) {
console.error('Error during notarization:', error)
}
// Stapling the app
console.log('STAPLING');
const appPath = `${appOutDir}/${appName}.app`;
exec(`xcrun stapler staple "${appPath}"`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`Stapling output: ${stdout}`);
console.error(`Stapling errors: ${stderr}`);
});
} catch (error) {
console.error('Error during notarization:', error);
}
};
checkStapleStatus()
}

Loading…
Cancel
Save