Skip to content

Commit

Permalink
now allowing unziped target files
Browse files Browse the repository at this point in the history
  • Loading branch information
freeformflow committed Aug 21, 2019
1 parent a463b0a commit e421ecd
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 56 deletions.
6 changes: 6 additions & 0 deletions files/configuration-schema/definitions.yaml
Expand Up @@ -118,6 +118,9 @@ viewerEdgeLambda:
description: >
The path to the ZIP archive containing your lambda codebase.
type: string

zip:
type: boolean
handler:
description: >
The path to the entry point on your lambda. Omitting this uses "index.handler"
Expand Down Expand Up @@ -164,6 +167,9 @@ originEdgeLambda:
description: >
The path to the ZIP archive containing your lambda codebase.
type: string

zip:
type: boolean
handler:
description: >
The path to the entry point on your lambda. Omitting this uses AWS's "index.handler"
Expand Down
145 changes: 91 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "haiku9",
"version": "4.0.0",
"version": "4.0.1",
"description": "Asset compilation, static-site generator",
"main": "build/npm/src/index.js",
"files": [
Expand Down Expand Up @@ -60,7 +60,7 @@
"panda-template": "^1.1.0",
"progress": "^2.0.3",
"source-map-support": "^0.5.12",
"sundog": "^5.0.2"
"sundog": "5.0.2"
},
"devDependencies": {
"panda-9000": "^4.4.0",
Expand Down
21 changes: 21 additions & 0 deletions src/configuration/preprocessor/lambdas.coffee
Expand Up @@ -108,6 +108,19 @@ buildPrimaryLambdas = (config) ->
await shell "rm -rf lib", "haiku9-deploy/primary"


compressLambda = (lambda) ->
{type, src} = lambda
# Origin Requst Lambda

sourceDir = resolve src
targetDir = resolve deployDir, "primary", "lib"
await mkdirp "0777", targetDir
await shell "cp -R #{sourceDir} #{targetDir}"

await zip (resolve deployDir, "primary"), "lib", "#{type}.zip"
await shell "rm -rf lib", "haiku9-deploy/primary"



applyDefaultPrimaryLambdas = (config) ->

Expand Down Expand Up @@ -180,12 +193,20 @@ expandConfig = (config) ->
config.environment.edge.originAccess = "haiku9-#{name}-#{env}"
config

checkForZipFlag = (config) ->
for _, lambda of config.environment.edge.primary when lambda.zip == true
await compressLambda lambda
lambda.src = resolve deployDir, "primary", "#{lambda.type}.zip"

config

go = flow [
cleanDirectory
startEdgeConfig
applySecondaryLambdas
applyDefaultPrimaryLambdas
expandConfig
checkForZipFlag
]

export default go
1 change: 1 addition & 0 deletions src/configuration/read.coffee
Expand Up @@ -15,6 +15,7 @@ readConfiguration = (config) ->
try
_config = yaml await read path
catch e
console.error e
console.error "Unable to read h9.yaml configuration at #{path}"
throw new Error()

Expand Down

0 comments on commit e421ecd

Please sign in to comment.