Skip to content

Commit a293289

Browse files
committed
refactor: remove npms
1 parent 230b7c7 commit a293289

File tree

4 files changed

+0
-97
lines changed

4 files changed

+0
-97
lines changed

docs/content/2.guide/1.features.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ Make sure to replace `TYPE` with one of the options listed below and `YOUR_PACKA
119119
- **types**: Indicates if TypeScript types are included. :img{src="https://img.shields.io/badge/%233b82f6-3b82f6" class="inline align-middle h-5 w-14"} / :img{src="https://img.shields.io/badge/%2364748b-64748b" class="inline align-middle h-5 w-14"}
120120
- **maintainers**: Displays the total count of package maintainers. :img{src="https://img.shields.io/badge/%2306b6d4-06b6d4" class="inline align-middle h-5 w-14"}
121121
- **deprecated**: Shows if the package is active or deprecated. :img{src="https://img.shields.io/badge/%2322c55e-22c55e" class="inline align-middle h-5 w-14"} / :img{src="https://img.shields.io/badge/%23ef4444-ef4444" class="inline align-middle h-5 w-14"}
122-
- **quality**: NPMS.io quality score based on linting and tests. :img{src="https://img.shields.io/badge/%23a855f7-a855f7" class="inline align-middle h-5 w-14"}
123-
- **popularity**: NPMS.io popularity score based on downloads and stars. :img{src="https://img.shields.io/badge/%2306b6d4-06b6d4" class="inline align-middle h-5 w-14"}
124-
- **maintenance**: NPMS.io maintenance score based on activity. :img{src="https://img.shields.io/badge/%23eab308-eab308" class="inline align-middle h-5 w-14"}
125-
- **score**: The overall NPMS.io combined score. :img{src="https://img.shields.io/badge/%233b82f6-3b82f6" class="inline align-middle h-5 w-14"}
126122
- **name**: Simple badge displaying the package name. :img{src="https://img.shields.io/badge/%2364748b-64748b" class="inline align-middle h-5 w-14"}
127123

128124
#### Examples
@@ -147,10 +143,6 @@ Make sure to replace `TYPE` with one of the options listed below and `YOUR_PACKA
147143
# Specific Version
148144

149145
[![Open on npmx.dev](https://npmx.dev/api/registry/badge/version/react/v/18.0.0)](https://npmx.dev/package/react)
150-
151-
# Quality Score
152-
153-
[![Open on npmx.dev](https://npmx.dev/api/registry/badge/quality/pinia)](https://npmx.dev/package/pinia)
154146
```
155147

156148
#### Customization Parameters

modules/runtime/server/cache.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,29 +140,6 @@ function getMockForUrl(url: string): MockResult | null {
140140
}
141141
}
142142

143-
// npms.io API - return mock package score data
144-
if (host === 'api.npms.io') {
145-
const packageMatch = decodeURIComponent(pathname).match(/^\/v2\/package\/(.+)$/)
146-
if (packageMatch?.[1]) {
147-
return {
148-
data: {
149-
analyzedAt: new Date().toISOString(),
150-
collected: {
151-
metadata: { name: packageMatch[1] },
152-
},
153-
score: {
154-
final: 0.75,
155-
detail: {
156-
quality: 0.8,
157-
popularity: 0.7,
158-
maintenance: 0.75,
159-
},
160-
},
161-
},
162-
}
163-
}
164-
}
165-
166143
// jsdelivr CDN - return 404 for README files, etc.
167144
if (host === 'cdn.jsdelivr.net') {
168145
// Return null data which will cause a 404 - README files are optional

server/api/registry/badge/[type]/[...pkg].get.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { handleApiError } from '#server/utils/error-handler'
1111
const NPM_DOWNLOADS_API = 'https://api.npmjs.org/downloads/point'
1212
const OSV_QUERY_API = 'https://api.osv.dev/v1/query'
1313
const BUNDLEPHOBIA_API = 'https://bundlephobia.com/api/size'
14-
const NPMS_API = 'https://api.npms.io/v2/package'
1514

1615
const SafeStringSchema = v.pipe(v.string(), v.regex(/^[^<>"&]*$/, 'Invalid characters'))
1716
const SafeColorSchema = v.pipe(
@@ -252,16 +251,6 @@ async function fetchDownloads(
252251
}
253252
}
254253

255-
async function fetchNpmsScore(packageName: string) {
256-
try {
257-
const response = await fetch(`${NPMS_API}/${encodeURIComponent(packageName)}`)
258-
const data = await response.json()
259-
return data.score
260-
} catch {
261-
return null
262-
}
263-
}
264-
265254
async function fetchVulnerabilities(packageName: string, version: string): Promise<number> {
266255
try {
267256
const response = await fetch(OSV_QUERY_API, {
@@ -395,30 +384,6 @@ const badgeStrategies = {
395384
color: isDeprecated ? COLORS.red : COLORS.green,
396385
}
397386
},
398-
399-
'quality': async (pkgData: globalThis.Packument) => {
400-
const score = await fetchNpmsScore(pkgData.name)
401-
const value = score ? `${Math.round(score.detail.quality * 100)}%` : 'unknown'
402-
return { label: 'quality', value, color: COLORS.purple }
403-
},
404-
405-
'popularity': async (pkgData: globalThis.Packument) => {
406-
const score = await fetchNpmsScore(pkgData.name)
407-
const value = score ? `${Math.round(score.detail.popularity * 100)}%` : 'unknown'
408-
return { label: 'popularity', value, color: COLORS.cyan }
409-
},
410-
411-
'maintenance': async (pkgData: globalThis.Packument) => {
412-
const score = await fetchNpmsScore(pkgData.name)
413-
const value = score ? `${Math.round(score.detail.maintenance * 100)}%` : 'unknown'
414-
return { label: 'maintenance', value, color: COLORS.yellow }
415-
},
416-
417-
'score': async (pkgData: globalThis.Packument) => {
418-
const score = await fetchNpmsScore(pkgData.name)
419-
const value = score ? `${Math.round(score.final * 100)}%` : 'unknown'
420-
return { label: 'score', value, color: COLORS.blue }
421-
},
422387
}
423388

424389
const BadgeTypeSchema = v.picklist(Object.keys(badgeStrategies) as [string, ...string[]])

test/fixtures/mock-routes.cjs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -373,36 +373,6 @@ function matchBundlephobiaApi(urlString) {
373373
return null
374374
}
375375

376-
/**
377-
* @param {string} urlString
378-
* @returns {MockResponse | null}
379-
*/
380-
function matchNpmsApi(urlString) {
381-
const url = new URL(urlString)
382-
const pathname = decodeURIComponent(url.pathname)
383-
384-
const packageMatch = pathname.match(/^\/v2\/package\/(.+)$/)
385-
if (packageMatch && packageMatch[1]) {
386-
const packageName = packageMatch[1]
387-
return json({
388-
analyzedAt: new Date().toISOString(),
389-
collected: {
390-
metadata: { name: packageName },
391-
},
392-
score: {
393-
final: 0.75,
394-
detail: {
395-
quality: 0.8,
396-
popularity: 0.7,
397-
maintenance: 0.75,
398-
},
399-
},
400-
})
401-
}
402-
403-
return null
404-
}
405-
406376
/**
407377
* @param {string} _urlString
408378
* @returns {MockResponse | null}
@@ -534,7 +504,6 @@ const routes = [
534504
{ name: 'fast-npm-meta', pattern: 'https://npm.antfu.dev/**', match: matchFastNpmMeta },
535505
{ name: 'JSR registry', pattern: 'https://jsr.io/**', match: matchJsrRegistry },
536506
{ name: 'Bundlephobia API', pattern: 'https://bundlephobia.com/**', match: matchBundlephobiaApi },
537-
{ name: 'npms.io API', pattern: 'https://api.npms.io/**', match: matchNpmsApi },
538507
{ name: 'jsdelivr CDN', pattern: 'https://cdn.jsdelivr.net/**', match: matchJsdelivrCdn },
539508
{
540509
name: 'jsdelivr Data API',

0 commit comments

Comments
 (0)