Repository navigation
fix(builds): read the macOS update floor from the packaged app #2111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,7 +132,6 @@ | |
| }, | ||
| "pnpm": { | ||
| "onlyBuiltDependencies": [ | ||
| "electron", | ||
| "electron-winstaller", | ||
| "esbuild", | ||
| "node-pty" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import fs from 'fs' | ||
| import os from 'os' | ||
| import path from 'path' | ||
| import { pathToFileURL } from 'url' | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| interface ReleaseInfo { | ||
| releaseNotes?: string | ||
| minimumSystemVersion?: string | ||
| } | ||
|
|
||
| interface PackContext { | ||
| electronPlatformName: string | ||
| appOutDir: string | ||
| packager: { | ||
| config: { releaseInfo?: ReleaseInfo } | ||
| platformSpecificBuildOptions: { releaseInfo?: ReleaseInfo } | ||
| getResourcesDir: (appOutDir: string) => string | ||
| } | ||
| } | ||
|
|
||
| interface AfterPackModule { | ||
| default: (context: PackContext) => Promise<void> | ||
| } | ||
|
|
||
| const APP_BUNDLE = 'Comfy Desktop.app' | ||
| const afterPackUrl = pathToFileURL(path.join(process.cwd(), 'scripts', 'afterPack.mjs')).href | ||
| const packedApps: string[] = [] | ||
|
|
||
| function packedMacApp(minimumMacOS: string | null): string { | ||
| const appOutDir = fs.mkdtempSync(path.join(os.tmpdir(), 'packed-mac-app-')) | ||
| packedApps.push(appOutDir) | ||
| const contentsDir = path.join(appOutDir, APP_BUNDLE, 'Contents') | ||
| fs.mkdirSync(contentsDir, { recursive: true }) | ||
| const minimumSystemEntry = | ||
| minimumMacOS === null | ||
| ? '' | ||
| : `\t<key>LSMinimumSystemVersion</key>\n\t<string>${minimumMacOS}</string>\n` | ||
| fs.writeFileSync( | ||
| path.join(contentsDir, 'Info.plist'), | ||
| [ | ||
| '<?xml version="1.0" encoding="UTF-8"?>', | ||
| '<plist version="1.0">', | ||
| '<dict>', | ||
| '\t<key>CFBundleName</key>', | ||
| '\t<string>Comfy Desktop</string>', | ||
| `${minimumSystemEntry}</dict>`, | ||
| '</plist>', | ||
| '' | ||
| ].join('\n') | ||
| ) | ||
| return appOutDir | ||
| } | ||
|
|
||
| function macPackContext(appOutDir: string, releaseInfo?: ReleaseInfo): PackContext { | ||
| return { | ||
| electronPlatformName: 'darwin', | ||
| appOutDir, | ||
| packager: { | ||
| config: { releaseInfo }, | ||
| platformSpecificBuildOptions: {}, | ||
| getResourcesDir: (dir) => path.join(dir, APP_BUNDLE, 'Contents', 'Resources') | ||
| } | ||
| } | ||
| } | ||
|
|
||
| async function runAfterPack(context: PackContext): Promise<void> { | ||
| const hook = (await import(afterPackUrl)) as AfterPackModule | ||
| await hook.default(context) | ||
| } | ||
|
|
||
| describe('the macOS update manifest', () => { | ||
| beforeEach(() => { | ||
| vi.spyOn(console, 'log').mockImplementation(() => {}) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| vi.restoreAllMocks() | ||
| for (const dir of packedApps.splice(0)) fs.rmSync(dir, { recursive: true, force: true }) | ||
| }) | ||
|
|
||
| it('holds an update back from a Mac older than the packaged app itself supports', async () => { | ||
| const context = macPackContext(packedMacApp('13.0'), { releaseNotes: 'What changed' }) | ||
|
|
||
| await runAfterPack(context) | ||
|
|
||
| expect(context.packager.platformSpecificBuildOptions.releaseInfo).toEqual({ | ||
| releaseNotes: 'What changed', | ||
| minimumSystemVersion: '22.0.0' | ||
| }) | ||
| }) | ||
|
|
||
| it('follows the app when a later Electron raises the macOS it needs', async () => { | ||
| const context = macPackContext(packedMacApp('26.0')) | ||
|
|
||
| await runAfterPack(context) | ||
|
|
||
| expect(context.packager.platformSpecificBuildOptions.releaseInfo?.minimumSystemVersion).toBe( | ||
| '25.0.0' | ||
| ) | ||
| }) | ||
|
|
||
| it('fails the build when the app needs a macOS whose Darwin version is not known', async () => { | ||
| const context = macPackContext(packedMacApp('99.0')) | ||
|
|
||
| await expect(runAfterPack(context)).rejects.toThrow('no Darwin version known for macOS 99.0') | ||
| }) | ||
|
|
||
| it('fails the build when the app does not say which macOS it needs', async () => { | ||
| const context = macPackContext(packedMacApp(null)) | ||
|
|
||
| await expect(runAfterPack(context)).rejects.toThrow('LSMinimumSystemVersion not found') | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail the build on minor or patch floors instead of lowering them.
darwinVersionForMacOSkeeps only the major number. A floor of13.3.0becomes22.0.0.LSMinimumSystemVersionallows minor revision numbers, so a valid floor can lose its minor part. Every Darwin 22.x release is above22.0.0, so the published floor admits older macOS 13.x releases that the app's floor excludes.The repository does not set
LSMinimumSystemVersionthroughextendInfoorminimumSystemVersion, and the reported build produced13.0. This path needs a deliberate minor-version override, so the impact is latent. Until the code maps minor versions to Darwin versions, reject those values:Suggested fix
Add a
13.3.0case tomacUpdateFloor.test.tsthat expects this error. Failing closed is safer than publishing a floor that admits unsupported systems.