mirror of https://github.com/laurent22/joplin.git
Chore: Desktop: Support uppercase DMG extensions when checking for updates (#8720)
parent
d590bd7720
commit
ea4d54aea6
|
@ -1,4 +1,4 @@
|
||||||
import { extractVersionInfo, Release, Platform, Architecture } from './checkForUpdatesUtils';
|
import { extractVersionInfo, Release, Platform, Architecture, GitHubRelease } from './checkForUpdatesUtils';
|
||||||
import { releases1, releases2 } from './checkForUpdatesUtilsTestData';
|
import { releases1, releases2 } from './checkForUpdatesUtilsTestData';
|
||||||
|
|
||||||
describe('checkForUpdates', () => {
|
describe('checkForUpdates', () => {
|
||||||
|
@ -104,4 +104,47 @@ describe('checkForUpdates', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('macOS should match both .DMG and .dmg extensions', () => {
|
||||||
|
// A .DMG may be used to prevent older versions of Joplin from downloading an incompatible
|
||||||
|
// release. Ensure that newer versions of Joplin can download these releases.
|
||||||
|
const releaseDataWithExtension = (extension: string) => {
|
||||||
|
const downloadURL = `https://github.com/laurent22/joplin/releases/download/v2.12.4/Joplin-2.12.4${extension}`;
|
||||||
|
const releaseData: GitHubRelease = {
|
||||||
|
prerelease: false,
|
||||||
|
body: 'this is a test',
|
||||||
|
tag_name: 'v2.12.4',
|
||||||
|
assets: [
|
||||||
|
{
|
||||||
|
name: `Joplin-2.12.4${extension}`,
|
||||||
|
browser_download_url: downloadURL,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
html_url: 'https://github.com/laurent22/joplin/releases/tag/v2.12.4',
|
||||||
|
};
|
||||||
|
|
||||||
|
return releaseData;
|
||||||
|
};
|
||||||
|
|
||||||
|
const releaseData = releaseDataWithExtension('-arm64.DMG');
|
||||||
|
const releaseInfo = extractVersionInfo([releaseData], 'darwin', 'arm64', false, { });
|
||||||
|
|
||||||
|
// Should match, with uppercase .DMG
|
||||||
|
expect(releaseInfo).toMatchObject({
|
||||||
|
version: '2.12.4',
|
||||||
|
downloadUrl: 'https://objects.joplinusercontent.com/v2.12.4/Joplin-2.12.4-arm64.DMG',
|
||||||
|
pageUrl: releaseData.html_url,
|
||||||
|
prerelease: releaseData.prerelease,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Should not match when the extension is invalid
|
||||||
|
expect(
|
||||||
|
extractVersionInfo([releaseDataWithExtension('-arm64.dmG')], 'darwin', 'arm64', false, { }),
|
||||||
|
).toMatchObject({
|
||||||
|
version: '2.12.4',
|
||||||
|
downloadUrl: null,
|
||||||
|
pageUrl: releaseData.html_url,
|
||||||
|
prerelease: releaseData.prerelease,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -86,18 +86,18 @@ export const extractVersionInfo = (releases: GitHubRelease[], platform: Platform
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const arm64DMGPattern = /arm64\.(dmg|DMG)$/;
|
||||||
if (platform === 'darwin' && arch === 'arm64') {
|
if (platform === 'darwin' && arch === 'arm64') {
|
||||||
foundAsset = release.assets.find(asset => {
|
foundAsset = release.assets.find(asset => {
|
||||||
return asset.name.endsWith('arm64.dmg');
|
return asset.name.match(arm64DMGPattern);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundAsset && platform === 'darwin') {
|
if (!foundAsset && platform === 'darwin') {
|
||||||
foundAsset = release.assets.find(asset => {
|
foundAsset = release.assets.find(asset => {
|
||||||
return fileExtension(asset.name) === 'dmg' && !asset.name.endsWith('arm64.dmg');
|
return fileExtension(asset.name) === 'dmg' && !asset.name.match(arm64DMGPattern);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platform === 'linux') {
|
if (platform === 'linux') {
|
||||||
foundAsset = release.assets.find(asset => {
|
foundAsset = release.assets.find(asset => {
|
||||||
return fileExtension(asset.name) === 'AppImage';
|
return fileExtension(asset.name) === 'AppImage';
|
||||||
|
|
Loading…
Reference in New Issue