-
Notifications
You must be signed in to change notification settings - Fork 355
Add version numbers next to key integrations that are often not up-to-date with the GitHub version #3553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add version numbers next to key integrations that are often not up-to-date with the GitHub version #3553
Changes from 3 commits
7b8c1c3
ca80894
caac7b5
7acf824
5959010
85c68ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { writable } from 'svelte/store'; | ||
|
|
||
| export const liveVersions = writable<Record<string, string>>({ | ||
| firefox: '', | ||
| js: '', | ||
| rust: '', | ||
| vscode: '', | ||
| }); | ||
|
|
||
| export async function loadLiveVersions() { | ||
| // 1. Firefox Addon | ||
| try { | ||
| const ver = ( | ||
| await ( | ||
| await fetch( | ||
| 'https://addons.mozilla.org/api/v5/addons/addon/private-grammar-checker-harper/', | ||
| ) | ||
| ).json() | ||
| ).current_version.version; | ||
| liveVersions.update((v) => ({ ...v, firefox: ver })); | ||
| } catch {} | ||
|
|
||
| // 2. JS Package | ||
| try { | ||
| const ver = (await (await fetch('https://registry.npmjs.org/harper.js')).json())['dist-tags'] | ||
| .latest; | ||
| liveVersions.update((v) => ({ ...v, js: ver })); | ||
| } catch {} | ||
|
|
||
| // 3. Rust Crate | ||
| try { | ||
| const lines = (await (await fetch('https://index.crates.io/ha/rp/harper-core')).text()).split( | ||
| '\n', | ||
| ); | ||
| liveVersions.update((v) => ({ ...v, rust: JSON.parse(lines[lines.length - 2]).vers })); | ||
| } catch {} | ||
|
|
||
| // 4. VS Code Extension | ||
| try { | ||
| const res = await fetch( | ||
| 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery', | ||
| { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| Accept: 'application/json;api-version=3.0-preview.1', | ||
| }, | ||
| body: JSON.stringify({ | ||
| filters: [ | ||
| { | ||
| criteria: [ | ||
| { filterType: 8, value: 'Microsoft.VisualStudio.Code' }, | ||
| { filterType: 7, value: 'elijah-potter.harper' }, | ||
| ], | ||
| pageNumber: 1, | ||
| pageSize: 1, | ||
| sortBy: 0, | ||
| sortOrder: 0, | ||
| }, | ||
| ], | ||
| assetTypes: [], | ||
| flags: 194, | ||
| }), | ||
| }, | ||
| ); | ||
| const ver = (await res.json()).results[0].extensions[0].versions[0].version; | ||
| liveVersions.update((v) => ({ ...v, vscode: ver })); | ||
| } catch {} | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ import PrivacySpeedCards from '$lib/marketing/PrivacySpeedCards.svelte'; | |
| import { featuredIntegrationIds, integrations, marketingLinks } from '$lib/marketing/data'; | ||
| import { LazyEditor } from 'harper-editor'; | ||
| import type { Linter } from 'harper.js'; | ||
| import { loadLiveVersions, liveVersions } from '$lib/marketing/versions'; | ||
| import { onMount } from 'svelte'; | ||
| import demoText from '../../../../demo.md?raw'; | ||
|
|
||
|
|
@@ -141,10 +142,17 @@ const faqs = [ | |
| }, | ||
| ]; | ||
|
|
||
| let liveFxVer = ''; | ||
| let liveJsVer = ''; | ||
| let liveRustVer = ''; | ||
| let liveVscodeVer = ''; | ||
|
|
||
| onMount(() => { | ||
| void (async () => { | ||
| linter = await createEditorLinter(); | ||
| })(); | ||
|
|
||
| void loadLiveVersions(); | ||
| }); | ||
|
|
||
| </script> | ||
|
|
@@ -246,8 +254,17 @@ onMount(() => { | |
| > | ||
| <IntegrationTile {integration} size={32} /> | ||
| <span class="flex min-w-0 flex-col"> | ||
| <strong class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.84rem]">{integration.name}</strong> | ||
| <small class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.72rem] text-[#807a6e] dark:text-white/55">{integration.desc}</small> | ||
| <div class="flex items-center gap-1.5 overflow-hidden"> | ||
| <strong class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.84rem]">{integration.name}</strong> | ||
| {#if $liveVersions[integration.id]} | ||
| <span class="inline-flex items-center rounded-full bg-[#f4f1ea] dark:bg-white/10 px-1.5 py-0.5 text-[0.65rem] font-mono font-medium text-[#6b6455] dark:text-white/80 border border-[#e4dfd3] dark:border-white/10 select-none"> | ||
| v{$liveVersions[integration.id]} | ||
| </span> | ||
| {/if} | ||
|
Comment on lines
+263
to
+273
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to have a small bit of hover text (which you can simply do with the Something like, "This version is slightly behind the core engine due to a delay".
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I was wondering about something like that, sounds like a way to handle it.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! |
||
| </div> | ||
| <small class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.72rem] text-[#807a6e] dark:text-white/55"> | ||
| {integration.desc} | ||
| </small> | ||
| </span> | ||
| </a> | ||
| {/if} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.