Open ezekg opened 6 years ago
what the updateTo key is actually supposed to point to, whether updateTo
updateTo
is effectively just the JSON payload an update server would respond with if you wanted to update to the given version. I.e. The JSON structure can be simplified to this
{
currentRelease: '1.2.3', // The latest version available
releases: [
{
version: '1.2.2', // The version number for this payload
updateTo: { ... } // The update server payload for this version
},
{
version: '1.2.3', // The version number for this payload
updateTo: { ... } // The update server payload for this version
}
]
}
Only one extra field is in updateTo
and that is version
.
How does Squirrel determine an update is required from the static JSON file?
Is does a version comparison between the version you provide Squirrel and the version in currentRelease
. If currentRelease
is determined to be higher it will trigger the update to that version.
Does the releases key need to be sorted or anything like that?
I don't believe so
Right now, the example schema's releases point to themselves (via updateTo). Is that correct?
Yes
Also, do we point Squirrel's updater directly to the file (with .json extension?)
Yes, you should point it directly to http://mysite.com/updates/myFileCalledAnything.json
Lastly, the static file example contains invalid JSON.
Woops
Cool, appreciate the clarification. I think the readme should be updated to make all of that a bit clearer for everybody in the future. Iβm open to providing a PR, if that helps. π
Iβm open to providing a PR, if that helps.
That'd be great, I'm not sure what exactly is missing because I kinda have everything in my head. So whatever you found useful if that could go in a PR that'd be awesome π
{
"currentRelease": "1.0.1",
"releases": [{
"version": "1.0.0",
"updateTo": {
"url": "https://s3-us-west-1.amazonaws.com/app-updator.innovatorsdna.com/idna-training-companion/releases/mac/1.0.1.zip"
}
},
{
"version": "1.0.1",
"updateTo": {
"url": "https://s3-us-west-1.amazonaws.com/app-updator.innovatorsdna.com/idna-training-companion/releases/mac/1.0.1.zip"
}
}
]
}
whats wrong in this json ?
@ricky300300 are you asking because the updater is not accepting that json file?
Hi @ezekg, I also share your confusion with the JSON formatting requirements from the README. Did you ever get around to creating that PR? I can gladly pick up the baton here if I can get some help getting mine to work.
@MarshallOfSound Thanks for your detailed response. I've got a question for you on this response:
Only one extra field is in updateTo and that is version.
What do you mean by that?
I'm confused by the following format of updateTo
:
{
"currentRelease": "1.2.3",
"releases": [
{
"version": "1.2.1",
"updateTo": {
"version": "1.2.1",
"pub_date": "2013-09-18T12:29:53+01:00",
"notes": "Theses are some release notes innit",
"name": "1.2.1",
"url": "https://mycompany.example.com/myapp/releases/myrelease"
}
},
{
"version": "1.2.3",
"updateTo": {
"version": "1.2.3",
"pub_date": "2014-09-18T12:29:53+01:00",
"notes": "Theses are some more release notes innit",
"name": "1.2.3",
"url": "https://mycompany.example.com/myapp/releases/myrelease3"
}
}
]
}
What is the point of having version
inside of updateTo
? It seems redundant, given that the version
is stated in the sibling node of updateTo
.
And just to be clear, this url
line:
"url": "https://mycompany.example.com/myapp/releases/myrelease"
Should be pointing to the .zip
file of the update, correct? Something like:
"url": "https://mycompany.example.com/myapp/releases/1.2.3.zip"
I appreciate all the help and will certainly make some edits to the README if you can help me get this working.
Thanks!
Check my answer below.
Is this feature working (in Electron context)?
I've tested with the default server style - response 204 and response 200 with json that contains the link to the updated file. It works, but not quite, because Squirrel keeps some internal cache and doesn't fetch the most recent .zip file. (It might be nginx configuration). I'm using the following nginx configuration and this works correctly from the browser.
server {
# add the following record to your hosts file
# 127.0.0.1 squirrel
listen 9001;
server_name squirrel;
location / {
root /Users/emilatanasov/squirrel;
index index.html index.htm;
try_files $uri $uri/ =404;
}
location ~ /osx/latest/(?<version>.*)$ {
alias /Users/emilatanasov/squirrel/osx/latest/;
if (-f /Users/emilatanasov/squirrel/osx/latest/$version.zip) {
# add_header Content-Type text/plain;
return 204 'Latest version: $1';
break;
}
expires 1M;
try_files version.json 404;
index index.html index.htm;
}
location /osx/version {
alias /Users/emilatanasov/squirrel/osx/version;
}
# the following file structure should be created
# /osx
# /latest
# /1.1.0.zip
# /version.json
# /version
# /1.0.1.zip
# /1.0.2.zip
# /1.0.10.zip
# /1.1.0.zip
# the content of version.json should be
# {
# "url": "http://squirrel:9001/osx/version/1.1.0.zip"
# }
}
With the new approach, in a single JSON file, I always get:
[Error: Update check failed. The server sent an invalid JSON response. Try again later.] {
code: 6,
domain: 'SQRLUpdaterErrorDomain'
}
I've found the proper part of the documentation on Electron page - https://www.electronjs.org/docs/api/auto-updater#methods. In short, it's working, but the correct options should be passed.
Could we update the documentation to reflect the flag that should be passed. If you are coming from Electron project it might slip.
The static json can be used if the Squirrel is initialized properly. For more information check the documentation. In Electron context you can find the required information here - https://www.electronjs.org/docs/api/auto-updater#methods
I'm agree with this issue.
I have this json:
{ "currentRelease": "3.3.118", "releases": [ { "version": "3.3.118", "updateTo": { "pub_date" : "2020-09-11T15:24:55-05:00", "version": "10.0.119_future", "name": "MyApp", "url": "https://path/to/release/MyApp.zip" } } ] }
My actual version is 3.3.118
The url is available but in the application goes on appearing the log:
2020-09-16T15:05:28.594Z - debug: app-updater - on: updates-not-available
If I upload this json the update is done properly:
{ "currentRelease": "8.2.3", "releases": [ { "version": "8.2.3", "updateTo": { "pub_date" : "2020-09-11T15:24:55-05:00", "version": "10.0.119_future", "name": "MyApp", "url": "https://path/to/release/MyApp.zip" } } ] }
Why the autoUpdater is updating with the electron version instead of myApp version?
@borlam you have to create a proper release, then your version is reflected properly. You can print the app version with the following code:
const electron = require('electron')
const app = electron.app
app.getVersion()
Hi @heitara,
I have a release inside a dmg.
This is my code for view the version and the autoupdate:
import { ipcMain, app, autoUpdater } from 'electron'; ...... dir = config.darwin + '/update-darwin.json'; fullurl = baseUrl + dir; serverType = 'json'; autoUpdater.setFeedURL({ url: fullurl, serverType: serverType }); autoUpdater.checkForUpdates();
app.getVersion() shows 3.3.118
:O
The electron version is 8.2.3
The app version is 3.3.118
With the following json doesn't update:
{ "currentRelease": "3.3.118", "releases": [ { "version": "3.3.118", "updateTo": { "pub_date" : "2020-09-11T15:24:55-05:00", "version": "10.0.119_future", "name": "MyApp", "url": "https://path/to/release/MyApp.zip" } } ] }
With the following json update:
{ "currentRelease": "8.2.3", "releases": [ { "version": "8.2.3", "updateTo": { "pub_date" : "2020-09-11T15:24:55-05:00", "version": "10.0.119_future", "name": "MyApp", "url": "https://path/to/release/MyApp.zip" } } ] }
I don' know what to do. I need help please.
It won't update, because the app is at the latest version 3.3.118
and you have the same version in the json file.
It updates with the later JSON because 8.2.3
is different from 3.3.118
.
I think this json says version 3.3.118 must update to 10.0.119_future", "name": "MyApp", "url": "https://path/to/release/MyApp.zip"
Could you please propose how to should be the json? I have the version 3.3.118 and the version 10.0.119
You have to change currentRelease": "8.2.3" to the release that's it the most recent one and you want every one to use.
@heitara how do you fix SQRLUpdaterErrorDomain error?
@lockiechen I'm using the following:
// mac os
let updateOptions = {};
updateOptions.serverType = 'json';
updateOptions.url = updateFeed; // .json url
//...
autoUpdater.setFeedURL(updateOptions)
Is there any reason not to only put the latest version info in releases
?
It's fine. Just keep the format of the json. You can have a single version the releases array.
@lockiechen I'm using the following:
// mac os let updateOptions = {}; updateOptions.serverType = 'json'; updateOptions.url = updateFeed; // .json url //... autoUpdater.setFeedURL(updateOptions)
This works, thanks a lot!
The new section in the readme about updates using a static JSON file (implemented in #219) isn't very clear as to e.g. what the
updateTo
key is actually supposed to point to, whetherupdateTo
points to the current version or the next version. It might be a good idea to clearly state the schema and what each key is for and how Squirrel processes it.How does Squirrel determine an update is required from the static JSON file? Is the version comparison done within Squirrel, or is it supposed to be handled in the JSON file? Does the
releases
key need to be sorted or anything like that?Right now, the example schema's releases point to themselves (via
updateTo
). Is that correct? What should a release look like when it doesn't have a version to update to i.e. it's the latest version?Also, do we point Squirrel's updater directly to the file (with
.json
extension?), or does Squirrel need a specific filename that it will automatically fetch similar to Squirrel.WindowsRELEASES
file?Lastly, the static file example contains invalid JSON. π