2026-09-18 19:21:23 +02:00
|
|
|
param(
|
|
|
|
|
[string]$ProjectName,
|
|
|
|
|
[string]$AccountId
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
|
|
|
$publishDirectory = Join-Path $root "wersja1"
|
|
|
|
|
$nodePath = "C:\Program Files\nodejs"
|
|
|
|
|
if ((Test-Path $nodePath) -and (($env:Path -split ";") -notcontains $nodePath)) {
|
|
|
|
|
$env:Path = "$nodePath;$env:Path"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (-not (Test-Path (Join-Path $publishDirectory "index.html"))) {
|
|
|
|
|
throw "Folder wersja1 nie zawiera index.html."
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-18 19:35:34 +02:00
|
|
|
# The repository root is the editing source; keep the Cloudflare bundle in sync
|
|
|
|
|
# before every manual deploy and post-push hook execution.
|
2026-09-19 22:16:00 +02:00
|
|
|
$publishFiles = @("index.html", "styles.css", "app.js", "atut_baza.csv", "_headers")
|
2026-09-18 19:34:06 +02:00
|
|
|
foreach ($file in $publishFiles) {
|
|
|
|
|
$source = Join-Path $root $file
|
|
|
|
|
$target = Join-Path $publishDirectory $file
|
|
|
|
|
if (-not (Test-Path $source)) {
|
|
|
|
|
throw "Brak pliku źródłowego: $source"
|
|
|
|
|
}
|
|
|
|
|
Copy-Item $source $target -Force
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-18 19:21:23 +02:00
|
|
|
if (-not $ProjectName) {
|
|
|
|
|
$ProjectName = $env:CLOUDFLARE_PAGES_PROJECT
|
|
|
|
|
}
|
|
|
|
|
if (-not $ProjectName) {
|
|
|
|
|
$ProjectName = git -C $root config --local --get cloudflare.pagesProject
|
|
|
|
|
}
|
|
|
|
|
if (-not $AccountId) {
|
|
|
|
|
$AccountId = $env:CLOUDFLARE_ACCOUNT_ID
|
|
|
|
|
}
|
|
|
|
|
if (-not $AccountId) {
|
|
|
|
|
$AccountId = git -C $root config --local --get cloudflare.accountId
|
|
|
|
|
}
|
|
|
|
|
if (-not $ProjectName) {
|
|
|
|
|
throw "Podaj nazwe projektu Pages przez -ProjectName albo CLOUDFLARE_PAGES_PROJECT."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$deployArguments = @("pages", "deploy", $publishDirectory, "--project-name", $ProjectName)
|
|
|
|
|
if ($AccountId) {
|
|
|
|
|
$deployArguments += @("--account-id", $AccountId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$wrangler = $null
|
|
|
|
|
$wranglerCommand = Get-Command wrangler.cmd -ErrorAction SilentlyContinue
|
|
|
|
|
if ($wranglerCommand) {
|
|
|
|
|
$wrangler = $wranglerCommand.Source
|
|
|
|
|
} else {
|
|
|
|
|
$userWrangler = Join-Path $env:APPDATA "npm\wrangler.cmd"
|
|
|
|
|
if (Test-Path $userWrangler) {
|
|
|
|
|
$wrangler = $userWrangler
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($wrangler) {
|
|
|
|
|
& $wrangler @deployArguments
|
|
|
|
|
} elseif (Get-Command npx.cmd -ErrorAction SilentlyContinue) {
|
|
|
|
|
npx.cmd --yes wrangler @deployArguments
|
|
|
|
|
} else {
|
|
|
|
|
throw "Nie znaleziono Wrangler ani npx. Zainstaluj Node.js LTS i uruchom ponownie terminal."
|
|
|
|
|
}
|