Skip to content

Commit f0fff3c

Browse files
Fix workflow to properly generate and update commands.json
This fixes the command index generation pipeline to ensure commands.json is properly created and updated with the latest dbatools commands. Changes: - generate-command-pages.ps1: Now copies dbatools-index.json to static/commands.json - deploy.yml: Added steps to run enrichment and update scripts after generation - update-popular-commands.ps1: Fixed error when 'popular' property doesn't exist The workflow now: 1. Downloads dbatools-index.json and generates markdown files 2. Copies the index to static/commands.json 3. Enriches commands.json with full-text search content 4. Updates popular commands (top 50) 5. Updates command URLs to point to local pages This ensures the command index is always up-to-date with the latest dbatools release without requiring manual intervention. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1f1f4eb commit f0fff3c

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,27 @@ jobs:
6161
./scripts/generate-command-pages.ps1
6262
Write-Host "Command pages generated successfully"
6363
64+
- name: Enrich commands.json with full content
65+
shell: pwsh
66+
run: |
67+
Write-Host "Enriching commands.json..."
68+
./scripts/enrich-commands-json.ps1
69+
Write-Host "Commands enriched successfully"
70+
71+
- name: Update popular commands
72+
shell: pwsh
73+
run: |
74+
Write-Host "Updating popular commands..."
75+
./scripts/update-popular-commands.ps1
76+
Write-Host "Popular commands updated successfully"
77+
78+
- name: Update command URLs
79+
shell: pwsh
80+
run: |
81+
Write-Host "Updating command URLs..."
82+
./scripts/update-commands-urls.ps1
83+
Write-Host "Command URLs updated successfully"
84+
6485
- name: Build Hugo site
6586
run: hugo --minify
6687

scripts/generate-command-pages.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,16 @@ if ($errors -gt 0) {
347347
Write-Host "✓ Output directory: $OutputFolder" -ForegroundColor Green
348348
Write-Host ""
349349

350+
# Copy index to static/commands.json for the website
351+
$StaticCommandsJson = Join-Path $PSScriptRoot ".." "static" "commands.json"
352+
Write-Host "Copying index to static/commands.json..." -ForegroundColor Yellow
353+
try {
354+
Copy-Item $IndexPath $StaticCommandsJson -Force
355+
Write-Host "✓ Copied to static/commands.json" -ForegroundColor Green
356+
} catch {
357+
Write-Warning "Failed to copy index to static/commands.json: $_"
358+
}
359+
350360
# Cleanup
351361
if (Test-Path $IndexPath) {
352362
Remove-Item $IndexPath -Force

scripts/update-popular-commands.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ $popularCommands = @(
7777
# Reset all commands to not popular
7878
Write-Host "Resetting all commands to not popular..." -ForegroundColor Yellow
7979
foreach ($cmd in $commands) {
80-
$cmd.popular = $false
80+
# Add popular property if it doesn't exist
81+
if (-not ($cmd.PSObject.Properties.Name -contains 'popular')) {
82+
$cmd | Add-Member -MemberType NoteProperty -Name 'popular' -Value $false
83+
} else {
84+
$cmd.popular = $false
85+
}
8186
# Add popularityRank property if it doesn't exist, set to 0 (not ranked)
8287
if (-not ($cmd.PSObject.Properties.Name -contains 'popularityRank')) {
8388
$cmd | Add-Member -MemberType NoteProperty -Name 'popularityRank' -Value 0

0 commit comments

Comments
 (0)