diff --git a/README.md b/README.md index 5a66c91..b52408f 100644 --- a/README.md +++ b/README.md @@ -2,54 +2,80 @@ This is a sample project for https://github.com/studds/nx-aws, powered by https://nx.dev -## Example app +### Example app -This repo currently provides a single simple example app, with front and backends. The frontend uses angular. The backend using AWS SAM, and is built using nx-aws. +This repo currently provides an example app highlighting how easy NX-AWS makes deploying frontend static sites and backend SAM applications from your mono-repo. -## Development server +The frontend (nx-aws-frontend) uses Angular (Could be React, nrwl NX has excellent support for React). -Frontend: `ng serve simple` -Backend: `ng serve api` +The SAM backend (nx-aws-api) depends on two lambda layers. + - One layer contains a custom function packaged into a layer with it's required dependencies + - One layer is just a package.json it contains bcrypt and is built correctly for the lambda node environment -## Build +The core SAM cloudfront file is in apps/nx-aws-api/template.yaml -Run `ng build simple --withDeps` build the project. [`withDeps`](https://nx.dev/latest/angular/cli/run-many#with-deps) -will automatically build dependencies, either explicit or -[implicit](https://nx.dev/latest/angular/getting-started/configuration#implicit-dependencies), -as well. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. +![nx aws setup](./nx-aws-diagram.png "NX AWS setup") + +### Development server + +- Frontend: `ng serve nx-aws-frontend` +- Backend: ** **You need to deploy the app (layers) before this will work** ** `ng serve nx-aws-api` + +*** TODO add comment explaining why you need to include the layers + +## Test it out + +1. Install the [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) +2. Set up your [AWS command line tools with the correct credentials](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-set-up-credentials.html) to a test account. +3. Create an S3 bucket to hold the cloud formation config + +### Build + +4. `ng build nx-aws-frontend --withDeps --prod` + +The [`withDeps`](https://nx.dev/latest/angular/cli/run-many#with-deps) flag will automatically build dependencies, either explicit or +[implicit](https://nx.dev/latest/angular/getting-started/configuration#implicit-dependencies). So it will build the frontend and backend code. + +The build artifacts will be stored in the `dist/` directory. +We used the `--prod` flag for a production build so all the frontend code is minified. + +![dependency graph](./nx-aws-dep-graph.png "Dependency Graph") ## Package and deploy The backend needs separate package and deploy steps. Both package and deploy require the [AWS SAM CLI to be installed](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html). You'll also need to have AWS permissions configured, and to configure an S3 bucket where deploy artefacts can be -stored - in these examples, `my-build-artefacts`. +stored - in these examples, `s3-bucket-setup-step-3`. -`ng run api:package --withDeps --s3Bucket my-build-artefacts` - -`ng run api:deploy --withDeps --s3Bucket my-build-artefacts` +5. `ng run nx-aws-api:package --withDeps --s3Bucket s3-bucket-setup-step-3` +6. `ng run nx-aws-api:deploy --withDeps --s3Bucket s3-bucket-setup-step-3` The first time you deploy the backend stack will take a while, as it deploys a CloudFront distribution. + You can then deploy the frontend app. The frontend app refers to the backend api in `angular.json` to derive the deploy bucket. +*** TODO we should expand on this + +`ng run nx-aws-frontend:deploy` -`ng run simple:deploy` +## Other nx command for you to try out if you have not already -## Running unit tests +### Running unit tests Run `ng test my-app` to execute the unit tests via [Jest](https://jestjs.io). Run `nx affected:test` to execute the unit tests affected by a change. -## Running end-to-end tests +### Running end-to-end tests Run `ng e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io). Run `nx affected:e2e` to execute the end-to-end tests affected by a change. -## Understand your workspace +### Understand your workspace Run `nx dep-graph` to see a diagram of the dependencies of your projects. -## Further help +### Further help Visit the [Nx Documentation](https://nx.dev/angular) to learn more. diff --git a/angular.json b/angular.json index 733478e..c8356fc 100644 --- a/angular.json +++ b/angular.json @@ -1,36 +1,217 @@ { "version": 1, + "cli": { + "analytics": false, + "defaultCollection": "@nrwl/angular" + }, + "schematics": { + "@nrwl/workspace": { + "library": { + "linter": "tslint" + } + }, + "@nrwl/cypress": { + "cypress-project": { + "linter": "tslint" + } + }, + "@nrwl/node": { + "application": { + "linter": "tslint" + }, + "library": { + "linter": "tslint" + } + }, + "@nrwl/nest": { + "application": { + "linter": "tslint" + }, + "library": { + "linter": "tslint" + } + }, + "@nrwl/express": { + "application": { + "linter": "tslint" + }, + "library": { + "linter": "tslint" + } + }, + "@nrwl/angular:application": { + "unitTestRunner": "jest", + "e2eTestRunner": "cypress" + }, + "@nrwl/angular:library": { + "unitTestRunner": "jest" + } + }, + "defaultProject": "nx-aws-frontend", "projects": { - "simple": { + "api-interfaces": { + "root": "libs/api-interfaces", + "sourceRoot": "libs/api-interfaces/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "libs/api-interfaces/tsconfig.lib.json", + "libs/api-interfaces/tsconfig.spec.json" + ], + "exclude": ["**/node_modules/**", "!libs/api-interfaces/**/*"] + } + }, + "test": { + "builder": "@nrwl/jest:jest", + "options": { + "jestConfig": "libs/api-interfaces/jest.config.js", + "passWithNoTests": true + }, + "outputs": ["coverage/libs/api-interfaces"] + } + } + }, + "nx-aws-api": { + "root": "apps/nx-aws-api", + "sourceRoot": "apps/nx-aws-api/src", + "projectType": "application", + "prefix": "api", + "schematics": {}, + "architect": { + "build": { + "builder": "@nx-aws/sam:build", + "options": { + "outputPath": "dist/apps/nx-aws-api", + "template": "apps/nx-aws-api/template.yaml", + "tsConfig": "apps/nx-aws-api/tsconfig.app.json", + "assets": ["apps/nx-aws-api/src/assets"], + "sourceMap": true, + "maxWorkers": 1, + "externalDependencies": ["bcrypt", "@nx-aws-example/nx-aws-lib-as-layer"] + }, + "configurations": { + "production": { + "optimization": true, + "extractLicenses": true, + "inspect": false, + "fileReplacements": [ + { + "replace": "apps/nx-aws-api/src/environments/environment.ts", + "with": "apps/nx-aws-api/src/environments/environment.prod.ts" + } + ] + } + } + }, + "serve": { + "builder": "@nx-aws/sam:execute", + "options": { + "buildTarget": "nx-aws-api:build", + "packageTarget": "nx-aws-api:package", + "importStackOutputs": { + "TestLayer": { + "targetName": "nx-aws-layer:deploy", + "outputName": "TestLayer" + }, + "LibAsLayer": { + "targetName": "nx-aws-lib-as-layer:deploy", + "outputName": "LibAsLayer" + } + }, + "mimicEnv": "dev" + } + }, + "package": { + "builder": "@nx-aws/sam:package", + "options": { + "templateFile": "apps/nx-aws-api/template.yaml", + "outputTemplateFile": "dist/apps/nx-aws-api/serverless-output.yaml", + "s3Prefix": "simple/api" + }, + "configurations": { + "production": {} + } + }, + "deploy": { + "builder": "@nx-aws/sam:deploy", + "options": { + "templateFile": "dist/apps/nx-aws-api/serverless-output.yaml", + "s3Prefix": "simple/api", + "capabilities": ["CAPABILITY_IAM", "CAPABILITY_AUTO_EXPAND"], + "importStackOutputs": { + "TestLayer": { + "targetName": "nx-aws-layer:deploy", + "outputName": "TestLayer" + }, + "LibAsLayer": { + "targetName": "nx-aws-lib-as-layer:deploy", + "outputName": "LibAsLayer" + } + } + }, + "configurations": { + "production": { + "stackSuffix": "prod" + } + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "apps/nx-aws-api/tsconfig.app.json", + "apps/nx-aws-api/tsconfig.spec.json" + ], + "exclude": ["**/node_modules/**", "!apps/nx-aws-api/**/*"] + } + }, + "test": { + "builder": "@nrwl/jest:jest", + "options": { + "jestConfig": "apps/nx-aws-api/jest.config.js", + "passWithNoTests": true + }, + "outputs": ["coverage/apps/nx-aws-api"] + } + } + }, + "nx-aws-frontend": { "projectType": "application", "schematics": { "@nrwl/angular:component": { "style": "scss" } }, - "root": "apps/simple", - "sourceRoot": "apps/simple/src", + "root": "apps/nx-aws-frontend", + "sourceRoot": "apps/nx-aws-frontend/src", "prefix": "nx-aws-example", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist/apps/simple", - "index": "apps/simple/src/index.html", - "main": "apps/simple/src/main.ts", - "polyfills": "apps/simple/src/polyfills.ts", - "tsConfig": "apps/simple/tsconfig.app.json", + "outputPath": "dist/apps/nx-aws-frontend", + "index": "apps/nx-aws-frontend/src/index.html", + "main": "apps/nx-aws-frontend/src/main.ts", + "polyfills": "apps/nx-aws-frontend/src/polyfills.ts", + "tsConfig": "apps/nx-aws-frontend/tsconfig.app.json", "aot": true, - "assets": ["apps/simple/src/favicon.ico", "apps/simple/src/assets"], - "styles": ["apps/simple/src/styles.scss"], + "assets": [ + "apps/nx-aws-frontend/src/favicon.ico", + "apps/nx-aws-frontend/src/assets" + ], + "styles": ["apps/nx-aws-frontend/src/styles.scss"], "scripts": [] }, "configurations": { "production": { "fileReplacements": [ { - "replace": "apps/simple/src/environments/environment.ts", - "with": "apps/simple/src/environments/environment.prod.ts" + "replace": "apps/nx-aws-frontend/src/environments/environment.ts", + "with": "apps/nx-aws-frontend/src/environments/environment.prod.ts" } ], "optimization": true, @@ -59,38 +240,38 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "simple:build", - "proxyConfig": "apps/simple/proxy.conf.json" + "browserTarget": "nx-aws-frontend:build", + "proxyConfig": "apps/nx-aws-frontend/proxy.conf.json" }, "configurations": { "production": { - "browserTarget": "simple:build:production" + "browserTarget": "nx-aws-frontend:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "simple:build" + "browserTarget": "nx-aws-frontend:build" } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ - "apps/simple/tsconfig.app.json", - "apps/simple/tsconfig.spec.json" + "apps/nx-aws-frontend/tsconfig.app.json", + "apps/nx-aws-frontend/tsconfig.spec.json" ], - "exclude": ["**/node_modules/**", "!apps/simple/**/*"] + "exclude": ["**/node_modules/**", "!apps/nx-aws-frontend/**/*"] } }, "test": { "builder": "@nrwl/jest:jest", "options": { - "jestConfig": "apps/simple/jest.config.js", + "jestConfig": "apps/nx-aws-frontend/jest.config.js", "passWithNoTests": true }, - "outputs": ["coverage/apps/simple"] + "outputs": ["coverage/apps/nx-aws-frontend"] }, "package": { "builder": "@nrwl/workspace:run-commands", @@ -104,12 +285,16 @@ "options": { "destPrefix": "public", "bucket": { - "targetName": "api:deploy", + "targetName": "nx-aws-api:deploy", "outputName": "WebBucket" }, "distribution": { - "targetName": "api:deploy", + "targetName": "nx-aws-api:deploy", "outputName": "DistributionId" + }, + "config": { + "configFileName": "config.json", + "importStackOutputs": {} } }, "configurations": { @@ -120,166 +305,36 @@ } } }, - "simple-e2e": { - "root": "apps/simple-e2e", - "sourceRoot": "apps/simple-e2e/src", + "nx-aws-frontend-e2e": { + "root": "apps/nx-aws-frontend-e2e", + "sourceRoot": "apps/nx-aws-frontend-e2e/src", "projectType": "application", "architect": { "e2e": { "builder": "@nrwl/cypress:cypress", "options": { - "cypressConfig": "apps/simple-e2e/cypress.json", - "tsConfig": "apps/simple-e2e/tsconfig.e2e.json", - "devServerTarget": "simple:serve" + "cypressConfig": "apps/nx-aws-frontend-e2e/cypress.json", + "tsConfig": "apps/nx-aws-frontend-e2e/tsconfig.e2e.json", + "devServerTarget": "nx-aws-frontend:serve" }, "configurations": { "production": { - "devServerTarget": "simple:serve:production" + "devServerTarget": "nx-aws-frontend:serve:production" } } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { - "tsConfig": ["apps/simple-e2e/tsconfig.e2e.json"], - "exclude": ["**/node_modules/**", "!apps/simple-e2e/**/*"] + "tsConfig": ["apps/nx-aws-frontend-e2e/tsconfig.e2e.json"], + "exclude": ["**/node_modules/**", "!apps/nx-aws-frontend-e2e/**/*"] } } } }, - "api": { - "root": "apps/api", - "sourceRoot": "apps/api/src", - "projectType": "application", - "prefix": "api", - "schematics": {}, - "architect": { - "build": { - "builder": "@nx-aws/sam:build", - "options": { - "outputPath": "dist/apps/api", - "template": "apps/api/template.yaml", - "tsConfig": "apps/api/tsconfig.app.json", - "assets": ["apps/api/src/assets"], - "sourceMap": true, - "maxWorkers": 1, - "externalDependencies": ["bcrypt", "@nx-aws-example/lib-as-layer"] - }, - "configurations": { - "production": { - "optimization": true, - "extractLicenses": true, - "inspect": false, - "fileReplacements": [ - { - "replace": "apps/api/src/environments/environment.ts", - "with": "apps/api/src/environments/environment.prod.ts" - } - ] - } - } - }, - "serve": { - "builder": "@nx-aws/sam:execute", - "options": { - "buildTarget": "api:build", - "packageTarget": "api:package", - "importStackOutputs": { - "TestLayer": { - "targetName": "layer:deploy", - "outputName": "TestLayer" - }, - "LibAsLayer": { - "targetName": "lib-as-layer:deploy", - "outputName": "LibAsLayer" - } - }, - "mimicEnv": "dev" - } - }, - "package": { - "builder": "@nx-aws/sam:package", - "options": { - "templateFile": "apps/api/template.yaml", - "outputTemplateFile": "dist/apps/api/serverless-output.yaml", - "s3Prefix": "simple/api" - }, - "configurations": { - "production": {} - } - }, - "deploy": { - "builder": "@nx-aws/sam:deploy", - "options": { - "templateFile": "dist/apps/api/serverless-output.yaml", - "s3Prefix": "simple/api", - "capabilities": ["CAPABILITY_IAM", "CAPABILITY_AUTO_EXPAND"], - "importStackOutputs": { - "TestLayer": { - "targetName": "layer:deploy", - "outputName": "TestLayer" - }, - "LibAsLayer": { - "targetName": "lib-as-layer:deploy", - "outputName": "LibAsLayer" - } - } - }, - "configurations": { - "production": { - "stackSuffix": "prod" - } - } - }, - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": [ - "apps/api/tsconfig.app.json", - "apps/api/tsconfig.spec.json" - ], - "exclude": ["**/node_modules/**", "!apps/api/**/*"] - } - }, - "test": { - "builder": "@nrwl/jest:jest", - "options": { - "jestConfig": "apps/api/jest.config.js", - "passWithNoTests": true - }, - "outputs": ["coverage/apps/api"] - } - } - }, - "api-interfaces": { - "root": "libs/api-interfaces", - "sourceRoot": "libs/api-interfaces/src", - "projectType": "library", - "schematics": {}, - "architect": { - "lint": { - "builder": "@angular-devkit/build-angular:tslint", - "options": { - "tsConfig": [ - "libs/api-interfaces/tsconfig.lib.json", - "libs/api-interfaces/tsconfig.spec.json" - ], - "exclude": ["**/node_modules/**", "!libs/api-interfaces/**/*"] - } - }, - "test": { - "builder": "@nrwl/jest:jest", - "options": { - "jestConfig": "libs/api-interfaces/jest.config.js", - "passWithNoTests": true - }, - "outputs": ["coverage/libs/api-interfaces"] - } - } - }, - "layer": { - "root": "apps/layer", - "sourceRoot": "apps/layer/src", + "nx-aws-layer": { + "root": "apps/nx-aws-layer", + "sourceRoot": "apps/nx-aws-layer/src", "projectType": "application", "prefix": "layer", "architect": { @@ -288,20 +343,20 @@ "options": { "parallel": false, "commands": [ - "rm -rf dist/apps/layer", - "mkdir -p dist/apps/layer/nodejs", - "cp -R apps/layer/nodejs dist/apps/layer/", - "cd dist/apps/layer/nodejs && npm install --target=12.2.0 --target_arch=x64 --target_platform=linux --target_libc=glibc", - "cd dist/apps/layer && zip -r layer.zip ./*" + "rm -rf dist/apps/nx-aws-layer", + "mkdir -p dist/apps/nx-aws-layer/nodejs", + "cp -R apps/nx-aws-layer/nodejs dist/apps/nx-aws-layer/", + "cd dist/apps/nx-aws-layer/nodejs && npm install --target=12.2.0 --target_arch=x64 --target_platform=linux --target_libc=glibc", + "cd dist/apps/nx-aws-layer && zip -r layer.zip ./*" ] } }, "package": { "builder": "@nx-aws/sam:package", "options": { - "templateFile": "apps/layer/template.yaml", - "outputTemplateFile": "dist/apps/layer/serverless-output.yaml", - "s3Prefix": "apps/layer" + "templateFile": "apps/nx-aws-layer/template.yaml", + "outputTemplateFile": "dist/apps/nx-aws-layer/serverless-output.yaml", + "s3Prefix": "apps/nx-aws-layer" }, "configurations": { "production": {} @@ -310,8 +365,8 @@ "deploy": { "builder": "@nx-aws/sam:deploy", "options": { - "templateFile": "dist/apps/layer/serverless-output.yaml", - "s3Prefix": "apps/layer", + "templateFile": "dist/apps/nx-aws-layer/serverless-output.yaml", + "s3Prefix": "apps/nx-aws-layer", "capabilities": ["CAPABILITY_IAM", "CAPABILITY_AUTO_EXPAND"] }, "configurations": { @@ -322,26 +377,26 @@ } } }, - "lib-as-layer": { - "root": "libs/lib-as-layer", - "sourceRoot": "libs/lib-as-layer/src", + "nx-aws-lib-as-layer": { + "root": "libs/nx-aws-lib-as-layer", + "sourceRoot": "libs/nx-aws-lib-as-layer/src", "projectType": "library", "architect": { "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ - "libs/lib-as-layer/tsconfig.lib.json", - "libs/lib-as-layer/tsconfig.spec.json" + "libs/nx-aws-lib-as-layer/tsconfig.lib.json", + "libs/nx-aws-lib-as-layer/tsconfig.spec.json" ], - "exclude": ["**/node_modules/**", "!libs/lib-as-layer/**/*"] + "exclude": ["**/node_modules/**", "!libs/nx-aws-lib-as-layer/**/*"] } }, "test": { "builder": "@nrwl/jest:jest", - "outputs": ["coverage/libs/lib-as-layer"], + "outputs": ["coverage/libs/nx-aws-lib-as-layer"], "options": { - "jestConfig": "libs/lib-as-layer/jest.config.js", + "jestConfig": "libs/nx-aws-lib-as-layer/jest.config.js", "passWithNoTests": true } }, @@ -349,11 +404,11 @@ "builder": "@nrwl/node:package", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/libs/lib-as-layer/layer/nodejs/node_modules/@nx-aws-example/lib-as-layer", - "tsConfig": "libs/lib-as-layer/tsconfig.lib.json", - "packageJson": "libs/lib-as-layer/package.json", - "main": "libs/lib-as-layer/src/index.ts", - "assets": ["libs/lib-as-layer/*.md"] + "outputPath": "dist/libs/nx-aws-lib-as-layer/layer/nodejs/node_modules/@nx-aws-example/nx-aws-lib-as-layer", + "tsConfig": "libs/nx-aws-lib-as-layer/tsconfig.lib.json", + "packageJson": "libs/nx-aws-lib-as-layer/package.json", + "main": "libs/nx-aws-lib-as-layer/src/index.ts", + "assets": ["libs/nx-aws-lib-as-layer/*.md"] } }, "build": { @@ -361,19 +416,19 @@ "options": { "parallel": false, "commands": [ - "rm -rf dist/libs/lib-as-layer", - "nx run lib-as-layer:node-package", - "cd dist/libs/lib-as-layer/layer/nodejs/node_modules/@nx-aws-example/lib-as-layer && npm install --target=12.2.0 --target_arch=x64 --target_platform=linux --target_libc=glibc", - "cd dist/libs/lib-as-layer/layer && zip -r layer.zip ./*" + "rm -rf dist/libs/nx-aws-lib-as-layer", + "nx run nx-aws-lib-as-layer:node-package", + "cd dist/libs/nx-aws-lib-as-layer/layer/nodejs/node_modules/@nx-aws-example/nx-aws-lib-as-layer && npm install --target=12.2.0 --target_arch=x64 --target_platform=linux --target_libc=glibc", + "cd dist/libs/nx-aws-lib-as-layer/layer && zip -r layer.zip ./*" ] } }, "package": { "builder": "@nx-aws/sam:package", "options": { - "templateFile": "libs/lib-as-layer/template.yaml", - "outputTemplateFile": "dist/libs/lib-as-layer/serverless-output.yaml", - "s3Prefix": "libs/lib-as-layer" + "templateFile": "libs/nx-aws-lib-as-layer/template.yaml", + "outputTemplateFile": "dist/libs/nx-aws-lib-as-layer/serverless-output.yaml", + "s3Prefix": "libs/nx-aws-lib-as-layer" }, "configurations": { "production": {} @@ -382,8 +437,8 @@ "deploy": { "builder": "@nx-aws/sam:deploy", "options": { - "templateFile": "dist/libs/lib-as-layer/serverless-output.yaml", - "s3Prefix": "libs/lib-as-layer", + "templateFile": "dist/libs/nx-aws-lib-as-layer/serverless-output.yaml", + "s3Prefix": "libs/nx-aws-lib-as-layer", "capabilities": ["CAPABILITY_IAM", "CAPABILITY_AUTO_EXPAND"] }, "configurations": { @@ -394,52 +449,5 @@ } } } - }, - "cli": { - "defaultCollection": "@nrwl/angular" - }, - "schematics": { - "@nrwl/workspace": { - "library": { - "linter": "tslint" - } - }, - "@nrwl/cypress": { - "cypress-project": { - "linter": "tslint" - } - }, - "@nrwl/node": { - "application": { - "linter": "tslint" - }, - "library": { - "linter": "tslint" - } - }, - "@nrwl/nest": { - "application": { - "linter": "tslint" - }, - "library": { - "linter": "tslint" - } - }, - "@nrwl/express": { - "application": { - "linter": "tslint" - }, - "library": { - "linter": "tslint" - } - }, - "@nrwl/angular:application": { - "unitTestRunner": "jest", - "e2eTestRunner": "cypress" - }, - "@nrwl/angular:library": { - "unitTestRunner": "jest" - } - }, - "defaultProject": "simple" + } } diff --git a/apps/api/jest.config.js b/apps/nx-aws-api/jest.config.js similarity index 63% rename from apps/api/jest.config.js rename to apps/nx-aws-api/jest.config.js index 482734d..cddd4dd 100644 --- a/apps/api/jest.config.js +++ b/apps/nx-aws-api/jest.config.js @@ -5,6 +5,6 @@ module.exports = { tsConfig: '/tsconfig.spec.json', }, }, - coverageDirectory: '../../coverage/apps/api', - displayName: 'api', + coverageDirectory: '../../coverage/apps/nx-aws-api', + displayName: 'nx-aws-api', }; diff --git a/apps/api/src/app/.gitkeep b/apps/nx-aws-api/src/app/.gitkeep similarity index 100% rename from apps/api/src/app/.gitkeep rename to apps/nx-aws-api/src/app/.gitkeep diff --git a/apps/api/src/app/hello/hello.ts b/apps/nx-aws-api/src/app/hello/hello.ts similarity index 84% rename from apps/api/src/app/hello/hello.ts rename to apps/nx-aws-api/src/app/hello/hello.ts index 581f344..c163f31 100644 --- a/apps/api/src/app/hello/hello.ts +++ b/apps/nx-aws-api/src/app/hello/hello.ts @@ -1,5 +1,5 @@ import { hash } from 'bcrypt'; -import { libAsLayer } from '@nx-aws-example/lib-as-layer'; +import { libAsLayer } from '@nx-aws-example/nx-aws-lib-as-layer'; export const handler = async () => { const saltRounds = 10; diff --git a/apps/api/src/assets/.gitkeep b/apps/nx-aws-api/src/assets/.gitkeep similarity index 100% rename from apps/api/src/assets/.gitkeep rename to apps/nx-aws-api/src/assets/.gitkeep diff --git a/apps/api/src/environments/environment.prod.ts b/apps/nx-aws-api/src/environments/environment.prod.ts similarity index 100% rename from apps/api/src/environments/environment.prod.ts rename to apps/nx-aws-api/src/environments/environment.prod.ts diff --git a/apps/api/src/environments/environment.ts b/apps/nx-aws-api/src/environments/environment.ts similarity index 100% rename from apps/api/src/environments/environment.ts rename to apps/nx-aws-api/src/environments/environment.ts diff --git a/apps/api/template.yaml b/apps/nx-aws-api/template.yaml similarity index 100% rename from apps/api/template.yaml rename to apps/nx-aws-api/template.yaml diff --git a/apps/api/tsconfig.app.json b/apps/nx-aws-api/tsconfig.app.json similarity index 100% rename from apps/api/tsconfig.app.json rename to apps/nx-aws-api/tsconfig.app.json diff --git a/apps/api/tsconfig.json b/apps/nx-aws-api/tsconfig.json similarity index 100% rename from apps/api/tsconfig.json rename to apps/nx-aws-api/tsconfig.json diff --git a/apps/api/tsconfig.spec.json b/apps/nx-aws-api/tsconfig.spec.json similarity index 100% rename from apps/api/tsconfig.spec.json rename to apps/nx-aws-api/tsconfig.spec.json diff --git a/apps/api/tslint.json b/apps/nx-aws-api/tslint.json similarity index 100% rename from apps/api/tslint.json rename to apps/nx-aws-api/tslint.json diff --git a/apps/simple-e2e/cypress.json b/apps/nx-aws-frontend-e2e/cypress.json similarity index 64% rename from apps/simple-e2e/cypress.json rename to apps/nx-aws-frontend-e2e/cypress.json index 0ee0b4c..66a85f1 100644 --- a/apps/simple-e2e/cypress.json +++ b/apps/nx-aws-frontend-e2e/cypress.json @@ -6,7 +6,7 @@ "pluginsFile": "./src/plugins/index", "supportFile": "./src/support/index.ts", "video": true, - "videosFolder": "../../dist/cypress/apps/simple-e2e/videos", - "screenshotsFolder": "../../dist/cypress/apps/simple-e2e/screenshots", + "videosFolder": "../../dist/cypress/apps/nx-aws-frontend-e2e/videos", + "screenshotsFolder": "../../dist/cypress/apps/nx-aws-frontend-e2e/screenshots", "chromeWebSecurity": false } diff --git a/apps/simple-e2e/src/fixtures/example.json b/apps/nx-aws-frontend-e2e/src/fixtures/example.json similarity index 100% rename from apps/simple-e2e/src/fixtures/example.json rename to apps/nx-aws-frontend-e2e/src/fixtures/example.json diff --git a/apps/simple-e2e/src/integration/app.spec.ts b/apps/nx-aws-frontend-e2e/src/integration/app.spec.ts similarity index 100% rename from apps/simple-e2e/src/integration/app.spec.ts rename to apps/nx-aws-frontend-e2e/src/integration/app.spec.ts diff --git a/apps/simple-e2e/src/plugins/index.js b/apps/nx-aws-frontend-e2e/src/plugins/index.js similarity index 100% rename from apps/simple-e2e/src/plugins/index.js rename to apps/nx-aws-frontend-e2e/src/plugins/index.js diff --git a/apps/simple-e2e/src/support/app.po.ts b/apps/nx-aws-frontend-e2e/src/support/app.po.ts similarity index 100% rename from apps/simple-e2e/src/support/app.po.ts rename to apps/nx-aws-frontend-e2e/src/support/app.po.ts diff --git a/apps/simple-e2e/src/support/commands.ts b/apps/nx-aws-frontend-e2e/src/support/commands.ts similarity index 100% rename from apps/simple-e2e/src/support/commands.ts rename to apps/nx-aws-frontend-e2e/src/support/commands.ts diff --git a/apps/simple-e2e/src/support/index.ts b/apps/nx-aws-frontend-e2e/src/support/index.ts similarity index 100% rename from apps/simple-e2e/src/support/index.ts rename to apps/nx-aws-frontend-e2e/src/support/index.ts diff --git a/apps/simple-e2e/tsconfig.e2e.json b/apps/nx-aws-frontend-e2e/tsconfig.e2e.json similarity index 100% rename from apps/simple-e2e/tsconfig.e2e.json rename to apps/nx-aws-frontend-e2e/tsconfig.e2e.json diff --git a/apps/simple-e2e/tsconfig.json b/apps/nx-aws-frontend-e2e/tsconfig.json similarity index 100% rename from apps/simple-e2e/tsconfig.json rename to apps/nx-aws-frontend-e2e/tsconfig.json diff --git a/apps/simple-e2e/tslint.json b/apps/nx-aws-frontend-e2e/tslint.json similarity index 100% rename from apps/simple-e2e/tslint.json rename to apps/nx-aws-frontend-e2e/tslint.json diff --git a/apps/simple/.browserslistrc b/apps/nx-aws-frontend/.browserslistrc similarity index 100% rename from apps/simple/.browserslistrc rename to apps/nx-aws-frontend/.browserslistrc diff --git a/apps/simple/jest.config.js b/apps/nx-aws-frontend/jest.config.js similarity index 87% rename from apps/simple/jest.config.js rename to apps/nx-aws-frontend/jest.config.js index 9a26241..4b21288 100644 --- a/apps/simple/jest.config.js +++ b/apps/nx-aws-frontend/jest.config.js @@ -13,11 +13,11 @@ module.exports = { }, }, }, - coverageDirectory: '../../coverage/apps/simple', + coverageDirectory: '../../coverage/apps/nx-aws-frontend', snapshotSerializers: [ 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js', 'jest-preset-angular/build/AngularSnapshotSerializer.js', 'jest-preset-angular/build/HTMLCommentSerializer.js', ], - displayName: 'simple', + displayName: 'nx-aws-frontend', }; diff --git a/apps/simple/proxy.conf.json b/apps/nx-aws-frontend/proxy.conf.json similarity index 100% rename from apps/simple/proxy.conf.json rename to apps/nx-aws-frontend/proxy.conf.json diff --git a/apps/simple/src/app/app.component.html b/apps/nx-aws-frontend/src/app/app.component.html similarity index 84% rename from apps/simple/src/app/app.component.html rename to apps/nx-aws-frontend/src/app/app.component.html index ed5f234..bdc3b1e 100644 --- a/apps/simple/src/app/app.component.html +++ b/apps/nx-aws-frontend/src/app/app.component.html @@ -1,4 +1,4 @@ -
+

Welcome to simple!

/apps/simple', - '/apps/api', - '/libs/api-interfaces', + '/apps/nx-aws-frontend', + '/apps/nx-aws-api', + '/apps/nx-aws-api-interfaces', '/apps/layer', - '/libs/lib-as-layer', + '/libs/nx-aws-lib-as-layer', ], }; diff --git a/libs/lib-as-layer/README.md b/libs/nx-aws-lib-as-layer/README.md similarity index 100% rename from libs/lib-as-layer/README.md rename to libs/nx-aws-lib-as-layer/README.md diff --git a/libs/lib-as-layer/jest.config.js b/libs/nx-aws-lib-as-layer/jest.config.js similarity index 71% rename from libs/lib-as-layer/jest.config.js rename to libs/nx-aws-lib-as-layer/jest.config.js index c02af1f..1f8709b 100644 --- a/libs/lib-as-layer/jest.config.js +++ b/libs/nx-aws-lib-as-layer/jest.config.js @@ -1,5 +1,5 @@ module.exports = { - displayName: 'lib-as-layer', + displayName: 'nx-aws-lib-as-layer', preset: '../../jest.preset.js', globals: { 'ts-jest': { @@ -10,5 +10,5 @@ module.exports = { '^.+\\.[tj]sx?$': 'ts-jest', }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/libs/lib-as-layer', + coverageDirectory: '../../coverage/libs/nx-aws-lib-as-layer', }; diff --git a/libs/lib-as-layer/package.json b/libs/nx-aws-lib-as-layer/package.json similarity index 100% rename from libs/lib-as-layer/package.json rename to libs/nx-aws-lib-as-layer/package.json diff --git a/libs/lib-as-layer/src/index.ts b/libs/nx-aws-lib-as-layer/src/index.ts similarity index 100% rename from libs/lib-as-layer/src/index.ts rename to libs/nx-aws-lib-as-layer/src/index.ts diff --git a/libs/lib-as-layer/src/lib/lib-as-layer.spec.ts b/libs/nx-aws-lib-as-layer/src/lib/lib-as-layer.spec.ts similarity index 100% rename from libs/lib-as-layer/src/lib/lib-as-layer.spec.ts rename to libs/nx-aws-lib-as-layer/src/lib/lib-as-layer.spec.ts diff --git a/libs/lib-as-layer/src/lib/lib-as-layer.ts b/libs/nx-aws-lib-as-layer/src/lib/lib-as-layer.ts similarity index 100% rename from libs/lib-as-layer/src/lib/lib-as-layer.ts rename to libs/nx-aws-lib-as-layer/src/lib/lib-as-layer.ts diff --git a/libs/lib-as-layer/template.yaml b/libs/nx-aws-lib-as-layer/template.yaml similarity index 100% rename from libs/lib-as-layer/template.yaml rename to libs/nx-aws-lib-as-layer/template.yaml diff --git a/libs/lib-as-layer/tsconfig.json b/libs/nx-aws-lib-as-layer/tsconfig.json similarity index 100% rename from libs/lib-as-layer/tsconfig.json rename to libs/nx-aws-lib-as-layer/tsconfig.json diff --git a/libs/lib-as-layer/tsconfig.lib.json b/libs/nx-aws-lib-as-layer/tsconfig.lib.json similarity index 100% rename from libs/lib-as-layer/tsconfig.lib.json rename to libs/nx-aws-lib-as-layer/tsconfig.lib.json diff --git a/libs/lib-as-layer/tsconfig.spec.json b/libs/nx-aws-lib-as-layer/tsconfig.spec.json similarity index 100% rename from libs/lib-as-layer/tsconfig.spec.json rename to libs/nx-aws-lib-as-layer/tsconfig.spec.json diff --git a/libs/lib-as-layer/tslint.json b/libs/nx-aws-lib-as-layer/tslint.json similarity index 100% rename from libs/lib-as-layer/tslint.json rename to libs/nx-aws-lib-as-layer/tslint.json diff --git a/nx-aws-dep-graph.png b/nx-aws-dep-graph.png new file mode 100644 index 0000000..d52387c Binary files /dev/null and b/nx-aws-dep-graph.png differ diff --git a/nx-aws-diagram.drawio b/nx-aws-diagram.drawio new file mode 100644 index 0000000..43a3776 --- /dev/null +++ b/nx-aws-diagram.drawio @@ -0,0 +1 @@ +7Vpbd9o4EP41PIZjWb6QRyCX7Wm6p10esn3qEbYAp8ZyZRFgf/2ObAl8EYGkBpImJCHWaCSNZuYbjSR38HC+uuUknX1hIY07thWuOviqY9vIcTD8k5S1olz2vIIy5VGoaFvCKPqPKqKlqIsopFmFUTAWiyitEgOWJDQQFRrhnC2rbBMWV0dNyZQ2CKOAxE3qfRSKWUHtudaW/heNpjM9MrJUzZxoZkXIZiRkyxIJX3fwkDMmiqf5akhjqT2tl6LdzY7ajWCcJuKQBv+ED9nom3X/Nxmhbxefbx++3wcXWAn3SOKFmrGSVqy1CjhbJCGVvaAOHixnkaCjlASydglWB9pMzGNVPWGJUFYEeaAcxfGQxYwDIWEJ0AchyWab7jLB2U+qOTo29vMP1BAeqI4wlJSYlAu62qkAtFErOCRlcyr4GlhUAz1X7YraMMutXf2eos1KNvU8RSTKl6abrrfqhgel8Wdo3+41lE1DcD9VZFzM2JQlJL7eUgdbc0j9bnnuGEuVUh+oEGulPLIQrGoiUBdf/1sufJeddV1dvFqpzovSWpUKWaWATxsA5sMWPKBPTVwhmfApFU/xOWaLchoTET1WBWnfPPuxwRYijhLwXx19LIWBkkfDz40cdTDlJIzotk7hoQwRYL+y3CHyG9Cog0cOJOEQQay6I2Maf2VZJCKWQN2YCcHmJYZ+HE1lhZAuMiCqFIAslO/EL7J1Wc1XDkmytJjoJFpJOQYpi2Qv14/QWaZBPSOpbDBfTeWy0CXLzOnGZD4OyY/JIgkKMdvAtNOrgtpDJlA3Ma1prfsM3u8zucbycd0B/ILAw+LPhdqhpHRt10A00fwmETXZ4B8yjVAnmmh+k4iabLKkpa4STTTfbUpcb40MrVGtNfwqB/xQZ1vq/K2IBnU32HF6dqnuKuJUIR6CGJeorIe8wRBh1zNlA5P88xrjnjHGcVosfZ+CPMBBsXiqcgUxW4QTxiFFbC0QetU46J85DLpnWTpt30eo6UdvfukcL4KfMk9qw1Hs2orpmFZM94Su4n2smG8sxHtWH2P/eSF+BzT/1BCftbRnRbW47l2eN65vDjNOumNtceepo93erad71p0nei9qRjv8/zR61mKeOE9x+9gauH9eniJd50fMAp3XVk8OWwiHuIcq4dA2nuGdMh42/eWNAVUfqu89ijsrTtEHTtvEaRLmvMeAaP1Ezri/OCVEkekY14vl5MPoER6n8rF/PwKeUf8LfF/RNGbruZwwNIuIrMDwNSi2YaoxCFNqX+nS0mYF6q+FvOAZxHQitiXdiqRpBv0kqwuwywVJIygIOk8BU7S7JuAKqtsxrw9UH76GBjCgqLqT0YcN1zMNl6x77jwKwzyOma6CqrGtfhvUxv7VcSv+ZTjpwDppLvuXc7RLHH9/bJqCWtKdk1d3l2Ss2a1nK8Wvgs7tNbWCkAF1G2L7ajlgX7/nLrER4F4QrJ4wWVObZW1ZBh/aENvX1gH3Bq9NW6qby4rn9Zp+d2JNOm9WkxqL62rxjLo8zzHuxw3ob7tSDZX2mY+NcDN/H+aXIJzJJOu95C5ObZnevJJShrjpFRT7WAjHe5LjgzPZ/tdPwH0LeeuSrE+Wo+ayvDYru/UdEMZd9zA742NtoHEzv8i3NOpmSb4Yx+W3xCPsDt8PJN2arZwmIm3LcB12PESa8peXIBJGLzaUMxiVtblrvcvXMXkCpc8RzrdLfRMRwLMPjgDu0SKAKZdrHIOok4iYrCk/wGWqjaLxBam13e8Rjd423pV3lL1zT3qxI3me5nyGK0Fx+0JyXld6rxtf/w8= \ No newline at end of file diff --git a/nx-aws-diagram.png b/nx-aws-diagram.png new file mode 100644 index 0000000..f5e311e Binary files /dev/null and b/nx-aws-diagram.png differ diff --git a/nx.json b/nx.json index 662213e..754f876 100644 --- a/nx.json +++ b/nx.json @@ -1,9 +1,14 @@ { "npmScope": "nx-aws-example", - "affected": { "defaultBase": "master" }, + "affected": { + "defaultBase": "master" + }, "implicitDependencies": { "angular.json": "*", - "package.json": { "dependencies": "*", "devDependencies": "*" }, + "package.json": { + "dependencies": "*", + "devDependencies": "*" + }, "tsconfig.base.json": "*", "tslint.json": "*", "nx.json": "*" @@ -11,15 +16,32 @@ "tasksRunnerOptions": { "default": { "runner": "@nrwl/workspace/tasks-runners/default", - "options": { "cacheableOperations": ["build", "lint", "test", "e2e"] } + "options": { + "cacheableOperations": ["build", "lint", "test", "e2e"] + } } }, "projects": { - "simple": { "tags": [], "implicitDependencies": ["api"] }, - "simple-e2e": { "tags": [], "implicitDependencies": ["simple"] }, - "api": { "tags": [], "implicitDependencies": ["layer"] }, - "api-interfaces": { "tags": [] }, - "layer": { "tags": [] }, - "lib-as-layer": { "tags": [] } + "api-interfaces": { + "tags": [] + }, + "nx-aws-api": { + "tags": [], + "implicitDependencies": ["nx-aws-layer"] + }, + "nx-aws-frontend": { + "tags": [], + "implicitDependencies": ["nx-aws-api"] + }, + "nx-aws-frontend-e2e": { + "tags": [], + "implicitDependencies": ["nx-aws-frontend"] + }, + "nx-aws-layer": { + "tags": [] + }, + "nx-aws-lib-as-layer": { + "tags": [] + } } } diff --git a/tsconfig.base.json b/tsconfig.base.json index 6d2238e..0a75137 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -18,7 +18,9 @@ "paths": { "@nx-aws-example/api-interfaces": ["libs/api-interfaces/src/index.ts"], "@nx-aws-example/layer": ["libs/layer/src/index.ts"], - "@nx-aws-example/lib-as-layer": ["libs/lib-as-layer/src/index.ts"] + "@nx-aws-example/nx-aws-lib-as-layer": [ + "libs/nx-aws-lib-as-layer/src/index.ts" + ] } }, "exclude": ["node_modules", "tmp"]