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..."
5
10
Copy-Item .\backup.js .\package\temp\
6
11
Copy-Item .\diff.js .\package\temp\
7
12
Copy-Item .\s3- backfill.js .\package\temp\
8
13
Copy-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"
12
16
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)'
16
18
19
+ Write-Output " Generating output..."
20
+ New-Item .\package\temp\index.js - type file -f | Out-Null
17
21
get-content .\config\$environmentFile , " .\index.js" | set-content " .\package\temp\index.js"
22
+ Write-Output " Output generated"
18
23
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"
20
28
21
- $destination = $currentdir + " \package\" + $packageName + " .zip"
29
+ if (Test-Path $outputFile ) {
30
+ Remove-Item $outputFile - Force
31
+ }
22
32
23
- Add-Type - assembly " system.io.compression.filesystem"
24
- [io.compression.zipfile ]::CreateFromDirectory($currentdir + " \package\temp" , $destination )
33
+ [io.compression.zipfile ]::CreateFromDirectory($sourcePath , $outputFile )
25
34
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