-
Notifications
You must be signed in to change notification settings - Fork 3
feat(auto-updater): manual DMG download flow for macOS #93
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d50c52a
build(mac): pin deterministic arch suffix in artifact names
alpha5611331 9f08b5a
feat(auto-updater): add pure helpers for macOS update matching
alpha5611331 0109adf
feat(auto-updater): manual DMG download/install flow for macOS
alpha5611331 30c2cfd
feat(preload): expose host platform to the renderer
alpha5611331 38dedc9
feat(update-notification): mac-specific install copy
alpha5611331 9c9e8d3
fix: clean up stale mac update downloads, verify DMG integrity, and f…
gitar-bot 5b479a5
test(mac-update-util): cover pre-release comparison and digest passth…
alpha5611331 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
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
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
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,69 @@ | ||
| // Pure helpers for the macOS manual-download update flow (see auto-updater.service.ts). | ||
| // No Electron imports here on purpose - keeps this directly unit-testable. | ||
|
|
||
| // Splits a version into its numeric core (e.g. "1.6.3") and an optional pre-release | ||
| // suffix (e.g. "beta.1" from "1.6.3-beta.1"). A version with a pre-release suffix is | ||
| // considered older than the same numeric core without one (per semver precedence rules). | ||
| function parseVersion(version: string): { core: number[]; prerelease: string | null } { | ||
| const [core, ...rest] = version.split('-'); | ||
| const prerelease = rest.length > 0 ? rest.join('-') : null; | ||
| const coreParts = core.split('.').map((part) => { | ||
| const num = Number(part); | ||
| return Number.isFinite(num) ? num : 0; | ||
| }); | ||
|
|
||
| return { core: coreParts, prerelease }; | ||
| } | ||
|
|
||
| export function isNewerVersion(remote: string, current: string): boolean { | ||
| const remoteVersion = parseVersion(remote); | ||
| const currentVersion = parseVersion(current); | ||
| const length = Math.max(remoteVersion.core.length, currentVersion.core.length); | ||
|
|
||
| for (let i = 0; i < length; i++) { | ||
| const remotePart = remoteVersion.core[i] ?? 0; | ||
| const currentPart = currentVersion.core[i] ?? 0; | ||
| if (remotePart !== currentPart) { | ||
| return remotePart > currentPart; | ||
| } | ||
| } | ||
|
|
||
| if (remoteVersion.prerelease === currentVersion.prerelease) { | ||
| return false; | ||
| } | ||
|
|
||
| // Same numeric core: a release (no pre-release suffix) is newer than a pre-release, | ||
| // and pre-release identifiers are compared lexically as a fallback. | ||
| if (remoteVersion.prerelease === null) { | ||
| return true; | ||
| } | ||
| if (currentVersion.prerelease === null) { | ||
| return false; | ||
| } | ||
|
|
||
| return remoteVersion.prerelease > currentVersion.prerelease; | ||
| } | ||
|
gitar-bot[bot] marked this conversation as resolved.
|
||
|
|
||
| export interface GitHubReleaseAsset { | ||
| name: string; | ||
| browser_download_url: string; | ||
| digest?: string | null; | ||
| } | ||
|
|
||
| export interface MacUpdateAsset { | ||
| name: string; | ||
| url: string; | ||
| digest: string | null; | ||
| } | ||
|
|
||
| // electron-builder's mac artifactName is pinned to `${productName}-${version}-${arch}.${ext}` | ||
| // (package.json), so every dmg unambiguously carries its arch - no defaultArch guessing. | ||
| export function pickMacAsset(assets: GitHubReleaseAsset[], arch: string): MacUpdateAsset | null { | ||
| const match = assets.find( | ||
| (asset) => asset.name.endsWith('.dmg') && asset.name.includes(`-${arch}.`) | ||
| ); | ||
|
|
||
| return match | ||
| ? { name: match.name, url: match.browser_download_url, digest: match.digest ?? null } | ||
| : null; | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.