-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c180907
commit c810473
Showing
17 changed files
with
332 additions
and
275 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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,19 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> | ||
<meta | ||
http-equiv="Content-Security-Policy" | ||
content="default-src 'self'; script-src 'self'" | ||
/> | ||
<title>Hello World!</title> | ||
</head> | ||
|
||
<body> | ||
<h1>Hello World!</h1> | ||
We are using Node.js <span id="node-version"></span>, Chromium | ||
<span id="chrome-version"></span>, and Electron | ||
<span id="electron-version"></span>. | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -1,45 +1,50 @@ | ||
const { checkUpdate } = require("../../index.js"); | ||
const { version } = require("./dist/ver.js"); | ||
const { join } = require("path"); | ||
const { app } = require("electron"); | ||
const { join } = require("node:path"); | ||
const { checkUpdate } = require("@crabnebula/updater"); | ||
|
||
console.log(version); | ||
const UPDATER_PUB_KEY = | ||
"dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDQ2Njc0OTE5Mzk2Q0ExODkKUldTSm9XdzVHVWxuUmtJdjB4RnRXZGVqR3NQaU5SVitoTk1qNFFWQ3pjL2hZWFVDOFNrcEVvVlcK"; | ||
|
||
const updaterFormat = process.env["UPDATER_FORMAT"]; | ||
const appimg = process.env["APPIMAGE"]; | ||
const isLinux = process.platfrom !== "win32" && process.platfrom !== "darwin"; | ||
const CURRENT_VERSION = "{{version}}"; | ||
|
||
checkUpdate(version, { | ||
pubkey: | ||
"dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDQ2Njc0OTE5Mzk2Q0ExODkKUldTSm9XdzVHVWxuUmtJdjB4RnRXZGVqR3NQaU5SVitoTk1qNFFWQ3pjL2hZWFVDOFNrcEVvVlcK", | ||
endpoints: ["http://localhost:3007"], | ||
executablePath: isLinux && appimg ? appimg : undefined, | ||
windows: { | ||
installerArgs: | ||
// /D sets the default installation directory ($INSTDIR), | ||
// overriding InstallDir and InstallDirRegKey. | ||
// It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. | ||
// Only absolute paths are supported. | ||
// NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder | ||
updaterFormat === "nsis" | ||
? [`/D=${join(process.execPath, "..")}`] | ||
: undefined, | ||
}, | ||
}) | ||
.then((u) => { | ||
if (u) { | ||
u.downloadAndInstall() | ||
.then((_) => { | ||
process.exit(0); | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); | ||
app.whenReady().then(async () => { | ||
console.log(CURRENT_VERSION); | ||
|
||
const updaterFormat = process.env["UPDATER_FORMAT"]; | ||
const appimg = process.env["APPIMAGE"]; | ||
const isLinux = process.platfrom !== "win32" && process.platfrom !== "darwin"; | ||
|
||
try { | ||
const update = await checkUpdate(CURRENT_VERSION, { | ||
pubkey: UPDATER_PUB_KEY, | ||
endpoints: ["http://localhost:3007"], | ||
executablePath: isLinux && appimg ? appimg : undefined, | ||
windows: { | ||
installerArgs: | ||
// /D sets the default installation directory ($INSTDIR), | ||
// overriding InstallDir and InstallDirRegKey. | ||
// It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. | ||
// Only absolute paths are supported. | ||
// NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder | ||
updaterFormat === "nsis" | ||
? [`/D=${join(process.execPath, "..")}`] | ||
: undefined, | ||
}, | ||
}); | ||
|
||
if (update) { | ||
try { | ||
await update.downloadAndInstall(); | ||
process.exit(0); | ||
} catch (e) { | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
} else { | ||
process.exit(0); | ||
} | ||
}) | ||
.catch((e) => { | ||
} catch (e) { | ||
console.error(e); | ||
process.exit(1); | ||
}); | ||
} | ||
}); |
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 |
---|---|---|
@@ -1,14 +1,30 @@ | ||
{ | ||
"name": "updater-app-test", | ||
"bin": "main.js", | ||
"scripts": { | ||
"build": "pkg . -t host -o ./dist/updater-app-test" | ||
"name": "electron-app", | ||
"productName": "ElectronApp", | ||
"version": "1.0.0", | ||
"description": "Hello World!", | ||
"main": "main.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/crabnebula-dev/cargo-packager.git" | ||
}, | ||
"author": "CrabNebula Ltd.", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/crabnebula-dev/cargo-packager/issues" | ||
}, | ||
"homepage": "https://github.com/crabnebula-dev/cargo-packager#readme", | ||
"dependencies": { | ||
"@crabnebula/updater": "../.." | ||
}, | ||
"devDependencies": { | ||
"pkg": "^5.8.1", | ||
"@crabnebula/packager": "../../../../packager/nodejs" | ||
"electron": "^27.0.3" | ||
}, | ||
"packager": { | ||
"outDir": "./dist", | ||
"identifier": "com.electron.example", | ||
"icons": [ | ||
"electron.png" | ||
] | ||
} | ||
} |
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,10 @@ | ||
window.addEventListener("DOMContentLoaded", () => { | ||
const replaceText = (selector, text) => { | ||
const element = document.getElementById(selector); | ||
if (element) element.innerText = text; | ||
}; | ||
|
||
for (const dependency of ["chrome", "node", "electron"]) { | ||
replaceText(`${dependency}-version`, process.versions[dependency]); | ||
} | ||
}); |
Oops, something went wrong.