From 4060b0eaefea5ccaa2769a7842742adc3ad2dbbe Mon Sep 17 00:00:00 2001 From: martzcodes <978362+martzcodes@users.noreply.github.com> Date: Mon, 15 May 2023 13:15:32 -0400 Subject: [PATCH] 1.1.1 - add install instructions, filter out characters mermaid doesn't like --- README.md | 11 +++++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/architecture-diagram.ts | 7 +------ test/arch-dia.test.ts | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index bee047b..b0aa47a 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,17 @@ This uses no external dependencies! - Normal arrow lines indicate an existing linkage - dashed/dotted arrow lines indicate a removed linkage +## Installation Instructions + +`npm install @aws-community/arch-dia --save-dev` + +then add the aspect to your Stack + +``` +const myStack = new Stack(app, 'MyStack'); +Aspects.of(myStack).add(new ArchitectureDiagramAspect()); +``` + ## Example 1 - Simple Stack ```mermaid diff --git a/package-lock.json b/package-lock.json index 5f6aafd..fa14872 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@aws-community/arch-dia", - "version": "1.2.0", + "version": "1.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@aws-community/arch-dia", - "version": "1.0.0", + "version": "1.1.1", "license": "Apache-2.0", "devDependencies": { "@aws-cdk/integ-runner": "^2.78.0-alpha.0", diff --git a/package.json b/package.json index 57910f8..dfae86d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "diagram" ], "license": "Apache-2.0", - "version": "1.0.0", + "version": "1.1.1", "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { diff --git a/src/architecture-diagram.ts b/src/architecture-diagram.ts index 2ca79bc..bc61581 100644 --- a/src/architecture-diagram.ts +++ b/src/architecture-diagram.ts @@ -20,14 +20,9 @@ export class ArchitectureDiagramAspect implements IAspect { private traverseConstruct (construct: IConstruct, parentPath: string): void { const parentSplit = parentPath.split(' --> '); const currentParent = parentSplit[parentSplit.length - 1]; - if (CfnResource.isCfnResource(construct)) { - console.log( - `CfnResource: ${construct.node.addr} - ${construct.node.id} - ${JSON.stringify(construct.cfnOptions)}`, - ); - } const currentPath = `${currentParent}${currentParent ? ' --> ' : ''}${ construct.node.addr - }[${construct.node.id}${ + }[${construct.node.id.replace(/{|}/g, '')}${ CfnResource.isCfnResource(construct) ? ` - ${construct.cfnResourceType}` : '' diff --git a/test/arch-dia.test.ts b/test/arch-dia.test.ts index f082b92..5017663 100644 --- a/test/arch-dia.test.ts +++ b/test/arch-dia.test.ts @@ -1,4 +1,4 @@ -import { App, Stack } from 'aws-cdk-lib'; +import { App, Aspects, Stack } from 'aws-cdk-lib'; import { Queue } from 'aws-cdk-lib/aws-sqs'; const writeFile = jest.fn();