Skip to content
Merged
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
5 changes: 5 additions & 0 deletions projects/internals/metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Node.js scripts that parse the monorepo and generate static JSON metadata files:
- **`lighthouse.ts`** - Collects performance metrics (bundled via Git LFS)
- **`wireit.ts`** - Generates build dependency graph visualization data
- **`releases.ts`** - Parses git history to extract package release information
- **`adoption.ts`** - Refreshes public npm, jsDelivr, and GitHub adoption metrics

### 2. Services (`src/services/`)

Expand All @@ -37,6 +38,7 @@ Runtime services that provide cached access to generated metadata with fallback
- **`TestsService`** - Exposes test coverage and results
- **`ReleasesService`** - Returns release history
- **`WireitService`** - Exposes build graph data
- **`AdoptionService`** - Returns the public adoption metrics snapshot
Comment thread
coderabbitai[bot] marked this conversation as resolved.

Services use a **dual-loading pattern**: first attempting to load from local `static/*.json` files, then falling back to fetching from public CDN if unavailable.

Expand Down Expand Up @@ -83,3 +85,6 @@ The metadata scripts generate common metadata about projects in the repo. This i
- `pnpm run generate:examples`: runs the examples metadata script gathering all the source examples from the packages.
- `pnpm run generate:wireit`: runs the wireit script that gathers all metadata details about the CI build and wireit dependencies.

## Manual/scheduled tasks

- `pnpm run generate:adoption`: refreshes the public adoption metrics snapshot from npm, jsDelivr, and GitHub public APIs. This task is not part of normal CI because it uses live public network data.
34 changes: 26 additions & 8 deletions projects/internals/metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "node --experimental-strip-types ./src/metadata.ts",
"dev": "node ./src/metadata.ts",
"ci": "wireit",
"build": "wireit",
"generate:api": "wireit",
"generate:tests": "wireit",
"generate:examples": "wireit",
"generate:adoption": "wireit",
"generate:lighthouse": "wireit",
"generate:wireit": "wireit",
"generate:releases": "wireit",
Expand All @@ -28,6 +29,10 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./services/adoption.service.js": {
"types": "./dist/services/adoption.service.d.ts",
"default": "./dist/src/services/adoption.service.js"
},
"./services/api.service.js": {
"types": "./dist/services/api.service.d.ts",
"default": "./dist/src/services/api.service.js"
Expand Down Expand Up @@ -65,6 +70,7 @@
"files": [
"src/**",
"!src/**/*.test.ts",
"static/adoption.json",
"static/lighthouse.json",
"static/releases.json",
"static/tests.json",
Expand All @@ -85,7 +91,7 @@
]
},
"generate:api": {
"command": "node --experimental-strip-types ./src/tasks/api.ts",
"command": "node ./src/tasks/api.ts",
"files": [
"./src/tasks/api.ts",
"./src/tasks/api.utils.ts",
Expand Down Expand Up @@ -143,7 +149,7 @@
]
},
"generate:projects": {
"command": "node --experimental-strip-types ./src/tasks/projects.ts",
"command": "node ./src/tasks/projects.ts",
"files": [
"./src/tasks/projects.ts",
"./src/tasks/projects.utils.ts",
Expand Down Expand Up @@ -177,7 +183,7 @@
]
},
"generate:tests": {
"command": "node --experimental-strip-types ./src/tasks/tests.ts",
"command": "node ./src/tasks/tests.ts",
"files": [
"./src/tasks/tests.ts",
"./src/tasks/tests.utils.ts",
Expand Down Expand Up @@ -272,7 +278,7 @@
]
},
"generate:examples": {
"command": "node --experimental-strip-types ./src/tasks/examples.ts",
"command": "node ./src/tasks/examples.ts",
"clean": false,
"files": [
"./src/tasks/examples.ts",
Expand Down Expand Up @@ -321,8 +327,20 @@
}
]
},
"generate:adoption": {
"command": "node ./src/tasks/adoption.ts",
"clean": false,
"files": [
"src/tasks/adoption.ts",
"src/tasks/adoption.utils.ts",
"../../*/package.json"
],
"output": [
"static/adoption.json"
]
Comment thread
coryrylan marked this conversation as resolved.
},
"generate:lighthouse": {
"command": "node --experimental-strip-types ./src/tasks/lighthouse.ts",
"command": "node ./src/tasks/lighthouse.ts",
"clean": false,
"files": [
"src/tasks/lighthouse.ts",
Expand All @@ -336,7 +354,7 @@
]
},
"generate:wireit": {
"command": "node --experimental-strip-types ./src/tasks/wireit.ts",
"command": "node ./src/tasks/wireit.ts",
"clean": false,
"files": [
"src/tasks/wireit.ts",
Expand All @@ -348,7 +366,7 @@
"dependencies": []
},
"generate:releases": {
"command": "node --experimental-strip-types ./src/tasks/releases.ts",
"command": "node ./src/tasks/releases.ts",
"clean": false,
"files": [
"src/tasks/releases.ts",
Expand Down
1 change: 1 addition & 0 deletions projects/internals/metadata/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

export { ExamplesService } from './services/examples.service.js';
export * from './services/adoption.service.js';
export * from './services/api.service.js';
export * from './services/tests.service.js';
export * from './services/wireit.service.js';
Expand Down
20 changes: 20 additions & 0 deletions projects/internals/metadata/src/services/adoption.service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it } from 'vitest';
import { AdoptionService } from './adoption.service.js';

describe('AdoptionService', () => {
it('should return the adoption data', async () => {
const adoption = await AdoptionService.getData();

expect(adoption.created).toBeDefined();
expect(adoption.packages.length).toBeGreaterThan(0);
expect(adoption.totals.packages).toBe(adoption.packages.length);
expect(adoption.github.repository).toBe('NVIDIA/elements');
expect(await AdoptionService.getData()).toEqual(adoption);

adoption.github.repository = 'modified';
expect((await AdoptionService.getData()).github.repository).toBe('NVIDIA/elements');
});
});
45 changes: 45 additions & 0 deletions projects/internals/metadata/src/services/adoption.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { AdoptionSummary } from '../types.js';

export class AdoptionService {
static #adoption: AdoptionSummary = {
created: '',
period: '',
sources: {
npmDownloads: '',
npmRegistry: '',
jsdelivr: '',
github: ''
},
totals: {
packages: 0,
publishedPackages: 0,
partialPackages: 0,
unavailablePackages: 0,
npmDownloads: 0,
cdnRequests: 0
},
packages: [],
github: {
repository: '',
stars: 0,
forks: 0,
subscribers: 0,
contributors: 0,
releases: 0,
stargazers: [],
errors: []
}
};

static async getData(): Promise<AdoptionSummary> {
if (AdoptionService.#adoption.created === '') {
AdoptionService.#adoption = (await import('../../static/adoption.json', { with: { type: 'json' } }))
.default as AdoptionSummary;
Comment on lines +37 to +40

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

The JSON import path does not survive the published dist layout.

getData() loads ../../static/adoption.json, which is correct from src/services, but this package exports the built runtime from ./dist/src/services/adoption.service.js. From that emitted location the same relative path points at dist/static/adoption.json, while this PR generates the artifact at static/adoption.json. Unless the build also copies the file into dist/static, the public AdoptionService export will throw at runtime.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@projects/internals/metadata/src/services/adoption.service.ts` around lines 37
- 40, The dynamic JSON import in AdoptionService.getData() uses a
source-relative path that breaks once the package is published from the dist
layout. Update the import in getData() so it resolves the built runtime artifact
correctly, or ensure the build copies adoption.json into the emitted dist/static
location that AdoptionService expects. Use the existing AdoptionService and
getData() symbols to locate the runtime import and make the published export
load the JSON successfully.

}

return structuredClone(AdoptionService.#adoption);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('ReleasesService', () => {
expect(releases).toBeDefined();
expect(releases.created).toBeDefined();
expect(releases.data).toBeDefined();
expect(releases.data.length).toBeGreaterThan(0);
expect(releases.data.length).toBeGreaterThan(1);
expect(releases.data.some(release => release.name === '@nvidia-elements/core-v2.0.2')).toBe(true);
Comment thread
coryrylan marked this conversation as resolved.
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { WireitService } from './wireit.service.js';

describe('WireitService', () => {
it('should return the wireit graph data', async () => {
expect(WireitService.getData).toBeTruthy();
const graph = await WireitService.getData();

expect(graph.nodes.length).toBeGreaterThan(0);
expect(graph.links.length).toBeGreaterThan(0);
expect(await WireitService.getData()).toBe(graph);
Comment thread
coryrylan marked this conversation as resolved.
});
});
12 changes: 12 additions & 0 deletions projects/internals/metadata/src/tasks/adoption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { getAdoptionData } from './adoption.utils.ts';

const adoption = await getAdoptionData();

writeFileSync(resolve(import.meta.dirname, '../../static/adoption.json'), JSON.stringify(adoption, null, 2));

console.log('✅ Adoption metrics generated successfully.');
Loading