@reallukemanning/folio 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/copy-components.js +31 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/core/copy-components.js.html +178 -0
- package/coverage/core/eslint.config.js.html +184 -0
- package/coverage/core/index.html +146 -0
- package/coverage/core/src/__tests__/benchmarks/ProjectCard.bench.tsx.html +364 -0
- package/coverage/core/src/__tests__/benchmarks/ProjectView.bench.tsx.html +484 -0
- package/coverage/core/src/__tests__/benchmarks/github.bench.ts.html +244 -0
- package/coverage/core/src/__tests__/benchmarks/index.html +191 -0
- package/coverage/core/src/__tests__/benchmarks/npm.bench.ts.html +271 -0
- package/coverage/core/src/__tests__/benchmarks/product-hunt.bench.ts.html +259 -0
- package/coverage/core/src/__tests__/benchmarks/utilities.bench.ts.html +478 -0
- package/coverage/core/src/components/FeaturedProject.test.tsx.html +697 -0
- package/coverage/core/src/components/FeaturedProject.tsx.html +163 -0
- package/coverage/core/src/components/ProjectCard/ProjectCard.test.tsx.html +928 -0
- package/coverage/core/src/components/ProjectCard/ProjectCard.tsx.html +379 -0
- package/coverage/core/src/components/ProjectCard/index.html +146 -0
- package/coverage/core/src/components/ProjectCard/index.ts.html +88 -0
- package/coverage/core/src/components/ProjectGrid/ProjectGrid.test.tsx.html +292 -0
- package/coverage/core/src/components/ProjectGrid/ProjectGrid.tsx.html +103 -0
- package/coverage/core/src/components/ProjectGrid/index.html +146 -0
- package/coverage/core/src/components/ProjectGrid/index.ts.html +88 -0
- package/coverage/core/src/components/ProjectList/ProjectList.test.tsx.html +292 -0
- package/coverage/core/src/components/ProjectList/ProjectList.tsx.html +103 -0
- package/coverage/core/src/components/ProjectList/index.html +146 -0
- package/coverage/core/src/components/ProjectList/index.ts.html +88 -0
- package/coverage/core/src/components/ProjectView/ProjectView.test.tsx.html +1108 -0
- package/coverage/core/src/components/ProjectView/ProjectView.tsx.html +589 -0
- package/coverage/core/src/components/ProjectView/index.html +146 -0
- package/coverage/core/src/components/ProjectView/index.ts.html +88 -0
- package/coverage/core/src/components/index.html +146 -0
- package/coverage/core/src/components/index.ts.html +97 -0
- package/coverage/core/src/index.html +116 -0
- package/coverage/core/src/index.ts.html +94 -0
- package/coverage/core/src/lib/__tests__/defineProjects.test.ts.html +421 -0
- package/coverage/core/src/lib/__tests__/filterByFeatured.test.ts.html +523 -0
- package/coverage/core/src/lib/__tests__/filterByStatus.test.ts.html +664 -0
- package/coverage/core/src/lib/__tests__/filterByType.test.ts.html +631 -0
- package/coverage/core/src/lib/__tests__/github.test.ts.html +1783 -0
- package/coverage/core/src/lib/__tests__/hybrid-config.test.ts.html +1345 -0
- package/coverage/core/src/lib/__tests__/index.html +311 -0
- package/coverage/core/src/lib/__tests__/normalise.test.ts.html +1585 -0
- package/coverage/core/src/lib/__tests__/npm-config.test.ts.html +385 -0
- package/coverage/core/src/lib/__tests__/npm.test.ts.html +1135 -0
- package/coverage/core/src/lib/__tests__/product-hunt-config.test.ts.html +397 -0
- package/coverage/core/src/lib/__tests__/product-hunt.test.ts.html +505 -0
- package/coverage/core/src/lib/__tests__/sortByDate.test.ts.html +751 -0
- package/coverage/core/src/lib/__tests__/sortByName.test.ts.html +832 -0
- package/coverage/core/src/lib/__tests__/sortByStars.test.ts.html +703 -0
- package/coverage/core/src/lib/defineProjects.ts.html +100 -0
- package/coverage/core/src/lib/filterByFeatured.ts.html +133 -0
- package/coverage/core/src/lib/filterByStatus.ts.html +145 -0
- package/coverage/core/src/lib/filterByType.ts.html +133 -0
- package/coverage/core/src/lib/github.ts.html +517 -0
- package/coverage/core/src/lib/index.html +281 -0
- package/coverage/core/src/lib/index.ts.html +130 -0
- package/coverage/core/src/lib/normalise.ts.html +868 -0
- package/coverage/core/src/lib/npm.ts.html +199 -0
- package/coverage/core/src/lib/product-hunt.ts.html +256 -0
- package/coverage/core/src/lib/sortByDate.ts.html +175 -0
- package/coverage/core/src/lib/sortByName.ts.html +172 -0
- package/coverage/core/src/lib/sortByStars.ts.html +172 -0
- package/coverage/core/src/types/index.html +116 -0
- package/coverage/core/src/types/index.ts.html +517 -0
- package/coverage/core/vitest.config.ts.html +178 -0
- package/coverage/coverage-final.json +53 -0
- package/coverage/coverage-summary.json +54 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +266 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.d.ts +6 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.d.ts.map +1 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.js +9 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.js.map +1 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.tsx +54 -0
- package/dist/cli-components/FeaturedProject/index.d.ts +3 -0
- package/dist/cli-components/FeaturedProject/index.d.ts.map +1 -0
- package/dist/cli-components/FeaturedProject/index.js +2 -0
- package/dist/cli-components/FeaturedProject/index.js.map +1 -0
- package/dist/cli-components/FeaturedProject/index.ts +2 -0
- package/dist/cli-components/ProjectCard/ProjectCard.d.ts +26 -0
- package/dist/cli-components/ProjectCard/ProjectCard.d.ts.map +1 -0
- package/dist/cli-components/ProjectCard/ProjectCard.js +33 -0
- package/dist/cli-components/ProjectCard/ProjectCard.js.map +1 -0
- package/dist/cli-components/ProjectCard/ProjectCard.tsx +90 -0
- package/dist/cli-components/ProjectCard/index.d.ts +3 -0
- package/dist/cli-components/ProjectCard/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectCard/index.js +2 -0
- package/dist/cli-components/ProjectCard/index.js.map +1 -0
- package/dist/cli-components/ProjectCard/index.ts +2 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.d.ts +5 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.d.ts.map +1 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.js +8 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.js.map +1 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/dist/cli-components/ProjectGrid/index.d.ts +3 -0
- package/dist/cli-components/ProjectGrid/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectGrid/index.js +2 -0
- package/dist/cli-components/ProjectGrid/index.js.map +1 -0
- package/dist/cli-components/ProjectGrid/index.ts +2 -0
- package/dist/cli-components/ProjectList/ProjectList.d.ts +5 -0
- package/dist/cli-components/ProjectList/ProjectList.d.ts.map +1 -0
- package/dist/cli-components/ProjectList/ProjectList.js +8 -0
- package/dist/cli-components/ProjectList/ProjectList.js.map +1 -0
- package/dist/cli-components/ProjectList/ProjectList.tsx +6 -0
- package/dist/cli-components/ProjectList/index.d.ts +3 -0
- package/dist/cli-components/ProjectList/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectList/index.js +2 -0
- package/dist/cli-components/ProjectList/index.js.map +1 -0
- package/dist/cli-components/ProjectList/index.ts +2 -0
- package/dist/cli-components/ProjectView/ProjectView.d.ts +17 -0
- package/dist/cli-components/ProjectView/ProjectView.d.ts.map +1 -0
- package/dist/cli-components/ProjectView/ProjectView.js +39 -0
- package/dist/cli-components/ProjectView/ProjectView.js.map +1 -0
- package/dist/cli-components/ProjectView/ProjectView.tsx +117 -0
- package/dist/cli-components/ProjectView/index.d.ts +3 -0
- package/dist/cli-components/ProjectView/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectView/index.js +2 -0
- package/dist/cli-components/ProjectView/index.js.map +1 -0
- package/dist/cli-components/ProjectView/index.ts +2 -0
- package/dist/cli-components/types.d.ts +52 -0
- package/dist/cli-components/types.d.ts.map +1 -0
- package/dist/cli-components/types.js +2 -0
- package/dist/cli-components/types.js.map +1 -0
- package/dist/cli-components/types.ts +58 -0
- package/dist/cli-types.d.ts +52 -0
- package/dist/cli-types.d.ts.map +1 -0
- package/dist/cli-types.js +2 -0
- package/dist/cli-types.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +166 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +231 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/components/FeaturedProject.d.ts +7 -0
- package/dist/components/FeaturedProject.d.ts.map +1 -0
- package/dist/components/FeaturedProject.js +10 -0
- package/dist/components/FeaturedProject.js.map +1 -0
- package/dist/components/FeaturedProject.test.tsx +204 -0
- package/dist/components/FeaturedProject.tsx +26 -0
- package/dist/components/ProjectCard/ProjectCard.d.ts +26 -0
- package/dist/components/ProjectCard/ProjectCard.d.ts.map +1 -0
- package/dist/components/ProjectCard/ProjectCard.js +39 -0
- package/dist/components/ProjectCard/ProjectCard.js.map +1 -0
- package/dist/components/ProjectCard/ProjectCard.test.tsx +281 -0
- package/dist/components/ProjectCard/ProjectCard.tsx +98 -0
- package/dist/components/ProjectCard/index.d.ts +2 -0
- package/dist/components/ProjectCard/index.d.ts.map +1 -0
- package/dist/components/ProjectCard/index.js +2 -0
- package/dist/components/ProjectCard/index.js.map +1 -0
- package/dist/components/ProjectCard/index.ts +1 -0
- package/dist/components/ProjectGrid/ProjectGrid.d.ts +5 -0
- package/dist/components/ProjectGrid/ProjectGrid.d.ts.map +1 -0
- package/dist/components/ProjectGrid/ProjectGrid.js +8 -0
- package/dist/components/ProjectGrid/ProjectGrid.js.map +1 -0
- package/dist/components/ProjectGrid/ProjectGrid.test.tsx +69 -0
- package/dist/components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/dist/components/ProjectGrid/index.d.ts +2 -0
- package/dist/components/ProjectGrid/index.d.ts.map +1 -0
- package/dist/components/ProjectGrid/index.js +2 -0
- package/dist/components/ProjectGrid/index.js.map +1 -0
- package/dist/components/ProjectGrid/index.ts +1 -0
- package/dist/components/ProjectList/ProjectList.d.ts +5 -0
- package/dist/components/ProjectList/ProjectList.d.ts.map +1 -0
- package/dist/components/ProjectList/ProjectList.js +8 -0
- package/dist/components/ProjectList/ProjectList.js.map +1 -0
- package/dist/components/ProjectList/ProjectList.test.tsx +69 -0
- package/dist/components/ProjectList/ProjectList.tsx +6 -0
- package/dist/components/ProjectList/index.d.ts +2 -0
- package/dist/components/ProjectList/index.d.ts.map +1 -0
- package/dist/components/ProjectList/index.js +2 -0
- package/dist/components/ProjectList/index.js.map +1 -0
- package/dist/components/ProjectList/index.ts +1 -0
- package/dist/components/ProjectView/ProjectView.d.ts +20 -0
- package/dist/components/ProjectView/ProjectView.d.ts.map +1 -0
- package/dist/components/ProjectView/ProjectView.js +64 -0
- package/dist/components/ProjectView/ProjectView.js.map +1 -0
- package/dist/components/ProjectView/ProjectView.test.tsx +341 -0
- package/dist/components/ProjectView/ProjectView.tsx +168 -0
- package/dist/components/ProjectView/index.d.ts +2 -0
- package/dist/components/ProjectView/index.d.ts.map +1 -0
- package/dist/components/ProjectView/index.js +2 -0
- package/dist/components/ProjectView/index.js.map +1 -0
- package/dist/components/ProjectView/index.ts +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.ts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/defineProjects.d.ts +3 -0
- package/dist/lib/defineProjects.d.ts.map +1 -0
- package/dist/lib/defineProjects.js +4 -0
- package/dist/lib/defineProjects.js.map +1 -0
- package/dist/lib/filterByFeatured.d.ts +3 -0
- package/dist/lib/filterByFeatured.d.ts.map +1 -0
- package/dist/lib/filterByFeatured.js +10 -0
- package/dist/lib/filterByFeatured.js.map +1 -0
- package/dist/lib/filterByStatus.d.ts +3 -0
- package/dist/lib/filterByStatus.d.ts.map +1 -0
- package/dist/lib/filterByStatus.js +13 -0
- package/dist/lib/filterByStatus.js.map +1 -0
- package/dist/lib/filterByType.d.ts +3 -0
- package/dist/lib/filterByType.d.ts.map +1 -0
- package/dist/lib/filterByType.js +10 -0
- package/dist/lib/filterByType.js.map +1 -0
- package/dist/lib/github.d.ts +24 -0
- package/dist/lib/github.d.ts.map +1 -0
- package/dist/lib/github.js +107 -0
- package/dist/lib/github.js.map +1 -0
- package/dist/lib/index.d.ts +16 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +12 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/normalise.d.ts +4 -0
- package/dist/lib/normalise.d.ts.map +1 -0
- package/dist/lib/normalise.js +221 -0
- package/dist/lib/normalise.js.map +1 -0
- package/dist/lib/npm.d.ts +7 -0
- package/dist/lib/npm.d.ts.map +1 -0
- package/dist/lib/npm.js +28 -0
- package/dist/lib/npm.js.map +1 -0
- package/dist/lib/product-hunt.d.ts +12 -0
- package/dist/lib/product-hunt.d.ts.map +1 -0
- package/dist/lib/product-hunt.js +40 -0
- package/dist/lib/product-hunt.js.map +1 -0
- package/dist/lib/sortByDate.d.ts +4 -0
- package/dist/lib/sortByDate.d.ts.map +1 -0
- package/dist/lib/sortByDate.js +21 -0
- package/dist/lib/sortByDate.js.map +1 -0
- package/dist/lib/sortByName.d.ts +4 -0
- package/dist/lib/sortByName.d.ts.map +1 -0
- package/dist/lib/sortByName.js +21 -0
- package/dist/lib/sortByName.js.map +1 -0
- package/dist/lib/sortByStars.d.ts +4 -0
- package/dist/lib/sortByStars.d.ts.map +1 -0
- package/dist/lib/sortByStars.js +21 -0
- package/dist/lib/sortByStars.js.map +1 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +2 -0
- package/dist/test-setup.js.map +1 -0
- package/dist/types/index.d.ts +121 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/eslint.config.js +33 -0
- package/package.json +47 -0
- package/playwright-report/index.html +85 -0
- package/src/__tests__/benchmarks/ProjectCard.bench.tsx +93 -0
- package/src/__tests__/benchmarks/ProjectView.bench.tsx +133 -0
- package/src/__tests__/benchmarks/github.bench.ts +53 -0
- package/src/__tests__/benchmarks/npm.bench.ts +62 -0
- package/src/__tests__/benchmarks/product-hunt.bench.ts +58 -0
- package/src/__tests__/benchmarks/utilities.bench.ts +131 -0
- package/src/cli-components/FeaturedProject/FeaturedProject.tsx +54 -0
- package/src/cli-components/FeaturedProject/index.ts +2 -0
- package/src/cli-components/ProjectCard/ProjectCard.tsx +90 -0
- package/src/cli-components/ProjectCard/index.ts +2 -0
- package/src/cli-components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/src/cli-components/ProjectGrid/index.ts +2 -0
- package/src/cli-components/ProjectList/ProjectList.tsx +6 -0
- package/src/cli-components/ProjectList/index.ts +2 -0
- package/src/cli-components/ProjectView/ProjectView.tsx +117 -0
- package/src/cli-components/ProjectView/index.ts +2 -0
- package/src/cli-components/types.ts +58 -0
- package/src/cli-types.ts +58 -0
- package/src/cli.ts +26 -0
- package/src/commands/add.ts +191 -0
- package/src/commands/init.ts +260 -0
- package/src/components/FeaturedProject.test.tsx +204 -0
- package/src/components/FeaturedProject.tsx +26 -0
- package/src/components/ProjectCard/ProjectCard.test.tsx +281 -0
- package/src/components/ProjectCard/ProjectCard.tsx +98 -0
- package/src/components/ProjectCard/index.ts +1 -0
- package/src/components/ProjectGrid/ProjectGrid.test.tsx +69 -0
- package/src/components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/src/components/ProjectGrid/index.ts +1 -0
- package/src/components/ProjectList/ProjectList.test.tsx +69 -0
- package/src/components/ProjectList/ProjectList.tsx +6 -0
- package/src/components/ProjectList/index.ts +1 -0
- package/src/components/ProjectView/ProjectView.test.tsx +341 -0
- package/src/components/ProjectView/ProjectView.tsx +168 -0
- package/src/components/ProjectView/index.ts +1 -0
- package/src/components/index.ts +4 -0
- package/src/index.ts +3 -0
- package/src/lib/__tests__/defineProjects.test.ts +112 -0
- package/src/lib/__tests__/filterByFeatured.test.ts +146 -0
- package/src/lib/__tests__/filterByStatus.test.ts +193 -0
- package/src/lib/__tests__/filterByType.test.ts +182 -0
- package/src/lib/__tests__/github.test.ts +566 -0
- package/src/lib/__tests__/hybrid-config.test.ts +420 -0
- package/src/lib/__tests__/normalise.test.ts +500 -0
- package/src/lib/__tests__/npm-config.test.ts +100 -0
- package/src/lib/__tests__/npm.test.ts +350 -0
- package/src/lib/__tests__/product-hunt-config.test.ts +104 -0
- package/src/lib/__tests__/product-hunt.test.ts +140 -0
- package/src/lib/__tests__/sortByDate.test.ts +222 -0
- package/src/lib/__tests__/sortByName.test.ts +249 -0
- package/src/lib/__tests__/sortByStars.test.ts +206 -0
- package/src/lib/defineProjects.ts +5 -0
- package/src/lib/filterByFeatured.ts +16 -0
- package/src/lib/filterByStatus.ts +20 -0
- package/src/lib/filterByType.ts +16 -0
- package/src/lib/github.ts +144 -0
- package/src/lib/index.ts +15 -0
- package/src/lib/normalise.ts +261 -0
- package/src/lib/npm.ts +38 -0
- package/src/lib/product-hunt.ts +57 -0
- package/src/lib/sortByDate.ts +30 -0
- package/src/lib/sortByName.ts +29 -0
- package/src/lib/sortByStars.ts +29 -0
- package/src/test-setup.ts +1 -0
- package/src/types/index.ts +144 -0
- package/test-results/.last-run.json +62 -0
- package/tsconfig.json +29 -0
- package/vitest.config.ts +31 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
|
+
import { normalise } from '../normalise'
|
|
3
|
+
import type { HybridProjectInput } from '../../types'
|
|
4
|
+
import { fetchGitHubRepo } from '../github'
|
|
5
|
+
import { fetchNpmPackage } from '../npm'
|
|
6
|
+
|
|
7
|
+
vi.mock('../github')
|
|
8
|
+
vi.mock('../npm')
|
|
9
|
+
|
|
10
|
+
const mockedFetchGitHubRepo = vi.mocked(fetchGitHubRepo)
|
|
11
|
+
const mockedFetchNpmPackage = vi.mocked(fetchNpmPackage)
|
|
12
|
+
|
|
13
|
+
describe('hybrid config recognition', () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
vi.clearAllMocks()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('should recognize a hybrid project when type is "hybrid"', async () => {
|
|
19
|
+
const input: HybridProjectInput = {
|
|
20
|
+
id: 'test-hybrid',
|
|
21
|
+
type: 'hybrid',
|
|
22
|
+
repo: 'user/repo',
|
|
23
|
+
package: 'test-package',
|
|
24
|
+
status: 'active',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const result = await normalise(input)
|
|
28
|
+
|
|
29
|
+
expect(result.type).toBe('hybrid')
|
|
30
|
+
expect(result.id).toBe('test-hybrid')
|
|
31
|
+
expect(result.repo).toBe('user/repo')
|
|
32
|
+
expect(result.package).toBe('test-package')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should fetch from both GitHub and npm APIs for hybrid projects', async () => {
|
|
36
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
37
|
+
name: 'test-package',
|
|
38
|
+
description: 'A test package',
|
|
39
|
+
stargazers_count: 100,
|
|
40
|
+
forks_count: 20,
|
|
41
|
+
language: 'TypeScript',
|
|
42
|
+
topics: [],
|
|
43
|
+
html_url: 'https://github.com/user/repo',
|
|
44
|
+
homepage: 'https://example.com',
|
|
45
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
46
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
50
|
+
name: 'test-package',
|
|
51
|
+
version: '1.0.0',
|
|
52
|
+
downloads: 5000,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const input: HybridProjectInput = {
|
|
56
|
+
id: 'test-hybrid',
|
|
57
|
+
type: 'hybrid',
|
|
58
|
+
repo: 'user/repo',
|
|
59
|
+
package: 'test-package',
|
|
60
|
+
status: 'active',
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
await normalise(input)
|
|
64
|
+
|
|
65
|
+
expect(mockedFetchGitHubRepo).toHaveBeenCalledWith('user/repo')
|
|
66
|
+
expect(mockedFetchNpmPackage).toHaveBeenCalledWith('test-package')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('should merge stats from both GitHub and npm', async () => {
|
|
70
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
71
|
+
name: 'test-package',
|
|
72
|
+
description: 'A test package',
|
|
73
|
+
stargazers_count: 100,
|
|
74
|
+
forks_count: 20,
|
|
75
|
+
language: 'TypeScript',
|
|
76
|
+
topics: [],
|
|
77
|
+
html_url: 'https://github.com/user/repo',
|
|
78
|
+
homepage: 'https://example.com',
|
|
79
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
80
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
84
|
+
name: 'test-package',
|
|
85
|
+
version: '1.0.0',
|
|
86
|
+
downloads: 5000,
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const input: HybridProjectInput = {
|
|
90
|
+
id: 'test-hybrid',
|
|
91
|
+
type: 'hybrid',
|
|
92
|
+
repo: 'user/repo',
|
|
93
|
+
package: 'test-package',
|
|
94
|
+
status: 'active',
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const result = await normalise(input)
|
|
98
|
+
|
|
99
|
+
expect(result.stats).toEqual({
|
|
100
|
+
stars: 100,
|
|
101
|
+
forks: 20,
|
|
102
|
+
downloads: '5000',
|
|
103
|
+
version: '1.0.0',
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('should merge successful source stats when one API fails', async () => {
|
|
108
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
109
|
+
name: 'test-package',
|
|
110
|
+
description: 'A test package',
|
|
111
|
+
stargazers_count: 100,
|
|
112
|
+
forks_count: 20,
|
|
113
|
+
language: 'TypeScript',
|
|
114
|
+
topics: [],
|
|
115
|
+
html_url: 'https://github.com/user/repo',
|
|
116
|
+
homepage: 'https://example.com',
|
|
117
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
118
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
mockedFetchNpmPackage.mockResolvedValue(null)
|
|
122
|
+
|
|
123
|
+
const input: HybridProjectInput = {
|
|
124
|
+
id: 'test-hybrid',
|
|
125
|
+
type: 'hybrid',
|
|
126
|
+
repo: 'user/repo',
|
|
127
|
+
package: 'test-package',
|
|
128
|
+
status: 'active',
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const result = await normalise(input)
|
|
132
|
+
|
|
133
|
+
expect(result.stats).toEqual({
|
|
134
|
+
stars: 100,
|
|
135
|
+
forks: 20,
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('should merge successful source stats when npm API succeeds but GitHub fails', async () => {
|
|
140
|
+
mockedFetchGitHubRepo.mockResolvedValue(null)
|
|
141
|
+
|
|
142
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
143
|
+
name: 'test-package',
|
|
144
|
+
version: '1.0.0',
|
|
145
|
+
downloads: 5000,
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
const input: HybridProjectInput = {
|
|
149
|
+
id: 'test-hybrid',
|
|
150
|
+
type: 'hybrid',
|
|
151
|
+
repo: 'user/repo',
|
|
152
|
+
package: 'test-package',
|
|
153
|
+
status: 'active',
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const result = await normalise(input)
|
|
157
|
+
|
|
158
|
+
expect(result.stats).toEqual({
|
|
159
|
+
downloads: '5000',
|
|
160
|
+
version: '1.0.0',
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('should auto-generate npm link from package name', async () => {
|
|
165
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
166
|
+
name: 'test-package',
|
|
167
|
+
description: 'A test package',
|
|
168
|
+
stargazers_count: 100,
|
|
169
|
+
forks_count: 20,
|
|
170
|
+
language: 'TypeScript',
|
|
171
|
+
topics: [],
|
|
172
|
+
html_url: 'https://github.com/user/repo',
|
|
173
|
+
homepage: null,
|
|
174
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
175
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
179
|
+
name: 'test-package',
|
|
180
|
+
version: '1.0.0',
|
|
181
|
+
downloads: 5000,
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
const input: HybridProjectInput = {
|
|
185
|
+
id: 'test-hybrid',
|
|
186
|
+
type: 'hybrid',
|
|
187
|
+
repo: 'user/repo',
|
|
188
|
+
package: 'test-package',
|
|
189
|
+
status: 'active',
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const result = await normalise(input)
|
|
193
|
+
|
|
194
|
+
expect(result.links.github).toBe('https://github.com/user/repo')
|
|
195
|
+
expect(result.links.npm).toBe('https://npmjs.com/package/test-package')
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('should allow manual override of auto-generated links', async () => {
|
|
199
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
200
|
+
name: 'test-package',
|
|
201
|
+
description: 'A test package',
|
|
202
|
+
stargazers_count: 100,
|
|
203
|
+
forks_count: 20,
|
|
204
|
+
language: 'TypeScript',
|
|
205
|
+
topics: [],
|
|
206
|
+
html_url: 'https://github.com/user/repo',
|
|
207
|
+
homepage: null,
|
|
208
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
209
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
213
|
+
name: 'test-package',
|
|
214
|
+
version: '1.0.0',
|
|
215
|
+
downloads: 5000,
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
const input: HybridProjectInput = {
|
|
219
|
+
id: 'test-hybrid',
|
|
220
|
+
type: 'hybrid',
|
|
221
|
+
repo: 'user/repo',
|
|
222
|
+
package: 'test-package',
|
|
223
|
+
status: 'active',
|
|
224
|
+
links: {
|
|
225
|
+
github: 'https://custom-github.com',
|
|
226
|
+
npm: 'https://custom-npm.com/package/test-package',
|
|
227
|
+
},
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const result = await normalise(input)
|
|
231
|
+
|
|
232
|
+
expect(result.links.github).toBe('https://custom-github.com')
|
|
233
|
+
expect(result.links.npm).toBe('https://custom-npm.com/package/test-package')
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
it('should use GitHub data for name, description, and language when available', async () => {
|
|
237
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
238
|
+
name: 'github-name',
|
|
239
|
+
description: 'GitHub description',
|
|
240
|
+
stargazers_count: 100,
|
|
241
|
+
forks_count: 20,
|
|
242
|
+
language: 'TypeScript',
|
|
243
|
+
topics: [],
|
|
244
|
+
html_url: 'https://github.com/user/repo',
|
|
245
|
+
homepage: null,
|
|
246
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
247
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
251
|
+
name: 'npm-name',
|
|
252
|
+
version: '1.0.0',
|
|
253
|
+
downloads: 5000,
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
const input: HybridProjectInput = {
|
|
257
|
+
id: 'test-hybrid',
|
|
258
|
+
type: 'hybrid',
|
|
259
|
+
repo: 'user/repo',
|
|
260
|
+
package: 'test-package',
|
|
261
|
+
status: 'active',
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const result = await normalise(input)
|
|
265
|
+
|
|
266
|
+
expect(result.name).toBe('github-name')
|
|
267
|
+
expect(result.description).toBe('GitHub description')
|
|
268
|
+
expect(result.language).toBe('TypeScript')
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
it('should allow override fields to take precedence over fetched data', async () => {
|
|
272
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
273
|
+
name: 'github-name',
|
|
274
|
+
description: 'GitHub description',
|
|
275
|
+
stargazers_count: 100,
|
|
276
|
+
forks_count: 20,
|
|
277
|
+
language: 'TypeScript',
|
|
278
|
+
topics: [],
|
|
279
|
+
html_url: 'https://github.com/user/repo',
|
|
280
|
+
homepage: null,
|
|
281
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
282
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
286
|
+
name: 'npm-name',
|
|
287
|
+
version: '1.0.0',
|
|
288
|
+
downloads: 5000,
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
const input: HybridProjectInput = {
|
|
292
|
+
id: 'test-hybrid',
|
|
293
|
+
type: 'hybrid',
|
|
294
|
+
repo: 'user/repo',
|
|
295
|
+
package: 'test-package',
|
|
296
|
+
status: 'active',
|
|
297
|
+
override: {
|
|
298
|
+
name: 'Custom Name',
|
|
299
|
+
tagline: 'Custom Tagline',
|
|
300
|
+
description: 'Custom Description',
|
|
301
|
+
stack: ['React', 'Next.js'],
|
|
302
|
+
},
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const result = await normalise(input)
|
|
306
|
+
|
|
307
|
+
expect(result.name).toBe('Custom Name')
|
|
308
|
+
expect(result.tagline).toBe('Custom Tagline')
|
|
309
|
+
expect(result.description).toBe('Custom Description')
|
|
310
|
+
expect(result.stack).toEqual(['React', 'Next.js'])
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
it('should handle hybrid project with all optional fields', async () => {
|
|
314
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
315
|
+
name: 'test-package',
|
|
316
|
+
description: 'GitHub description',
|
|
317
|
+
stargazers_count: 100,
|
|
318
|
+
forks_count: 20,
|
|
319
|
+
language: 'TypeScript',
|
|
320
|
+
topics: ['react', 'nextjs'],
|
|
321
|
+
html_url: 'https://github.com/user/repo',
|
|
322
|
+
homepage: 'https://example.com',
|
|
323
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
324
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
328
|
+
name: 'test-package',
|
|
329
|
+
version: '1.0.0',
|
|
330
|
+
downloads: 5000,
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
const input: HybridProjectInput = {
|
|
334
|
+
id: 'full-hybrid',
|
|
335
|
+
type: 'hybrid',
|
|
336
|
+
repo: 'user/repo',
|
|
337
|
+
package: 'test-package',
|
|
338
|
+
status: 'shipped',
|
|
339
|
+
featured: true,
|
|
340
|
+
name: 'Full Hybrid',
|
|
341
|
+
tagline: 'A complete hybrid project',
|
|
342
|
+
description: 'Description of the project',
|
|
343
|
+
background: 'Background info',
|
|
344
|
+
why: 'Why I built it',
|
|
345
|
+
struggles: [{ type: 'warn', text: 'A warning' }],
|
|
346
|
+
timeline: [{ date: '2024-01-01', note: 'Started' }],
|
|
347
|
+
posts: [{ title: 'First Post', date: '2024-01-01' }],
|
|
348
|
+
stack: ['TypeScript', 'React'],
|
|
349
|
+
links: {
|
|
350
|
+
live: 'https://custom-live.com',
|
|
351
|
+
},
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const result = await normalise(input)
|
|
355
|
+
|
|
356
|
+
expect(result.type).toBe('hybrid')
|
|
357
|
+
expect(result.repo).toBe('user/repo')
|
|
358
|
+
expect(result.package).toBe('test-package')
|
|
359
|
+
expect(result.name).toBe('Full Hybrid')
|
|
360
|
+
expect(result.tagline).toBe('A complete hybrid project')
|
|
361
|
+
expect(result.description).toBe('Description of the project')
|
|
362
|
+
expect(result.background).toBe('Background info')
|
|
363
|
+
expect(result.why).toBe('Why I built it')
|
|
364
|
+
expect(result.struggles).toEqual([{ type: 'warn', text: 'A warning' }])
|
|
365
|
+
expect(result.timeline).toEqual([{ date: '2024-01-01', note: 'Started' }])
|
|
366
|
+
expect(result.posts).toEqual([{ title: 'First Post', date: '2024-01-01' }])
|
|
367
|
+
expect(result.stack).toEqual(['TypeScript', 'React'])
|
|
368
|
+
expect(result.links.github).toBe('https://github.com/user/repo')
|
|
369
|
+
expect(result.links.live).toBe('https://custom-live.com')
|
|
370
|
+
expect(result.links.npm).toBe('https://npmjs.com/package/test-package')
|
|
371
|
+
expect(result.stats).toEqual({
|
|
372
|
+
stars: 100,
|
|
373
|
+
forks: 20,
|
|
374
|
+
downloads: '5000',
|
|
375
|
+
version: '1.0.0',
|
|
376
|
+
})
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
it('should allow manual stats to override fetched stats', async () => {
|
|
380
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
381
|
+
name: 'test-package',
|
|
382
|
+
description: 'A test package',
|
|
383
|
+
stargazers_count: 100,
|
|
384
|
+
forks_count: 20,
|
|
385
|
+
language: 'TypeScript',
|
|
386
|
+
topics: [],
|
|
387
|
+
html_url: 'https://github.com/user/repo',
|
|
388
|
+
homepage: null,
|
|
389
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
390
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
394
|
+
name: 'test-package',
|
|
395
|
+
version: '1.0.0',
|
|
396
|
+
downloads: 5000,
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
const input: HybridProjectInput = {
|
|
400
|
+
id: 'test-hybrid',
|
|
401
|
+
type: 'hybrid',
|
|
402
|
+
repo: 'user/repo',
|
|
403
|
+
package: 'test-package',
|
|
404
|
+
status: 'active',
|
|
405
|
+
stats: {
|
|
406
|
+
stars: 999,
|
|
407
|
+
downloads: '9999',
|
|
408
|
+
},
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const result = await normalise(input)
|
|
412
|
+
|
|
413
|
+
expect(result.stats).toEqual({
|
|
414
|
+
stars: 999,
|
|
415
|
+
forks: 20,
|
|
416
|
+
downloads: '9999',
|
|
417
|
+
version: '1.0.0',
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
})
|