#!/usr/bin/env pwsh # https://docs.sheetjs.com/docs/demos/static/eleventy # This script builds the Static Site. It does not test HMR! $oldDir = Get-Location $tempDir = Join-Path -Path $env:TEMP -ChildPath "sheetjs-11ty" if (Test-Path -Path $tempDir) { Remove-Item -Path $tempDir -Recurse -Force } New-Item -ItemType Directory -Path $tempDir | Out-Null Set-Location -Path $tempDir npm init -y New-Item -ItemType Directory -Path "_data" | Out-Null Invoke-WebRequest -Uri "https://docs.sheetjs.com/pres.xlsx" -OutFile "_data/pres.xlsx" Invoke-WebRequest -Uri "https://docs.sheetjs.com/eleventy/_eleventy.js" -OutFile ".eleventy.js" Invoke-WebRequest -Uri "https://docs.sheetjs.com/eleventy/index.njk" -OutFile "index.njk" $versions = @("2.0.1", "3.1.2", "4.0.0-alpha.6") foreach ($n in $versions) { npm i --save https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz @11ty/eleventy@$n npx @11ty/eleventy@$n $htmlContent = Get-Content -Path "_site/index.html" -Raw $clintonCount = ($htmlContent | Select-String -Pattern "Clinton" -AllMatches).Matches.Count $besseljCount = ($htmlContent | Select-String -Pattern "BESSELJ" -AllMatches).Matches.Count $jsCount = ($htmlContent | Select-String -Pattern '\.js' -AllMatches).Matches.Count Write-Output "Clinton $clintonCount BESSELJ $besseljCount JS $jsCount" # Expected output: Clinton 1 BESSELJ 0 JS 0 } Set-Location $oldDir Remove-Item -Path $tempDir -Recurse -Force