mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Added support for pre-releases
This commit is contained in:
parent
f6640bcc32
commit
8ff2418b02
@ -589,7 +589,7 @@ class Application extends BaseApplication {
|
||||
}, {
|
||||
label: _('Check for updates...'),
|
||||
click: () => {
|
||||
bridge().checkForUpdates(false, bridge().window(), this.checkForUpdateLoggerPath());
|
||||
bridge().checkForUpdates(false, bridge().window(), this.checkForUpdateLoggerPath(), { includePreReleases: Setting.value('autoUpdate.includePreReleases') });
|
||||
}
|
||||
}, {
|
||||
type: 'separator',
|
||||
@ -772,7 +772,7 @@ class Application extends BaseApplication {
|
||||
if (shim.isWindows() || shim.isMac()) {
|
||||
const runAutoUpdateCheck = () => {
|
||||
if (Setting.value('autoUpdateEnabled')) {
|
||||
bridge().checkForUpdates(true, bridge().window(), this.checkForUpdateLoggerPath());
|
||||
bridge().checkForUpdates(true, bridge().window(), this.checkForUpdateLoggerPath(), { includePreReleases: Setting.value('autoUpdate.includePreReleases') });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,9 +116,9 @@ class Bridge {
|
||||
return require('electron').shell.openItem(fullPath)
|
||||
}
|
||||
|
||||
checkForUpdates(inBackground, window, logFilePath) {
|
||||
checkForUpdates(inBackground, window, logFilePath, options) {
|
||||
const { checkForUpdates } = require('./checkForUpdates.js');
|
||||
checkForUpdates(inBackground, window, logFilePath);
|
||||
checkForUpdates(inBackground, window, logFilePath, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,15 +29,35 @@ function onCheckEnded() {
|
||||
isCheckingForUpdate_ = false;
|
||||
}
|
||||
|
||||
async function fetchLatestRelease() {
|
||||
const response = await fetch('https://api.github.com/repos/laurent22/joplin/releases/latest');
|
||||
async function fetchLatestRelease(options) {
|
||||
options = Object.assign({}, { includePreReleases: false }, options);
|
||||
|
||||
if (!response.ok) {
|
||||
const responseText = await response.text();
|
||||
throw new Error('Cannot get latest release info: ' + responseText.substr(0,500));
|
||||
let json = null;
|
||||
|
||||
if (options.includePreReleases) {
|
||||
// This end-point will include all releases, including pre-releases (but not draft), so we take
|
||||
// whatever is the latest release. It might be the same as releases/latest, or it might be
|
||||
// a pre-release.
|
||||
const response = await fetch('https://api.github.com/repos/laurent22/joplin/releases');
|
||||
|
||||
if (!response.ok) {
|
||||
const responseText = await response.text();
|
||||
throw new Error('Cannot get latest release info: ' + responseText.substr(0,500));
|
||||
}
|
||||
|
||||
json = await response.json();
|
||||
if (!json.length) throw new Error('Cannot get latest release info: ' + responseText.substr(0,500));
|
||||
json = json[0];
|
||||
} else {
|
||||
const response = await fetch('https://api.github.com/repos/laurent22/joplin/releases/latest');
|
||||
|
||||
if (!response.ok) {
|
||||
const responseText = await response.text();
|
||||
throw new Error('Cannot get latest release info: ' + responseText.substr(0,500));
|
||||
}
|
||||
|
||||
json = await response.json();
|
||||
}
|
||||
|
||||
const json = await response.json();
|
||||
|
||||
const version = json.tag_name.substr(1);
|
||||
let downloadUrl = null;
|
||||
@ -69,10 +89,11 @@ async function fetchLatestRelease() {
|
||||
downloadUrl: downloadUrl,
|
||||
notes: json.body,
|
||||
pageUrl: json.html_url,
|
||||
prerelease: json.prerelease,
|
||||
};
|
||||
}
|
||||
|
||||
function checkForUpdates(inBackground, window, logFilePath) {
|
||||
function checkForUpdates(inBackground, window, logFilePath, options) {
|
||||
if (isCheckingForUpdate_) {
|
||||
autoUpdateLogger_.info('checkForUpdates: Skipping check because it is already running');
|
||||
return;
|
||||
@ -91,9 +112,12 @@ function checkForUpdates(inBackground, window, logFilePath) {
|
||||
|
||||
checkInBackground_ = inBackground;
|
||||
|
||||
fetchLatestRelease().then(release => {
|
||||
autoUpdateLogger_.info('checkForUpdates: Checking with options ' + JSON.stringify(options));
|
||||
|
||||
fetchLatestRelease(options).then(release => {
|
||||
autoUpdateLogger_.info('Current version: ' + packageInfo.version);
|
||||
autoUpdateLogger_.info('Latest version: ' + release.version);
|
||||
autoUpdateLogger_.info('Is Pre-release:', release.prerelease);
|
||||
|
||||
if (compareVersions(release.version, packageInfo.version) <= 0) {
|
||||
if (!checkInBackground_) dialog.showMessageBox({ message: _('Current version is up-to-date.') })
|
||||
|
@ -105,6 +105,7 @@ class Setting extends BaseModel {
|
||||
'style.editor.fontSize': {value: 12, type: Setting.TYPE_INT, public: true, appTypes: ['desktop'], label: () => _('Editor font size'), minimum: 4, maximum: 50, step: 1},
|
||||
'style.editor.fontFamily': {value: "", type: Setting.TYPE_STRING, public: true, appTypes: ['desktop'], label: () => _('Editor font family'), description: () => _('This must be *monospace* font or it will not work properly. If the font is incorrect or empty, it will default to a generic monospace font.')},
|
||||
'autoUpdateEnabled': { value: true, type: Setting.TYPE_BOOL, public: true, appTypes: ['desktop'], label: () => _('Automatically update the application') },
|
||||
'autoUpdate.includePreReleases': { value: false, type: Setting.TYPE_BOOL, public: true, appTypes: ['desktop'], label: () => _('Get pre-releases when checking for updates'), description: () => _('See the pre-release page for more details: %s', 'https://joplin.cozic.net/prereleases') },
|
||||
'clipperServer.autoStart': { value: false, type: Setting.TYPE_BOOL, public: false },
|
||||
'sync.interval': { value: 300, type: Setting.TYPE_INT, isEnum: true, public: true, label: () => _('Synchronisation interval'), options: () => {
|
||||
return {
|
||||
|
@ -24,7 +24,7 @@ async function main() {
|
||||
|
||||
const releaseOptions = { isDraft: true, isPreRelease: !!argv.beta };
|
||||
|
||||
console.info('Release options: ' + releaseOptions);
|
||||
console.info('Release options: ', releaseOptions);
|
||||
|
||||
const release = await githubRelease('joplin', tagName, releaseOptions);
|
||||
|
||||
|
9
readme/prereleases.md
Normal file
9
readme/prereleases.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Getting pre-releases
|
||||
|
||||
Pre-releases are available for the desktop application. They are pretty much like regular releases, except that they have not yet been tested by many users, so it is possible that a bug or two went through.
|
||||
|
||||
You can help the development of Joplin by choosing to receive these early releases when updating the application. If you find any bug or other issue, you may report it [on the forum](https://discourse.joplin.cozic.net/) or [GitHub](https://github.com/laurent22/joplin/issues).
|
||||
|
||||
In general it is safe to use these pre-releases (they do not include any experimental or unstable features). In fact most pre-release eventually become regular releases after a few days.
|
||||
|
||||
To have access to these pre-releases, simply go to **Configuration screen** and tick the box "**Also get pre-releases when checking for updates**".
|
Loading…
Reference in New Issue
Block a user