Commit ab76a33
authored
Load GitHub tools.json file locally (#86)
* Phase 1: Data Layer Modernization
This commit introduces build-time static data generation, replacing runtime
GitHub API calls for tools data. Key changes:
## New Build System
- Added scripts/build-data.ts: Fetches and consolidates tools data from
static-analysis and dynamic-analysis repos at build time
- Added prebuild hook in package.json to run build-data before next build
- Data is stored in data/tools.json, data/tags.json, data/tool-stats.json,
and data/tag-stats.json (all gitignored as they're generated)
## New Static Data Utilities
- utils/static-data.ts: Core utility for reading pre-built static data
- utils/tools.ts: Simplified tools API using static data
- utils/tools-with-votes.ts: Merges tools with votes data
- utils/firebase-votes.ts: Simplified Firebase votes fetching
- utils/tags.ts: Tags utility using static data
- utils/filters.ts: Filtering utility (moved from utils-api)
- utils/stats.ts: View statistics utility
## Updated Pages
- pages/index.tsx: Uses new static data utilities
- pages/tool/[slug].tsx: Uses new static data utilities
- pages/tag/[slug].tsx: Uses new static data utilities
## Build/Deploy Updates
- Dockerfile: Removed manual tools.json download (now handled by build-data)
- deploy.yml: Updated to hash generated data files for cache busting
## Benefits
- No runtime GitHub API calls for tools data
- Faster page generation (data is pre-fetched)
- Simplified data flow
- Old utils-api code preserved for backwards compatibility
Note: API routes and old utils-api code are preserved for now. The /tools
page still uses API routes which will be addressed in Phase 2 with
InstantSearch integration.
* Phase 1: Data Layer Modernization
This commit introduces build-time static data generation, replacing runtime
GitHub API calls for tools data. Key changes:
## New Build System
- Added scripts/build-data.ts: Fetches and consolidates tools data from
static-analysis and dynamic-analysis repos at build time
- Added prebuild hook in package.json to run build-data before next build
- Data is stored in data/tools.json, data/tags.json, data/tool-stats.json,
and data/tag-stats.json (all gitignored as they're generated)
## New Static Data Utilities
- utils/static-data.ts: Core utility for reading pre-built static data
- utils/tools.ts: Simplified tools API using static data
- utils/tools-with-votes.ts: Merges tools with votes data
- utils/firebase-votes.ts: Simplified Firebase votes fetching
- utils/tags.ts: Tags utility using static data
- utils/filters.ts: Filtering utility (moved from utils-api)
- utils/stats.ts: View statistics utility
## Updated Pages
- pages/index.tsx: Uses new static data utilities
- pages/tool/[slug].tsx: Uses new static data utilities
- pages/tag/[slug].tsx: Uses new static data utilities
## Build/Deploy Updates
- Dockerfile: Removed manual tools.json download (now handled by build-data)
- deploy.yml: Updated to hash generated data files for cache busting
## Benefits
- No runtime GitHub API calls for tools data
- Faster page generation (data is pre-fetched)
- Simplified data flow
- Old utils-api code preserved for backwards compatibility
Note: API routes and old utils-api code are preserved for now. The /tools
page still uses API routes which will be addressed in Phase 2 with
InstantSearch integration.
* Phase 1: Data Layer Modernization
This commit introduces build-time static data generation, replacing runtime
GitHub API calls for tools data. Key changes:
## New Build System
- Added scripts/build-data.ts: Fetches and consolidates tools data from
static-analysis and dynamic-analysis repos at build time
- Added prebuild hook in package.json to run build-data before next build
- Data is stored in data/tools.json, data/tags.json, data/tool-stats.json,
and data/tag-stats.json (all gitignored as they're generated)
## New Repository Classes (lib/repositories/)
- ToolsRepository: Singleton for accessing tools data with caching
- TagsRepository: Singleton for accessing tags and descriptions
- StatsRepository: Singleton for tool/tag view statistics
- VotesRepository: Singleton for Firebase votes fetching
- ToolsFilter: Fluent filter class for querying tools by various criteria
## Updated Pages
- pages/index.tsx: Uses StatsRepository and VotesRepository
- pages/tool/[slug].tsx: Uses ToolsRepository and VotesRepository
- pages/tag/[slug].tsx: Uses TagsRepository, ToolsRepository, and ToolsFilter
## Build/Deploy Updates
- Dockerfile: Removed manual tools.json download (now handled by build-data)
- deploy.yml: Updated to hash generated data files for cache busting
- tsconfig.json: Added @lib/* path alias
## Benefits
- No runtime GitHub API calls for tools data
- Faster page generation (data is pre-fetched)
- Idiomatic TypeScript with proper class-based repositories
- Singleton pattern ensures data is loaded once and cached
- Old utils-api code preserved for backwards compatibility
Note: API routes and old utils-api code are preserved for now. The /tools
page still uses API routes which will be addressed in Phase 2 with
InstantSearch integration.1 parent e3a1bc7 commit ab76a33
16 files changed
Lines changed: 1292 additions & 122 deletions
File tree
- .github/workflows
- lib/repositories
- pages
- tag
- tool
- scripts
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
98 | 95 | | |
99 | | - | |
100 | | - | |
| 96 | + | |
101 | 97 | | |
102 | 98 | | |
103 | 99 | | |
104 | 100 | | |
105 | | - | |
106 | | - | |
| 101 | + | |
107 | 102 | | |
108 | | - | |
| 103 | + | |
109 | 104 | | |
110 | 105 | | |
111 | 106 | | |
112 | | - | |
| 107 | + | |
113 | 108 | | |
114 | 109 | | |
115 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
| 56 | + | |
| 57 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 14 | + | |
| 15 | + | |
18 | 16 | | |
19 | | - | |
| 17 | + | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
0 commit comments