-
Notifications
You must be signed in to change notification settings - Fork 5
chore(docs): add adoption metrics generation and service #156
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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'); | ||
| }); | ||
| }); |
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| return structuredClone(AdoptionService.#adoption); | ||
| } | ||
| } | ||
| 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.'); |
Uh oh!
There was an error while loading. Please reload this page.