remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/apps/remixdesktop/aftersign.js

76 lines
2.3 KiB

9 months ago
const { notarize } = require('@electron/notarize')
const fs = require('fs')
const { exec } = require('child_process') // Import the exec function
9 months ago
exports.default = async function notarizing(context) {
9 months ago
const { electronPlatformName, appOutDir } = context // Provided by electron-builder
9 months ago
9 months ago
console.log('NOTARIZING')
9 months ago
9 months ago
if (electronPlatformName !== 'darwin' || !process.env.CIRCLE_BRANCH) {
9 months ago
return
9 months ago
}
9 months ago
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.')
})
}
9 months ago
9 months ago
9 months ago
async function runNotarize() {
9 months ago
9 months ago
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)
9 months ago
})
9 months ago
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)
}
}
9 months ago
checkStapleStatus()
}