mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Doc: Fixed Android APK links
This commit is contained in:
parent
cde7b4d4f6
commit
a6f22bb7a9
@ -367,6 +367,7 @@ packages/app-mobile/components/CustomButton.js
|
||||
packages/app-mobile/components/Dropdown.js
|
||||
packages/app-mobile/components/ExtendedWebView.js
|
||||
packages/app-mobile/components/FolderPicker.js
|
||||
packages/app-mobile/components/Modal.js
|
||||
packages/app-mobile/components/NoteBodyViewer/NoteBodyViewer.js
|
||||
packages/app-mobile/components/NoteBodyViewer/hooks/useOnMessage.js
|
||||
packages/app-mobile/components/NoteBodyViewer/hooks/useOnResourceLongPress.js
|
||||
@ -875,6 +876,7 @@ packages/tools/spellcheck.js
|
||||
packages/tools/tagServerLatest.js
|
||||
packages/tools/tool-utils.js
|
||||
packages/tools/update-readme-download.js
|
||||
packages/tools/update-readme-download.test.js
|
||||
packages/tools/update-readme-sponsors.js
|
||||
packages/tools/updateMarkdownDoc.js
|
||||
packages/tools/utils/discourse.js
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -861,6 +861,7 @@ packages/tools/spellcheck.js
|
||||
packages/tools/tagServerLatest.js
|
||||
packages/tools/tool-utils.js
|
||||
packages/tools/update-readme-download.js
|
||||
packages/tools/update-readme-download.test.js
|
||||
packages/tools/update-readme-sponsors.js
|
||||
packages/tools/updateMarkdownDoc.js
|
||||
packages/tools/utils/discourse.js
|
||||
|
@ -38,7 +38,7 @@ The install and update script supports the [following flags](https://github.com/
|
||||
|
||||
Operating System | Download | Alt. Download
|
||||
---|---|---
|
||||
Android | <a href='https://play.google.com/store/apps/details?id=net.cozic.joplin&utm_source=GitHub&utm_campaign=README&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'><img alt='Get it on Google Play' height="40px" src='https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/BadgeAndroid.png'/></a> | or download the APK file: [64-bit](https://objects.joplinusercontent.com/android-v2.9.8/joplin-v2.9.8.apk?source=JoplinWebsite&type=New) [32-bit](https://objects.joplinusercontent.com/android-v2.9.8/joplin-v2.9.8-32bit.apk?source=JoplinWebsite&type=New)
|
||||
Android | <a href='https://play.google.com/store/apps/details?id=net.cozic.joplin&utm_source=GitHub&utm_campaign=README&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'><img alt='Get it on Google Play' height="40px" src='https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/BadgeAndroid.png'/></a> | or download the APK file: [64-bit](https://objects.joplinusercontent.com/v2.9.8/joplin-v2.9.8.apk?source=JoplinWebsite&type=New) [32-bit](https://objects.joplinusercontent.com/v2.9.8/joplin-v2.9.8-32bit.apk?source=JoplinWebsite&type=New)
|
||||
iOS | <a href='https://itunes.apple.com/us/app/joplin/id1315599797'><img alt='Get it on the App Store' height="40px" src='https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/BadgeIOS.png'/></a> | -
|
||||
|
||||
## Terminal application
|
||||
|
51
packages/tools/update-readme-download.test.ts
Normal file
51
packages/tools/update-readme-download.test.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import { GitHubRelease } from './tool-utils';
|
||||
import { downloadUrl, OS } from './update-readme-download';
|
||||
|
||||
describe('update-readme-download', () => {
|
||||
|
||||
it('convert download URLs', async () => {
|
||||
const createRelease = (assetName: string, browserDownloadUrl: string) => {
|
||||
const r: GitHubRelease = {
|
||||
assets: [
|
||||
{
|
||||
browser_download_url: browserDownloadUrl,
|
||||
name: assetName,
|
||||
},
|
||||
],
|
||||
tag_name: '',
|
||||
upload_url: '',
|
||||
html_url: '',
|
||||
prerelease: false,
|
||||
draft: false,
|
||||
};
|
||||
return r;
|
||||
};
|
||||
|
||||
const testCases: [GitHubRelease, OS, boolean, string][] = [
|
||||
[
|
||||
createRelease('joplin-v2.9.8.apk', 'https://github.com/laurent22/joplin-android/releases/download/android-v2.9.8/joplin-v2.9.8.apk'),
|
||||
OS.Android,
|
||||
false,
|
||||
'https://objects.joplinusercontent.com/v2.9.8/joplin-v2.9.8.apk',
|
||||
],
|
||||
[
|
||||
createRelease('Joplin-Setup-2.11.11.exe', 'https://github.com/laurent22/joplin/releases/download/v2.11.11/Joplin-Setup-2.11.11.exe'),
|
||||
OS.Windows,
|
||||
false,
|
||||
'https://objects.joplinusercontent.com/v2.11.11/Joplin-Setup-2.11.11.exe',
|
||||
],
|
||||
[
|
||||
createRelease('JoplinPortable.exe', 'https://github.com/laurent22/joplin/releases/download/v2.11.11/JoplinPortable.exe'),
|
||||
OS.Windows,
|
||||
true,
|
||||
'https://objects.joplinusercontent.com/v2.11.11/JoplinPortable.exe',
|
||||
],
|
||||
];
|
||||
|
||||
for (const [release, os, portable, expected] of testCases) {
|
||||
const actual = downloadUrl(release, os, portable);
|
||||
expect(actual).toBe(expected);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
@ -11,7 +11,15 @@ async function msleep(ms: number) {
|
||||
});
|
||||
}
|
||||
|
||||
function downloadUrl(release: GitHubRelease, os: string, portable = false) {
|
||||
export enum OS {
|
||||
MacOs = 'macos',
|
||||
Windows = 'windows',
|
||||
Android = 'android',
|
||||
Android32 = 'android32',
|
||||
Linux = 'linux',
|
||||
}
|
||||
|
||||
export const downloadUrl = (release: GitHubRelease, os: OS, portable = false) => {
|
||||
if (!release || !release.assets || !release.assets.length) return null;
|
||||
|
||||
for (let i = 0; i < release.assets.length; i++) {
|
||||
@ -19,13 +27,13 @@ function downloadUrl(release: GitHubRelease, os: string, portable = false) {
|
||||
const name = asset.name;
|
||||
const ext = fileExtension(name);
|
||||
|
||||
const githubAndroidUrl = 'github.com/laurent22/joplin-android/releases/download';
|
||||
const githubUrl = 'github.com/laurent22/joplin/releases/download';
|
||||
const joplinDomain = 'objects.joplinusercontent.com';
|
||||
const githubAndroidUrl = 'github.com/laurent22/joplin-android/releases/download/android-';
|
||||
const githubUrl = 'github.com/laurent22/joplin/releases/download/';
|
||||
const joplinDomain = 'objects.joplinusercontent.com/';
|
||||
|
||||
if (ext === 'dmg' && os === 'macos') return asset.browser_download_url.replace(githubUrl, joplinDomain);
|
||||
if (ext === 'dmg' && os === OS.MacOs) return asset.browser_download_url.replace(githubUrl, joplinDomain);
|
||||
|
||||
if (ext === 'exe' && os === 'windows') {
|
||||
if (ext === 'exe' && os === OS.Windows) {
|
||||
if (portable) {
|
||||
if (name === 'JoplinPortable.exe') return asset.browser_download_url.replace(githubUrl, joplinDomain);
|
||||
} else {
|
||||
@ -33,15 +41,15 @@ function downloadUrl(release: GitHubRelease, os: string, portable = false) {
|
||||
}
|
||||
}
|
||||
|
||||
if (ext === 'AppImage' && os === 'linux') return asset.browser_download_url.replace(githubUrl, joplinDomain);
|
||||
if (ext === 'AppImage' && os === OS.Linux) return asset.browser_download_url.replace(githubUrl, joplinDomain);
|
||||
|
||||
if (os === 'android32' && name.endsWith('32bit.apk')) return asset.browser_download_url.replace(githubAndroidUrl, joplinDomain);
|
||||
if (os === OS.Android32 && name.endsWith('32bit.apk')) return asset.browser_download_url.replace(githubAndroidUrl, joplinDomain);
|
||||
|
||||
if (os === 'android' && ext === 'apk' && !name.endsWith('32bit.apk')) return asset.browser_download_url.replace(githubAndroidUrl, joplinDomain);
|
||||
if (os === OS.Android && ext === 'apk' && !name.endsWith('32bit.apk')) return asset.browser_download_url.replace(githubAndroidUrl, joplinDomain);
|
||||
}
|
||||
|
||||
throw new Error(`Could not find download URL for: ${os}`);
|
||||
}
|
||||
};
|
||||
|
||||
function readmeContent() {
|
||||
if (!fs.existsSync(readmePath)) throw new Error(`Cannot find ${readmePath}`);
|
||||
@ -73,12 +81,12 @@ async function main(argv: any) {
|
||||
|
||||
const androidRelease = await gitHubLatestRelease('joplin-android');
|
||||
|
||||
const android32Url = downloadUrl(androidRelease, 'android32');
|
||||
const androidUrl = downloadUrl(androidRelease, 'android');
|
||||
const winUrl = downloadUrl(release, 'windows');
|
||||
const winPortableUrl = downloadUrl(release, 'windows', true);
|
||||
const macOsUrl = downloadUrl(release, 'macos');
|
||||
const linuxUrl = downloadUrl(release, 'linux');
|
||||
const android32Url = downloadUrl(androidRelease, OS.Android32);
|
||||
const androidUrl = downloadUrl(androidRelease, OS.Android);
|
||||
const winUrl = downloadUrl(release, OS.Windows);
|
||||
const winPortableUrl = downloadUrl(release, OS.Windows, true);
|
||||
const macOsUrl = downloadUrl(release, OS.MacOs);
|
||||
const linuxUrl = downloadUrl(release, OS.Linux);
|
||||
|
||||
console.info('Windows: ', winUrl);
|
||||
console.info('Windows Portable: ', winPortableUrl);
|
||||
@ -94,18 +102,17 @@ async function main(argv: any) {
|
||||
if (macOsUrl) content = content.replace(/(https:\/\/objects.joplinusercontent.com\/v\d+\.\d+\.\d+\/Joplin-.*?\.dmg)/, macOsUrl);
|
||||
if (linuxUrl) content = content.replace(/(https:\/\/objects.joplinusercontent.com\/v\d+\.\d+\.\d+\/Joplin-.*?\.AppImage)/, linuxUrl);
|
||||
|
||||
// Disable for now due to broken /latest API end point, which returns a
|
||||
// version from 6 months ago.
|
||||
|
||||
if (androidUrl) content = content.replace(/(https:\/\/objects.joplinusercontent.com\/android-v\d+\.\d+\.\d+\/joplin-v\d+\.\d+\.\d+\.apk)/, androidUrl);
|
||||
if (android32Url) content = content.replace(/(https:\/\/objects.joplinusercontent.com\/android-v\d+\.\d+\.\d+\/joplin-v\d+\.\d+\.\d+-32bit\.apk)/, android32Url);
|
||||
if (androidUrl) content = content.replace(/(https:\/\/objects.joplinusercontent.com\/v\d+\.\d+\.\d+\/joplin-v\d+\.\d+\.\d+\.apk)/, androidUrl);
|
||||
if (android32Url) content = content.replace(/(https:\/\/objects.joplinusercontent.com\/v\d+\.\d+\.\d+\/joplin-v\d+\.\d+\.\d+-32bit\.apk)/, android32Url);
|
||||
|
||||
setReadmeContent(content);
|
||||
|
||||
// console.info("git pull && git add -A && git commit -m 'Update readme downloads' && git push")
|
||||
}
|
||||
|
||||
main(process.argv).catch((error) => {
|
||||
console.error('Fatal error', error);
|
||||
process.exit(1);
|
||||
});
|
||||
if (require.main === module) {
|
||||
// eslint-disable-next-line promise/prefer-await-to-then
|
||||
main(process.argv).catch((error) => {
|
||||
console.error('Fatal error');
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user