-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: auto updater electron forge (#547)
* fix prod publish gha * use autoUpdater from electron with github feedUrl for dialog control * deb and rpm updater split with package manager selection
- Loading branch information
Showing
10 changed files
with
497 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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,66 @@ | ||
import { exec as execCallback } from 'node:child_process'; | ||
import { promisify } from 'node:util'; | ||
|
||
const exec = promisify(execCallback); | ||
|
||
export type PackageType = "deb" | "rpm"; | ||
export type PackageManager = "dpkg" | "dnf" | "yum" | "zypper"; | ||
|
||
interface PackageManagerMap { | ||
[key: string]: PackageManager; | ||
} | ||
|
||
interface PackageManagerToTypeMap { | ||
[key: string]: PackageType; | ||
} | ||
|
||
const packageManagers: PackageManagerMap = { | ||
"apt-get": "dpkg", // "deb (apt)", | ||
dnf: "dnf", // "rpm (dnf)", | ||
yum: "yum", // "rpm (yum)", | ||
// pacman: "pacman", | ||
zypper: "zypper", // "rpm (zypper)" | ||
}; | ||
|
||
const packageTypes: PackageManagerToTypeMap = { | ||
"apt-get": "deb", // "deb (apt)", | ||
dnf: "rpm", // "rpm (dnf)", | ||
yum: "rpm", // "rpm (yum)", | ||
// pacman: "pacman", | ||
zypper: "rpm", // "rpm (zypper)" | ||
}; | ||
|
||
export const findPackageManager = async (): Promise<PackageManager | null> => { | ||
for (const pkgManager of Object.keys(packageManagers)) { | ||
try { | ||
const { stdout } = await exec(`command -v ${pkgManager}`); | ||
if (stdout.trim()) { | ||
return packageManagers[pkgManager]; | ||
} | ||
} catch (error) { | ||
// Command not found, continue checking the next | ||
} | ||
} | ||
// "Package manager not found."; | ||
return null; | ||
} | ||
|
||
export const findPackageType = async (): Promise<PackageType | null> => { | ||
for (const pkgManager of Object.keys(packageManagers)) { | ||
try { | ||
const { stdout } = await exec(`command -v ${pkgManager}`); | ||
if (stdout.trim()) { | ||
return packageTypes[pkgManager]; | ||
} | ||
} catch (error) { | ||
// Command not found, continue checking the next | ||
} | ||
} | ||
// "Package manager not found."; | ||
return null; | ||
} | ||
|
||
// (async () => { | ||
// const result = await findPackageManager(); | ||
// console.log("+++++++++++++++++++++++++", result); | ||
// })(); |
Oops, something went wrong.