From d668016e4c5e1e40497493b53421809c6e786f79 Mon Sep 17 00:00:00 2001 From: Joooye_34 Date: Fri, 29 Dec 2023 09:01:35 +0000 Subject: [PATCH] feat(electron): use release api to filter draft release (#5443) --- .../main/updater/custom-github-provider.ts | 73 +++++++++++- .../electron/test/main/fixtures/feeds.txt | 55 ++++++++- .../test/main/fixtures/release-list.txt | 94 +++++++++++++++ .../fixtures/releases/0.11.1-canary.2.txt | 20 ++++ .../electron/test/main/updater.spec.ts | 109 +++++++++++++++--- 5 files changed, 328 insertions(+), 23 deletions(-) create mode 100644 packages/frontend/electron/test/main/fixtures/release-list.txt create mode 100644 packages/frontend/electron/test/main/fixtures/releases/0.11.1-canary.2.txt diff --git a/packages/frontend/electron/src/main/updater/custom-github-provider.ts b/packages/frontend/electron/src/main/updater/custom-github-provider.ts index 75a9861f6a..1690e9391d 100644 --- a/packages/frontend/electron/src/main/updater/custom-github-provider.ts +++ b/packages/frontend/electron/src/main/updater/custom-github-provider.ts @@ -24,6 +24,17 @@ interface GithubUpdateInfo extends UpdateInfo { tag: string; } +interface GithubRelease { + id: number; + tag_name: string; + target_commitish: string; + name: string; + draft: boolean; + prerelease: boolean; + created_at: string; + published_at: string; +} + const hrefRegExp = /\/tag\/([^/]+)$/; export class CustomGitHubProvider extends BaseGitHubProvider { @@ -54,7 +65,7 @@ export class CustomGitHubProvider extends BaseGitHubProvider { const feed = parseXml(feedXml); // noinspection TypeScriptValidateJSTypes - const latestRelease = feed.element( + let latestRelease = feed.element( 'entry', false, `No published versions on GitHub` @@ -74,6 +85,10 @@ export class CustomGitHubProvider extends BaseGitHubProvider { ); } + const releaseTag = await this.getLatestTagByRelease( + currentChannel, + cancellationToken + ); for (const element of feed.getElements('entry')) { // noinspection TypeScriptValidateJSTypes const hrefElement = hrefRegExp.exec( @@ -90,9 +105,16 @@ export class CustomGitHubProvider extends BaseGitHubProvider { const hrefChannel = (semver.prerelease(hrefTag)?.[0] as string) || 'stable'; - const isNextPreRelease = hrefChannel === currentChannel; + let isNextPreRelease = false; + if (releaseTag) { + isNextPreRelease = releaseTag === hrefTag; + } else { + isNextPreRelease = hrefChannel === currentChannel; + } + if (isNextPreRelease) { tag = hrefTag; + latestRelease = element; break; } } @@ -154,7 +176,7 @@ export class CustomGitHubProvider extends BaseGitHubProvider { } const result = parseUpdateInfo(rawData, channelFile, channelFileUrl); - if (result.releaseName === null) { + if (result.releaseName == null) { result.releaseName = latestRelease.elementValueOrEmpty('title'); } @@ -176,6 +198,51 @@ export class CustomGitHubProvider extends BaseGitHubProvider { return `/${this.options.owner}/${this.options.repo}/releases`; } + /** + * Use release api to get latest version to filter draft version. + * But this api have low request limit 60-times/1-hour, use this to help, not depend on it + * https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28 + * https://api.github.com/repos/toeverything/affine/releases + * https://docs.github.com/en/rest/rate-limit/rate-limit?apiVersion=2022-11-28#about-rate-limits + */ + private async getLatestTagByRelease( + currentChannel: string, + cancellationToken: CancellationToken + ) { + try { + const releasesStr = await this.httpRequest( + newUrlFromBase(`/repos${this.basePath}`, this.baseApiUrl), + { + accept: 'Accept: application/vnd.github+json', + 'X-GitHub-Api-Version': '2022-11-28', + }, + cancellationToken + ); + + if (!releasesStr) { + return null; + } + + const releases: GithubRelease[] = JSON.parse(releasesStr); + for (const release of releases) { + if (release.draft) { + continue; + } + + const releaseTag = release.tag_name; + const releaseChannel = + (semver.prerelease(releaseTag)?.[0] as string) || 'stable'; + if (releaseChannel === currentChannel) { + return release.tag_name; + } + } + } catch (e: any) { + console.info(`Cannot parse release: ${e.stack || e.message}`); + } + + return null; + } + resolveFiles(updateInfo: GithubUpdateInfo): Array { // still replace space to - due to backward compatibility return resolveFiles(updateInfo, this.baseUrl, p => diff --git a/packages/frontend/electron/test/main/fixtures/feeds.txt b/packages/frontend/electron/test/main/fixtures/feeds.txt index 315f9574f1..479db4e7f4 100644 --- a/packages/frontend/electron/test/main/fixtures/feeds.txt +++ b/packages/frontend/electron/test/main/fixtures/feeds.txt @@ -21,6 +21,19 @@ 2023-12-27T19:40:15+08:00 0.11.1 + <p>fix(core): enable page history for beta/stable (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056965718" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5415" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5415/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5415">#5415</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a><br> +fix(component): fix font display on safari (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055383919" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5393" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5393/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5393">#5393</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/EYHN/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/EYHN">@EYHN</a><br> +fix(core): avatars are not aligned (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056136302" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5404" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5404/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5404">#5404</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/JimmFly/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/JimmFly">@JimmFly</a><br> +fix(core): trash page footer display issue (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056129348" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5402" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5402/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5402">#5402</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a><br> +fix(electron): set stable base url to app.affine.pro (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056113464" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5401" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5401/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5401">#5401</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/joooye34/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/joooye34">@joooye34</a><br> +fix(core): about setting blink issue (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056090521" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5399" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5399/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5399">#5399</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a><br> +fix(core): workpace list blink issue on open (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056096694" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5400" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5400/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5400">#5400</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a><br> +chore(core): add background color to questionnaire (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055986563" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5396" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5396/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5396">#5396</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/JimmFly/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/JimmFly">@JimmFly</a><br> +fix(core): correct title of onboarding article-2 (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2053650286" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5387" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5387/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5387">#5387</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/CatsJuice/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/CatsJuice">@CatsJuice</a><br> +fix: use prefix in electron to prevent formdata bug (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055616549" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5395" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5395/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5395">#5395</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/darkskygit/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/darkskygit">@darkskygit</a><br> +fix(core): fix flickering workspace list (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055363698" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5391" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5391/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5391">#5391</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/EYHN/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/EYHN">@EYHN</a><br> +fix(workspace): fix svg file with xml header (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2053693777" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5388" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5388/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5388">#5388</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/EYHN/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/EYHN">@EYHN</a><br> +feat: bump blocksuite (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2053645163" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5386" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5386/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5386">#5386</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/regischen/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/regischen">@regischen</a></p> github-actions[bot] @@ -31,6 +44,30 @@ 2023-12-27T18:30:52+08:00 0.11.1-beta.1 + <p>fix(core): enable page history for beta/stable (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056965718" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5415" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5415/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5415">#5415</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a><br> +fix(component): fix font display on safari (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055383919" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5393" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5393/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5393">#5393</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/EYHN/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/EYHN">@EYHN</a><br> +fix(core): avatars are not aligned (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056136302" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5404" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5404/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5404">#5404</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/JimmFly/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/JimmFly">@JimmFly</a><br> +fix(core): trash page footer display issue (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056129348" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5402" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5402/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5402">#5402</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a><br> +fix(electron): set stable base url to app.affine.pro (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056113464" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5401" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5401/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5401">#5401</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/joooye34/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/joooye34">@joooye34</a><br> +fix(core): about setting blink issue (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056090521" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5399" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5399/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5399">#5399</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a><br> +fix(core): workpace list blink issue on open (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056096694" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5400" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5400/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5400">#5400</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a><br> +chore(core): add background color to questionnaire (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055986563" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5396" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5396/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5396">#5396</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/JimmFly/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/JimmFly">@JimmFly</a><br> +fix(core): correct title of onboarding article-2 (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2053650286" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5387" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5387/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5387">#5387</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/CatsJuice/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/CatsJuice">@CatsJuice</a><br> +fix: use prefix in electron to prevent formdata bug (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055616549" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5395" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5395/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5395">#5395</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/darkskygit/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/darkskygit">@darkskygit</a><br> +fix(core): fix flickering workspace list (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055363698" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5391" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5391/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5391">#5391</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/EYHN/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/EYHN">@EYHN</a><br> +fix(workspace): fix svg file with xml header (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2053693777" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5388" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5388/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5388">#5388</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/EYHN/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/EYHN">@EYHN</a><br> +feat: bump blocksuite (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2053645163" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5386" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5386/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5386">#5386</a>) <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/regischen/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/regischen">@regischen</a></p> + + github-actions[bot] + + + + + tag:github.com,2008:Repository/519859998/v0.11.1-canary.2 + 2023-12-28T10:47:52+08:00 + + 0.11.1-canary.2 + No content. github-actions[bot] @@ -41,7 +78,23 @@ 2023-12-27T10:47:52+08:00 0.11.1-canary.1 - + <h2>What's Changed</h2> +<ul> +<li>fix(core): remove plugins settings by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2048206391" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5337" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5337/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5337">#5337</a></li> +<li>chore: bump up @vitejs/plugin-vue version to v5 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/renovate/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/renovate">@renovate</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055571407" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5394" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5394/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5394">#5394</a></li> +<li>fix(core): correct title of onboarding article-2 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/CatsJuice/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/CatsJuice">@CatsJuice</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2053650286" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5387" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5387/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5387">#5387</a></li> +<li>chore(core): add background color to questionnaire by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/JimmFly/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/JimmFly">@JimmFly</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2055986563" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5396" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5396/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5396">#5396</a></li> +<li>ci: define tag name to fix nightly release failing by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/joooye34/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/joooye34">@joooye34</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056068417" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5397" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5397/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5397">#5397</a></li> +<li>fix(core): workpace list blink issue on open by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056096694" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5400" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5400/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5400">#5400</a></li> +<li>fix(core): about setting blink issue by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056090521" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5399" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5399/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5399">#5399</a></li> +<li>fix(electron): set stable base url to app.affine.pro by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/joooye34/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/joooye34">@joooye34</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056113464" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5401" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5401/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5401">#5401</a></li> +<li>fix(core): trash page footer display issue by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056129348" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5402" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5402/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5402">#5402</a></li> +<li>chore: bump up @types/supertest version to v6 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/renovate/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/renovate">@renovate</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2053226342" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5376" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5376/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5376">#5376</a></li> +<li>chore: bump up react-i18next version to v14 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/renovate/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/renovate">@renovate</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2052675317" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5375" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5375/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5375">#5375</a></li> +<li>fix(core): avatars are not aligned by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/JimmFly/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/JimmFly">@JimmFly</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056136302" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5404" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5404/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5404">#5404</a></li> +<li>fix(infra): workaround for self-referencing in storybook by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pengx17/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pengx17">@pengx17</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2056165203" data-permission-text="Title is private" data-url="https://github.com/toeverything/AFFiNE/issues/5406" data-hovercard-type="pull_request" data-hovercard-url="/toeverything/AFFiNE/pull/5406/hovercard" href="https://github.com/toeverything/AFFiNE/pull/5406">#5406</a></li> +</ul> +<p><strong>Full Changelog</strong>: <a class="commit-link" href="https://github.com/toeverything/AFFiNE/compare/v0.11.1-canary.0...v0.11.1-canary.1"><tt>v0.11.1-canary.0...v0.11.1-canary.1</tt></a></p> github-actions[bot] diff --git a/packages/frontend/electron/test/main/fixtures/release-list.txt b/packages/frontend/electron/test/main/fixtures/release-list.txt new file mode 100644 index 0000000000..172fd73260 --- /dev/null +++ b/packages/frontend/electron/test/main/fixtures/release-list.txt @@ -0,0 +1,94 @@ +[ + { + "url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135252810", + "assets_url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135252810/assets", + "upload_url": "https://uploads.github.com/repos/toeverything/AFFiNE/releases/135252810/assets{?name,label}", + "html_url": "https://github.com/toeverything/AFFiNE/releases/tag/0.11.0-nightly-202312280901-e11e827", + "id": 135252810, + "node_id": "RE_kwDOHvxvHs4ID8tK", + "tag_name": "0.11.0-nightly-202312280901-e11e827", + "target_commitish": "canary", + "name": "0.11.0-nightly-202312280901-e11e827", + "draft": false, + "prerelease": true, + "created_at": "2023-12-28T08:36:36Z", + "published_at": "2023-12-28T09:23:07Z", + "tarball_url": "https://api.github.com/repos/toeverything/AFFiNE/tarball/0.11.0-nightly-202312280901-e11e827", + "zipball_url": "https://api.github.com/repos/toeverything/AFFiNE/zipball/0.11.0-nightly-202312280901-e11e827", + "body": "" + }, + { + "url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135173430", + "assets_url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135173430/assets", + "upload_url": "https://uploads.github.com/repos/toeverything/AFFiNE/releases/135173430/assets{?name,label}", + "html_url": "https://github.com/toeverything/AFFiNE/releases/tag/v0.11.1", + "id": 135173430, + "node_id": "RE_kwDOHvxvHs4IDpU2", + "tag_name": "v0.11.1", + "target_commitish": "canary", + "name": "0.11.1", + "draft": false, + "prerelease": false, + "created_at": "2023-12-27T06:39:59Z", + "published_at": "2023-12-27T11:40:15Z", + "tarball_url": "https://api.github.com/repos/toeverything/AFFiNE/tarball/v0.11.1", + "zipball_url": "https://api.github.com/repos/toeverything/AFFiNE/zipball/v0.11.1", + "mentions_count": 7 + }, + { + "url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135163918", + "assets_url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135163918/assets", + "upload_url": "https://uploads.github.com/repos/toeverything/AFFiNE/releases/135163918/assets{?name,label}", + "html_url": "https://github.com/toeverything/AFFiNE/releases/tag/v0.11.1-beta.1", + "id": 135163918, + "node_id": "RE_kwDOHvxvHs4IDnAO", + "tag_name": "v0.11.1-beta.1", + "target_commitish": "canary", + "name": "0.11.1-beta.1", + "draft": false, + "prerelease": true, + "created_at": "2023-12-27T06:39:59Z", + "published_at": "2023-12-27T10:30:52Z", + "tarball_url": "https://api.github.com/repos/toeverything/AFFiNE/tarball/v0.11.1-beta.1", + "zipball_url": "https://api.github.com/repos/toeverything/AFFiNE/zipball/v0.11.1-beta.1", + "mentions_count": 7 + }, + { + "url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135103520", + "assets_url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135103520/assets", + "upload_url": "https://uploads.github.com/repos/toeverything/AFFiNE/releases/135103520/assets{?name,label}", + "html_url": "https://github.com/toeverything/AFFiNE/releases/tag/v0.11.1-canary.1", + "id": 135103520, + "node_id": "RE_kwDOHvxvHs4IDYQg", + "tag_name": "v0.11.1-canary.2", + "target_commitish": "canary", + "name": "0.11.1-canary.2", + "draft": true, + "prerelease": true, + "created_at": "2023-12-26T12:27:20Z", + "published_at": "2023-12-26T13:24:28Z", + "tarball_url": "https://api.github.com/repos/toeverything/AFFiNE/tarball/v0.11.1-canary.1", + "zipball_url": "https://api.github.com/repos/toeverything/AFFiNE/zipball/v0.11.1-canary.1", + "body": "## What's Changed\r\n* fix(core): remove plugins settings by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5337\r\n* chore: bump up @vitejs/plugin-vue version to v5 by @renovate in https://github.com/toeverything/AFFiNE/pull/5394\r\n* fix(core): correct title of onboarding article-2 by @CatsJuice in https://github.com/toeverything/AFFiNE/pull/5387\r\n* chore(core): add background color to questionnaire by @JimmFly in https://github.com/toeverything/AFFiNE/pull/5396\r\n* ci: define tag name to fix nightly release failing by @joooye34 in https://github.com/toeverything/AFFiNE/pull/5397\r\n* fix(core): workpace list blink issue on open by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5400\r\n* fix(core): about setting blink issue by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5399\r\n* fix(electron): set stable base url to app.affine.pro by @joooye34 in https://github.com/toeverything/AFFiNE/pull/5401\r\n* fix(core): trash page footer display issue by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5402\r\n* chore: bump up @types/supertest version to v6 by @renovate in https://github.com/toeverything/AFFiNE/pull/5376\r\n* chore: bump up react-i18next version to v14 by @renovate in https://github.com/toeverything/AFFiNE/pull/5375\r\n* fix(core): avatars are not aligned by @JimmFly in https://github.com/toeverything/AFFiNE/pull/5404\r\n* fix(infra): workaround for self-referencing in storybook by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5406\r\n\r\n\r\n**Full Changelog**: https://github.com/toeverything/AFFiNE/compare/v0.11.1-canary.0...v0.11.1-canary.1", + "mentions_count": 5 + }, + { + "url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135103520", + "assets_url": "https://api.github.com/repos/toeverything/AFFiNE/releases/135103520/assets", + "upload_url": "https://uploads.github.com/repos/toeverything/AFFiNE/releases/135103520/assets{?name,label}", + "html_url": "https://github.com/toeverything/AFFiNE/releases/tag/v0.11.1-canary.1", + "id": 135103520, + "node_id": "RE_kwDOHvxvHs4IDYQg", + "tag_name": "v0.11.1-canary.1", + "target_commitish": "canary", + "name": "0.11.1-canary.1", + "draft": false, + "prerelease": true, + "created_at": "2023-12-26T12:27:20Z", + "published_at": "2023-12-26T13:24:28Z", + "tarball_url": "https://api.github.com/repos/toeverything/AFFiNE/tarball/v0.11.1-canary.1", + "zipball_url": "https://api.github.com/repos/toeverything/AFFiNE/zipball/v0.11.1-canary.1", + "body": "## What's Changed\r\n* fix(core): remove plugins settings by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5337\r\n* chore: bump up @vitejs/plugin-vue version to v5 by @renovate in https://github.com/toeverything/AFFiNE/pull/5394\r\n* fix(core): correct title of onboarding article-2 by @CatsJuice in https://github.com/toeverything/AFFiNE/pull/5387\r\n* chore(core): add background color to questionnaire by @JimmFly in https://github.com/toeverything/AFFiNE/pull/5396\r\n* ci: define tag name to fix nightly release failing by @joooye34 in https://github.com/toeverything/AFFiNE/pull/5397\r\n* fix(core): workpace list blink issue on open by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5400\r\n* fix(core): about setting blink issue by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5399\r\n* fix(electron): set stable base url to app.affine.pro by @joooye34 in https://github.com/toeverything/AFFiNE/pull/5401\r\n* fix(core): trash page footer display issue by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5402\r\n* chore: bump up @types/supertest version to v6 by @renovate in https://github.com/toeverything/AFFiNE/pull/5376\r\n* chore: bump up react-i18next version to v14 by @renovate in https://github.com/toeverything/AFFiNE/pull/5375\r\n* fix(core): avatars are not aligned by @JimmFly in https://github.com/toeverything/AFFiNE/pull/5404\r\n* fix(infra): workaround for self-referencing in storybook by @pengx17 in https://github.com/toeverything/AFFiNE/pull/5406\r\n\r\n\r\n**Full Changelog**: https://github.com/toeverything/AFFiNE/compare/v0.11.1-canary.0...v0.11.1-canary.1", + "mentions_count": 5 + } +] diff --git a/packages/frontend/electron/test/main/fixtures/releases/0.11.1-canary.2.txt b/packages/frontend/electron/test/main/fixtures/releases/0.11.1-canary.2.txt new file mode 100644 index 0000000000..fe8f4de82d --- /dev/null +++ b/packages/frontend/electron/test/main/fixtures/releases/0.11.1-canary.2.txt @@ -0,0 +1,20 @@ +version: 0.11.1-canary.2 +files: + - url: affine-canary-windows-x64.exe + sha512: qbK4N6+axVO2dA/iPzfhANWxCZXY1S3ci9qYIT1v/h0oCjc6vqpXU+2KRGL5mplL6wmVgJAOpqrfnq9gHMsfDg== + size: 179526504 + - url: affine-canary-macos-arm64.dmg + sha512: ++LAGuxTmFAVd65k8UpKKfU19iisvXHKDDfPkGlTVC000QP3foeS21BmTgYnM1ZuhEC6KGzSGrqvUDVDNYnRmA== + size: 169903530 + - url: affine-canary-macos-arm64.zip + sha512: IAWbCpVqPPVVzDowGKGnKZzHN2jPgAW40v+bUZR2tdgDrqIAVy4YdamYz8WmEwpg1TXmi0ueSsWgGFPgBIr0iA== + size: 169085665 + - url: affine-canary-macos-x64.dmg + sha512: 4y4/KkmkmFmZ94ntRAN0lSX7aZzgEd4Wg7f85Tff296P3x85sbPF4FFIp++Zx/cgBZBUQwMWe9xeGlefompQ/g== + size: 175920978 + - url: affine-canary-macos-x64.zip + sha512: S1MuMHooMOQ9eJ+coRYmyz6k5lnWIMqHotSrywxGGo7sFXBY+O5F4PeKgNREJtwXjAIxv0GxZVvbe5jc+onw9w== + size: 175315484 +path: affine-canary-windows-x64.exe +sha512: qbK4N6+axVO2dA/iPzfhANWxCZXY1S3ci9qYIT1v/h0oCjc6vqpXU+2KRGL5mplL6wmVgJAOpqrfnq9gHMsfDg== +releaseDate: 2023-12-26T13:24:28.221Z diff --git a/packages/frontend/electron/test/main/updater.spec.ts b/packages/frontend/electron/test/main/updater.spec.ts index 51c2864479..bfcd6e4ee9 100644 --- a/packages/frontend/electron/test/main/updater.spec.ts +++ b/packages/frontend/electron/test/main/updater.spec.ts @@ -1,10 +1,10 @@ import nodePath from 'node:path'; +import type { UpdateCheckResult } from 'electron-updater'; import fs from 'fs-extra'; import { flatten } from 'lodash-es'; import { http, HttpResponse } from 'msw'; import { setupServer } from 'msw/node'; -import { compare } from 'semver'; import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; import { CustomGitHubProvider } from '../../src/main/updater/custom-github-provider'; @@ -22,6 +22,13 @@ const platformTail = (() => { } })(); +function response404() { + return HttpResponse.text('Not Found', { status: 404 }); +} +function response403() { + return HttpResponse.text('403', { status: 403 }); +} + describe('testing for client update', () => { const expectReleaseList = [ { buildType: 'stable', version: '0.11.1' }, @@ -29,7 +36,7 @@ describe('testing for client update', () => { { buildType: 'canary', version: '0.11.1-canary.1' }, ]; - const restHandlers = [ + const basicRequestHandlers = [ http.get( 'https://github.com/toeverything/AFFiNE/releases.atom', async () => { @@ -42,14 +49,10 @@ describe('testing for client update', () => { ), ...flatten( expectReleaseList.map(({ version, buildType }) => { - function response404() { - return HttpResponse.text('Not Found', { status: 404 }); - } - return [ http.get( `https://github.com/toeverything/AFFiNE/releases/download/v${version}/latest${platformTail}.yml`, - async function responseContent() { + async () => { const buffer = await fs.readFile( nodePath.join( __dirname, @@ -71,34 +74,102 @@ describe('testing for client update', () => { ), ]; - const server = setupServer(...restHandlers); + describe('release api request successfully', () => { + const server = setupServer( + ...basicRequestHandlers, + http.get( + 'https://api.github.com/repos/toeverything/affine/releases', + async () => { + const buffer = await fs.readFile( + nodePath.join(__dirname, 'fixtures', 'release-list.txt') + ); + const content = buffer.toString(); + return HttpResponse.xml(content); + } + ) + ); + beforeAll(() => server.listen({ onUnhandledRequest: 'error' })); + afterAll(() => server.close()); + afterEach(() => server.resetHandlers()); - beforeAll(() => server.listen({ onUnhandledRequest: 'error' })); - afterAll(() => server.close()); - afterEach(() => server.resetHandlers()); + for (const { buildType, version } of expectReleaseList) { + it(`check update for ${buildType} channel successfully`, async () => { + const app = new MockedAppAdapter('0.10.0'); + const updater = new MockedUpdater(null, app); + updater.allowPrerelease = buildType !== 'stable'; - for (const { buildType } of expectReleaseList) { - it(`check update for ${buildType} channel successfully`, async () => { + const feedUrl: Parameters[0] = { + channel: buildType, + // hack for custom provider + provider: 'custom' as 'github', + repo: 'AFFiNE', + owner: 'toeverything', + releaseType: buildType === 'stable' ? 'release' : 'prerelease', + // @ts-expect-error hack for custom provider + updateProvider: CustomGitHubProvider, + }; + + updater.setFeedURL(feedUrl); + + const info = (await updater.checkForUpdates()) as UpdateCheckResult; + expect(info).not.toBe(null); + expect(info.updateInfo.releaseName).toBe(version); + expect(info.updateInfo.version).toBe(version); + expect(info.updateInfo.releaseNotes?.length).toBeGreaterThan(0); + }); + } + }); + + describe('release api request limited', () => { + const server = setupServer( + ...basicRequestHandlers, + http.get( + 'https://api.github.com/repos/toeverything/affine/releases', + response403 + ), + http.get( + `https://github.com/toeverything/AFFiNE/releases/download/v0.11.1-canary.2/latest${platformTail}.yml`, + async () => { + const buffer = await fs.readFile( + nodePath.join( + __dirname, + 'fixtures', + 'releases', + `0.11.1-canary.2.txt` + ) + ); + const content = buffer.toString(); + return HttpResponse.text(content); + } + ) + ); + beforeAll(() => server.listen({ onUnhandledRequest: 'error' })); + afterAll(() => server.close()); + afterEach(() => server.resetHandlers()); + + it('check update for canary channel get v0.11.1-canary.2', async () => { const app = new MockedAppAdapter('0.10.0'); const updater = new MockedUpdater(null, app); - updater.allowPrerelease = buildType !== 'stable'; + updater.allowPrerelease = true; const feedUrl: Parameters[0] = { - channel: buildType, + channel: 'canary', // hack for custom provider provider: 'custom' as 'github', repo: 'AFFiNE', owner: 'toeverything', - releaseType: buildType === 'stable' ? 'release' : 'prerelease', + releaseType: 'prerelease', // @ts-expect-error hack for custom provider updateProvider: CustomGitHubProvider, }; updater.setFeedURL(feedUrl); - const info = await updater.checkForUpdates(); + const info = (await updater.checkForUpdates()) as UpdateCheckResult; expect(info).not.toBe(null); - expect(compare(info!.updateInfo.version, '0.10.0')).toBe(1); + expect(info.updateInfo.releaseName).toBe('0.11.1-canary.2'); + expect(info.updateInfo.version).toBe('0.11.1-canary.2'); + expect(info.updateInfo.releaseNotes?.length).toBe(0); }); - } + }); });