|
| 1 | +# Scripts Documentation |
| 2 | + |
| 3 | +This directory contains utility scripts for managing and validating the AI Coding Stack project. Scripts are organized into four categories: |
| 4 | + |
| 5 | +- **`validate/`** - Validation scripts that check data integrity |
| 6 | +- **`generate/`** - Generation scripts that create derived files |
| 7 | +- **`refactor/`** - Refactoring scripts that reorganize or reformat data |
| 8 | +- **`fetch/`** - Data fetching scripts that retrieve external data |
| 9 | + |
| 10 | +## Directory Structure |
| 11 | + |
| 12 | +``` |
| 13 | +scripts/ |
| 14 | +├── validate/ |
| 15 | +│ ├── index.mjs # Entry point for all validation scripts |
| 16 | +│ ├── validate-manifests.mjs |
| 17 | +│ ├── validate-github-stars.mjs |
| 18 | +│ └── validate-urls.mjs |
| 19 | +├── generate/ |
| 20 | +│ ├── index.mjs # Entry point for all generation scripts |
| 21 | +│ ├── generate-manifest-indexes.mjs |
| 22 | +│ └── generate-metadata.mjs |
| 23 | +├── refactor/ |
| 24 | +│ ├── index.mjs # Entry point for all refactoring scripts |
| 25 | +│ └── sort-manifest-fields.mjs |
| 26 | +└── fetch/ |
| 27 | + ├── index.mjs # Entry point for all fetch scripts |
| 28 | + └── fetch-github-stars.mjs |
| 29 | +``` |
| 30 | + |
| 31 | +## Usage |
| 32 | + |
| 33 | +### Running All Scripts in a Category |
| 34 | + |
| 35 | +Each category has an entry point script (`index.mjs`) that can run all scripts in that category: |
| 36 | + |
| 37 | +```bash |
| 38 | +# Run all validation scripts |
| 39 | +npm run validate |
| 40 | + |
| 41 | +# Run all generation scripts |
| 42 | +npm run generate |
| 43 | + |
| 44 | +# Run all refactoring scripts |
| 45 | +npm run refactor |
| 46 | + |
| 47 | +# Run all fetch scripts |
| 48 | +npm run fetch |
| 49 | +``` |
| 50 | + |
| 51 | +### Running Individual Scripts |
| 52 | + |
| 53 | +You can also run individual scripts by passing the script name to the entry point: |
| 54 | + |
| 55 | +```bash |
| 56 | +# Validation scripts |
| 57 | +npm run validate:manifests |
| 58 | +npm run validate:github-stars |
| 59 | +npm run validate:urls |
| 60 | + |
| 61 | +# Generation scripts |
| 62 | +npm run generate:manifests |
| 63 | +npm run generate:metadata |
| 64 | + |
| 65 | +# Refactoring scripts |
| 66 | +npm run refactor:sort-fields |
| 67 | + |
| 68 | +# Fetch scripts |
| 69 | +npm run fetch:github-stars |
| 70 | +``` |
| 71 | + |
| 72 | +Or directly using Node: |
| 73 | + |
| 74 | +```bash |
| 75 | +# Run specific script |
| 76 | +node scripts/validate/index.mjs manifests |
| 77 | +node scripts/generate/index.mjs metadata |
| 78 | +node scripts/fetch/index.mjs github-stars |
| 79 | +``` |
| 80 | + |
| 81 | +## Validation Scripts |
| 82 | + |
| 83 | +### validate-manifests.mjs |
| 84 | + |
| 85 | +Validates all manifest JSON files against their corresponding JSON schemas. |
| 86 | + |
| 87 | +```bash |
| 88 | +npm run validate:manifests |
| 89 | +``` |
| 90 | + |
| 91 | +**What it checks:** |
| 92 | +- JSON syntax validity |
| 93 | +- Schema compliance for each manifest type |
| 94 | +- Required fields presence |
| 95 | +- Field format validation (URLs, enums, etc.) |
| 96 | +- Filename matches the `id` field in the manifest |
| 97 | + |
| 98 | +**Manifest types validated:** |
| 99 | +- `manifests/clis/*.json` - CLI tools |
| 100 | +- `manifests/ides/*.json` - IDEs |
| 101 | +- `manifests/extensions/*.json` - Editor extensions |
| 102 | +- `manifests/providers/*.json` - API providers |
| 103 | +- `manifests/models/*.json` - LLM models |
| 104 | +- `manifests/vendors/*.json` - Vendor information |
| 105 | +- `manifests/collections.json` - Collections data |
| 106 | + |
| 107 | +### validate-github-stars.mjs |
| 108 | + |
| 109 | +Validates that entries in `data/github-stars.json` match the actual manifest files. |
| 110 | + |
| 111 | +```bash |
| 112 | +npm run validate:github-stars |
| 113 | +``` |
| 114 | + |
| 115 | +**What it checks:** |
| 116 | +- All entries in `github-stars.json` have corresponding manifest files |
| 117 | +- All manifest files are present in `github-stars.json` |
| 118 | +- No orphaned entries in either direction |
| 119 | + |
| 120 | +**Categories validated:** |
| 121 | +- `extensions` |
| 122 | +- `clis` |
| 123 | +- `ides` |
| 124 | + |
| 125 | +**Common issues:** |
| 126 | +- Orphaned entries: Entries in `github-stars.json` without manifest files |
| 127 | +- Missing entries: Manifest files without corresponding `github-stars.json` entries |
| 128 | + |
| 129 | +**How to fix:** |
| 130 | +1. Remove orphaned entries from `data/github-stars.json` |
| 131 | +2. Add missing entries to `data/github-stars.json` (set value to `null` if unknown) |
| 132 | +3. Or remove unused manifest files if they are not needed |
| 133 | + |
| 134 | +### validate-urls.mjs |
| 135 | + |
| 136 | +Validates URLs in manifest files to ensure they are accessible. |
| 137 | + |
| 138 | +```bash |
| 139 | +npm run validate:urls |
| 140 | +``` |
| 141 | + |
| 142 | +**What it checks:** |
| 143 | +- URL accessibility (HTTP status codes) |
| 144 | +- Network connectivity |
| 145 | +- URL format validity |
| 146 | + |
| 147 | +**Note:** This script may take a while as it makes HTTP requests to validate each URL. |
| 148 | + |
| 149 | +## Generation Scripts |
| 150 | + |
| 151 | +### generate-manifest-indexes.mjs |
| 152 | + |
| 153 | +Generates TypeScript index files from individual manifest files. |
| 154 | + |
| 155 | +```bash |
| 156 | +npm run generate:manifests |
| 157 | +``` |
| 158 | + |
| 159 | +**What it generates:** |
| 160 | +- `src/lib/generated/ides.ts` - IDE manifest index |
| 161 | +- `src/lib/generated/clis.ts` - CLI manifest index |
| 162 | +- `src/lib/generated/models.ts` - Model manifest index |
| 163 | +- `src/lib/generated/providers.ts` - Provider manifest index |
| 164 | +- `src/lib/generated/extensions.ts` - Extension manifest index |
| 165 | +- `src/lib/generated/vendors.ts` - Vendor manifest index |
| 166 | +- `src/lib/generated/index.ts` - Main manifest index |
| 167 | +- `src/lib/generated/github-stars.ts` - GitHub stars data |
| 168 | + |
| 169 | +### generate-metadata.mjs |
| 170 | + |
| 171 | +Generates TypeScript metadata files from MDX content and manifest data. |
| 172 | + |
| 173 | +```bash |
| 174 | +npm run generate:metadata |
| 175 | +``` |
| 176 | + |
| 177 | +**What it generates:** |
| 178 | +- `src/lib/generated/metadata.ts` - Articles, docs, FAQ, and collections metadata |
| 179 | +- `src/lib/generated/articles.ts` - Article components and metadata |
| 180 | +- `src/lib/generated/docs.ts` - Doc components and metadata |
| 181 | +- `src/lib/generated/manifesto.ts` - Manifesto component loader |
| 182 | + |
| 183 | +## Refactoring Scripts |
| 184 | + |
| 185 | +### sort-manifest-fields.mjs |
| 186 | + |
| 187 | +Sorts fields in manifest JSON files according to their schema definitions. |
| 188 | + |
| 189 | +```bash |
| 190 | +npm run refactor:sort-fields |
| 191 | +``` |
| 192 | + |
| 193 | +**What it does:** |
| 194 | +- Reorders fields in manifest files to match schema property order |
| 195 | +- Ensures consistent field ordering across all manifests |
| 196 | +- Handles nested objects and arrays |
| 197 | + |
| 198 | +## Data Fetching Scripts |
| 199 | + |
| 200 | +### fetch-github-stars.mjs |
| 201 | + |
| 202 | +Fetches GitHub star counts for projects listed in manifests. |
| 203 | + |
| 204 | +```bash |
| 205 | +npm run fetch:github-stars |
| 206 | +``` |
| 207 | + |
| 208 | +**What it does:** |
| 209 | +- Reads `githubUrl` from manifest files |
| 210 | +- Fetches star counts from GitHub API |
| 211 | +- Updates `data/github-stars.json` with latest counts |
| 212 | + |
| 213 | +**Environment variables:** |
| 214 | +- `GITHUB_TOKEN` - Optional GitHub token to avoid rate limits (recommended) |
| 215 | + |
| 216 | +**Note:** Without a GitHub token, you may hit rate limits (60 requests/hour). |
| 217 | + |
| 218 | +## Build Process |
| 219 | + |
| 220 | +The build process runs validation and generation scripts automatically: |
| 221 | + |
| 222 | +```bash |
| 223 | +npm run build:next |
| 224 | +``` |
| 225 | + |
| 226 | +This runs in order: |
| 227 | +1. `validate:manifests` - Validate all manifest schemas |
| 228 | +2. `validate:github-stars` - Validate github-stars.json consistency |
| 229 | +3. `generate:manifests` - Generate manifest indexes |
| 230 | +4. `generate:metadata` - Generate TypeScript metadata |
| 231 | +5. Next.js build |
| 232 | + |
| 233 | +## Development Workflow |
| 234 | + |
| 235 | +During development, use: |
| 236 | + |
| 237 | +```bash |
| 238 | +npm run dev |
| 239 | +``` |
| 240 | + |
| 241 | +This will: |
| 242 | +1. Generate manifest indexes |
| 243 | +2. Generate metadata |
| 244 | +3. Start Next.js development server |
| 245 | + |
| 246 | +## CI/CD Integration |
| 247 | + |
| 248 | +For CI/CD pipelines, you can use the entry point scripts to run all scripts in a category: |
| 249 | + |
| 250 | +```bash |
| 251 | +# Run all validations (recommended for CI) |
| 252 | +npm run validate |
| 253 | + |
| 254 | +# Run all generation scripts |
| 255 | +npm run generate |
| 256 | + |
| 257 | +# Run all refactoring scripts |
| 258 | +npm run refactor |
| 259 | + |
| 260 | +# Run all fetch scripts (if needed) |
| 261 | +npm run fetch |
| 262 | +``` |
| 263 | + |
| 264 | +Or run individual scripts as needed: |
| 265 | + |
| 266 | +```bash |
| 267 | +npm run validate:manifests |
| 268 | +npm run generate:manifests |
| 269 | +npm run generate:metadata |
| 270 | +npm run refactor:sort-fields |
| 271 | +``` |
| 272 | + |
| 273 | +## Manual Execution |
| 274 | + |
| 275 | +To run scripts manually without npm: |
| 276 | + |
| 277 | +```bash |
| 278 | +# Run all scripts in a category |
| 279 | +node scripts/validate/index.mjs |
| 280 | +node scripts/generate/index.mjs |
| 281 | +node scripts/fetch/index.mjs |
| 282 | + |
| 283 | +# Run specific script |
| 284 | +node scripts/validate/index.mjs manifests |
| 285 | +node scripts/generate/index.mjs metadata |
| 286 | +node scripts/fetch/index.mjs github-stars |
| 287 | +``` |
0 commit comments