Skip to content

Commit

Permalink
Merge commit 'c84843053a8f9e0b6af14c6b2ed33c5f82d495b3' into feat/ele…
Browse files Browse the repository at this point in the history
…ctron-fuses

# Conflicts:
#	packages/app-builder-lib/package.json
#	pnpm-lock.yaml
  • Loading branch information
mmaietta committed Oct 12, 2024
2 parents 25d4131 + c848430 commit 924894e
Show file tree
Hide file tree
Showing 19 changed files with 2,602 additions and 1,766 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-candles-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": minor
---

feat: migrate to official `electron/asar` packaging
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest TEST_FILES",
"runtimeExecutable": "pnpm",
"program": "ci:test",
"console": "integratedTerminal",
"internalConsoleOptions": "openOnFirstSessionStart",
"env": {
"TEST_FILES": "BuildTest"
}
}
]
}
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ A complete solution to package and build a ready for distribution [Electron](htt

Always looking for community contributions! 👀 Setting up a [dev environment](https://github.com/electron-userland/electron-builder/blob/master/CONTRIBUTING.md) is easy to do 🪩

**We condemn Russia’s military aggression against Ukraine. We stand with the people of Ukraine.**

## Sponsors

<table>
Expand Down
1 change: 1 addition & 0 deletions packages/app-builder-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"dependencies": {
"@develar/schema-utils": "~2.6.5",
"@electron/fuses": "^1.8.0",
"@electron/asar": "^3.2.13",
"@electron/notarize": "2.5.0",
"@electron/osx-sign": "1.3.1",
"@electron/rebuild": "3.7.0",
Expand Down
35 changes: 10 additions & 25 deletions packages/app-builder-lib/src/asar/asarFileChecker.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
import { statOrNull } from "builder-util"
import { Node, readAsar } from "./asar"
import * as asar from "@electron/asar"
import { FilesystemEntry, FilesystemFileEntry } from "@electron/asar/lib/filesystem"

/** @internal */
export async function checkFileInArchive(asarFile: string, relativeFile: string, messagePrefix: string) {
export function checkFileInArchive(asarFile: string, relativeFile: string, messagePrefix: string) {
function error(text: string) {
return new Error(`${messagePrefix} "${relativeFile}" in the "${asarFile}" ${text}`)
}

let fs
let stat: FilesystemEntry
try {
fs = await readAsar(asarFile)
stat = asar.statFile(asarFile, relativeFile, false)
} catch (e: any) {
throw error(`is corrupted: ${e}`)
}

let stat: Node | null
try {
stat = fs.getFile(relativeFile)
} catch (_e: any) {
const fileStat = await statOrNull(asarFile)
if (fileStat == null) {
throw error(`does not exist. Seems like a wrong configuration.`)
if (e.message.includes("Cannot read properties of undefined (reading 'link')")) {
throw error("does not exist. Seems like a wrong configuration.")
}

// asar throws error on access to undefined object (info.link)
stat = null
}

if (stat == null) {
throw error(`does not exist. Seems like a wrong configuration.`)
throw error(`is corrupted: ${e}`)
}
if (stat.size === 0) {
if ((stat as FilesystemFileEntry).size === 0) {
throw error(`is corrupted: size 0`)
}
return stat
}
Loading

0 comments on commit 924894e

Please sign in to comment.