Skip to content
Draft

Tui #3193

Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 0 deletions knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const config: KnipConfig = {
project: ['**/*.{ts,vue,cjs,mjs,css}'],
ignoreDependencies: ['@nuxtjs/mdc'],
},
'tui': {
project: ['src/**/*.ts!'],
},
},
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build:test": "TEST=1 vp run build",
"dev": "nuxt dev",
"dev:docs": "vp run --filter npmx-docs dev --port=3001",
"npmx-tui": "vp run --filter npmx-tui dev",
"i18n:check:fix": "node scripts/compare-translations.ts --fix",
"i18n:report:fix": "node scripts/remove-unused-translations.ts",
"knip:fix": "knip --fix",
Expand All @@ -36,7 +37,7 @@
"test:browser:ui": "vp run build:test && vp run test:browser:prebuilt --ui",
"test:browser:update": "vp run build:test && vp run test:browser:prebuilt --update-snapshots",
"test:nuxt": "vp test --project nuxt",
"test:types": "vp run generate:lexicons && nuxt prepare && vue-tsc -b --noEmit && vp run --filter npmx-connector test:types",
"test:types": "vp run generate:lexicons && nuxt prepare && vue-tsc -b --noEmit && vp run --filter npmx-connector test:types && vp run --filter npmx-tui test:types",
"test:unit": "vp test --project unit",
"start:playwright:webserver": "TEST=1 vp run preview --port 5678",
"storybook": "STORYBOOK=true storybook dev -p 6006",
Expand Down
131 changes: 131 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ packages:
- .
- cli
- docs
- tui

allowBuilds:
'@atcute/time-ms': true
Expand Down
44 changes: 40 additions & 4 deletions server/api/registry/package-meta/[...pkg].get.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
import { normalizeLicense } from '#shared/utils/npm'
import type { PackumentVersion } from '#shared/types'

function countRecordEntries(value: Record<string, unknown> | undefined): number {
return value ? Object.keys(value).length : 0
}

function getBinNames(bin: PackumentVersion['bin'] | undefined): string[] {
if (!bin) {
return []
}

if (typeof bin === 'string') {
return ['bin']
}

return Object.keys(bin)
}

/**
* Returns lightweight package metadata for search results.
Expand Down Expand Up @@ -31,7 +48,9 @@ export default defineCachedEventHandler(

const latestVersion =
packument['dist-tags']?.latest || Object.values(packument['dist-tags'] ?? {})[0] || ''
const latestManifest = latestVersion ? packument.versions?.[latestVersion] : undefined
const modified = packument.time?.modified || packument.time?.[latestVersion] || ''
const created = packument.time?.created || ''
const date = packument.time?.[latestVersion] || modified

// Extract repository URL from the packument's repository field
Expand Down Expand Up @@ -68,23 +87,40 @@ export default defineCachedEventHandler(
author = typeof a === 'string' ? { name: a } : { name: a.name, email: a.email, url: a.url }
}

const license = normalizeLicense(packument.license)
const license = normalizeLicense(latestManifest?.license ?? packument.license)

return {
name: packument.name,
version: latestVersion,
description: packument.description,
keywords: packument.keywords,
description: packument.description ?? 'No description provided.',
keywords: latestManifest?.keywords ?? packument.keywords ?? [],
license,
date,
modified,
created,
distTags: packument['dist-tags'] ?? {},
versionCount: Object.keys(packument.versions ?? {}).length,
deprecated: latestManifest?.deprecated,
unpackedSize: latestManifest?.dist?.unpackedSize,
entryPoints: {
type: latestManifest?.type,
main: latestManifest?.main,
module: latestManifest?.module,
types: latestManifest?.types ?? latestManifest?.typings,
hasExports: latestManifest?.exports !== undefined,
binNames: getBinNames(latestManifest?.bin),
engines: latestManifest?.engines,
dependenciesCount: countRecordEntries(latestManifest?.dependencies),
peerDependenciesCount: countRecordEntries(latestManifest?.peerDependencies),
},
links: {
npm: `https://www.npmjs.com/package/${packument.name}`,
homepage: packument.homepage,
repository: repositoryUrl,
bugs: bugsUrl,
},
author,
maintainers: packument.maintainers,
maintainers: packument.maintainers ?? [],
weeklyDownloads: downloads?.downloads,
}
} catch (error: unknown) {
Expand Down
Loading
Loading