Working project
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Publish/
|
||||
dist/
|
||||
Caddy/caddy.exe
|
||||
4
Caddy/caddyfile
Normal file
4
Caddy/caddyfile
Normal file
@@ -0,0 +1,4 @@
|
||||
http://localhost:7070 {
|
||||
root * ../publish
|
||||
file_server
|
||||
}
|
||||
130
Proof/.gitignore
vendored
Normal file
130
Proof/.gitignore
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
14
Proof/README.md
Normal file
14
Proof/README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
Where I found to configure a custom build
|
||||
https://gist.github.com/layerssss/5d7b69c0f8c6e54e8b501e6e0fe36186
|
||||
|
||||
there is a bit of tooling to setup. there is also some things to consider
|
||||
I discovered if the publish folder is in the root, the build kept adding all those files to the installer
|
||||
The installer didn't put them anywhere that I found.
|
||||
The installer was greater than 1 gb when I noticed.
|
||||
The build was taking a lot of time until I moved the publish folder.
|
||||
|
||||
I feel the installer should be per user. The per machine requires administrative access.
|
||||
|
||||
I was able to work out the process that allowed the autoupdater to run before the window is shown.
|
||||
We should display a window that an update is downloading. This will keep the user from clicking multiple times.
|
||||
That can be displayed in the update-available event.
|
||||
15
Proof/build/electron-publisher-custom.js
Normal file
15
Proof/build/electron-publisher-custom.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const { Publisher } = require("electron-publish");
|
||||
const fsPromises = require("fs/promises");
|
||||
const path = require("path");
|
||||
|
||||
module.exports = class CustomPublisher extends Publisher {
|
||||
// more about task:
|
||||
// https://github.com/electron-userland/electron-builder/blob/a94532164709a545c0f6551fdc336dbc5377bda8/packages/electron-publish/src/publisher.ts#L29
|
||||
async upload(task) {
|
||||
const filename = path.basename(task.file);
|
||||
await fsPromises.cp(
|
||||
task.file,
|
||||
path.join(__dirname, "../../publish", filename)
|
||||
);
|
||||
}
|
||||
};
|
||||
2765
Proof/package-lock.json
generated
Normal file
2765
Proof/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
35
Proof/package.json
Normal file
35
Proof/package.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "autoupdateproof",
|
||||
"productName": "Auto updater proof",
|
||||
"version": "1.0.5",
|
||||
"description": "Auto updater proof of concept",
|
||||
"main": "src/js/main.js",
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"dist": "electron-builder --publish always"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.tracypearson.autoupdateproof",
|
||||
"win": {
|
||||
"target": "nsis",
|
||||
"publish": {
|
||||
"provider": "custom"
|
||||
}
|
||||
},
|
||||
"nsis": {
|
||||
"oneClick": false,
|
||||
"perMachine": true,
|
||||
"allowToChangeInstallationDirectory": true,
|
||||
"installerIcon": null
|
||||
}
|
||||
},
|
||||
"author": "Tracy Pearson",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"electron-updater": "^5.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^23.0.0",
|
||||
"electron-builder": "^23.6.0"
|
||||
}
|
||||
}
|
||||
22
Proof/src/index.html
Normal file
22
Proof/src/index.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!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'"
|
||||
/>
|
||||
<meta
|
||||
http-equiv="X-Content-Security-Policy"
|
||||
content="default-src 'self'; script-src 'self'"
|
||||
/>
|
||||
<title>Hello from Electron renderer!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello from Electron renderer!</h1>
|
||||
<p>👋</p>
|
||||
<p id="info"></p>
|
||||
</body>
|
||||
<script src="./js/renderer.js"></script>
|
||||
</html>
|
||||
40
Proof/src/js/main.js
Normal file
40
Proof/src/js/main.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
const createWindow = () => {
|
||||
const win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
ipcMain.handle('ping', () => 'pong')
|
||||
ipcMain.handle('getVersion',() => app.getVersion())
|
||||
win.loadFile('src/index.html')
|
||||
}
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
|
||||
|
||||
function runUpdater() {
|
||||
const { autoUpdater } = require("electron-updater")
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
autoUpdater.quitAndInstall()
|
||||
})
|
||||
autoUpdater.on('update-available', () => {
|
||||
autoUpdater.downloadUpdate()
|
||||
})
|
||||
autoUpdater.on('update-not-available', () => {
|
||||
createWindow()
|
||||
})
|
||||
autoUpdater.setFeedURL("http://localhost:7070")
|
||||
autoUpdater.checkForUpdates()
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
runUpdater()
|
||||
})
|
||||
10
Proof/src/js/preload.js
Normal file
10
Proof/src/js/preload.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('versions', {
|
||||
getNodeVersion: () => process.versions.node,
|
||||
getChromeVersion: () => process.versions.chrome,
|
||||
getElectronVersion: () => process.versions.electron,
|
||||
getAppVersion: () => ipcRenderer.invoke('getVersion'),
|
||||
ping: () => ipcRenderer.invoke('ping')
|
||||
// we can also expose variables, not just functions
|
||||
})
|
||||
13
Proof/src/js/renderer.js
Normal file
13
Proof/src/js/renderer.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const information = document.getElementById('info')
|
||||
async function setInnerTextOfInfo() {
|
||||
let appVersion = await window.versions.getAppVersion()
|
||||
information.innerText = `This app is version (v${appVersion}) using Chrome (v${versions.getChromeVersion()}), Node.js (v${versions.getNodeVersion()}), and Electron (v${versions.getElectronVersion()})`
|
||||
}
|
||||
setInnerTextOfInfo()
|
||||
|
||||
const func = async() => {
|
||||
const response = await window.versions.ping()
|
||||
console.log(response)
|
||||
}
|
||||
|
||||
func()
|
||||
Reference in New Issue
Block a user