feat: add automated deployment ZIP creation with PowerShell script
- Add create-deployment-zip.ps1 script for automated ZIP packaging - Include npm scripts: build:deploy and create-zip for streamlined deployment - Fix PowerShell encoding issues by replacing emojis with text labels - Automatically package production-ready files: .next, public, .env.production, server.js, etc. - ZIP filename uses package.json name and version (e.g., nodemap-1.1.305.zip) - Add file existence validation and detailed logging for deployment process - Clean temporary files after ZIP creation The script creates a complete deployment package (84MB) containing all necessary files for production deployment, streamlining the build and packaging workflow.
This commit is contained in:
@@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=true
|
|||||||
NEXT_PUBLIC_BASE_PATH=/talas5
|
NEXT_PUBLIC_BASE_PATH=/talas5
|
||||||
# Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH=
|
# Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH=
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.1.305
|
NEXT_PUBLIC_APP_VERSION=1.1.306
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ NEXT_PUBLIC_BASE_PATH=/talas5
|
|||||||
# Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH=
|
# Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH=
|
||||||
|
|
||||||
# App-Versionsnummer
|
# App-Versionsnummer
|
||||||
NEXT_PUBLIC_APP_VERSION=1.1.305
|
NEXT_PUBLIC_APP_VERSION=1.1.306
|
||||||
BIN
nodemap-1.1.305.zip
Normal file
BIN
nodemap-1.1.305.zip
Normal file
Binary file not shown.
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.305",
|
"version": "1.1.306",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.305",
|
"version": "1.1.306",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.305",
|
"version": "1.1.306",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
@@ -39,6 +39,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "node server.js",
|
"dev": "node server.js",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
"build:deploy": "next build && npm run create-zip",
|
||||||
|
"create-zip": "powershell -ExecutionPolicy Bypass -File ./scripts/create-deployment-zip.ps1",
|
||||||
"start": "cross-env NODE_ENV=production node server.js",
|
"start": "cross-env NODE_ENV=production node server.js",
|
||||||
"export": "next export",
|
"export": "next export",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
|
|||||||
105
scripts/create-deployment-zip.ps1
Normal file
105
scripts/create-deployment-zip.ps1
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
# PowerShell Script to create deployment ZIP after successful build
|
||||||
|
param(
|
||||||
|
[string]$ProjectRoot = $PSScriptRoot + "\.."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Read package.json to get name and version
|
||||||
|
$packageJsonPath = Join-Path $ProjectRoot "package.json"
|
||||||
|
$packageJson = Get-Content $packageJsonPath | ConvertFrom-Json
|
||||||
|
$projectName = $packageJson.name
|
||||||
|
$version = $packageJson.version
|
||||||
|
|
||||||
|
# Create ZIP filename
|
||||||
|
$zipFileName = "${projectName}-${version}.zip"
|
||||||
|
$zipPath = Join-Path $ProjectRoot $zipFileName
|
||||||
|
|
||||||
|
# Remove existing ZIP if it exists
|
||||||
|
if (Test-Path $zipPath) {
|
||||||
|
Remove-Item $zipPath -Force
|
||||||
|
Write-Host "[DELETE] Removed existing ZIP: $zipFileName" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define files and directories to include
|
||||||
|
$itemsToInclude = @(
|
||||||
|
".next",
|
||||||
|
"public",
|
||||||
|
".env.production",
|
||||||
|
"server.js",
|
||||||
|
"nssm.exe",
|
||||||
|
"nssm.exe Installation.md",
|
||||||
|
"package.json",
|
||||||
|
"package-lock.json",
|
||||||
|
"Start-Dev.ps1",
|
||||||
|
"StartNodeApp.bat"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check which items exist
|
||||||
|
$existingItems = @()
|
||||||
|
foreach ($item in $itemsToInclude) {
|
||||||
|
$itemPath = Join-Path $ProjectRoot $item
|
||||||
|
if (Test-Path $itemPath) {
|
||||||
|
$existingItems += $item
|
||||||
|
Write-Host "[FOUND] $item" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "[MISSING] $item" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($existingItems.Count -eq 0) {
|
||||||
|
Write-Host "[ERROR] No items found to include in ZIP!" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create temporary directory for ZIP contents
|
||||||
|
$tempDir = Join-Path $ProjectRoot "temp-deployment"
|
||||||
|
if (Test-Path $tempDir) {
|
||||||
|
Remove-Item $tempDir -Recurse -Force
|
||||||
|
}
|
||||||
|
New-Item -ItemType Directory -Path $tempDir | Out-Null
|
||||||
|
|
||||||
|
# Copy items to temporary directory
|
||||||
|
foreach ($item in $existingItems) {
|
||||||
|
$sourcePath = Join-Path $ProjectRoot $item
|
||||||
|
$destPath = Join-Path $tempDir $item
|
||||||
|
|
||||||
|
if (Test-Path $sourcePath -PathType Container) {
|
||||||
|
# It's a directory
|
||||||
|
Copy-Item $sourcePath $destPath -Recurse -Force
|
||||||
|
Write-Host "[COPY DIR] $item" -ForegroundColor Cyan
|
||||||
|
} else {
|
||||||
|
# It's a file
|
||||||
|
Copy-Item $sourcePath $destPath -Force
|
||||||
|
Write-Host "[COPY FILE] $item" -ForegroundColor Cyan
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create ZIP file
|
||||||
|
try {
|
||||||
|
Write-Host "[CREATE] Creating ZIP: $zipFileName..." -ForegroundColor Blue
|
||||||
|
|
||||||
|
# Use .NET compression to create ZIP
|
||||||
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||||
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($tempDir, $zipPath)
|
||||||
|
|
||||||
|
# Get ZIP file size
|
||||||
|
$zipSize = (Get-Item $zipPath).Length
|
||||||
|
$zipSizeMB = [math]::Round($zipSize / 1MB, 2)
|
||||||
|
|
||||||
|
Write-Host "[SUCCESS] Successfully created deployment ZIP!" -ForegroundColor Green
|
||||||
|
Write-Host "[FILE] $zipFileName" -ForegroundColor White
|
||||||
|
Write-Host "[SIZE] $zipSizeMB MB" -ForegroundColor White
|
||||||
|
Write-Host "[LOCATION] $zipPath" -ForegroundColor White
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
Write-Host "[ERROR] Failed to create ZIP: $($_.Exception.Message)" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
} finally {
|
||||||
|
# Clean up temporary directory
|
||||||
|
if (Test-Path $tempDir) {
|
||||||
|
Remove-Item $tempDir -Recurse -Force
|
||||||
|
Write-Host "[CLEANUP] Cleaned up temporary files" -ForegroundColor Gray
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "[COMPLETE] Deployment ZIP ready for production deployment!" -ForegroundColor Green
|
||||||
Reference in New Issue
Block a user