-
Notifications
You must be signed in to change notification settings - Fork 18.5k
fix(core): plugins are always reinstalled #9675
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
beff163
fix: slow plugins
neriousy 9a84dba
Merge branch 'dev' into fix/slow-plugins
neriousy be79d7c
feat(core): add Npm module for version management and update BunProc …
neriousy 71a274c
revert(desktop): undo slow server guard
neriousy 1d954eb
refactor: streamline dependency installation logic and improve versio…
neriousy 1038fc1
feat: handle custom registries
neriousy 4d4c02c
feat(core): add semver dependency and enhance version retrieval npm m…
neriousy 11a5976
fix: semver version
neriousy 0f282dc
refactor: npm -> package-registry
neriousy d04f4d8
fix: types semver ver
neriousy 9ce1240
wip
neriousy b9a2ff4
refactor
neriousy 9d0a325
clean up
neriousy c37becb
Merge branch 'dev' into fix/slow-plugins
neriousy e6030de
mock test
neriousy caeaa38
fix: last one
neriousy 0b783cd
new lock file
neriousy 19c2aa4
remove semver dependency
neriousy 87e0c43
Merge branch 'dev' into fix/slow-plugins
neriousy 3170262
Merge branch 'dev' into fix/slow-plugins
neriousy 7bcf7ef
Merge branch 'dev' into fix/slow-plugins
neriousy 0609a92
restore lock file from dev
neriousy b57788b
remove mocks
neriousy 3169695
revert changes
neriousy 3fb7de1
fix: plugin package reinstall
neriousy ef0767e
Merge branch 'dev' into fix/slow-plugins
neriousy ac56535
remove dead codE
neriousy 83f833c
review: refactor
neriousy efd1649
tests: increase time-out
neriousy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { Log } from "../util/log" | ||
|
|
||
| export namespace Npm { | ||
| const log = Log.create({ service: "npm" }) | ||
|
|
||
| export async function getLatestVersion(pkg: string): Promise<string | null> { | ||
| const encoded = pkg.replace("/", "%2F") | ||
| const url = `https://registry.npmjs.org/${encoded}/latest` | ||
|
neriousy marked this conversation as resolved.
Outdated
|
||
| const response = await fetch(url, { | ||
| headers: { | ||
| Accept: "application/json", | ||
| }, | ||
| }).catch(() => null) | ||
|
|
||
| if (!response) { | ||
| log.warn("Failed to fetch latest version from registry", { pkg }) | ||
| return null | ||
| } | ||
|
|
||
| if (!response.ok) { | ||
| log.warn("Failed to fetch latest version from registry", { pkg, status: response.status }) | ||
| return null | ||
| } | ||
|
|
||
| const data = (await response.json().catch(() => null)) as { version?: string } | null | ||
| if (!data?.version) return null | ||
| return data.version | ||
| } | ||
|
|
||
| export function compareVersions(left: string, right: string): number { | ||
| const leftParts = left.split(".").map((part) => parseInt(part, 10) || 0) | ||
| const rightParts = right.split(".").map((part) => parseInt(part, 10) || 0) | ||
| const length = Math.max(leftParts.length, rightParts.length) | ||
|
|
||
| for (let i = 0; i < length; i++) { | ||
| const leftValue = leftParts[i] ?? 0 | ||
| const rightValue = rightParts[i] ?? 0 | ||
| if (leftValue < rightValue) return -1 | ||
| if (leftValue > rightValue) return 1 | ||
| } | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
| export async function isOutdated(pkg: string, cachedVersion: string): Promise<boolean> { | ||
| const latestVersion = await getLatestVersion(pkg) | ||
| if (!latestVersion) { | ||
| log.warn("Failed to resolve latest version, using cached", { pkg, cachedVersion }) | ||
| return false | ||
| } | ||
| return compareVersions(cachedVersion, latestVersion) < 0 | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.