1- Write-Output " Packaging Lambda app"
2- Remove-Item - Recurse - Force .\package
3- New-Item .\package - type directory -f
4- New-Item .\package\temp - type directory -f
1+ Write-Output " Packaging Lambda app"
2+ if (Test-Path .\package) {
3+ Remove-Item .\package - Recurse - Force
4+ }
5+
6+
7+ New-Item .\package - type directory -f | Out-Null
8+ New-Item .\package\temp - type directory -f | Out-Null
9+ Write-Output " Copying dependencies..."
510Copy-Item .\backup.js .\package\temp\
611Copy-Item .\diff.js .\package\temp\
712Copy-Item .\s3- backfill.js .\package\temp\
813Copy-Item .\s3- snapshot.js .\package\temp\
9- Copy-Item .\node_modules\ .\package\temp\ - recurse
10-
11- $environmentFile = Read-Host - Prompt ' Enter the name of the config file you would like to add to your deployment (e.g. dcx.env)'
14+ robocopy .\node_modules\ .\package\temp\ / E | Out-Null
15+ Write-Output " Dependencies sorted"
1216
13- $currentdir = $PSScriptRoot
14-
15- New-Item .\package\temp\index.js - type file -f
17+ $environmentFile = Read-Host - Prompt ' Enter the name of the config file you would like to add to your deployment (e.g. Forms-dc4.env)'
1618
19+ Write-Output " Generating output..."
20+ New-Item .\package\temp\index.js - type file -f | Out-Null
1721get-content .\config\$environmentFile , " .\index.js" | set-content " .\package\temp\index.js"
22+ Write-Output " Output generated"
1823
19- $packageName = " LambdaFunction"
24+ Add-Type - assembly " system.io.compression.filesystem"
25+ $currentPath = (Get-Item - Path " .\" - Verbose).FullName
26+ $sourcePath = $currentPath + " \package\temp"
27+ $outputFile = $currentPath + " \LambdaFunction.zip"
2028
21- $destination = $currentdir + " \package\" + $packageName + " .zip"
29+ if (Test-Path $outputFile ) {
30+ Remove-Item $outputFile - Force
31+ }
2232
23- Add-Type - assembly " system.io.compression.filesystem"
24- [io.compression.zipfile ]::CreateFromDirectory($currentdir + " \package\temp" , $destination )
33+ [io.compression.zipfile ]::CreateFromDirectory($sourcePath , $outputFile )
2534
26- Write-Output " lambda app ready to be uploaded. Located at: " $destination
35+ Write-Output " λ function ready to be uploaded at: $ ( $outputFile ) "
0 commit comments