Skip to content

Commit

Permalink
[Revert] Refactor Extraction methods #3181 (#3663)
Browse files Browse the repository at this point in the history
* [Revert] Refactor Extraction methods #3181

* Tech/upstream electron (#3664)

* chore: yarn.lock

* [TECH] Revert Electron to Upstream

* chore: Remove unused import in main.ts

---------

Co-authored-by: Flavio F Lima <[email protected]>

* chore: pnpm-lock

* fix: codecheck

* tests: remove unused packages

* chore: remove mock for decompress in compatibility_layers.test.ts

* chore: pr comments

* Consolidate tar file extraction into one function again (#3909)

---------

Co-authored-by: Flavio F Lima <[email protected]>
Co-authored-by: Mathis Dröge <[email protected]>
  • Loading branch information
3 people authored Aug 9, 2024
1 parent 9171769 commit 37ceada
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 581 deletions.
4 changes: 0 additions & 4 deletions electron-builder.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
appId: com.heroicgameslauncher.hgl
productName: Heroic
afterSign: sign/afterSign.js
afterPack: sign/afterPack.js
files:
- build/**/*
- node_modules/**/*
Expand All @@ -18,9 +17,6 @@ asarUnpack:
- build/bin/**/*
- '!build/bin/legendary.LICENSE'

electronDownload:
mirror: https://github.com/castlabs/electron-releases/releases/download/v

protocols:
- name: heroic
schemes:
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"dependencies": {
"@emotion/react": "11.10.6",
"@emotion/styled": "11.10.6",
"@felipecrs/decompress-tarxz": "4.0.0",
"@fontsource/cabin": "4.5.10",
"@fontsource/rubik": "4.5.14",
"@fortawesome/fontawesome-svg-core": "6.3.0",
Expand All @@ -65,9 +64,6 @@
"@mui/material": "5.11.12",
"@node-steam/vdf": "2.2.0",
"@shockpkg/icon-encoder": "2.1.3",
"@xhmikosr/decompress": "9.0.1",
"@xhmikosr/decompress-targz": "7.0.0",
"@xhmikosr/decompress-unzip": "^7.0.0",
"axios": "0.26.1",
"classnames": "2.3.1",
"compare-versions": "6.1.0",
Expand Down Expand Up @@ -133,7 +129,7 @@
"@typescript-eslint/parser": "5.47.1",
"@vitejs/plugin-react-swc": "3.6.0",
"cross-env": "7.0.3",
"electron": "github:castlabs/electron-releases#v29.1.3+wvcus",
"electron": "29.1.3",
"electron-builder": "24.13.3",
"electron-vite": "^2.0.0",
"eslint": "8.36.0",
Expand Down
405 changes: 12 additions & 393 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions sign/afterPack.js

This file was deleted.

11 changes: 3 additions & 8 deletions sign/afterSign.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// const notarize = require("./notarize").default
const vmp = require("./vmp").default
const notarize = require("./notarize").default

exports.default = async function (context) {
// await notarize(context);
console.log("Finshed Signing, signing with VMP if on Windows. Platform:", context.packager.platform.name)
if (context.packager.platform.name === 'windows') {
console.log("Signing with VMP on Windows")
await vmp(context);
}
await notarize(context);
console.log("Finshed Signing, Notarizing with Apple")
}
45 changes: 0 additions & 45 deletions sign/vmp.js

This file was deleted.

1 change: 0 additions & 1 deletion src/backend/__mocks__/@xhmikosr/decompress-targz.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/backend/__mocks__/@xhmikosr/decompress.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
protocol,
screen,
clipboard,
components,
session
} from 'electron'
import 'backend/updater'
Expand Down Expand Up @@ -317,17 +316,6 @@ if (!gotTheLock) {
)
}

if (!process.env.CI) {
await components.whenReady().catch((e) => {
logError([
'Failed to download / update DRM components.',
'Make sure you do not block update.googleapis.com domain if you want to use WideVine in Browser sideloaded apps',
e
])
})
logInfo(['DRM module staus', components.status()])
}

// try to fix notification app name on windows
if (isWindows) {
app.setAppUserModelId('Heroic Games Launcher')
Expand Down
27 changes: 10 additions & 17 deletions src/backend/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,17 @@ async function installOrUpdateTool(tool: Tool) {

const extractDestination = join(toolsPath, tool.name, latestVersion)
mkdirSync(extractDestination, { recursive: true })
try {
await extractFiles({
path: latestVersionArchivePath,
destination: extractDestination,
strip: tool.strip ?? 1
})
} catch (error) {
logError(
[`Extraction of ${tool.name} failed with:`, error],
LogPrefix.DXVKInstaller
)
return
} finally {
rmSync(latestVersionArchivePath)
}
const extractResult = await extractFiles({
path: latestVersionArchivePath,
destination: extractDestination,
strip: tool.strip ?? 1
})
rmSync(latestVersionArchivePath)

writeFileSync(installedVersionStorage, latestVersion)
logInfo(`${tool.name} updated!`, LogPrefix.DXVKInstaller)
if (extractResult.status === 'done') {
writeFileSync(installedVersionStorage, latestVersion)
logInfo(`${tool.name} updated!`, LogPrefix.DXVKInstaller)
}
}

export const DXVK = {
Expand Down
53 changes: 10 additions & 43 deletions src/backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import {
GITHUB_API,
isMac,
configStore,
isLinux,
isSnap
isLinux
} from './constants'
import {
appendGamePlayLog,
Expand Down Expand Up @@ -81,10 +80,6 @@ import { backendEvents } from './backend_events'
import { wikiGameInfoStore } from './wiki_game_info/electronStore'
import EasyDl from 'easydl'

import decompress from '@xhmikosr/decompress'
import decompressTargz from '@xhmikosr/decompress-targz'
import decompressTarxz from '@felipecrs/decompress-tarxz'
import decompressUnzip from '@xhmikosr/decompress-unzip'
import {
deviceNameCache,
vendorNameCache
Expand Down Expand Up @@ -1490,26 +1485,17 @@ interface ExtractOptions {
}

async function extractFiles({ path, destination, strip = 0 }: ExtractOptions) {
if (!isSnap && (path.endsWith('.tar.xz') || path.endsWith('.tar.gz'))) {
try {
await extractNative(path, destination, strip)
} catch (error) {
logError(['Error:', error], LogPrefix.Backend)
}
} else {
try {
await extractDecompress(path, destination, strip)
} catch (error) {
logError(['Error:', error], LogPrefix.Backend)
}
}
if (path.includes('.tar')) return extractTarFile({ path, destination, strip })

logError(['extractFiles: Unsupported file', path], LogPrefix.Backend)
return { status: 'error', error: 'Unsupported file type' }
}

async function extractNative(path: string, destination: string, strip: number) {
logInfo(
`Extracting ${path} to ${destination} using native tar`,
LogPrefix.Backend
)
async function extractTarFile({
path,
destination,
strip = 0
}: ExtractOptions) {
const { code, stderr } = await spawnAsync('tar', [
'-xf',
path,
Expand All @@ -1524,25 +1510,6 @@ async function extractNative(path: string, destination: string, strip: number) {
return { status: 'done', installPath: destination }
}

async function extractDecompress(
path: string,
destination: string,
strip: number
) {
logInfo(
`Extracting ${path} to ${destination} using decompress`,
LogPrefix.Backend
)
try {
await decompress(path, destination, {
plugins: [decompressTargz(), decompressTarxz(), decompressUnzip()],
strip
})
} catch (error) {
logError(['Error:', error], LogPrefix.Backend)
}
}

const axiosClient = axios.create({
timeout: 10 * 1000,
httpsAgent: new https.Agent({ keepAlive: true })
Expand Down
1 change: 0 additions & 1 deletion src/backend/utils/__tests__/compatibility_layers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { mkdirSync } from 'graceful-fs'
import { dirname, join } from 'path'
import { tmpdir } from 'os'

jest.mock('@xhmikosr/decompress')
jest.mock('../../logger/logfile')

describe('getDefaultWine', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@ import { unzipFile } from '../../utilities'

jest.mock('backend/logger/logger')
jest.mock('backend/logger/logfile')
jest.mock('@xhmikosr/decompress', () => {
return jest.fn().mockImplementation(async () => Promise.resolve())
})

jest.mock('@xhmikosr/decompress-unzip', () => {
return jest.fn().mockImplementation(() => {})
})

jest.mock('@xhmikosr/decompress-targz', () => {
return jest.fn().mockImplementation(() => {})
})

jest.mock('@felipecrs/decompress-tarxz', () => {
return jest.fn().mockImplementation(() => {})
})

describe('Utilities - Unzip', () => {
test('unzip file fails because of invalid archive path', async () => {
Expand Down
1 change: 0 additions & 1 deletion src/backend/wine/runtimes/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ async function extractTarFile(
extractedPath = splitPath.join('.tar')
}
mkdirSync(extractedPath, { recursive: true })

const strip = options?.strip

return extractFiles({
Expand Down
26 changes: 0 additions & 26 deletions src/common/typedefs/decompress.d.ts

This file was deleted.

0 comments on commit 37ceada

Please sign in to comment.