Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bae54bb
Implementation of svelte.dev/packages only with no package search
benmccann Sep 5, 2025
4f9e1a5
remove unused code
benmccann Sep 19, 2025
22b615f
fix bad data
benmccann Sep 19, 2025
a9203db
add missing sv add-ons
benmccann Sep 19, 2025
23e3be0
add vite-plugin-devtools-json
benmccann Sep 19, 2025
1029b9a
add back alias
benmccann Sep 19, 2025
f4b7dfb
keep one packages-meta
jycouet Sep 20, 2025
ffa80fe
add sv cmd display
jycouet Sep 20, 2025
6082afe
add link to title of pkg
jycouet Sep 20, 2025
6df755f
rmv icon for border left
jycouet Sep 20, 2025
cd3b623
update main redirect (hompage or sv)
jycouet Sep 20, 2025
6590e5e
homelink & sv link
jycouet Sep 20, 2025
9f3052a
Merge branch 'main' into packages-launch
teemingc Sep 21, 2025
17c7595
remove little used routers
benmccann Sep 22, 2025
242bc62
add router from svelte faq
benmccann Sep 22, 2025
5c06311
move svelte-chartjs. lowercase titles
benmccann Sep 22, 2025
515cb55
remove unused field from registry
benmccann Sep 22, 2025
704b712
update sv add-ons title
benmccann Sep 23, 2025
7ea75ed
show some categories as alternatives to sveltekit functionality
benmccann Sep 23, 2025
a97e894
cleanup list of packages and descriptions
benmccann Sep 23, 2025
00868e5
better display of add-ons
benmccann Sep 23, 2025
22458b2
svelte-check
benmccann Sep 23, 2025
31a37d0
category descriptions
benmccann Sep 23, 2025
82cb0a4
update descriptions to mention tailwind
benmccann Sep 23, 2025
4f4e635
prettier
benmccann Sep 23, 2025
3a94e92
cleanup
benmccann Sep 23, 2025
acde235
scroll y
jycouet Sep 23, 2025
04805e7
Merge branch 'packages-launch' of github.com:sveltejs/svelte.dev into…
jycouet Sep 23, 2025
ce092fb
more cleanup
jycouet Sep 23, 2025
b2fdc27
add 2 missing json
jycouet Sep 23, 2025
b9cc49f
rmv unused json
jycouet Sep 23, 2025
0a221e4
update metadata
jycouet Sep 23, 2025
eb59c03
repo_rul back
jycouet Sep 23, 2025
1a1c02a
update metadata script
jycouet Sep 23, 2025
231c17c
Merge branch 'main' into packages-launch
teemingc Sep 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/svelte.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"check": "node scripts/update.js && svelte-kit sync && svelte-check",
"format": "prettier --write .",
"lint": "prettier --check .",
"sync-docs": "tsx scripts/sync-docs/index.ts"
"sync-docs": "tsx scripts/sync-docs/index.ts",
"sync-packages": "tsx scripts/sync-packages/index.ts"
},
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.15",
Expand Down
142 changes: 142 additions & 0 deletions apps/svelte.dev/scripts/sync-packages/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import { PACKAGES_META } from '../../src/lib/packages-meta';
import { execSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';

const start = performance.now();
console.log('[sync-packages] start');

const packages = [
...PACKAGES_META.FEATURED.flatMap((pkg) => pkg.packages),
...PACKAGES_META.SV_ADD.packages
];

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)) {
console.warn(` "${pkg}" -> "${jsonPath}" not found, we will create it!`);
const p = await fetchData(pkg);
writeButPretty(jsonPath, JSON.stringify(p, null, 2));
}
}

// PART 2: check if all json files are needed
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) {
console.error(jsonNotNeeded.join('\n'));
console.error(
`ERROR: ${jsonNotNeeded.length} json files are not needed as they are not in the packages array`
);

// delete json files
// for (const pkg of jsonNotNeeded) {
// fs.unlinkSync(path.join(registryFolder, pkg));
// }

theEnd(1);
}

// PART 3: refresh data
registryJsonFiles = fs.readdirSync(registryFolder); // .slice(0, 1);

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 refreshJson(path.join(registryFolder, pkg));
})
);
}

theEnd(0);

// HELPERS

function theEnd(val: number) {
console.log(`[sync-packages] exit(${val}) - took: ${(performance.now() - start).toFixed(0)}ms`);
process.exit(val);
}

async function fetchData(pkg: string) {
const [npmInfo, npmDlInfo] = await Promise.all([
fetch(`https://registry.npmjs.org/${pkg}`).then((r) => r.json()),
fetch(`https://api.npmjs.org/downloads/point/last-week/${pkg}`).then((r) => r.json())
]);
// delete npmInfo.readme;
// delete npmInfo.versions;
const 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}`);
}
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];

let github_stars = 0;
if (git_org && git_repo) {
const githubInfo = await fetch(`https://api.github.com/repos/${git_org}/${git_repo}`).then(
(r) => r.json()
);
github_stars = githubInfo.stargazers_count;
}

return {
name: pkg,
// description, // let's not overwrite the description for now.
repo_url,
authors,
homepage,
downloads,
version,
updated,
// runes: false,
github_stars
// typescript: false,
// kit_range: '',
// last_rune_check_version: ''
};
}

async function refreshJson(fullPath: string) {
console.log(`Working on:`, fullPath);

const currentJson = JSON.parse(fs.readFileSync(fullPath, 'utf-8'));
const newData = await fetchData(currentJson.name);

// remove all undefined values
for (const key in newData) {
if (newData[key] === undefined) {
delete newData[key];
}
}

writeButPretty(fullPath, JSON.stringify({ ...currentJson, ...newData }, null, 2));
}

function writeButPretty(path: string, data: any) {
fs.writeFileSync(path, data);
execSync(`prettier --write ${path}`);
}
Loading