@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.
Files changed (332) hide show
  1. package/LICENSE +21 -0
  2. package/copy-components.js +31 -0
  3. package/coverage/base.css +224 -0
  4. package/coverage/block-navigation.js +87 -0
  5. package/coverage/core/copy-components.js.html +178 -0
  6. package/coverage/core/eslint.config.js.html +184 -0
  7. package/coverage/core/index.html +146 -0
  8. package/coverage/core/src/__tests__/benchmarks/ProjectCard.bench.tsx.html +364 -0
  9. package/coverage/core/src/__tests__/benchmarks/ProjectView.bench.tsx.html +484 -0
  10. package/coverage/core/src/__tests__/benchmarks/github.bench.ts.html +244 -0
  11. package/coverage/core/src/__tests__/benchmarks/index.html +191 -0
  12. package/coverage/core/src/__tests__/benchmarks/npm.bench.ts.html +271 -0
  13. package/coverage/core/src/__tests__/benchmarks/product-hunt.bench.ts.html +259 -0
  14. package/coverage/core/src/__tests__/benchmarks/utilities.bench.ts.html +478 -0
  15. package/coverage/core/src/components/FeaturedProject.test.tsx.html +697 -0
  16. package/coverage/core/src/components/FeaturedProject.tsx.html +163 -0
  17. package/coverage/core/src/components/ProjectCard/ProjectCard.test.tsx.html +928 -0
  18. package/coverage/core/src/components/ProjectCard/ProjectCard.tsx.html +379 -0
  19. package/coverage/core/src/components/ProjectCard/index.html +146 -0
  20. package/coverage/core/src/components/ProjectCard/index.ts.html +88 -0
  21. package/coverage/core/src/components/ProjectGrid/ProjectGrid.test.tsx.html +292 -0
  22. package/coverage/core/src/components/ProjectGrid/ProjectGrid.tsx.html +103 -0
  23. package/coverage/core/src/components/ProjectGrid/index.html +146 -0
  24. package/coverage/core/src/components/ProjectGrid/index.ts.html +88 -0
  25. package/coverage/core/src/components/ProjectList/ProjectList.test.tsx.html +292 -0
  26. package/coverage/core/src/components/ProjectList/ProjectList.tsx.html +103 -0
  27. package/coverage/core/src/components/ProjectList/index.html +146 -0
  28. package/coverage/core/src/components/ProjectList/index.ts.html +88 -0
  29. package/coverage/core/src/components/ProjectView/ProjectView.test.tsx.html +1108 -0
  30. package/coverage/core/src/components/ProjectView/ProjectView.tsx.html +589 -0
  31. package/coverage/core/src/components/ProjectView/index.html +146 -0
  32. package/coverage/core/src/components/ProjectView/index.ts.html +88 -0
  33. package/coverage/core/src/components/index.html +146 -0
  34. package/coverage/core/src/components/index.ts.html +97 -0
  35. package/coverage/core/src/index.html +116 -0
  36. package/coverage/core/src/index.ts.html +94 -0
  37. package/coverage/core/src/lib/__tests__/defineProjects.test.ts.html +421 -0
  38. package/coverage/core/src/lib/__tests__/filterByFeatured.test.ts.html +523 -0
  39. package/coverage/core/src/lib/__tests__/filterByStatus.test.ts.html +664 -0
  40. package/coverage/core/src/lib/__tests__/filterByType.test.ts.html +631 -0
  41. package/coverage/core/src/lib/__tests__/github.test.ts.html +1783 -0
  42. package/coverage/core/src/lib/__tests__/hybrid-config.test.ts.html +1345 -0
  43. package/coverage/core/src/lib/__tests__/index.html +311 -0
  44. package/coverage/core/src/lib/__tests__/normalise.test.ts.html +1585 -0
  45. package/coverage/core/src/lib/__tests__/npm-config.test.ts.html +385 -0
  46. package/coverage/core/src/lib/__tests__/npm.test.ts.html +1135 -0
  47. package/coverage/core/src/lib/__tests__/product-hunt-config.test.ts.html +397 -0
  48. package/coverage/core/src/lib/__tests__/product-hunt.test.ts.html +505 -0
  49. package/coverage/core/src/lib/__tests__/sortByDate.test.ts.html +751 -0
  50. package/coverage/core/src/lib/__tests__/sortByName.test.ts.html +832 -0
  51. package/coverage/core/src/lib/__tests__/sortByStars.test.ts.html +703 -0
  52. package/coverage/core/src/lib/defineProjects.ts.html +100 -0
  53. package/coverage/core/src/lib/filterByFeatured.ts.html +133 -0
  54. package/coverage/core/src/lib/filterByStatus.ts.html +145 -0
  55. package/coverage/core/src/lib/filterByType.ts.html +133 -0
  56. package/coverage/core/src/lib/github.ts.html +517 -0
  57. package/coverage/core/src/lib/index.html +281 -0
  58. package/coverage/core/src/lib/index.ts.html +130 -0
  59. package/coverage/core/src/lib/normalise.ts.html +868 -0
  60. package/coverage/core/src/lib/npm.ts.html +199 -0
  61. package/coverage/core/src/lib/product-hunt.ts.html +256 -0
  62. package/coverage/core/src/lib/sortByDate.ts.html +175 -0
  63. package/coverage/core/src/lib/sortByName.ts.html +172 -0
  64. package/coverage/core/src/lib/sortByStars.ts.html +172 -0
  65. package/coverage/core/src/types/index.html +116 -0
  66. package/coverage/core/src/types/index.ts.html +517 -0
  67. package/coverage/core/vitest.config.ts.html +178 -0
  68. package/coverage/coverage-final.json +53 -0
  69. package/coverage/coverage-summary.json +54 -0
  70. package/coverage/favicon.png +0 -0
  71. package/coverage/index.html +266 -0
  72. package/coverage/prettify.css +1 -0
  73. package/coverage/prettify.js +2 -0
  74. package/coverage/sort-arrow-sprite.png +0 -0
  75. package/coverage/sorter.js +210 -0
  76. package/dist/cli-components/FeaturedProject/FeaturedProject.d.ts +6 -0
  77. package/dist/cli-components/FeaturedProject/FeaturedProject.d.ts.map +1 -0
  78. package/dist/cli-components/FeaturedProject/FeaturedProject.js +9 -0
  79. package/dist/cli-components/FeaturedProject/FeaturedProject.js.map +1 -0
  80. package/dist/cli-components/FeaturedProject/FeaturedProject.tsx +54 -0
  81. package/dist/cli-components/FeaturedProject/index.d.ts +3 -0
  82. package/dist/cli-components/FeaturedProject/index.d.ts.map +1 -0
  83. package/dist/cli-components/FeaturedProject/index.js +2 -0
  84. package/dist/cli-components/FeaturedProject/index.js.map +1 -0
  85. package/dist/cli-components/FeaturedProject/index.ts +2 -0
  86. package/dist/cli-components/ProjectCard/ProjectCard.d.ts +26 -0
  87. package/dist/cli-components/ProjectCard/ProjectCard.d.ts.map +1 -0
  88. package/dist/cli-components/ProjectCard/ProjectCard.js +33 -0
  89. package/dist/cli-components/ProjectCard/ProjectCard.js.map +1 -0
  90. package/dist/cli-components/ProjectCard/ProjectCard.tsx +90 -0
  91. package/dist/cli-components/ProjectCard/index.d.ts +3 -0
  92. package/dist/cli-components/ProjectCard/index.d.ts.map +1 -0
  93. package/dist/cli-components/ProjectCard/index.js +2 -0
  94. package/dist/cli-components/ProjectCard/index.js.map +1 -0
  95. package/dist/cli-components/ProjectCard/index.ts +2 -0
  96. package/dist/cli-components/ProjectGrid/ProjectGrid.d.ts +5 -0
  97. package/dist/cli-components/ProjectGrid/ProjectGrid.d.ts.map +1 -0
  98. package/dist/cli-components/ProjectGrid/ProjectGrid.js +8 -0
  99. package/dist/cli-components/ProjectGrid/ProjectGrid.js.map +1 -0
  100. package/dist/cli-components/ProjectGrid/ProjectGrid.tsx +6 -0
  101. package/dist/cli-components/ProjectGrid/index.d.ts +3 -0
  102. package/dist/cli-components/ProjectGrid/index.d.ts.map +1 -0
  103. package/dist/cli-components/ProjectGrid/index.js +2 -0
  104. package/dist/cli-components/ProjectGrid/index.js.map +1 -0
  105. package/dist/cli-components/ProjectGrid/index.ts +2 -0
  106. package/dist/cli-components/ProjectList/ProjectList.d.ts +5 -0
  107. package/dist/cli-components/ProjectList/ProjectList.d.ts.map +1 -0
  108. package/dist/cli-components/ProjectList/ProjectList.js +8 -0
  109. package/dist/cli-components/ProjectList/ProjectList.js.map +1 -0
  110. package/dist/cli-components/ProjectList/ProjectList.tsx +6 -0
  111. package/dist/cli-components/ProjectList/index.d.ts +3 -0
  112. package/dist/cli-components/ProjectList/index.d.ts.map +1 -0
  113. package/dist/cli-components/ProjectList/index.js +2 -0
  114. package/dist/cli-components/ProjectList/index.js.map +1 -0
  115. package/dist/cli-components/ProjectList/index.ts +2 -0
  116. package/dist/cli-components/ProjectView/ProjectView.d.ts +17 -0
  117. package/dist/cli-components/ProjectView/ProjectView.d.ts.map +1 -0
  118. package/dist/cli-components/ProjectView/ProjectView.js +39 -0
  119. package/dist/cli-components/ProjectView/ProjectView.js.map +1 -0
  120. package/dist/cli-components/ProjectView/ProjectView.tsx +117 -0
  121. package/dist/cli-components/ProjectView/index.d.ts +3 -0
  122. package/dist/cli-components/ProjectView/index.d.ts.map +1 -0
  123. package/dist/cli-components/ProjectView/index.js +2 -0
  124. package/dist/cli-components/ProjectView/index.js.map +1 -0
  125. package/dist/cli-components/ProjectView/index.ts +2 -0
  126. package/dist/cli-components/types.d.ts +52 -0
  127. package/dist/cli-components/types.d.ts.map +1 -0
  128. package/dist/cli-components/types.js +2 -0
  129. package/dist/cli-components/types.js.map +1 -0
  130. package/dist/cli-components/types.ts +58 -0
  131. package/dist/cli-types.d.ts +52 -0
  132. package/dist/cli-types.d.ts.map +1 -0
  133. package/dist/cli-types.js +2 -0
  134. package/dist/cli-types.js.map +1 -0
  135. package/dist/cli.d.ts +3 -0
  136. package/dist/cli.d.ts.map +1 -0
  137. package/dist/cli.js +21 -0
  138. package/dist/cli.js.map +1 -0
  139. package/dist/commands/add.d.ts +2 -0
  140. package/dist/commands/add.d.ts.map +1 -0
  141. package/dist/commands/add.js +166 -0
  142. package/dist/commands/add.js.map +1 -0
  143. package/dist/commands/init.d.ts +6 -0
  144. package/dist/commands/init.d.ts.map +1 -0
  145. package/dist/commands/init.js +231 -0
  146. package/dist/commands/init.js.map +1 -0
  147. package/dist/components/FeaturedProject.d.ts +7 -0
  148. package/dist/components/FeaturedProject.d.ts.map +1 -0
  149. package/dist/components/FeaturedProject.js +10 -0
  150. package/dist/components/FeaturedProject.js.map +1 -0
  151. package/dist/components/FeaturedProject.test.tsx +204 -0
  152. package/dist/components/FeaturedProject.tsx +26 -0
  153. package/dist/components/ProjectCard/ProjectCard.d.ts +26 -0
  154. package/dist/components/ProjectCard/ProjectCard.d.ts.map +1 -0
  155. package/dist/components/ProjectCard/ProjectCard.js +39 -0
  156. package/dist/components/ProjectCard/ProjectCard.js.map +1 -0
  157. package/dist/components/ProjectCard/ProjectCard.test.tsx +281 -0
  158. package/dist/components/ProjectCard/ProjectCard.tsx +98 -0
  159. package/dist/components/ProjectCard/index.d.ts +2 -0
  160. package/dist/components/ProjectCard/index.d.ts.map +1 -0
  161. package/dist/components/ProjectCard/index.js +2 -0
  162. package/dist/components/ProjectCard/index.js.map +1 -0
  163. package/dist/components/ProjectCard/index.ts +1 -0
  164. package/dist/components/ProjectGrid/ProjectGrid.d.ts +5 -0
  165. package/dist/components/ProjectGrid/ProjectGrid.d.ts.map +1 -0
  166. package/dist/components/ProjectGrid/ProjectGrid.js +8 -0
  167. package/dist/components/ProjectGrid/ProjectGrid.js.map +1 -0
  168. package/dist/components/ProjectGrid/ProjectGrid.test.tsx +69 -0
  169. package/dist/components/ProjectGrid/ProjectGrid.tsx +6 -0
  170. package/dist/components/ProjectGrid/index.d.ts +2 -0
  171. package/dist/components/ProjectGrid/index.d.ts.map +1 -0
  172. package/dist/components/ProjectGrid/index.js +2 -0
  173. package/dist/components/ProjectGrid/index.js.map +1 -0
  174. package/dist/components/ProjectGrid/index.ts +1 -0
  175. package/dist/components/ProjectList/ProjectList.d.ts +5 -0
  176. package/dist/components/ProjectList/ProjectList.d.ts.map +1 -0
  177. package/dist/components/ProjectList/ProjectList.js +8 -0
  178. package/dist/components/ProjectList/ProjectList.js.map +1 -0
  179. package/dist/components/ProjectList/ProjectList.test.tsx +69 -0
  180. package/dist/components/ProjectList/ProjectList.tsx +6 -0
  181. package/dist/components/ProjectList/index.d.ts +2 -0
  182. package/dist/components/ProjectList/index.d.ts.map +1 -0
  183. package/dist/components/ProjectList/index.js +2 -0
  184. package/dist/components/ProjectList/index.js.map +1 -0
  185. package/dist/components/ProjectList/index.ts +1 -0
  186. package/dist/components/ProjectView/ProjectView.d.ts +20 -0
  187. package/dist/components/ProjectView/ProjectView.d.ts.map +1 -0
  188. package/dist/components/ProjectView/ProjectView.js +64 -0
  189. package/dist/components/ProjectView/ProjectView.js.map +1 -0
  190. package/dist/components/ProjectView/ProjectView.test.tsx +341 -0
  191. package/dist/components/ProjectView/ProjectView.tsx +168 -0
  192. package/dist/components/ProjectView/index.d.ts +2 -0
  193. package/dist/components/ProjectView/index.d.ts.map +1 -0
  194. package/dist/components/ProjectView/index.js +2 -0
  195. package/dist/components/ProjectView/index.js.map +1 -0
  196. package/dist/components/ProjectView/index.ts +1 -0
  197. package/dist/components/index.d.ts +5 -0
  198. package/dist/components/index.d.ts.map +1 -0
  199. package/dist/components/index.js +5 -0
  200. package/dist/components/index.js.map +1 -0
  201. package/dist/components/index.ts +4 -0
  202. package/dist/index.d.ts +4 -0
  203. package/dist/index.d.ts.map +1 -0
  204. package/dist/index.js +4 -0
  205. package/dist/index.js.map +1 -0
  206. package/dist/lib/defineProjects.d.ts +3 -0
  207. package/dist/lib/defineProjects.d.ts.map +1 -0
  208. package/dist/lib/defineProjects.js +4 -0
  209. package/dist/lib/defineProjects.js.map +1 -0
  210. package/dist/lib/filterByFeatured.d.ts +3 -0
  211. package/dist/lib/filterByFeatured.d.ts.map +1 -0
  212. package/dist/lib/filterByFeatured.js +10 -0
  213. package/dist/lib/filterByFeatured.js.map +1 -0
  214. package/dist/lib/filterByStatus.d.ts +3 -0
  215. package/dist/lib/filterByStatus.d.ts.map +1 -0
  216. package/dist/lib/filterByStatus.js +13 -0
  217. package/dist/lib/filterByStatus.js.map +1 -0
  218. package/dist/lib/filterByType.d.ts +3 -0
  219. package/dist/lib/filterByType.d.ts.map +1 -0
  220. package/dist/lib/filterByType.js +10 -0
  221. package/dist/lib/filterByType.js.map +1 -0
  222. package/dist/lib/github.d.ts +24 -0
  223. package/dist/lib/github.d.ts.map +1 -0
  224. package/dist/lib/github.js +107 -0
  225. package/dist/lib/github.js.map +1 -0
  226. package/dist/lib/index.d.ts +16 -0
  227. package/dist/lib/index.d.ts.map +1 -0
  228. package/dist/lib/index.js +12 -0
  229. package/dist/lib/index.js.map +1 -0
  230. package/dist/lib/normalise.d.ts +4 -0
  231. package/dist/lib/normalise.d.ts.map +1 -0
  232. package/dist/lib/normalise.js +221 -0
  233. package/dist/lib/normalise.js.map +1 -0
  234. package/dist/lib/npm.d.ts +7 -0
  235. package/dist/lib/npm.d.ts.map +1 -0
  236. package/dist/lib/npm.js +28 -0
  237. package/dist/lib/npm.js.map +1 -0
  238. package/dist/lib/product-hunt.d.ts +12 -0
  239. package/dist/lib/product-hunt.d.ts.map +1 -0
  240. package/dist/lib/product-hunt.js +40 -0
  241. package/dist/lib/product-hunt.js.map +1 -0
  242. package/dist/lib/sortByDate.d.ts +4 -0
  243. package/dist/lib/sortByDate.d.ts.map +1 -0
  244. package/dist/lib/sortByDate.js +21 -0
  245. package/dist/lib/sortByDate.js.map +1 -0
  246. package/dist/lib/sortByName.d.ts +4 -0
  247. package/dist/lib/sortByName.d.ts.map +1 -0
  248. package/dist/lib/sortByName.js +21 -0
  249. package/dist/lib/sortByName.js.map +1 -0
  250. package/dist/lib/sortByStars.d.ts +4 -0
  251. package/dist/lib/sortByStars.d.ts.map +1 -0
  252. package/dist/lib/sortByStars.js +21 -0
  253. package/dist/lib/sortByStars.js.map +1 -0
  254. package/dist/test-setup.d.ts +2 -0
  255. package/dist/test-setup.d.ts.map +1 -0
  256. package/dist/test-setup.js +2 -0
  257. package/dist/test-setup.js.map +1 -0
  258. package/dist/types/index.d.ts +121 -0
  259. package/dist/types/index.d.ts.map +1 -0
  260. package/dist/types/index.js +2 -0
  261. package/dist/types/index.js.map +1 -0
  262. package/eslint.config.js +33 -0
  263. package/package.json +47 -0
  264. package/playwright-report/index.html +85 -0
  265. package/src/__tests__/benchmarks/ProjectCard.bench.tsx +93 -0
  266. package/src/__tests__/benchmarks/ProjectView.bench.tsx +133 -0
  267. package/src/__tests__/benchmarks/github.bench.ts +53 -0
  268. package/src/__tests__/benchmarks/npm.bench.ts +62 -0
  269. package/src/__tests__/benchmarks/product-hunt.bench.ts +58 -0
  270. package/src/__tests__/benchmarks/utilities.bench.ts +131 -0
  271. package/src/cli-components/FeaturedProject/FeaturedProject.tsx +54 -0
  272. package/src/cli-components/FeaturedProject/index.ts +2 -0
  273. package/src/cli-components/ProjectCard/ProjectCard.tsx +90 -0
  274. package/src/cli-components/ProjectCard/index.ts +2 -0
  275. package/src/cli-components/ProjectGrid/ProjectGrid.tsx +6 -0
  276. package/src/cli-components/ProjectGrid/index.ts +2 -0
  277. package/src/cli-components/ProjectList/ProjectList.tsx +6 -0
  278. package/src/cli-components/ProjectList/index.ts +2 -0
  279. package/src/cli-components/ProjectView/ProjectView.tsx +117 -0
  280. package/src/cli-components/ProjectView/index.ts +2 -0
  281. package/src/cli-components/types.ts +58 -0
  282. package/src/cli-types.ts +58 -0
  283. package/src/cli.ts +26 -0
  284. package/src/commands/add.ts +191 -0
  285. package/src/commands/init.ts +260 -0
  286. package/src/components/FeaturedProject.test.tsx +204 -0
  287. package/src/components/FeaturedProject.tsx +26 -0
  288. package/src/components/ProjectCard/ProjectCard.test.tsx +281 -0
  289. package/src/components/ProjectCard/ProjectCard.tsx +98 -0
  290. package/src/components/ProjectCard/index.ts +1 -0
  291. package/src/components/ProjectGrid/ProjectGrid.test.tsx +69 -0
  292. package/src/components/ProjectGrid/ProjectGrid.tsx +6 -0
  293. package/src/components/ProjectGrid/index.ts +1 -0
  294. package/src/components/ProjectList/ProjectList.test.tsx +69 -0
  295. package/src/components/ProjectList/ProjectList.tsx +6 -0
  296. package/src/components/ProjectList/index.ts +1 -0
  297. package/src/components/ProjectView/ProjectView.test.tsx +341 -0
  298. package/src/components/ProjectView/ProjectView.tsx +168 -0
  299. package/src/components/ProjectView/index.ts +1 -0
  300. package/src/components/index.ts +4 -0
  301. package/src/index.ts +3 -0
  302. package/src/lib/__tests__/defineProjects.test.ts +112 -0
  303. package/src/lib/__tests__/filterByFeatured.test.ts +146 -0
  304. package/src/lib/__tests__/filterByStatus.test.ts +193 -0
  305. package/src/lib/__tests__/filterByType.test.ts +182 -0
  306. package/src/lib/__tests__/github.test.ts +566 -0
  307. package/src/lib/__tests__/hybrid-config.test.ts +420 -0
  308. package/src/lib/__tests__/normalise.test.ts +500 -0
  309. package/src/lib/__tests__/npm-config.test.ts +100 -0
  310. package/src/lib/__tests__/npm.test.ts +350 -0
  311. package/src/lib/__tests__/product-hunt-config.test.ts +104 -0
  312. package/src/lib/__tests__/product-hunt.test.ts +140 -0
  313. package/src/lib/__tests__/sortByDate.test.ts +222 -0
  314. package/src/lib/__tests__/sortByName.test.ts +249 -0
  315. package/src/lib/__tests__/sortByStars.test.ts +206 -0
  316. package/src/lib/defineProjects.ts +5 -0
  317. package/src/lib/filterByFeatured.ts +16 -0
  318. package/src/lib/filterByStatus.ts +20 -0
  319. package/src/lib/filterByType.ts +16 -0
  320. package/src/lib/github.ts +144 -0
  321. package/src/lib/index.ts +15 -0
  322. package/src/lib/normalise.ts +261 -0
  323. package/src/lib/npm.ts +38 -0
  324. package/src/lib/product-hunt.ts +57 -0
  325. package/src/lib/sortByDate.ts +30 -0
  326. package/src/lib/sortByName.ts +29 -0
  327. package/src/lib/sortByStars.ts +29 -0
  328. package/src/test-setup.ts +1 -0
  329. package/src/types/index.ts +144 -0
  330. package/test-results/.last-run.json +62 -0
  331. package/tsconfig.json +29 -0
  332. package/vitest.config.ts +31 -0
@@ -0,0 +1,20 @@
1
+ import type { FolioProject, ProjectStatus } from '../types'
2
+
3
+ export function filterByStatus(
4
+ projects: FolioProject[],
5
+ status: ProjectStatus | 'all' | ProjectStatus[] | undefined
6
+ ): FolioProject[] {
7
+ if (projects.length === 0) {
8
+ return []
9
+ }
10
+
11
+ if (status === 'all' || status === undefined) {
12
+ return [...projects]
13
+ }
14
+
15
+ if (Array.isArray(status)) {
16
+ return projects.filter(project => status.includes(project.status))
17
+ }
18
+
19
+ return projects.filter(project => project.status === status)
20
+ }
@@ -0,0 +1,16 @@
1
+ import type { FolioProject, ProjectType } from '../types'
2
+
3
+ export function filterByType(
4
+ projects: FolioProject[],
5
+ type: ProjectType | 'all' | undefined
6
+ ): FolioProject[] {
7
+ if (projects.length === 0) {
8
+ return []
9
+ }
10
+
11
+ if (type === 'all' || type === undefined) {
12
+ return [...projects]
13
+ }
14
+
15
+ return projects.filter(project => project.type === type)
16
+ }
@@ -0,0 +1,144 @@
1
+ export interface GitHubRepoData {
2
+ name: string
3
+ description: string | null
4
+ stargazers_count: number
5
+ forks_count: number
6
+ language: string | null
7
+ topics: string[]
8
+ html_url: string
9
+ homepage: string | null
10
+ created_at: string
11
+ updated_at: string
12
+ fork?: boolean
13
+ archived?: boolean
14
+ }
15
+
16
+ export const LANGUAGE_COLORS: Record<string, string> = {
17
+ TypeScript: '#3178c6',
18
+ JavaScript: '#f1e05a',
19
+ Python: '#3572A5',
20
+ Java: '#b07219',
21
+ Go: '#00ADD8',
22
+ Rust: '#dea584',
23
+ C: '#555555',
24
+ 'C++': '#f34b7d',
25
+ 'C#': '#239120',
26
+ PHP: '#4F5D95',
27
+ Ruby: '#701516',
28
+ Swift: '#F05138',
29
+ Kotlin: '#A97BFF',
30
+ Dart: '#00B4AB',
31
+ Scala: '#c22d40',
32
+ Haskell: '#5e5086',
33
+ Lua: '#000080',
34
+ Shell: '#89e051',
35
+ HTML: '#e34c26',
36
+ CSS: '#563d7c',
37
+ }
38
+
39
+ export async function fetchGitHubRepo(repo: string): Promise<GitHubRepoData | null> {
40
+ try {
41
+ const url = `https://api.github.com/repos/${repo}`
42
+
43
+ const headers: HeadersInit = {
44
+ Accept: 'application/vnd.github.v3+json',
45
+ }
46
+
47
+ const token = process.env.GITHUB_TOKEN
48
+ if (token) {
49
+ headers.Authorization = `Bearer ${token}`
50
+ } else {
51
+ console.warn('GITHUB_TOKEN not set - using unauthenticated GitHub API (60/hr rate limit)')
52
+ }
53
+
54
+ const response = await fetch(url, {
55
+ headers,
56
+ cache: 'force-cache',
57
+ })
58
+
59
+ if (!response.ok) {
60
+ return null
61
+ }
62
+
63
+ const data = await response.json()
64
+
65
+ return {
66
+ name: data.name,
67
+ description: data.description,
68
+ stargazers_count: data.stargazers_count,
69
+ forks_count: data.forks_count,
70
+ language: data.language,
71
+ topics: data.topics || [],
72
+ html_url: data.html_url,
73
+ homepage: data.homepage,
74
+ created_at: data.created_at,
75
+ updated_at: data.updated_at,
76
+ }
77
+ } catch {
78
+ return null
79
+ }
80
+ }
81
+
82
+ export type FetchReposError = 'rate_limit' | 'network' | 'not_found' | 'other'
83
+
84
+ export interface FetchReposResult {
85
+ data: GitHubRepoData[] | null
86
+ error: FetchReposError | null
87
+ rateLimitRemaining: number | null
88
+ }
89
+
90
+ export async function fetchGitHubRepos(username: string): Promise<FetchReposResult> {
91
+ try {
92
+ const url = `https://api.github.com/users/${username}/repos?sort=updated&per_page=100`
93
+
94
+ const headers: HeadersInit = {
95
+ Accept: 'application/vnd.github.v3+json',
96
+ }
97
+
98
+ const token = process.env.GITHUB_TOKEN
99
+ if (token) {
100
+ headers.Authorization = `Bearer ${token}`
101
+ }
102
+
103
+ const response = await fetch(url, {
104
+ headers,
105
+ })
106
+
107
+ const rateLimitRemaining = response.headers.get('X-RateLimit-Remaining')
108
+ ? parseInt(response.headers.get('X-RateLimit-Remaining')!)
109
+ : null
110
+
111
+ if (response.status === 403) {
112
+ return { data: null, error: 'rate_limit', rateLimitRemaining }
113
+ }
114
+
115
+ if (response.status === 404) {
116
+ return { data: null, error: 'not_found', rateLimitRemaining }
117
+ }
118
+
119
+ if (!response.ok) {
120
+ return { data: null, error: 'other', rateLimitRemaining }
121
+ }
122
+
123
+ const data = await response.json()
124
+
125
+ const repos = data.map((repo: any) => ({
126
+ name: repo.name,
127
+ description: repo.description,
128
+ stargazers_count: repo.stargazers_count,
129
+ forks_count: repo.forks_count,
130
+ language: repo.language,
131
+ topics: repo.topics || [],
132
+ html_url: repo.html_url,
133
+ homepage: repo.homepage,
134
+ fork: repo.fork,
135
+ archived: repo.archived,
136
+ created_at: repo.created_at,
137
+ updated_at: repo.updated_at,
138
+ }))
139
+
140
+ return { data: repos, error: null, rateLimitRemaining }
141
+ } catch {
142
+ return { data: null, error: 'network', rateLimitRemaining: null }
143
+ }
144
+ }
@@ -0,0 +1,15 @@
1
+ export { defineProjects } from './defineProjects'
2
+ export { fetchGitHubRepo, fetchGitHubRepos, LANGUAGE_COLORS } from './github'
3
+ export type { GitHubRepoData, FetchReposResult, FetchReposError } from './github'
4
+ export { fetchNpmPackage } from './npm'
5
+ export { fetchProductHuntPost } from './product-hunt'
6
+ export { filterByFeatured } from './filterByFeatured'
7
+ export { filterByStatus } from './filterByStatus'
8
+ export { filterByType } from './filterByType'
9
+ export { normalise } from './normalise'
10
+ export { sortByDate } from './sortByDate'
11
+ export { sortByName } from './sortByName'
12
+ export { sortByStars } from './sortByStars'
13
+ export type { NpmPackageData } from './npm'
14
+ export type { ProductHuntPostData } from './product-hunt'
15
+ export type { SortOrder } from './sortByDate'
@@ -0,0 +1,261 @@
1
+ import { fetchGitHubRepo, LANGUAGE_COLORS } from './github'
2
+ import { fetchNpmPackage } from './npm'
3
+ import { fetchProductHuntPost } from './product-hunt'
4
+ import type { FolioProject, FolioProjectInput, NormalizedStat, ProjectType } from '../types'
5
+
6
+ export async function normalise(input: FolioProjectInput): Promise<FolioProject> {
7
+ const {
8
+ id,
9
+ type,
10
+ status,
11
+ featured,
12
+ name: inputName,
13
+ tagline: inputTagline,
14
+ description: inputDescription,
15
+ links: inputLinks,
16
+ stack: inputStack,
17
+ stats: inputStats,
18
+ background: inputBackground,
19
+ why: inputWhy,
20
+ image: inputImage,
21
+ struggles: inputStruggles,
22
+ timeline: inputTimeline,
23
+ posts: inputPosts,
24
+ createdAt: inputCreatedAt,
25
+ updatedAt: inputUpdatedAt,
26
+ override,
27
+ } = input
28
+
29
+ const repo = 'repo' in input ? input.repo : undefined
30
+
31
+ let githubData = null
32
+
33
+ if (type === 'github' || type === 'hybrid') {
34
+ if (repo) {
35
+ githubData = await fetchGitHubRepo(repo)
36
+ }
37
+ }
38
+
39
+ const npmPackage = 'package' in input ? input.package : undefined
40
+
41
+ let npmData = null
42
+
43
+ if (type === 'npm' || type === 'hybrid') {
44
+ if (npmPackage) {
45
+ npmData = await fetchNpmPackage(npmPackage)
46
+ }
47
+ }
48
+
49
+ const slug = 'slug' in input ? input.slug : undefined
50
+
51
+ let productHuntData = null
52
+
53
+ if (type === 'product-hunt') {
54
+ if (slug) {
55
+ productHuntData = await fetchProductHuntPost(slug)
56
+ }
57
+ }
58
+
59
+ let finalName: string
60
+ let finalTagline: string
61
+ let finalDescription: string
62
+ let finalStack: string[]
63
+
64
+ if (type === 'github') {
65
+ finalName = override?.name || githubData?.name || inputName || ''
66
+ finalTagline = override?.tagline || inputTagline || ''
67
+ finalDescription = override?.description || githubData?.description || inputDescription || ''
68
+ finalStack = override?.stack || inputStack || []
69
+ } else if (type === 'hybrid') {
70
+ finalName = override?.name || inputName || githubData?.name || ''
71
+ finalTagline = override?.tagline || inputTagline || ''
72
+ finalDescription = override?.description || inputDescription || githubData?.description || ''
73
+ finalStack = override?.stack || inputStack || []
74
+ } else {
75
+ finalName = inputName || ''
76
+ finalTagline = inputTagline || ''
77
+ finalDescription = inputDescription || ''
78
+ finalStack = inputStack || []
79
+ }
80
+
81
+ let finalLinks: FolioProject['links'] = {}
82
+ if (type === 'github') {
83
+ if (githubData) {
84
+ finalLinks = {
85
+ github: githubData.html_url,
86
+ live: githubData.homepage || undefined,
87
+ }
88
+ }
89
+ if (inputLinks) {
90
+ finalLinks = { ...finalLinks, ...inputLinks }
91
+ }
92
+ } else if (type === 'hybrid') {
93
+ finalLinks = inputLinks || {}
94
+ if (githubData) {
95
+ finalLinks.github = finalLinks.github || githubData.html_url
96
+ finalLinks.live = finalLinks.live || githubData.homepage || undefined
97
+ }
98
+ if (npmData && npmPackage) {
99
+ finalLinks.npm = finalLinks.npm || `https://npmjs.com/package/${npmPackage}`
100
+ }
101
+ } else {
102
+ finalLinks = inputLinks || {}
103
+ }
104
+
105
+ let finalStats: FolioProject['stats'] | null = null
106
+ if (type === 'github' || type === 'hybrid' || type === 'npm' || type === 'product-hunt') {
107
+ if (githubData) {
108
+ finalStats = {
109
+ stars: githubData.stargazers_count,
110
+ forks: githubData.forks_count,
111
+ }
112
+ }
113
+ if (npmData) {
114
+ finalStats = {
115
+ ...finalStats,
116
+ downloads: String(npmData.downloads),
117
+ version: npmData.version,
118
+ }
119
+ }
120
+ if (productHuntData) {
121
+ finalStats = {
122
+ ...finalStats,
123
+ upvotes: productHuntData.votes_count,
124
+ comments: productHuntData.comments_count,
125
+ launchDate: productHuntData.featured_at || undefined,
126
+ }
127
+ }
128
+ if (inputStats) {
129
+ finalStats = { ...finalStats, ...inputStats }
130
+ }
131
+ } else {
132
+ finalStats = inputStats || null
133
+ }
134
+
135
+ let finalLanguage: FolioProject['language'] = null
136
+ let finalLanguageColor: FolioProject['languageColor'] = null
137
+ let finalCreatedAt: FolioProject['createdAt'] = null
138
+ let finalUpdatedAt: FolioProject['updatedAt'] = null
139
+
140
+ if (type === 'github') {
141
+ finalLanguage = githubData?.language || null
142
+ finalLanguageColor = githubData?.language ? LANGUAGE_COLORS[githubData.language] || null : null
143
+ finalCreatedAt = githubData?.created_at || inputCreatedAt || null
144
+ finalUpdatedAt = githubData?.updated_at || inputUpdatedAt || null
145
+ } else if (type === 'hybrid') {
146
+ finalLanguage = githubData?.language || null
147
+ finalLanguageColor = githubData?.language ? LANGUAGE_COLORS[githubData.language] || null : null
148
+ finalCreatedAt = githubData?.created_at || inputCreatedAt || null
149
+ finalUpdatedAt = githubData?.updated_at || inputUpdatedAt || null
150
+ } else {
151
+ finalLanguage = null
152
+ finalLanguageColor = null
153
+ finalCreatedAt = inputCreatedAt || null
154
+ finalUpdatedAt = inputUpdatedAt || null
155
+ }
156
+
157
+ return {
158
+ id,
159
+ type,
160
+ status,
161
+ featured: featured || false,
162
+ name: finalName,
163
+ tagline: finalTagline,
164
+ description: finalDescription,
165
+ background: inputBackground || null,
166
+ why: inputWhy || null,
167
+ image: inputImage || null,
168
+ struggles: inputStruggles || [],
169
+ timeline: inputTimeline || [],
170
+ posts: inputPosts || [],
171
+ stack: finalStack,
172
+ links: finalLinks,
173
+ stats: finalStats,
174
+ language: finalLanguage,
175
+ languageColor: finalLanguageColor,
176
+ createdAt: finalCreatedAt,
177
+ updatedAt: finalUpdatedAt,
178
+ repo,
179
+ package: npmPackage,
180
+ slug: 'slug' in input ? input.slug : undefined,
181
+ }
182
+ }
183
+
184
+ function formatNumber(value: number): string {
185
+ if (value >= 1000000) {
186
+ return (value / 1000000).toFixed(1) + 'M'
187
+ }
188
+ if (value >= 1000) {
189
+ return (value / 1000).toFixed(1) + 'K'
190
+ }
191
+ return value.toString()
192
+ }
193
+
194
+ function formatDate(value: string | number): string {
195
+ try {
196
+ const date = new Date(value)
197
+ if (isNaN(date.getTime())) {
198
+ return String(value)
199
+ }
200
+ return date.toLocaleDateString('en-US', {
201
+ year: 'numeric',
202
+ month: 'short',
203
+ day: 'numeric',
204
+ })
205
+ } catch {
206
+ return String(value)
207
+ }
208
+ }
209
+
210
+ export function normalizeStats(stats: Record<string, unknown>, _type: ProjectType): NormalizedStat[] {
211
+ const result: NormalizedStat[] = []
212
+
213
+ if (stats.stars !== undefined && stats.stars !== null) {
214
+ const value = Number(stats.stars)
215
+ if (!isNaN(value)) {
216
+ result.push({ label: 'Stars', value: formatNumber(value) })
217
+ }
218
+ }
219
+
220
+ if (stats.forks !== undefined && stats.forks !== null) {
221
+ const value = Number(stats.forks)
222
+ if (!isNaN(value)) {
223
+ result.push({ label: 'Forks', value: formatNumber(value) })
224
+ }
225
+ }
226
+
227
+ if (stats.downloads !== undefined && stats.downloads !== null) {
228
+ const value = Number(stats.downloads)
229
+ if (!isNaN(value)) {
230
+ result.push({ label: 'Downloads', value: formatNumber(value), unit: 'month' })
231
+ }
232
+ }
233
+
234
+ if (stats.version !== undefined && stats.version !== null) {
235
+ let version = String(stats.version)
236
+ if (version && !version.startsWith('v')) {
237
+ version = 'v' + version
238
+ }
239
+ result.push({ label: 'Version', value: version })
240
+ }
241
+
242
+ if (stats.upvotes !== undefined && stats.upvotes !== null) {
243
+ const value = Number(stats.upvotes)
244
+ if (!isNaN(value)) {
245
+ result.push({ label: 'Upvotes', value: formatNumber(value) })
246
+ }
247
+ }
248
+
249
+ if (stats.comments !== undefined && stats.comments !== null) {
250
+ const value = Number(stats.comments)
251
+ if (!isNaN(value)) {
252
+ result.push({ label: 'Comments', value: formatNumber(value) })
253
+ }
254
+ }
255
+
256
+ if (stats.launchDate !== undefined && stats.launchDate !== null) {
257
+ result.push({ label: 'Launched', value: formatDate(String(stats.launchDate)) })
258
+ }
259
+
260
+ return result
261
+ }
package/src/lib/npm.ts ADDED
@@ -0,0 +1,38 @@
1
+ export interface NpmPackageData {
2
+ name: string
3
+ version: string
4
+ downloads: number
5
+ }
6
+
7
+ export async function fetchNpmPackage(packageName: string): Promise<NpmPackageData | null> {
8
+ try {
9
+ const downloadsUrl = `https://api.npmjs.org/downloads/point/last-month/${packageName}`
10
+ const registryUrl = `https://registry.npmjs.org/${packageName}`
11
+
12
+ const [downloadsResponse, registryResponse] = await Promise.all([
13
+ fetch(downloadsUrl, { cache: 'force-cache' }),
14
+ fetch(registryUrl, { cache: 'force-cache' }),
15
+ ])
16
+
17
+ if (!downloadsResponse.ok || !registryResponse.ok) {
18
+ return null
19
+ }
20
+
21
+ const downloadsData = await downloadsResponse.json()
22
+ const registryData = await registryResponse.json()
23
+
24
+ const version = registryData['dist-tags']?.latest
25
+
26
+ if (!version) {
27
+ return null
28
+ }
29
+
30
+ return {
31
+ name: downloadsData.package || packageName,
32
+ version,
33
+ downloads: downloadsData.downloads || 0,
34
+ }
35
+ } catch {
36
+ return null
37
+ }
38
+ }
@@ -0,0 +1,57 @@
1
+ export interface ProductHuntPostData {
2
+ name: string
3
+ tagline: string
4
+ description: string
5
+ votes_count: number
6
+ comments_count: number
7
+ featured_at: string | null
8
+ website: string
9
+ url: string
10
+ }
11
+
12
+ export async function fetchProductHuntPost(slug: string): Promise<ProductHuntPostData | null> {
13
+ try {
14
+ const url = `https://api.producthunt.com/v2/posts/${slug}`
15
+
16
+ const token = process.env.PRODUCT_HUNT_TOKEN
17
+ if (!token) {
18
+ console.warn('PRODUCT_HUNT_TOKEN not set - cannot fetch Product Hunt data')
19
+ return null
20
+ }
21
+
22
+ const headers: HeadersInit = {
23
+ Authorization: `Bearer ${token}`,
24
+ Accept: 'application/json',
25
+ }
26
+
27
+ const response = await fetch(url, {
28
+ headers,
29
+ cache: 'force-cache',
30
+ })
31
+
32
+ if (!response.ok) {
33
+ return null
34
+ }
35
+
36
+ const data = await response.json()
37
+
38
+ const post = data.post
39
+
40
+ if (!post) {
41
+ return null
42
+ }
43
+
44
+ return {
45
+ name: post.name,
46
+ tagline: post.tagline,
47
+ description: post.description || '',
48
+ votes_count: post.votes_count || 0,
49
+ comments_count: post.comments_count || 0,
50
+ featured_at: post.featured_at || null,
51
+ website: post.website || '',
52
+ url: post.url || '',
53
+ }
54
+ } catch {
55
+ return null
56
+ }
57
+ }
@@ -0,0 +1,30 @@
1
+ import type { FolioProject } from '../types'
2
+
3
+ export type SortOrder = 'asc' | 'desc'
4
+
5
+ export function sortByDate(projects: FolioProject[], order: SortOrder = 'desc'): FolioProject[] {
6
+ if (projects.length === 0) {
7
+ return []
8
+ }
9
+
10
+ const multiplier = order === 'asc' ? 1 : -1
11
+
12
+ return [...projects].sort((a, b) => {
13
+ const dateA = a.updatedAt || a.createdAt || null
14
+ const dateB = b.updatedAt || b.createdAt || null
15
+
16
+ if (!dateA && !dateB) {
17
+ return 0
18
+ }
19
+
20
+ if (!dateA) {
21
+ return 1 * multiplier
22
+ }
23
+
24
+ if (!dateB) {
25
+ return -1 * multiplier
26
+ }
27
+
28
+ return (new Date(dateA).getTime() - new Date(dateB).getTime()) * multiplier
29
+ })
30
+ }
@@ -0,0 +1,29 @@
1
+ import type { FolioProject } from '../types'
2
+ import type { SortOrder } from './sortByDate'
3
+
4
+ export function sortByName(projects: FolioProject[], order: SortOrder = 'asc'): FolioProject[] {
5
+ if (projects.length === 0) {
6
+ return []
7
+ }
8
+
9
+ const multiplier = order === 'asc' ? 1 : -1
10
+
11
+ return [...projects].sort((a, b) => {
12
+ const nameA = a.name ?? null
13
+ const nameB = b.name ?? null
14
+
15
+ if (!nameA && !nameB) {
16
+ return 0
17
+ }
18
+
19
+ if (!nameA) {
20
+ return 1
21
+ }
22
+
23
+ if (!nameB) {
24
+ return -1
25
+ }
26
+
27
+ return nameA.localeCompare(nameB, undefined, { sensitivity: 'base' }) * multiplier
28
+ })
29
+ }
@@ -0,0 +1,29 @@
1
+ import type { FolioProject } from '../types'
2
+ import type { SortOrder } from './sortByDate'
3
+
4
+ export function sortByStars(projects: FolioProject[], order: SortOrder = 'desc'): FolioProject[] {
5
+ if (projects.length === 0) {
6
+ return []
7
+ }
8
+
9
+ const multiplier = order === 'asc' ? 1 : -1
10
+
11
+ return [...projects].sort((a, b) => {
12
+ const starsA = a.type === 'github' ? (a.stats?.stars ?? 0) : 0
13
+ const starsB = b.type === 'github' ? (b.stats?.stars ?? 0) : 0
14
+
15
+ if (starsA === 0 && starsB === 0) {
16
+ return 0
17
+ }
18
+
19
+ if (starsA === 0) {
20
+ return 1
21
+ }
22
+
23
+ if (starsB === 0) {
24
+ return -1
25
+ }
26
+
27
+ return (starsA - starsB) * multiplier
28
+ })
29
+ }
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom/vitest'