From b145d1fa17bcc90a18eedf83e102a8beda1f597a Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Sun, 7 Jun 2020 22:33:33 +0300 Subject: [PATCH] clean ups --- packages/@aws-cdk/core/lib/deps.ts | 12 ++++++------ packages/@aws-cdk/core/lib/private/prepare-app.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/@aws-cdk/core/lib/deps.ts b/packages/@aws-cdk/core/lib/deps.ts index 3b5dc0fd542b2..c34f11ef2c5a7 100644 --- a/packages/@aws-cdk/core/lib/deps.ts +++ b/packages/@aws-cdk/core/lib/deps.ts @@ -30,12 +30,12 @@ export function addDependency(source: T, target: T, reason?: } const sourceStack = Stack.of(source); - const sourceAssembly = Stage.of(sourceStack); const targetStack = Stack.of(target); - const targetAssembly = Stage.of(targetStack); - if (sourceAssembly !== targetAssembly) { - throw new Error(`You cannot add a dependency from '${source.node.path}' (in ${describeAssembly(sourceAssembly)}) to '${target.node.path}' (in ${describeAssembly(targetAssembly)}): dependency cannot cross stage boundaries`); + const sourceStage = Stage.of(sourceStack); + const targetStage = Stage.of(targetStack); + if (sourceStage !== targetStage) { + throw new Error(`You cannot add a dependency from '${source.node.path}' (in ${describeStage(sourceStage)}) to '${target.node.path}' (in ${describeStage(targetStage)}): dependency cannot cross stage boundaries`); } // find the deepest common stack between the two elements @@ -43,7 +43,7 @@ export function addDependency(source: T, target: T, reason?: const targetPath = pathToRoot(targetStack); const commonStack = findLastCommonElement(sourcePath, targetPath); - // if there is no common stack, then define an assembly-level dependency + // if there is no common stack, then define a assembly-level dependency // between the two top-level stacks if (!commonStack) { const topLevelSource = sourcePath[0]; // first path element is the top-level stack @@ -99,7 +99,7 @@ export function addDependency(source: T, target: T, reason?: /** * Return a string representation of the given assembler, for use in error messages */ -function describeAssembly(assembly: Stage | undefined): string { +function describeStage(assembly: Stage | undefined): string { if (!assembly) { return 'an unrooted construct tree'; } if (!assembly.parentStage) { return 'the App'; } return `Stage '${assembly.node.path}'`; diff --git a/packages/@aws-cdk/core/lib/private/prepare-app.ts b/packages/@aws-cdk/core/lib/private/prepare-app.ts index ec8ba916b24e0..de5ef433fb1ad 100644 --- a/packages/@aws-cdk/core/lib/private/prepare-app.ts +++ b/packages/@aws-cdk/core/lib/private/prepare-app.ts @@ -17,7 +17,7 @@ import { resolveReferences } from './refs'; */ export function prepareApp(root: IConstruct) { if (root.node.scope && !Stage.isStage(root)) { - throw new Error('prepareApp can only be called on an Assembly or a root construct'); + throw new Error('prepareApp can only be called on a stage or a root construct'); } // apply dependencies between resources in depending subtrees @@ -67,7 +67,7 @@ function findAllNestedStacks(root: IConstruct) { if (!Stack.isStack(stack)) { return false; } if (!stack.nested) { return false; } - // test: if we are not within an assembly, then include it. + // test: if we are not within a stage, then include it. if (!Stage.of(stack)) { return true; } return Stage.of(stack) === root;