From 351822f05e3c4e0a3838c5355625d7d5370b6cc0 Mon Sep 17 00:00:00 2001 From: Will McVay Date: Wed, 12 Feb 2020 12:58:06 +0000 Subject: [PATCH] fix: lamda build and add license (#248) --- DISCLAIMER.md | 5 +++++ README.md | 2 ++ .../cognito-custom-mail-lambda/package.json | 2 +- .../cognito-custom-mail-lambda/serverless.yml | 8 ++++---- .../cognito-custom-mail-lambda/yml-helpers.js | 19 +++++++++++++++++++ scripts/release/release-serverless.js | 2 +- 6 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 DISCLAIMER.md create mode 100644 packages/cognito-custom-mail-lambda/yml-helpers.js diff --git a/DISCLAIMER.md b/DISCLAIMER.md new file mode 100644 index 0000000000..2f11476019 --- /dev/null +++ b/DISCLAIMER.md @@ -0,0 +1,5 @@ +We’ve made our Foundations’ roadmap public on GitHub to outline Reapit’s current product plans for its developer platform and marketplace. + +All information is provided for INFORMATIONAL PURPOSES ONLY, is general in nature, and should not be relied upon or construed as a binding commitment to deliver any material, code, or functionality. Reapit makes no guarantees of any kind regarding the information herein. + +Please do not rely on this information in making decisions, as the development, release and timing of any products, features or functionality shall be made in Reapit’s sole discretion, and is subject to change. \ No newline at end of file diff --git a/README.md b/README.md index b4b732c5a2..af1a84ec7f 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,5 @@ This is the repository for the Reapit Foundations API, Marketplace, cloud applic * If you want to request a feature, please open an issue [here](https://github.com/reapit/foundations/issues/new?labels=feature-request&projects=reapit/foundations/3&body=Summary%20of%20Request:%0d%0dExpected%20Behaviour). If it is accepted for development, you can track it's progress on our [features board](https://github.com/reapit/foundations/projects/3). * If you wish to report a bug, again please [raise an issue](https://github.com/reapit/foundations/issues/new?labels=bug&projects=reapit/foundations/2&body=Summary:%0d%0dSteps%20to%20reproduce:%0d%0dExpected%20Results:%0d%0dActual%20Results). You can track it [here](https://github.com/reapit/foundations/projects/2) as our engineers look into it. * If you are interested in our future roadmap, you can see our [project milestones here](https://github.com/reapit/foundations/milestones?direction=asc&sort=due_date&state=open). + +Please read our [license](./LICENSE.md) and [disclaimer](./DISCLAIMER.md) before proceeding. \ No newline at end of file diff --git a/packages/cognito-custom-mail-lambda/package.json b/packages/cognito-custom-mail-lambda/package.json index d664c110ec..056a202c48 100644 --- a/packages/cognito-custom-mail-lambda/package.json +++ b/packages/cognito-custom-mail-lambda/package.json @@ -10,7 +10,7 @@ "test:ci": "cross-env TZ=UTC jest --ci --colors --coverage --silent --forceExit", "test:dev": "cross-env TZ=UTC jest --watch --verbose", "build:prod": "rimraf dist && tsc --p tsconfig.json && cp -rf ./src/mailer/templates/ejs ./dist/mailer/templates/ejs", - "release:dev": "cross-env CI=true serverless deploy --stage DEV", + "release:dev": "cross-env CI=true serverless deploy --stage dev", "release:prod": "node ../../scripts/release/release-serverless.js cognito-custom-mail-lambda", "test:update-badges": "yarn test:ci && jest-coverage-badges --input src/tests/coverage/coverage-summary.json --output src/tests/badges" }, diff --git a/packages/cognito-custom-mail-lambda/serverless.yml b/packages/cognito-custom-mail-lambda/serverless.yml index f2918163bb..9522cdfbf6 100644 --- a/packages/cognito-custom-mail-lambda/serverless.yml +++ b/packages/cognito-custom-mail-lambda/serverless.yml @@ -3,14 +3,14 @@ custom: ${file(../../reapit-config.json)} provider: name: aws runtime: nodejs10.x - stage: ${opt:stage, 'DEV'} + stage: ${opt:stage, 'dev'} region: eu-west-2 deploymentBucket: name: cognito.mailer.${self:provider.stage} blockPublicAccess: false environment: - COGNITO_USERPOOL_ID: ${self:custom.${self:provider.stage}.COGNITO_USERPOOL_ID} - MARKET_PLACE_URL: ${self:custom.${self:provider.stage}.MARKET_PLACE_URL} + COGNITO_USERPOOL_ID: ${self:custom.${file(./yml-helpers.js):provider.stage.uppercase}.COGNITO_USERPOOL_ID} + MARKET_PLACE_URL: ${self:custom.${file(./yml-helpers.js):provider.stage.uppercase}.MARKET_PLACE_URL} package: include: - dist/** @@ -37,6 +37,6 @@ functions: handler: dist/app.cognitoCustomMailerHandler events: - cognitoUserPool: - pool: ${self:custom.${self:provider.stage}.COGNITO_USERPOOL_ID} + pool: ${self:custom.${file(./yml-helpers.js):provider.stage.uppercase}.COGNITO_USERPOOL_ID} trigger: CustomMessage existing: true diff --git a/packages/cognito-custom-mail-lambda/yml-helpers.js b/packages/cognito-custom-mail-lambda/yml-helpers.js new file mode 100644 index 0000000000..c45df557e9 --- /dev/null +++ b/packages/cognito-custom-mail-lambda/yml-helpers.js @@ -0,0 +1,19 @@ +// https://stackoverflow.com/questions/48226686/serverless-yml-touppercase#48249468 +module.exports.provider = serverless => { + // The `serverless` argument containers all the information in the .yml file + const provider = serverless.service.provider + + return Object.entries(provider).reduce( + (accumulator, [key, value]) => ({ + ...accumulator, + [key]: + typeof value === 'string' + ? { + lowercase: value.toLowerCase(), + uppercase: value.toUpperCase(), + } + : value, + }), + {}, + ) +} diff --git a/scripts/release/release-serverless.js b/scripts/release/release-serverless.js index 43a6167f95..6c808a6b89 100644 --- a/scripts/release/release-serverless.js +++ b/scripts/release/release-serverless.js @@ -12,7 +12,7 @@ const releaseServerless = async () => { } if (packageName === packageNameOnTag) { - execSync('cross-env CI=true serverless deploy --stage PROD') + execSync('cross-env CI=true serverless deploy --stage prod') const previousTag = getPreviousTag({ packageName: packageNameOnTag }) await editReleaseNote({ packageName: packageNameOnTag, version, previousTag })