M1 Support

This commit is contained in:
Fedor Indutny 2021-12-03 23:49:15 +01:00 committed by GitHub
parent dccd3fbf73
commit 874a019227
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 397 additions and 316 deletions

View file

@ -22,61 +22,65 @@ export function zipMacOSRelease(): void {
'No zip file found. Maybe the release did not complete properly?'
);
}
if (files.length > 1) {
if (files.length !== 2) {
throw new Error(
'More than one zip file found, release directory was not cleared.'
'Multiple versions of zip files found, release directory was not cleared.'
);
}
const zipFile = files[0];
const zipPath = path.join('release', zipFile);
console.log('Removing current zip file');
rimraf.sync(zipPath);
for (const zipFile of files) {
const zipPath = path.join('release', zipFile);
const appName = `${packageJSON.productName}.app`;
const appPath = path.join('release', 'mac', appName);
console.log('Removing current zip file', zipFile);
rimraf.sync(zipPath);
const tmpPath = path.join('release', 'tmp');
const appDir = path.dirname(appPath);
const tmpZip = path.join(appDir, zipFile);
console.log('Creating temporary zip file at', tmpZip);
try {
execSync(`cd ${appDir} && zip -ro ${zipFile} "${appName}"`);
console.log(
'Unzipping to remove duplicate electron references from',
tmpZip
const postfix = zipFile.includes('arm64') ? '-arm64' : '';
const appName = `${packageJSON.productName}.app`;
const appPath = path.join('release', `mac${postfix}`, appName);
const tmpPath = path.join('release', `tmp${postfix}`);
const appDir = path.dirname(appPath);
const tmpZip = path.join(appDir, zipFile);
console.log('Creating temporary zip file at', tmpZip);
try {
execSync(`cd ${appDir} && zip -ro ${zipFile} "${appName}"`);
console.log(
'Unzipping to remove duplicate electron references from',
tmpZip
);
execSync(`unzip ${tmpZip} -d ${tmpPath}`);
} catch (err) {
console.log('stdout:', String(err.stdout));
console.log('stderr:', String(err.stderr));
throw err;
}
console.log('Removing temporary zip file');
rimraf.sync(tmpZip);
const electronFrameworkPath = path.join(
tmpPath,
appName,
'Contents',
'Frameworks',
'Electron Framework.framework',
'Versions'
);
execSync(`unzip ${tmpZip} -d ${tmpPath}`);
} catch (err) {
console.log('stdout:', String(err.stdout));
console.log('stderr:', String(err.stderr));
throw err;
}
console.log('Removing temporary zip file');
rimraf.sync(tmpZip);
console.log('Removing duplicate electron framework', electronFrameworkPath);
rimraf.sync(electronFrameworkPath);
const electronFrameworkPath = path.join(
tmpPath,
appName,
'Contents',
'Frameworks',
'Electron Framework.framework',
'Versions'
);
console.log('Removing duplicate electron framework', electronFrameworkPath);
rimraf.sync(electronFrameworkPath);
try {
console.log('Creating final zip');
execSync(`cd ${tmpPath} && zip -ro ${zipFile} "${appName}"`);
} catch (err) {
console.log('stdout:', String(err.stdout));
console.log('stderr:', String(err.stderr));
throw err;
try {
console.log('Creating final zip');
execSync(`cd ${tmpPath} && zip -ro ${zipFile} "${appName}"`);
} catch (err) {
console.log('stdout:', String(err.stdout));
console.log('stderr:', String(err.stderr));
throw err;
}
console.log('Moving into the final destination', zipPath);
fs.renameSync(path.join(tmpPath, zipFile), zipPath);
rimraf.sync(tmpPath);
}
console.log('Moving into the final destination', zipPath);
fs.renameSync(path.join(tmpPath, zipFile), zipPath);
rimraf.sync(tmpPath);
console.log('zip-macos-release is done');
}