Merged
Conversation
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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoid fetching the tools files via the network; they don't change often anyway and it's fine to do a rebuild.