-
-
Notifications
You must be signed in to change notification settings - Fork 187
svelte.dev/packages #1523
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
svelte.dev/packages #1523
Changes from all commits
Commits
Show all changes
151 commits
Select commit
Hold shift + click to select a range
bae54bb
Implementation of svelte.dev/packages only with no package search
benmccann 4f9e1a5
remove unused code
benmccann 22b615f
fix bad data
benmccann a9203db
add missing sv add-ons
benmccann 23e3be0
add vite-plugin-devtools-json
benmccann 1029b9a
add back alias
benmccann f4b7dfb
keep one packages-meta
jycouet ffa80fe
add sv cmd display
jycouet 6082afe
add link to title of pkg
jycouet 6df755f
rmv icon for border left
jycouet cd3b623
update main redirect (hompage or sv)
jycouet 6590e5e
homelink & sv link
jycouet 9f3052a
Merge branch 'main' into packages-launch
teemingc 17c7595
remove little used routers
benmccann 242bc62
add router from svelte faq
benmccann 5c06311
move svelte-chartjs. lowercase titles
benmccann 515cb55
remove unused field from registry
benmccann 704b712
update sv add-ons title
benmccann 7ea75ed
show some categories as alternatives to sveltekit functionality
benmccann a97e894
cleanup list of packages and descriptions
benmccann 00868e5
better display of add-ons
benmccann 22458b2
svelte-check
benmccann 31a37d0
category descriptions
benmccann 82cb0a4
update descriptions to mention tailwind
benmccann 4f4e635
prettier
benmccann 3a94e92
cleanup
benmccann acde235
scroll y
jycouet 04805e7
Merge branch 'packages-launch' of github.com:sveltejs/svelte.dev into…
jycouet ce092fb
more cleanup
jycouet b2fdc27
add 2 missing json
jycouet b9cc49f
rmv unused json
jycouet 0a221e4
update metadata
jycouet eb59c03
repo_rul back
jycouet 1a1c02a
update metadata script
jycouet 231c17c
Merge branch 'main' into packages-launch
teemingc 2b1a418
update melt to new package
benmccann 6d9812b
add testing and devtools section
benmccann 6ed8629
i18n category
benmccann 4d09c7f
cleanup media category
benmccann 8895ce6
update metadata
jycouet 214fcbf
rmv duplicate
jycouet 287d73f
Merge branch 'main' into packages-launch
teemingc 837e3ea
add links in descriptions
benmccann 6115add
bug fix: don't mutate existing data
benmccann 483001d
change wuchale to '@wuchale/svelte'
benmccann 7c801bf
format
benmccann fb961a9
update browser extension listing
benmccann 88802ae
remove a couple more entries
benmccann 490bd6f
Merge branch 'packages-launch' of github.com:sveltejs/svelte.dev into…
jycouet e95b77b
update stats
jycouet c01a662
addin a report at the end
jycouet 8584955
add github token (preparing action) & update stars
jycouet 19b0e2a
add some reports
jycouet 4f4610d
moving things around for stats & better understanding
jycouet 47e0dc6
pretty
jycouet 84b229a
update with svelte_range & kit_range
jycouet 78a4238
stable order
jycouet 73588f1
fetcher
jycouet b2827b2
address deprecations
benmccann cd7c37e
add sveltepress
benmccann 2491346
no filter npm stats
jycouet d096f30
CI sync-packages v001
jycouet 3f17a42
CI sync-packages v002
jycouet 3c33d6f
CI sync-packages v003
jycouet 28203cd
CI sync-packages v004
jycouet f0512b3
CI sync-packages v005
jycouet 3f474e9
CI sync-packages v006
jycouet 2b884a3
CI sync-packages v007
jycouet 6cf1dd3
CI sync-packages v008
jycouet 3bb55f1
CI sync-packages v009
jycouet 3fdd8e1
CI sync-packages v011
jycouet 4673561
update metadata
jycouet 57f702b
adding a readme
jycouet 3d94a1a
update stats
jycouet 166a17d
switch to full ts first (description)
jycouet 065ec62
better CRUD management
jycouet 68b1d41
Don't use @html description (and strip out makdown links). Descriptio…
jycouet c6700f0
more package cleanup
benmccann 51ac8c8
remove comment
benmccann 4903fac
add deno sveltekit adapter
benmccann 66c561b
reorder categories
benmccann ab85fe6
move ark down a few places out of the default viewport
benmccann 04ba8cc
Update .github/workflows/sync-packages.yml
benmccann 619d1af
Update .github/workflows/sync-packages.yml
benmccann a5bdc7a
update setup-node action
benmccann e7be61e
don't use tsx for new script
benmccann c755de9
add a link to sveltesociety
benmccann d3cc0d8
format
benmccann dab7641
more-less
jycouet af99bcb
tweak styles
Rich-Harris 0e4c140
style tweaks
Rich-Harris fe0cf69
tweak
Rich-Harris f622bee
fix scroll
Rich-Harris 7db7c1c
dark mode
Rich-Harris de61946
tweaks
Rich-Harris e2e491c
more useful title
Rich-Harris 8eb152e
make the entire card a link
Rich-Harris 08032ba
tidy up
Rich-Harris 2f05761
tweak wording
Rich-Harris aa1ed61
move stuff to top
Rich-Harris 5cc6a81
remove link to sveltesociety.dev
Rich-Harris d6406c2
add note
Rich-Harris 76ac0f4
tweak styles
Rich-Harris 038a857
unused
Rich-Harris 15944db
design cleanup (#1568)
jycouet 900d220
description overrides
benmccann c78510e
merge
Rich-Harris f783a19
use <details>
Rich-Harris b4ac581
Merge branch 'packages-launch' of github.com:sveltejs/svelte.dev into…
Rich-Harris 2a3ba4d
tweak
Rich-Harris b6f1306
unused
Rich-Harris 4a07942
sync script update
jycouet c6142cf
rmc dots at the end of desc
jycouet 068d55e
cleanup description will not end by "." & links will not end with #re…
jycouet 11f4013
update data
jycouet 1156513
cursor: pointer all the way
jycouet 1555565
always link
Rich-Harris c7861b5
omit links element for sv add-ons
Rich-Harris 8637923
remove stats from sv add-ons
Rich-Harris be5bcce
more description updates
benmccann e8013a5
a few more descriptions
benmccann 70feaae
logos
Rich-Harris 4e77684
hack
Rich-Harris f316a39
Merge branch 'packages-launch-logos' into packages-launch
Rich-Harris 3d535d8
fix playwright logo cropping
Rich-Harris 38490ab
tweak some wording slightly
Rich-Harris e23cc5e
slim down some descriptions
Rich-Harris c11b9d0
lucia description
Rich-Harris fe47214
bunch more
Rich-Harris 6720f3a
more
Rich-Harris 503f8ae
more
Rich-Harris 74c0498
more
Rich-Harris 62b9249
more
Rich-Harris e83c328
fix lucide
benmccann c259d69
finish removing package
benmccann 136da5f
more
Rich-Harris 09bef26
Merge branch 'packages-launch' of github.com:sveltejs/svelte.dev into…
Rich-Harris d9cb37a
fix
Rich-Harris 75847e2
focus ring on links
Rich-Harris 30b9020
small tweak
Rich-Harris e18467a
fix
Rich-Harris 293424a
text-decoration to make it clear it links
Rich-Harris b4c50fe
tweak
Rich-Harris 1d64167
add permalink
jycouet 9412126
sharing links are open
jycouet 46c1913
rmv auto, add static, tweak order
jycouet 609aaa8
semi
jycouet a33d4ff
sync packages
benmccann 09e3979
remove kit-docs as unmaintained
benmccann 186100b
remove amp package
Rich-Harris cf28cf9
Merge branch 'packages-launch' of github.com:sveltejs/svelte.dev into…
Rich-Harris 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Sync packages | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * 0' # At 00:00 on Sunday. | ||
workflow_dispatch: # Allow manual triggering | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pnpm/action-setup@v4 | ||
- uses: actions/setup-node@v5 | ||
with: | ||
node-version: 24 | ||
- run: pnpm install --frozen-lockfile --ignore-scripts | ||
|
||
- name: Sync packages | ||
run: cd apps/svelte.dev && pnpm sync-packages | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create or update pull request | ||
uses: peter-evans/create-pull-request@599a7e63a6240886b1b61fe984db1de9e0b05bc4 # v7.0.8 | ||
with: | ||
commit-message: 'chore(packages): Update metadata' | ||
title: 'chore(packages): Update metadata' | ||
body: Automatically fetch latest packages metadata from NPM & GitHub. | ||
branch: ci/update-packages-metadata | ||
delete-branch: true |
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
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,19 @@ | ||
# sync-packages | ||
|
||
This script syncs the packages metadata from NPM & GitHub. | ||
|
||
## Usage | ||
|
||
```bash | ||
pnpm sync-packages | ||
``` | ||
|
||
## Notes | ||
|
||
- All packages `names` are in `FEATURED` of [packages-meta.ts](apps/svelte.dev/src/lib/packages-meta.ts) file. | ||
|
||
If you want to add or remove a package, you need to update `FEATURED` objects and run the script again (it will update the json files in the `src/lib/server/generated/registry` directory). | ||
|
||
- [sync-packages.yml](/.github/workflows/sync-packages.yml) is responsible for running the script regularly and update all metadata (it can also be triggered manually). | ||
|
||
- Ambassadors and maintainers are curating the list of packages. |
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,280 @@ | ||
import { PACKAGES_META } from '../../src/lib/packages-meta.ts'; | ||
import type { PackageKey, PackageNpm, PackageGithub } from '../../src/lib/server/content.ts'; | ||
import { execSync } from 'node:child_process'; | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import process from 'node:process'; | ||
|
||
let skipGithubStars = false; | ||
|
||
const start = performance.now(); | ||
console.log('[sync-packages] start'); | ||
|
||
let logsAtTheEnd: { | ||
type: | ||
| 'no_repo_url' | ||
| 'low_downloads' | ||
| 'low_github_stars' | ||
| 'new_json_file' | ||
| 'deleted_unused_json_file' | ||
| 'outdated' | ||
| 'deprecated' | ||
| 'npm_error'; | ||
pkg: string; | ||
extra: string; | ||
}[] = []; | ||
|
||
const packages = PACKAGES_META.FEATURED.flatMap((pkg) => pkg.packages).map((pkg) => pkg.name); | ||
|
||
const registryFolder = 'src/lib/server/generated/registry'; | ||
|
||
// PART 1: create missing json files | ||
for (const pkg of packages) { | ||
const cleanPkg = pkg.replace('@', '').replace('/', '-'); | ||
const jsonPath = path.join(registryFolder, `${cleanPkg}.json`); | ||
if (!fs.existsSync(jsonPath)) { | ||
const p = await getNpmAndGitHubData(pkg); | ||
writeJsonData(jsonPath, p); | ||
logsAtTheEnd.push({ type: 'new_json_file', pkg, extra: `created -> ${jsonPath}` }); | ||
} | ||
} | ||
|
||
// PART 2: delete unused json files | ||
let registryJsonFiles = fs.readdirSync(registryFolder); | ||
const jsonUsed: string[] = []; | ||
for (const pkg of packages) { | ||
const cleanPkg = pkg.replace('@', '').replace('/', '-'); | ||
const cleanPkgFile = `${cleanPkg}.json`; | ||
const jsonPath = path.join(registryFolder, cleanPkgFile); | ||
if (fs.existsSync(jsonPath)) { | ||
jsonUsed.push(cleanPkgFile); | ||
} | ||
} | ||
const jsonNotNeeded = registryJsonFiles.filter((pkg) => !jsonUsed.includes(pkg)); | ||
if (jsonNotNeeded.length > 0) { | ||
// delete json files | ||
for (const pkg of jsonNotNeeded) { | ||
const jsonPath = path.join(registryFolder, pkg); | ||
fs.unlinkSync(jsonPath); | ||
logsAtTheEnd.push({ type: 'deleted_unused_json_file', pkg, extra: `deleted -> ${jsonPath}` }); | ||
} | ||
|
||
// Let's continue | ||
// theEnd(1); | ||
} | ||
|
||
// PART 3: refresh data | ||
registryJsonFiles = fs.readdirSync(registryFolder); //.slice(0, 20); | ||
|
||
const batch = 10; | ||
for (let i = 0; i < registryJsonFiles.length; i += batch) { | ||
const batchFiles = registryJsonFiles.slice(i, i + batch); | ||
await Promise.all( | ||
batchFiles.map(async (pkg) => { | ||
await refreshJsonFile(path.join(registryFolder, pkg)); | ||
}) | ||
); | ||
} | ||
|
||
theEnd(0); | ||
|
||
// HELPERS | ||
|
||
function theEnd(val: number) { | ||
const msg = ['[sync-packages]']; | ||
if (val > 0) { | ||
msg.push(`exit(${val}) - `); | ||
} | ||
msg.push(`took: ${(performance.now() - start).toFixed(0)}ms`); | ||
console.log(msg.join(' ')); | ||
if (logsAtTheEnd.length > 0) { | ||
console.log('[sync-packages] report:'); | ||
const typePrints: Record<(typeof logsAtTheEnd)[number]['type'], string> = { | ||
no_repo_url: 'No GitHub URL', | ||
low_downloads: 'Low Downloads', | ||
low_github_stars: 'Low Stars', | ||
new_json_file: 'NEW JSON', | ||
deleted_unused_json_file: 'DEL JSON', | ||
outdated: 'Outdated', | ||
deprecated: 'Deprecated', | ||
npm_error: 'NPM Error' | ||
}; | ||
console.log( | ||
` - ${logsAtTheEnd.map((l) => `${typePrints[l.type].padEnd(15)} | ${l.pkg.padEnd(35)} | ${l.extra}`).join('\n - ')}` | ||
); | ||
} | ||
process.exit(val); | ||
} | ||
|
||
async function getNpmAndGitHubData(pkg: string): Promise<PackageKey & PackageNpm & PackageGithub> { | ||
const [npmInfo, npmDlInfo] = await Promise.all([ | ||
fetchJson(`https://registry.npmjs.org/${pkg}`), | ||
fetchJson(`https://api.npmjs.org/downloads/point/last-week/${pkg}`) | ||
]); | ||
|
||
if (npmInfo.error) { | ||
logsAtTheEnd.push({ type: 'npm_error', pkg, extra: npmInfo.error }); | ||
theEnd(1); | ||
} | ||
|
||
// delete npmInfo.readme; | ||
// delete npmInfo.versions; | ||
// console.log(`npmInfo`, npmInfo); | ||
|
||
const npm_description = npmInfo.description; | ||
const raw_repo_url = npmInfo.repository?.url ?? ''; | ||
const repo_url = raw_repo_url?.replace(/^git\+/, '').replace(/\.git$/, ''); | ||
if (!repo_url) { | ||
// console.error(`repo_url not found for ${pkg}`); | ||
logsAtTheEnd.push({ type: 'no_repo_url', pkg, extra: `not found` }); | ||
} | ||
const git_org = repo_url?.split('/')[3]; | ||
const git_repo = repo_url?.split('/')[4]; | ||
|
||
const authors = npmInfo.maintainers?.map((m: { name: string }) => m.name); | ||
const homepage = npmInfo.homepage; | ||
const downloads = npmDlInfo.downloads; | ||
const version = npmInfo['dist-tags'].latest; | ||
const updated = npmInfo.time[version]; | ||
const pkgInfo = npmInfo.versions[version]; | ||
const deprecated_reason = pkgInfo.deprecated; | ||
|
||
const svelte_range = | ||
pkgInfo.peerDependencies?.svelte ?? | ||
pkgInfo.dependencies?.svelte ?? | ||
pkgInfo.devDependencies?.svelte; | ||
|
||
const kit_range = | ||
pkgInfo.peerDependencies?.['@sveltejs/kit'] ?? | ||
pkgInfo.dependencies?.['@sveltejs/kit'] ?? | ||
pkgInfo.devDependencies?.['@sveltejs/kit']; | ||
|
||
// GitHub | ||
let github_stars: number | undefined = undefined; | ||
if (git_org && git_repo && !skipGithubStars) { | ||
const token = process.env.GITHUB_TOKEN; | ||
const headers = token ? new Headers({ authorization: 'Bearer ' + token }) : {}; | ||
const res = await fetchJson(`https://api.github.com/repos/${git_org}/${git_repo}`, { headers }); | ||
if (res?.message && res?.message.startsWith('API rate limit exceeded')) { | ||
skipGithubStars = true; | ||
} else { | ||
github_stars = res.stargazers_count; | ||
} | ||
} | ||
|
||
return { | ||
name: pkg, | ||
npm_description, | ||
repo_url, | ||
authors, | ||
homepage, | ||
version, | ||
deprecated_reason, | ||
downloads, | ||
updated, | ||
svelte_range, | ||
kit_range, | ||
|
||
// GitHub | ||
github_stars | ||
}; | ||
} | ||
|
||
async function refreshJsonFile(fullPath: string) { | ||
console.log(`Refreshing:`, fullPath); | ||
|
||
const currentJson = JSON.parse(fs.readFileSync(fullPath, 'utf-8')); | ||
const newData = await getNpmAndGitHubData(currentJson.name); | ||
|
||
// remove all undefined values | ||
for (const key in newData) { | ||
if (newData[key] === undefined) { | ||
delete newData[key]; | ||
} | ||
} | ||
|
||
// Let's not filter npm downloads changes | ||
// // filter changes of downloads | ||
// if (newData.downloads && currentJson.downloads) { | ||
// const dlDelta = Math.abs( | ||
// ((newData.downloads - currentJson.downloads) / currentJson.downloads) * 100 | ||
// ); | ||
// if (dlDelta < 2.5) delete newData.downloads; | ||
// } | ||
|
||
const data = { ...currentJson, ...newData }; | ||
|
||
// Some stats infos to log | ||
if (data.downloads && data.downloads < 255) { | ||
logsAtTheEnd.push({ type: 'low_downloads', pkg: data.name, extra: `${data.downloads}` }); | ||
} | ||
|
||
if (data.github_stars && data.github_stars < 42) { | ||
logsAtTheEnd.push({ | ||
type: 'low_github_stars', | ||
pkg: data.name, | ||
extra: `${data.github_stars}` | ||
}); | ||
} | ||
|
||
if (data.updated && PACKAGES_META.is_outdated(data.updated)) { | ||
logsAtTheEnd.push({ type: 'outdated', pkg: data.name, extra: `${data.updated}` }); | ||
} | ||
|
||
if (data.deprecated_reason) { | ||
logsAtTheEnd.push({ type: 'deprecated', pkg: data.name, extra: `${data.deprecated_reason}` }); | ||
} | ||
|
||
writeJsonData(fullPath, data); | ||
} | ||
|
||
function writeJsonData(path: string, data: any) { | ||
const keysOrder: (keyof PackageKey | keyof PackageNpm | keyof PackageGithub)[] = [ | ||
'name', | ||
'npm_description', | ||
'repo_url', | ||
'authors', | ||
'homepage', | ||
'version', | ||
'deprecated_reason', | ||
'downloads', | ||
'github_stars', | ||
'updated', | ||
'svelte_range', | ||
'kit_range', | ||
'typescript', | ||
'runes', | ||
'last_rune_check_version' | ||
]; | ||
|
||
const sortedData: Record<string, any> = {}; | ||
for (const key of keysOrder) { | ||
if (data[key] !== undefined) { | ||
sortedData[key] = data[key]; | ||
} | ||
} | ||
// all all the remaining keys | ||
for (const key in data) { | ||
if (!keysOrder.includes(key as keyof PackageKey | keyof PackageNpm | keyof PackageGithub)) { | ||
sortedData[key] = data[key]; | ||
} | ||
} | ||
|
||
fs.writeFileSync(path, JSON.stringify(sortedData, null, 2)); | ||
execSync(`prettier --write ${path}`); | ||
} | ||
|
||
async function fetchJson(url: string, options: RequestInit = {}): Promise<any> { | ||
const headers = new Headers({ ...options.headers, 'User-Agent': 'svelte.dev/packages_v0.0.1' }); | ||
|
||
for (let i = 0; i < 5; i++) { | ||
try { | ||
const res = await fetch(url, { ...options, headers }); | ||
return await res.json(); | ||
} catch (e) { | ||
console.error(`Failed to fetch ${url} after ${i + 1} retries`); | ||
} | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 1000 * Math.pow(2, i + 1))); | ||
} | ||
} |
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.