1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Desktop: Resolves #8467: Auto-update to ARM64 version on Apple M1 hardware

This commit is contained in:
Laurent Cozic 2023-08-06 12:57:26 +01:00
parent 9a8c0e9813
commit ad975a473f
6 changed files with 5305 additions and 4082 deletions

View File

@ -368,6 +368,7 @@ packages/app-desktop/services/spellChecker/SpellCheckerServiceDriverNative.js
packages/app-desktop/tools/notarizeMacApp.js packages/app-desktop/tools/notarizeMacApp.js
packages/app-desktop/utils/checkForUpdatesUtils.test.js packages/app-desktop/utils/checkForUpdatesUtils.test.js
packages/app-desktop/utils/checkForUpdatesUtils.js packages/app-desktop/utils/checkForUpdatesUtils.js
packages/app-desktop/utils/checkForUpdatesUtilsTestData.js
packages/app-desktop/utils/markupLanguageUtils.js packages/app-desktop/utils/markupLanguageUtils.js
packages/app-mobile/PluginAssetsLoader.js packages/app-mobile/PluginAssetsLoader.js
packages/app-mobile/components/ActionButton.js packages/app-mobile/components/ActionButton.js

1
.gitignore vendored
View File

@ -353,6 +353,7 @@ packages/app-desktop/services/spellChecker/SpellCheckerServiceDriverNative.js
packages/app-desktop/tools/notarizeMacApp.js packages/app-desktop/tools/notarizeMacApp.js
packages/app-desktop/utils/checkForUpdatesUtils.test.js packages/app-desktop/utils/checkForUpdatesUtils.test.js
packages/app-desktop/utils/checkForUpdatesUtils.js packages/app-desktop/utils/checkForUpdatesUtils.js
packages/app-desktop/utils/checkForUpdatesUtilsTestData.js
packages/app-desktop/utils/markupLanguageUtils.js packages/app-desktop/utils/markupLanguageUtils.js
packages/app-mobile/PluginAssetsLoader.js packages/app-mobile/PluginAssetsLoader.js
packages/app-mobile/components/ActionButton.js packages/app-mobile/components/ActionButton.js

View File

@ -77,7 +77,7 @@ export default async function checkForUpdates(inBackground: boolean, parentWindo
try { try {
const releases = await fetchLatestRelease(); const releases = await fetchLatestRelease();
const release = extractVersionInfo(releases, process.platform, options); const release = extractVersionInfo(releases, process.platform, process.arch, shim.isPortable(), options);
logger.info(`Current version: ${packageInfo.version}`); logger.info(`Current version: ${packageInfo.version}`);
logger.info(`Latest version: ${release.version}`); logger.info(`Latest version: ${release.version}`);

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,23 @@
import { fileExtension } from '@joplin/lib/path-utils'; import { fileExtension } from '@joplin/lib/path-utils';
import shim from '@joplin/lib/shim';
export interface CheckForUpdateOptions { export interface CheckForUpdateOptions {
includePreReleases?: boolean; includePreReleases?: boolean;
} }
interface GitHubReleaseAsset {
name: string;
browser_download_url: string;
}
export interface GitHubRelease { export interface GitHubRelease {
tag_name: string; tag_name: string;
prerelease: boolean; prerelease: boolean;
body: string; body: string;
assets: { assets: GitHubReleaseAsset[];
name: string;
browser_download_url: string;
}[];
html_url: string; html_url: string;
} }
interface Release { export interface Release {
version: string; version: string;
prerelease: boolean; prerelease: boolean;
downloadUrl: string; downloadUrl: string;
@ -24,13 +25,17 @@ interface Release {
pageUrl: string; pageUrl: string;
} }
export type Platform = typeof process.platform;
export type Architecture = typeof process.arch;
function getMajorMinorTagName(tagName: string) { function getMajorMinorTagName(tagName: string) {
const s = tagName.split('.'); const s = tagName.split('.');
s.pop(); s.pop();
return s.join('.'); return s.join('.');
} }
export const extractVersionInfo = (releases: GitHubRelease[], platform: typeof process.platform, options: CheckForUpdateOptions) => { export const extractVersionInfo = (releases: GitHubRelease[], platform: Platform, arch: Architecture, portable: boolean, options: CheckForUpdateOptions) => {
options = { includePreReleases: false, ...options }; options = { includePreReleases: false, ...options };
if (!releases.length) throw new Error('Cannot get latest release info (JSON)'); if (!releases.length) throw new Error('Cannot get latest release info (JSON)');
@ -67,28 +72,43 @@ export const extractVersionInfo = (releases: GitHubRelease[], platform: typeof p
} }
} }
let downloadUrl = null; let foundAsset: GitHubReleaseAsset = null;
for (let i = 0; i < release.assets.length; i++) {
const asset = release.assets[i];
let found = false;
const ext = fileExtension(asset.name);
if (platform === 'win32' && ext === 'exe') {
if (shim.isPortable()) {
found = asset.name === 'JoplinPortable.exe';
} else {
found = !!asset.name.match(/^Joplin-Setup-[\d.]+\.exe$/);
}
} else if (platform === 'darwin' && ext === 'dmg' && !asset.name.endsWith('arm64.dmg')) { // We don't return the arm64 version for now
found = true;
} else if (platform === 'linux' && ext === '.AppImage') {
found = true;
}
if (found) { if (platform === 'win32' && portable) {
downloadUrl = asset.browser_download_url.replace('github.com/laurent22/joplin/releases/download', 'objects.joplinusercontent.com'); foundAsset = release.assets.find(asset => {
downloadUrl.concat('?source=DesktopApp&type=Update'); return asset.name === 'JoplinPortable.exe';
break; });
} }
if (!foundAsset && platform === 'win32') {
foundAsset = release.assets.find(asset => {
return !!asset.name.match(/^Joplin-Setup-[\d.]+\.exe$/);
});
}
if (platform === 'darwin' && arch === 'arm64') {
foundAsset = release.assets.find(asset => {
return asset.name.endsWith('arm64.dmg');
});
}
if (!foundAsset && platform === 'darwin') {
foundAsset = release.assets.find(asset => {
return fileExtension(asset.name) === 'dmg' && !asset.name.endsWith('arm64.dmg');
});
}
if (platform === 'linux') {
foundAsset = release.assets.find(asset => {
return fileExtension(asset.name) === 'AppImage';
});
}
let downloadUrl: string = null;
if (foundAsset) {
downloadUrl = foundAsset.browser_download_url.replace('github.com/laurent22/joplin/releases/download', 'objects.joplinusercontent.com');
downloadUrl.concat('?source=DesktopApp&type=Update');
} }
function cleanUpReleaseNotes(releaseNotes: string[]) { function cleanUpReleaseNotes(releaseNotes: string[]) {

File diff suppressed because it is too large Load Diff