-
Notifications
You must be signed in to change notification settings - Fork 6
Rules 101
An update rule is a set of urls, settings and filters that allow retrieving the latest download link for an app. It is written in JSON format and located in the update-rules.json file. A rule is composed of several items:
- updater: Contains the instructions to update the download link.
- url: Points to the url where the data needed by the updater can be retrieved. The URL should only be defined there if all architectures (x86/x64) can be updated from a single URL. If not, the architecture specific urls are defined within the updater.
- version_extractor: Regular expression that extracts the version number.
- version_source (optional): Allows specifying the data source to be used for extracting the version number.
- modifiers (optional): Modifiers alter the final download link after it has been retrieved. They can be placed at the root of the rule or within the updater instructions if you wish to alter a specific link.
Note that the entry name must match that of the entry in the just-install registry for the same app.
"myapp": {
"url": "https://myapp.com/download/",
"updater": {...},
"version_extractor": "([0-9]*(?:\\.[0-9]+)*[a-z]?)\\.msi$"
}
The updater dictates how to get and process the data needed to update the registry. It contains one entry for each architecture, and must reflect the architectures present in the just-install registry file (just-install.json) for each app.
"x86":{...},
"x86_64":{...}
Each entry contains some of the following elements, depending on the rule type:
- rule_type: the type of the rule
- url: optional architecture specific url for retrieving the data
- selector: css selector used to select the relevant items on the pages
- link_attribute: the attribute from which to retrieve the link (default: "href")
- filter: regexp filter used to filter the results
- baselink: download url in which the version number can be inserted with the version placeholders.
"baselink": "https://dl.myapp.com/windows/Setup-{{.version}}.exe"
There are several flavors of this placeholder:
- {{.version}} for the raw version number.
- {{.version_}} for the version number with underscores replacing the periods.
- {{.version-}} for the version number with dashes replacing the periods.
- {{.version#}} for the version number without separators.
- {{.version[0]}} The first part of the version number (e.g. if the version is 25.32.133, this would insert 25 in the baselink)
- {{.version[1]}} The second part of the version number
- {{.version[2]}} The third part of the version number
These parameters control how the version number is extracted from the data:
version_extractor: Regexp filter used to extract the version number from the data. In general, only one set of capturing parenthesis is needed to capture the whole version number.
"version_extractor": "myapp-v([0-9]*(?:\\.[0-9]*)*).{4}\\.msi$"
If more than one set of capturing parenthesis are used, they will be concatenated together separated by coma. This can be useful if the version number is not formatted properly in the data from which it is retrieved.
"version_extractor": "myapp([0-9]{2})([0-9]{2}).{0,4}\\.msi$"
version_source (optional): By default, the version number is retrieved from the data selected/filtered by the updater. If you wish to retrieve the version number from the full web-page instead, define this parameter to "page".
"version_source": "page"
Modifiers alter the download links after they have been retrieved. The following modifiers are implemented:
- forceHTTPS: If set to true (Boolean), http links will be changed to https links.
- append: The value of this element will be added at the end of the links.
- replace: Allows replacing strings in the links. The strings are stored in pair in an array of array. See the example below to see how the strings are stored in this variable.
They can be placed at the root of the rule or within the entries of the updater if you wish to alter the link for a specific architecture only.
"myapp": {
"url": "https://myapp.com/download/",
"forceHTTPS": true,
"updater": {...},
"versioner": {...}
}
"x86":{
"rule_type": "css-link",
"selector": "#downloadButton2",
"append": "&p=win"
}
"myapp": {
"url": "https://myapp.com/download/",
"replace": [["replaced_01","replacement_01"], ["replaced_02","replacement_02"]],
"updater": {...},
"versioner": {...}
}