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

90 lines
2.6 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`
9 months ago
// 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;
}
9 months ago
console.log(`stdout: ${stdout}`);
9 months ago
resolve(stdout);
});
});
}
9 months ago
// Function to check if the app is stapled
9 months ago
// Async function to check the stapling status
async function checkStapleStatus(appPath) {
try {
9 months ago
console.log(`xcrun stapler validate "${appPath}"`)
9 months ago
await execShellCommand(`xcrun stapler validate "${appPath}"`);
console.log('App is already stapled. No action needed.');
return true
} catch (error) {
console.log(`App is not stapled: ${error.message}`);
return false
}
9 months ago
}
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
9 months ago
console.log('STAPLING', `xcrun stapler staple "${appPath}"`)
9 months ago
9 months ago
await execShellCommand(`xcrun stapler staple "${appPath}"`)
9 months ago
} catch (error) {
console.error('Error during notarization:', error)
}
}
9 months ago
9 months ago
if(!await checkStapleStatus()){
await runNotarize()
await checkStapleStatus()
}else{
return []
}
9 months ago
}