Auto-update Electron app to a specific (non-latest) version - electron

I need to support a special release per user (or group), and I want each user will auto-update to a new available release only if it's suitable for him (by some kind of logic in the backend).
I've tried to do so by using electron-builder's electron-updater module, and also by using Electron's autoUpdater built in module, but it seems that both always fetch the latest version when calling autoUpdater.checkForUpdates.
I've seen that when deploying my own update server, some of them (such as nuts) support a download url for a specific version.
as described using nuts
Specific version for detected platform: http://download.myapp.com/download/1.1.0
but there seem to be no support to request a specific version in the app itself using autoUpdater.
summarizing all this up: How can I achieve auto-update to a specific release other than latest?

The solution for me was channels.
appUpdater.channel (getter and setter)
Define the channel which the Auto-Updater will follow (see the
auto-update with channels tutorial) using appUpdater.channel = 'beta'
or get the current channel with currentChannel = appUpdater.channel.
Note that channels are not supported when using GitHub as a provider (for now), as described in electron-builder autoUpdate documentation:
channel String - Get the update channel. Not applicable for GitHub. Doesn’t return channel from the update configuration, only if was previously set.
You can set the channel name to anything, and can even dynamically (if needed) direct your users to pull updates from that channel.
You can also edit the {your-channel-name}.latest file manually and add parameters that will help you determine whether the current "asking for update" user should consume the certain version (in the update-available event from the updateInfo parameter for example).

Related

Get specific release from github releases for electron-updater

I'm building an electron application that will be distributed to different clients. Currently, I'm testing how to update the application.
To describe my problem:
In order for this application to work client must buy a licens. And based on this licens I know who the client is and what features does he need. On star I must call my API endpoint that checks clients licens and returns where electron-updater should go and check for updates (not all clients get the same version; it's even possible that one client has a completely different version of the application from others).
Currently, I'm testing with local http-server and my URL look something like this: http://localhost:8080/v0.0.3 (inside this map I have the installer, latest.yml and blockmap files) and in main.js I use it like this:
autoUpdater.setFeedURL({
provider: 'generic',
url: ret.url // <- http://localhost:8080/v0.0.3
});
autoUpdater.checkForUpdates();
So far this approach works fine, but I'm testing now if it would be possible to use GitHub repository and through my API return URL to specific version, because all I could achieve from using GitHub was getting the latest version (it would be great if repository could be private).
So if it is could it be done something like this: https://github.com/<user>/<repo>/releases/tag/v0.0.3

How to create custom AR button

Does someone have any examples how to generate AR URL?
Reading Web SDK documentation, seems that there is no functionality to do that.
Found https://github.com/Roomle/roomle-button but not sure that`s still way to go since it has not been updated for 2 years.
If you are using the Roomle SDK you can use saveCurrentConfiguration to get the configuration id (hash) of the current configuration. Not sure what you used at the moment to obtain a configuration id but you need to call this in order to save it on the Roomle server and open it in another place.
Also make sure to set the configuratorId URL param when linking to the AR site.

Getting file version from TFS rest API Get Item

I am pulling a file from on premise TFS source control using the Rest API. I can't find on premise specific documentation, but it seems to be very close to version 4.1 of the Azure Get Item call. According to this documentaiton, it should return a TfvcItem object which has a lot of metadata including the version. However, when I make the call it only returns the file contents (the content field of the documentation's TfvcItem).
How do I get the current version of the file?
I need the version when I check itin with create changeset. I don't need it for any other reason, so if you know another way to check in an edited file that would help.
Instead of using Get Item API, some related REST APIs are not documented. For these REST APIs we can use tools such as Fiddler or directly press F12 - network in Chrome to track them.
You should use below API to fetch latest changeset version of a file:
post https://dev.azure.com/{organizationname}/{Projectname}/_api/_versioncontrol/history?__v=5
For body:
{"repositoryId":"","searchCriteria":"{\"itemPath\":\"$/MyFirstProject/Main/1.txt\",\"itemVersion\":\"T\",\"top\":50}"}
itemPath is your server path of the file.
From the response, you will get the version info such as "version": "139", instead of the file content.
Not sure your detail version of TFS, I was using Azure DevOps Service for an example. There maybe some difference for different TFS version. You could track the detail API on your own side.
More detail info kindly take a look at this question: VSTS Release API Documentation
Had the same issue. You can get item metadata by specifying "scopePath" URI parameter, instead of "path". Microsoft example in API documentation seems incorrect, as it indeed returns only item content: https://learn.microsoft.com/en-us/rest/api/azure/devops/tfvc/items/get?view=azure-devops-rest-6.0#get-item-metadata-and/or-content-for-a-single-item.

Workbox's service worker not updating when changed

Explanation
I'm having an issue with Workbox where my website doesn't update when a file's content is changed, unless I manually clear storage/site data in my browser.
Since v4 release this year, the cleanupOutdatedCaches, which is in my code, should take care of this, but the problem persists.
Example
I created this website to exemplify. Once you access it, Workbox will install the service worker, but if I change, for example, test1 to test2, you won't see the change, unless you clear the site data in your browser and refresh.
I also tried only unregistering the sw; it shows the updated version (test2), but when refreshing twice it goes back to the old version (test1).
You can see the website's code in GitHub here.
Thanks in advance,
Luiz.
cleanOutdatedCaches will only clean caches created by older versions of the workbox library. In this case, since you are using the same version fo workbox, the call to this method does nothing.
https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.precaching#.cleanupOutdatedCaches
Once a particular file is precached by Workbox, it will never attempt to retrieve that file from the network, unless the revision you have specified in the precacheAndRoute call is different from what was previously cached.
Since you changed index.html but not the revision in precacheAndRoute, workbox assumes the file is unchanged. So,what you need to do is to update the precacheAndRoute with a new hash that corresponds to the new version of index.html
You can achieve this by either using injectManifest
https://developers.google.com/web/tools/workbox/modules/workbox-build
or any other build tooling you use.
Edit:
You can invoke skipWaiting programmatically as well
https://developers.google.com/web/tools/workbox/modules/workbox-core#skip_waiting_and_clients_claim
But you do need to use it with caution. Here is one way to do it :
https://developers.google.com/web/tools/workbox/guides/advanced-recipes

Building Passbook Passes

I've been working on integration of Passbook for some of my apps. Right now, I've used Ray Wenderlich's tutorial on this, and it is quite frankly a pain to build even one Pass. I have to get the icon files all in place, program the JSON file, get the manifest file filled in with all the SHA1 values, and run a few lines in terminal to sign it, and then another line to zip it. Are there any online services or programs that can be used to save a pkpass file to computer, that I can then upload to my server?
There are also quite some developer tools that help you to create passes, you can find a list on wikipedia.
We provide an Objective-C SDK and a free cloud service that lets you create templates and generate passes. You can find the SDK on github (Sample App is included).
There are a number of services that can be used to generate passess. Take a look on wikipedia for a comprehensive list of providers, tools and projects.
If you want to update passes, then you will need to build a Passbook Web Service. When a pass is updated, the web service sends a new .pkpass bundle to the device. Therefore, your web service must also be capable of signing passes unless you want to manually create and upload them to your server before sending out a push request.
Using our service, PassKit, you can create a template using WSIYWIG editor then create a pass directly on your server via a simple API call. You can also update passes and push updates to passes via our API. If you just want to get hold of the .pkpass bundle, then you can append /d to the pass URL (the one beginning with r.pass.is), or use PassKit API in your User Agent string.
you should also check out Apple's Passbook Support Materials here:
https://developer.apple.com/passbook/
They have a simple XCode project called SignPass that you can use to easily create your own Passes.
Note: you need to be a member of Apple's Developer program to access these materials ..
There's lots more Passbook related info here:
http://www.flonsolutions.com
Andrew

Resources