9 Commits

Author SHA1 Message Date
Quang Lam
1fc0005ae8 fix: merged ASAR does not unpack when there is only one unpacked file (#55) 2022-10-18 17:17:11 -07:00
Samuel Attard
64cbc83faf build: configure semantic release for main branch 2022-10-18 16:08:05 -07:00
Samuel Attard
691e4ef31d fix: migrate from asar to @electron/asar 2022-10-18 16:06:38 -07:00
Samuel Attard
d902197267 build: migrate master <-> main 2022-10-18 16:05:13 -07:00
Mike Maietta
72a3f83d27 fix: export MakeUniversalOpts (#48)
This is to allow other packages to extract specific logic/options with typesafety
2022-10-03 00:05:29 -07:00
Samuel Attard
3cc1365561 Update config.yml 2022-10-03 00:04:43 -07:00
dependabot[bot]
3a30fe989b build(deps): bump plist from 3.0.4 to 3.0.5 (#44)
Bumps [plist](https://github.com/TooTallNate/node-plist) from 3.0.4 to 3.0.5.
- [Release notes](https://github.com/TooTallNate/node-plist/releases)
- [Changelog](https://github.com/TooTallNate/plist.js/blob/master/History.md)
- [Commits](https://github.com/TooTallNate/node-plist/commits)

---
updated-dependencies:
- dependency-name: plist
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-01 13:06:11 -07:00
Jesse Vincent
01dfb8a963 feat: don't lipo binaries that are identical in the x64 and arm64 versions and match an allowlist (#47)
* fix: Don’t lipo binaries that are already a universal file or the same arch #17

Some Mach-O files may have already been fat binaries and will throw an error if lipoed again.

Co-authored-by: Mitch Cohen <mitch@1password.com>
Co-authored-by: Nick McGuire <nick.mcguire@1password.com>

* Add a x64ArchFiles config key to allow allow-listing of files that are only always x64Arch

Co-authored-by: Andrew Beyer <beyer@1password.com>
Co-authored-by: Mitch Cohen <mitch@1password.com>
Co-authored-by: Nick McGuire <nick.mcguire@1password.com>
2022-06-01 13:05:54 -07:00
dependabot[bot]
3bd173d61a build(deps): bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-29 18:07:33 -07:00
7 changed files with 63 additions and 27 deletions

View File

@@ -20,7 +20,7 @@ version: 2.1
jobs: jobs:
test: test:
macos: macos:
xcode: "12.2.0" xcode: "13.4.1"
<<: *steps-test <<: *steps-test
release: release:
@@ -30,6 +30,7 @@ jobs:
- checkout - checkout
- *step-restore-cache - *step-restore-cache
- run: yarn --frozen-lockfile - run: yarn --frozen-lockfile
- run: npx @continuous-auth/circleci-oidc-github-auth@1.0.5
- run: npx semantic-release - run: npx semantic-release
workflows: workflows:
version: 2 version: 2
@@ -42,5 +43,6 @@ workflows:
filters: filters:
branches: branches:
only: only:
- master - main
context: cfa-release

View File

@@ -4,6 +4,7 @@
"@semantic-release/release-notes-generator", "@semantic-release/release-notes-generator",
"@continuous-auth/semantic-release-npm", "@continuous-auth/semantic-release-npm",
"@semantic-release/github" "@semantic-release/github"
] ],
"branches": [ "main" ]
} }

View File

@@ -2,7 +2,7 @@
> Create universal macOS Electron applications > Create universal macOS Electron applications
[![CircleCI](https://circleci.com/gh/electron/universal/tree/master.svg?style=svg)](https://circleci.com/gh/electron/universal) [![CircleCI](https://circleci.com/gh/electron/universal/tree/main.svg?style=svg)](https://circleci.com/gh/electron/universal)
## Usage ## Usage

View File

@@ -43,8 +43,8 @@
"typescript": "^4.0.5" "typescript": "^4.0.5"
}, },
"dependencies": { "dependencies": {
"@electron/asar": "^3.2.1",
"@malept/cross-spawn-promise": "^1.1.0", "@malept/cross-spawn-promise": "^1.1.0",
"asar": "^3.1.0",
"debug": "^4.3.1", "debug": "^4.3.1",
"dir-compare": "^2.4.0", "dir-compare": "^2.4.0",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",

View File

@@ -1,4 +1,4 @@
import * as asar from 'asar'; import * as asar from '@electron/asar';
import { execFileSync } from 'child_process'; import { execFileSync } from 'child_process';
import * as crypto from 'crypto'; import * as crypto from 'crypto';
import * as fs from 'fs-extra'; import * as fs from 'fs-extra';
@@ -195,8 +195,15 @@ export const mergeASARs = async ({
const resolvedUnpack = Array.from(unpackedFiles).map((file) => path.join(x64Dir, file)); const resolvedUnpack = Array.from(unpackedFiles).map((file) => path.join(x64Dir, file));
let unpack: string | undefined;
if (resolvedUnpack.length > 1) {
unpack = `{${resolvedUnpack.join(',')}}`;
} else if (resolvedUnpack.length === 1) {
unpack = resolvedUnpack[0];
}
await asar.createPackageWithOptions(x64Dir, outputAsarPath, { await asar.createPackageWithOptions(x64Dir, outputAsarPath, {
unpack: `{${resolvedUnpack.join(',')}}`, unpack,
}); });
d('done merging'); d('done merging');

View File

@@ -1,7 +1,8 @@
import { spawn } from '@malept/cross-spawn-promise'; import { spawn } from '@malept/cross-spawn-promise';
import * as asar from 'asar'; import * as asar from '@electron/asar';
import * as crypto from 'crypto'; import * as crypto from 'crypto';
import * as fs from 'fs-extra'; import * as fs from 'fs-extra';
import * as minimatch from 'minimatch';
import * as os from 'os'; import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as plist from 'plist'; import * as plist from 'plist';
@@ -12,7 +13,7 @@ import { AsarMode, detectAsarMode, generateAsarIntegrity, mergeASARs } from './a
import { sha } from './sha'; import { sha } from './sha';
import { d } from './debug'; import { d } from './debug';
type MakeUniversalOpts = { export type MakeUniversalOpts = {
/** /**
* Absolute file system path to the x64 version of your application. E.g. /Foo/bar/MyApp_x64.app * Absolute file system path to the x64 version of your application. E.g. /Foo/bar/MyApp_x64.app
*/ */
@@ -39,6 +40,10 @@ type MakeUniversalOpts = {
* Minimatch pattern of paths that are allowed to be present in one of the ASAR files, but not in the other. * Minimatch pattern of paths that are allowed to be present in one of the ASAR files, but not in the other.
*/ */
singleArchFiles?: string; singleArchFiles?: string;
/**
* Minimatch pattern of binaries that are expected to be the same x64 binary in both of the ASAR files.
*/
x64ArchFiles?: string;
}; };
const dupedFiles = (files: AppFile[]) => const dupedFiles = (files: AppFile[]) =>
@@ -130,6 +135,27 @@ export const makeUniversalApp = async (opts: MakeUniversalOpts): Promise<void> =
const first = await fs.realpath(path.resolve(tmpApp, machOFile.relativePath)); const first = await fs.realpath(path.resolve(tmpApp, machOFile.relativePath));
const second = await fs.realpath(path.resolve(opts.arm64AppPath, machOFile.relativePath)); const second = await fs.realpath(path.resolve(opts.arm64AppPath, machOFile.relativePath));
const x64Sha = await sha(path.resolve(opts.x64AppPath, machOFile.relativePath));
const arm64Sha = await sha(path.resolve(opts.arm64AppPath, machOFile.relativePath));
if (x64Sha === arm64Sha) {
if (
opts.x64ArchFiles === undefined ||
!minimatch(machOFile.relativePath, opts.x64ArchFiles, { matchBase: true })
) {
throw new Error(
`Detected file "${machOFile.relativePath}" that's the same in both x64 and arm64 builds and not covered by the ` +
`x64ArchFiles rule: "${opts.x64ArchFiles}"`,
);
}
d(
'SHA for Mach-O file',
machOFile.relativePath,
`matches across builds ${x64Sha}===${arm64Sha}, skipping lipo`,
);
continue;
}
d('joining two MachO files with lipo', { d('joining two MachO files with lipo', {
first, first,
second, second,

View File

@@ -48,6 +48,18 @@
read-pkg "^4.0.0" read-pkg "^4.0.0"
registry-auth-token "^3.3.1" registry-auth-token "^3.3.1"
"@electron/asar@^3.2.1":
version "3.2.1"
resolved "https://registry.yarnpkg.com/@electron/asar/-/asar-3.2.1.tgz#c4143896f3dd43b59a80a9c9068d76f77efb62ea"
integrity sha512-hE2cQMZ5+4o7+6T2lUaVbxIzrOjZZfX7dB02xuapyYFJZEAiWTelq6J3mMoxzd0iONDvYLPVKecB5tyjIoVDVA==
dependencies:
chromium-pickle-js "^0.2.0"
commander "^5.0.0"
glob "^7.1.6"
minimatch "^3.0.4"
optionalDependencies:
"@types/glob" "^7.1.1"
"@iarna/cli@^1.2.0": "@iarna/cli@^1.2.0":
version "1.2.0" version "1.2.0"
resolved "https://registry.yarnpkg.com/@iarna/cli/-/cli-1.2.0.tgz#0f7af5e851afe895104583c4ca07377a8094d641" resolved "https://registry.yarnpkg.com/@iarna/cli/-/cli-1.2.0.tgz#0f7af5e851afe895104583c4ca07377a8094d641"
@@ -510,18 +522,6 @@ asap@^2.0.0:
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=
asar@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/asar/-/asar-3.1.0.tgz#70b0509449fe3daccc63beb4d3c7d2e24d3c6473"
integrity sha512-vyxPxP5arcAqN4F/ebHd/HhwnAiZtwhglvdmc7BR2f0ywbVNTOpSeyhLDbGXtE/y58hv1oC75TaNIXutnsOZsQ==
dependencies:
chromium-pickle-js "^0.2.0"
commander "^5.0.0"
glob "^7.1.6"
minimatch "^3.0.4"
optionalDependencies:
"@types/glob" "^7.1.1"
asn1@~0.2.3: asn1@~0.2.3:
version "0.2.4" version "0.2.4"
resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136"
@@ -2938,9 +2938,9 @@ minimist-options@4.1.0:
kind-of "^6.0.3" kind-of "^6.0.3"
minimist@^1.2.0, minimist@^1.2.5: minimist@^1.2.0, minimist@^1.2.5:
version "1.2.5" version "1.2.6"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
minipass@^2.3.5, minipass@^2.6.0, minipass@^2.9.0: minipass@^2.3.5, minipass@^2.6.0, minipass@^2.9.0:
version "2.9.0" version "2.9.0"
@@ -3732,9 +3732,9 @@ please-upgrade-node@^3.2.0:
semver-compare "^1.0.0" semver-compare "^1.0.0"
plist@^3.0.4: plist@^3.0.4:
version "3.0.4" version "3.0.5"
resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.4.tgz#a62df837e3aed2bb3b735899d510c4f186019cbe" resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.5.tgz#2cbeb52d10e3cdccccf0c11a63a85d830970a987"
integrity sha512-ksrr8y9+nXOxQB2osVNqrgvX/XQPOXaU4BQMKjYq8PvaY1U18mo+fKgBSwzK+luSyinOuPae956lSVcBwxlAMg== integrity sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA==
dependencies: dependencies:
base64-js "^1.5.1" base64-js "^1.5.1"
xmlbuilder "^9.0.7" xmlbuilder "^9.0.7"