Skip to content

Commit d82d579

Browse files
feat: Adding Astro Build ( Fixes PoshWeb#14 )
1 parent f693a9e commit d82d579

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

build.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,54 @@ $BuildTimeHistoryUrl = "https://4kb.powershellweb.com/history.json"
1414
# Make sure we're in the right place.
1515
Push-Location $PSScriptRoot
1616

17+
$initStart = [DateTime]::Now
18+
1719
#region Install Prereqs
1820
if ($env:GITHUB_WORKFLOW) {
1921
# Install 11ty to reduce 11ty build time
2022
$null = sudo npm install -g '@11ty/eleventy'
2123

24+
#region Astro Initialization
25+
# Install Astro to reduce astro build time
26+
$null = sudo npm install -g 'astro'
27+
28+
$astroDevRoot = Join-Path $PSScriptRoot "astrodev"
29+
New-Item -ItemType File -Path (
30+
Join-Path $astroDevRoot package.json
31+
) -Force -Value (
32+
[Ordered]@{
33+
name='astro-test'
34+
type='module'
35+
version='0.0.1'
36+
scripts = [Ordered]@{
37+
"build" = "astro build"
38+
}
39+
dependencies = @{
40+
"astro" = 'latest'
41+
}
42+
} | ConvertTo-Json
43+
)
44+
45+
Push-Location $astroDevRoot
46+
47+
npm install | Out-Host
48+
49+
$pagesRoot = Join-Path $PSScriptRoot "src/pages"
50+
if (-not (Test-Path $pagesRoot)) {
51+
New-Item -ItemType Directory -Path $pagesRoot
52+
}
53+
54+
Copy-Item ../TestMarkdown/* $pagesRoot
55+
56+
Pop-Location
57+
58+
#endregion Astro Initialization
59+
2260
Install-Module MarkX -Force
2361

2462
Import-Module MarkX -Global
2563
}
64+
$initEnd = [DateTime]::Now
2665
#endregion Install Prereqs
2766

2867
#region Get Clock Speed

build.with.astro.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<#
2+
.SYNOPSIS
3+
Builds 4kb markdown files with astro
4+
.DESCRIPTION
5+
Builds 4kb markdown files with astro.
6+
#>
7+
param(
8+
[Alias('Input')]
9+
[string]
10+
$InputPath = "$psScriptRoot/TestMarkdown",
11+
12+
[string]
13+
$OutputPath = "$psScriptRoot/astro",
14+
15+
[string]
16+
$AstroProjectRoot = "$psScriptRoot/astrodev"
17+
)
18+
19+
20+
if (-not (Test-path $AstroProjectRoot)) {
21+
$null = New-Item -ItemType Directory -Path $AstroProjectRoot -Force
22+
}
23+
24+
Push-Location $AstroProjectRoot
25+
26+
@"
27+
// @ts-check
28+
import { defineConfig } from 'astro/config';
29+
30+
// https://astro.build/config
31+
export default defineConfig($(
32+
[ordered]@{
33+
outDir = $OutputPath
34+
} | ConvertTo-Json
35+
));
36+
"@ > ./astro.config.mjs
37+
38+
npm run build
39+
40+
Pop-Location
41+

0 commit comments

Comments
 (0)