From 367999eb9431f2883b44328b370e0733d7349aec Mon Sep 17 00:00:00 2001 From: Timi Date: Fri, 16 Oct 2026 18:33:03 +0800 Subject: [PATCH] zip time for build --- package.json | 2 +- scripts/build-zip.ps1 | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 scripts/build-zip.ps1 diff --git a/package.json b/package.json index 62b3c0d..b91e6e8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "vite --host", "build": "pnpm run type-check:publish && vite build", - "build:zip": "pnpm run build && powershell -NoProfile -Command \"New-Item -ItemType Directory -Force -Path release | Out-Null; Compress-Archive -Path dist\\* -DestinationPath release\\gao-customer-h5.zip -Force\"", + "build:zip": "pnpm run build && powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-zip.ps1", "twa:build": "cd twa && pnpm --config.registry=https://registry.npmjs.org dlx @bubblewrap/cli@1.25.0 build --manifest=./twa-manifest.json", "twa:update": "cd twa && pnpm --config.registry=https://registry.npmjs.org dlx @bubblewrap/cli@1.25.0 update --skipVersionUpgrade --manifest=./twa-manifest.json", "twa:validate": "pnpm --config.registry=https://registry.npmjs.org dlx @bubblewrap/cli@1.25.0 validate --url=https://gao.imyeyu.com/", diff --git a/scripts/build-zip.ps1 b/scripts/build-zip.ps1 new file mode 100644 index 0000000..0b56538 --- /dev/null +++ b/scripts/build-zip.ps1 @@ -0,0 +1,20 @@ +$ErrorActionPreference = "Stop" + +$projectRoot = Split-Path -Parent $PSScriptRoot +$releaseDirectory = Join-Path $projectRoot "release" +$distPath = Join-Path $projectRoot "dist" + +New-Item -ItemType Directory -Force -Path $releaseDirectory | Out-Null + +$timestamp = Get-Date -Format "yyyyMMdd-HHmmss" +$archiveBaseName = "gao-customer-h5-$timestamp" +$archivePath = Join-Path $releaseDirectory "$archiveBaseName.zip" +$collisionIndex = 1 + +while (Test-Path -LiteralPath $archivePath) { + $archivePath = Join-Path $releaseDirectory "$archiveBaseName-$collisionIndex.zip" + $collisionIndex++ +} + +Compress-Archive -Path (Join-Path $distPath "*") -DestinationPath $archivePath -ErrorAction Stop +Write-Output "Created archive: $archivePath"