diff --git a/.projenrc.ts b/.projenrc.ts index 319a7b950..43286463c 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -863,7 +863,7 @@ cli.gitignore.addPatterns('build-info.json'); const cliPackageJson = `${cli.workspaceDirectory}/package.json`; cli.preCompileTask.prependExec('./generate.sh'); -cli.preCompileTask.prependExec('ts-node scripts/user-input-gen.ts'); +cli.preCompileTask.prependExec('ts-node --prefer-ts-exts scripts/user-input-gen.ts'); const includeCliResourcesCommands = [ 'cp $(node -p \'require.resolve("cdk-from-cfn/index_bg.wasm")\') ./lib/', diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/aws-cdk.ts b/packages/@aws-cdk/toolkit-lib/lib/api/aws-cdk.ts index e79757154..85c4b2d2d 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/aws-cdk.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/aws-cdk.ts @@ -8,29 +8,27 @@ export { Settings } from '../../../../aws-cdk/lib/api/settings'; export { tagsForStack } from '../../../../aws-cdk/lib/api/tags'; export { DEFAULT_TOOLKIT_STACK_NAME } from '../../../../aws-cdk/lib/api/toolkit-info'; export { ResourceMigrator } from '../../../../aws-cdk/lib/api/resource-import'; +export { StackActivityProgress } from '../../../../aws-cdk/lib/api/stack-events'; +export { CloudWatchLogEventMonitor, findCloudWatchLogGroups } from '../../../../aws-cdk/lib/api/logs'; +export { WorkGraph, WorkGraphBuilder, AssetBuildNode, AssetPublishNode, StackNode, Concurrency } from '../../../../aws-cdk/lib/api/work-graph'; // Context Providers export * as contextproviders from '../../../../aws-cdk/lib/context-providers'; +// utils +export { formatTime } from '../../../../aws-cdk/lib/util/string-manipulation'; +export { formatErrorMessage } from '../../../../aws-cdk/lib/util/format-error'; +export { obscureTemplate, serializeStructure } from '../../../../aws-cdk/lib/util/serialize'; +export { validateSnsTopicArn } from '../../../../aws-cdk/lib/util/cloudformation'; +export { splitBySize } from '../../../../aws-cdk/lib/util/objects'; + // @todo APIs not clean import export { HotswapMode } from '../../../../aws-cdk/lib/api/hotswap/common'; -export { StackActivityProgress } from '../../../../aws-cdk/lib/api/util/cloudformation/stack-activity-monitor'; +export { HotswapPropertyOverrides, EcsHotswapProperties } from '../../../../aws-cdk/lib/api/hotswap/common'; export { RWLock, type ILock } from '../../../../aws-cdk/lib/api/util/rwlock'; -export { formatTime } from '../../../../aws-cdk/lib/api/util/string-manipulation'; // @todo Not yet API probably should be -export { formatErrorMessage } from '../../../../aws-cdk/lib/util/error'; -export { obscureTemplate, serializeStructure } from '../../../../aws-cdk/lib/serialize'; export { loadTree, some } from '../../../../aws-cdk/lib/tree'; -export { splitBySize } from '../../../../aws-cdk/lib/util'; -export { validateSnsTopicArn } from '../../../../aws-cdk/lib/util/validate-notification-arn'; -export { WorkGraph } from '../../../../aws-cdk/lib/util/work-graph'; -export type { Concurrency } from '../../../../aws-cdk/lib/util/work-graph'; -export { WorkGraphBuilder } from '../../../../aws-cdk/lib/util/work-graph-builder'; -export type { AssetBuildNode, AssetPublishNode, StackNode } from '../../../../aws-cdk/lib/util/work-graph-types'; -export { CloudWatchLogEventMonitor } from '../../../../aws-cdk/lib/api/logs/logs-monitor'; -export { findCloudWatchLogGroups } from '../../../../aws-cdk/lib/api/logs/find-cloudwatch-logs'; -export { HotswapPropertyOverrides, EcsHotswapProperties } from '../../../../aws-cdk/lib/api/hotswap/common'; // @todo Cloud Assembly and Executable - this is a messy API right now export { CloudAssembly, sanitizePatterns, type StackDetails, StackCollection, ExtendedStackSelection } from '../../../../aws-cdk/lib/api/cxapp/cloud-assembly'; diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/context-aware-source.ts b/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/context-aware-source.ts index f4d0e2d2e..e39bc8d4f 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/context-aware-source.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/context-aware-source.ts @@ -1,7 +1,7 @@ import type { MissingContext } from '@aws-cdk/cloud-assembly-schema'; import * as cxapi from '@aws-cdk/cx-api'; import { ToolkitServices } from '../../../toolkit/private'; -import { Context, contextproviders, PROJECT_CONTEXT } from '../../aws-cdk'; +import { type Context, contextproviders, PROJECT_CONTEXT } from '../../aws-cdk'; import { ToolkitError } from '../../errors'; import { ActionAwareIoHost, debug } from '../../io/private'; import { ICloudAssemblySource } from '../types'; diff --git a/packages/aws-cdk/.projen/tasks.json b/packages/aws-cdk/.projen/tasks.json index 49151b887..eff3eee71 100644 --- a/packages/aws-cdk/.projen/tasks.json +++ b/packages/aws-cdk/.projen/tasks.json @@ -165,7 +165,7 @@ "description": "Prepare the project for compilation", "steps": [ { - "exec": "ts-node scripts/user-input-gen.ts" + "exec": "ts-node --prefer-ts-exts scripts/user-input-gen.ts" }, { "exec": "./generate.sh" diff --git a/packages/aws-cdk/lib/api/aws-auth/credential-plugins.ts b/packages/aws-cdk/lib/api/aws-auth/credential-plugins.ts index 6f70ab67b..8342f5142 100644 --- a/packages/aws-cdk/lib/api/aws-auth/credential-plugins.ts +++ b/packages/aws-cdk/lib/api/aws-auth/credential-plugins.ts @@ -4,7 +4,7 @@ import type { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smit import { credentialsAboutToExpire, makeCachingProvider } from './provider-caching'; import { debug, warning } from '../../logging'; import { AuthenticationError } from '../../toolkit/error'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; import { Mode } from '../plugin/mode'; import { PluginHost } from '../plugin/plugin'; diff --git a/packages/aws-cdk/lib/api/aws-auth/sdk-logger.ts b/packages/aws-cdk/lib/api/aws-auth/sdk-logger.ts index 4ac90ad16..2a3d8230c 100644 --- a/packages/aws-cdk/lib/api/aws-auth/sdk-logger.ts +++ b/packages/aws-cdk/lib/api/aws-auth/sdk-logger.ts @@ -1,7 +1,7 @@ import { inspect, format } from 'util'; import { Logger } from '@smithy/types'; -import { replacerBufferWithInfo } from '../../serialize'; import type { IIoHost } from '../../toolkit/cli-io-host'; +import { replacerBufferWithInfo } from '../../util/serialize'; export class SdkToCliLogger implements Logger { private readonly ioHost: IIoHost; diff --git a/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts b/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts index 8b5025088..55ea6fd00 100644 --- a/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts +++ b/packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts @@ -13,7 +13,7 @@ import { SDK } from './sdk'; import { callTrace, traceMemberMethods } from './tracing'; import { debug, warning } from '../../logging'; import { AuthenticationError } from '../../toolkit/error'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; import { Mode } from '../plugin/mode'; export type AssumeRoleAdditionalOptions = Partial>; diff --git a/packages/aws-cdk/lib/api/aws-auth/sdk.ts b/packages/aws-cdk/lib/api/aws-auth/sdk.ts index d544021ae..5c6c3302a 100644 --- a/packages/aws-cdk/lib/api/aws-auth/sdk.ts +++ b/packages/aws-cdk/lib/api/aws-auth/sdk.ts @@ -321,7 +321,7 @@ import { traceMemberMethods } from './tracing'; import { defaultCliUserAgent } from './user-agent'; import { debug } from '../../logging'; import { AuthenticationError } from '../../toolkit/error'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; export interface S3ClientOptions { /** diff --git a/packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts b/packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts index 4d8547d73..fd3e45a2c 100644 --- a/packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts +++ b/packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts @@ -5,10 +5,10 @@ import type { BootstrapEnvironmentOptions, BootstrappingParameters } from './boo import { BootstrapStack, bootstrapVersionFromTemplate } from './deploy-bootstrap'; import { legacyBootstrapTemplate } from './legacy-template'; import { warn } from '../../cli/messages'; -import { loadStructuredFile, serializeStructure } from '../../serialize'; import { IoMessaging } from '../../toolkit/cli-io-host'; import { ToolkitError } from '../../toolkit/error'; import { rootDir } from '../../util/directories'; +import { loadStructuredFile, serializeStructure } from '../../util/serialize'; import type { SDK, SdkProvider } from '../aws-auth'; import type { SuccessfulDeployStackResult } from '../deployments'; import { Mode } from '../plugin/mode'; diff --git a/packages/aws-cdk/lib/api/deployments/cloudformation.ts b/packages/aws-cdk/lib/api/deployments/cloudformation.ts index f3892e701..56a16830a 100644 --- a/packages/aws-cdk/lib/api/deployments/cloudformation.ts +++ b/packages/aws-cdk/lib/api/deployments/cloudformation.ts @@ -12,14 +12,14 @@ import { } from '@aws-sdk/client-cloudformation'; import { AssetManifest, FileManifestEntry } from 'cdk-assets'; import { AssetManifestBuilder } from './asset-manifest-builder'; +import type { Deployments } from './deployments'; import { debug } from '../../cli/messages'; -import { deserializeStructure } from '../../serialize'; import { IoMessaging } from '../../toolkit/cli-io-host'; import { ToolkitError } from '../../toolkit/error'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; +import { deserializeStructure } from '../../util/serialize'; import type { ICloudFormationClient, SdkProvider } from '../aws-auth'; -import type { Deployments } from './deployments'; -import { StackStatus } from '../util/cloudformation/stack-status'; +import { StackStatus } from '../stack-events'; import { makeBodyParameter, TemplateBodyParameter } from '../util/template-body-parameter'; export type ResourcesToImport = ResourceToImport[]; diff --git a/packages/aws-cdk/lib/api/deployments/deploy-stack.ts b/packages/aws-cdk/lib/api/deployments/deploy-stack.ts index 2280cfbf3..2d7e81a13 100644 --- a/packages/aws-cdk/lib/api/deployments/deploy-stack.ts +++ b/packages/aws-cdk/lib/api/deployments/deploy-stack.ts @@ -31,12 +31,12 @@ import { tryHotswapDeployment } from './hotswap-deployments'; import { debug, info, warn } from '../../cli/messages'; import { IIoHost, IoMessaging, ToolkitAction } from '../../toolkit/cli-io-host'; import { ToolkitError } from '../../toolkit/error'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; import type { SDK, SdkProvider, ICloudFormationClient } from '../aws-auth'; import type { EnvironmentResources } from '../environment'; import { CfnEvaluationException } from '../evaluate-cloudformation-template'; import { HotswapMode, HotswapPropertyOverrides, ICON } from '../hotswap/common'; -import { StackActivityMonitor, type StackActivityProgress } from '../util/cloudformation/stack-activity-monitor'; +import { StackActivityMonitor, type StackActivityProgress } from '../stack-events'; import { StringWithoutPlaceholders } from '../util/placeholders'; import { type TemplateBodyParameter, makeBodyParameter } from '../util/template-body-parameter'; diff --git a/packages/aws-cdk/lib/api/deployments/deployments.ts b/packages/aws-cdk/lib/api/deployments/deployments.ts index ca8a33e62..a9cc3b00e 100644 --- a/packages/aws-cdk/lib/api/deployments/deployments.ts +++ b/packages/aws-cdk/lib/api/deployments/deployments.ts @@ -27,15 +27,13 @@ import { import { debug, warn } from '../../cli/messages'; import { IIoHost, IoMessaging, ToolkitAction } from '../../toolkit/cli-io-host'; import { ToolkitError } from '../../toolkit/error'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; import type { SdkProvider } from '../aws-auth/sdk-provider'; import { type EnvironmentResources, EnvironmentAccess } from '../environment'; import { HotswapMode, HotswapPropertyOverrides } from '../hotswap/common'; +import { StackActivityMonitor, StackActivityProgress, StackEventPoller, RollbackChoice } from '../stack-events'; import type { Tag } from '../tags'; import { DEFAULT_TOOLKIT_STACK_NAME } from '../toolkit-info'; -import { StackActivityMonitor, StackActivityProgress } from '../util/cloudformation/stack-activity-monitor'; -import { StackEventPoller } from '../util/cloudformation/stack-event-poller'; -import { RollbackChoice } from '../util/cloudformation/stack-status'; import { makeBodyParameter } from '../util/template-body-parameter'; const BOOTSTRAP_STACK_VERSION_FOR_ROLLBACK = 23; diff --git a/packages/aws-cdk/lib/api/deployments/hotswap-deployments.ts b/packages/aws-cdk/lib/api/deployments/hotswap-deployments.ts index 6fa5617e1..2066ea82a 100644 --- a/packages/aws-cdk/lib/api/deployments/hotswap-deployments.ts +++ b/packages/aws-cdk/lib/api/deployments/hotswap-deployments.ts @@ -8,7 +8,7 @@ import type { CloudFormationStack } from './cloudformation'; import { NestedStackTemplates, loadCurrentTemplateWithNestedStacks } from './nested-stack-helpers'; import { info } from '../../cli/messages'; import { ToolkitError } from '../../toolkit/error'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; import { EvaluateCloudFormationTemplate } from '../evaluate-cloudformation-template'; import { isHotswappableAppSyncChange } from '../hotswap/appsync-mapping-templates'; import { isHotswappableCodeBuildProjectChange } from '../hotswap/code-build-projects'; diff --git a/packages/aws-cdk/lib/api/deployments/nested-stack-helpers.ts b/packages/aws-cdk/lib/api/deployments/nested-stack-helpers.ts index cb3fc1c75..09d6445f8 100644 --- a/packages/aws-cdk/lib/api/deployments/nested-stack-helpers.ts +++ b/packages/aws-cdk/lib/api/deployments/nested-stack-helpers.ts @@ -3,7 +3,7 @@ import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; import * as fs from 'fs-extra'; import type { SDK } from '../aws-auth'; import { CloudFormationStack, type Template } from './cloudformation'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; import { LazyListStackResources, type ListStackResources } from '../evaluate-cloudformation-template'; export interface NestedStackTemplates { diff --git a/packages/aws-cdk/lib/api/environment/environment-access.ts b/packages/aws-cdk/lib/api/environment/environment-access.ts index 309d2dd55..2d3fe1288 100644 --- a/packages/aws-cdk/lib/api/environment/environment-access.ts +++ b/packages/aws-cdk/lib/api/environment/environment-access.ts @@ -4,7 +4,7 @@ import { EnvironmentResources, EnvironmentResourcesRegistry } from './environmen import { warn } from '../../cli/messages'; import { IoMessaging } from '../../toolkit/cli-io-host'; import { ToolkitError } from '../../toolkit/error'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; import { CredentialsOptions, SdkForEnvironment, SdkProvider } from '../aws-auth/sdk-provider'; import { Mode } from '../plugin/mode'; import { replaceEnvPlaceholders, StringWithoutPlaceholders } from '../util/placeholders'; diff --git a/packages/aws-cdk/lib/api/environment/environment-resources.ts b/packages/aws-cdk/lib/api/environment/environment-resources.ts index 084296830..df4155592 100644 --- a/packages/aws-cdk/lib/api/environment/environment-resources.ts +++ b/packages/aws-cdk/lib/api/environment/environment-resources.ts @@ -3,7 +3,7 @@ import { debug, warn } from '../../cli/messages'; import { Notices } from '../../notices'; import { IoMessaging } from '../../toolkit/cli-io-host'; import { ToolkitError } from '../../toolkit/error'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; import type { SDK } from '../aws-auth'; import { type EcrRepositoryInfo, ToolkitInfo } from '../toolkit-info'; diff --git a/packages/aws-cdk/lib/api/logs/find-cloudwatch-logs.ts b/packages/aws-cdk/lib/api/logs/find-cloudwatch-logs.ts index f2317200b..194a8003b 100644 --- a/packages/aws-cdk/lib/api/logs/find-cloudwatch-logs.ts +++ b/packages/aws-cdk/lib/api/logs/find-cloudwatch-logs.ts @@ -2,7 +2,7 @@ import type { CloudFormationStackArtifact, Environment } from '@aws-cdk/cx-api'; import type { StackResourceSummary } from '@aws-sdk/client-cloudformation'; import { debug } from '../../logging'; import { IoMessaging } from '../../toolkit/cli-io-host'; -import { formatErrorMessage } from '../../util/error'; +import { formatErrorMessage } from '../../util/format-error'; import type { SDK, SdkProvider } from '../aws-auth'; import { EnvironmentAccess } from '../environment'; import { EvaluateCloudFormationTemplate, LazyListStackResources } from '../evaluate-cloudformation-template'; diff --git a/packages/aws-cdk/lib/api/logs/index.ts b/packages/aws-cdk/lib/api/logs/index.ts new file mode 100644 index 000000000..4475be9a7 --- /dev/null +++ b/packages/aws-cdk/lib/api/logs/index.ts @@ -0,0 +1,2 @@ +export * from './logs-monitor'; +export * from './find-cloudwatch-logs'; diff --git a/packages/aws-cdk/lib/api/resource-import/importer.ts b/packages/aws-cdk/lib/api/resource-import/importer.ts index 3246aa4fc..894113315 100644 --- a/packages/aws-cdk/lib/api/resource-import/importer.ts +++ b/packages/aws-cdk/lib/api/resource-import/importer.ts @@ -9,8 +9,8 @@ import { error, info, warn } from '../../cli/messages'; import { IIoHost, ToolkitAction } from '../../toolkit/cli-io-host'; import { ToolkitError } from '../../toolkit/error'; import { assertIsSuccessfulDeployStackResult, type Deployments, DeploymentMethod, ResourceIdentifierProperties, ResourcesToImport } from '../deployments'; -import { Tag } from '../tags'; -import { StackActivityProgress } from '../util/cloudformation/stack-activity-monitor'; +import type { StackActivityProgress } from '../stack-events'; +import type { Tag } from '../tags'; export interface ResourceImporterProps { deployments: Deployments; diff --git a/packages/aws-cdk/lib/api/resource-import/migrator.ts b/packages/aws-cdk/lib/api/resource-import/migrator.ts index 06e2b5208..e0f2e421a 100644 --- a/packages/aws-cdk/lib/api/resource-import/migrator.ts +++ b/packages/aws-cdk/lib/api/resource-import/migrator.ts @@ -4,9 +4,9 @@ import * as fs from 'fs-extra'; import { ImportDeploymentOptions, ResourceImporter } from './importer'; import { info } from '../../cli/messages'; import type { IIoHost, ToolkitAction } from '../../toolkit/cli-io-host'; +import { formatTime } from '../../util/string-manipulation'; import { StackCollection } from '../cxapp/cloud-assembly'; import type { Deployments, ResourcesToImport } from '../deployments'; -import { formatTime } from '../util/string-manipulation'; export interface ResourceMigratorProps { deployments: Deployments; diff --git a/packages/aws-cdk/lib/api/util/display.ts b/packages/aws-cdk/lib/api/stack-events/display.ts similarity index 100% rename from packages/aws-cdk/lib/api/util/display.ts rename to packages/aws-cdk/lib/api/stack-events/display.ts diff --git a/packages/aws-cdk/lib/api/stack-events/index.ts b/packages/aws-cdk/lib/api/stack-events/index.ts new file mode 100644 index 000000000..831096516 --- /dev/null +++ b/packages/aws-cdk/lib/api/stack-events/index.ts @@ -0,0 +1,3 @@ +export * from './stack-activity-monitor'; +export * from './stack-event-poller'; +export * from './stack-status'; diff --git a/packages/aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.ts b/packages/aws-cdk/lib/api/stack-events/stack-activity-monitor.ts similarity index 99% rename from packages/aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.ts rename to packages/aws-cdk/lib/api/stack-events/stack-activity-monitor.ts index de46599ce..962b505dd 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.ts +++ b/packages/aws-cdk/lib/api/stack-events/stack-activity-monitor.ts @@ -3,10 +3,10 @@ import { ArtifactMetadataEntryType, type MetadataEntry } from '@aws-cdk/cloud-as import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; import * as chalk from 'chalk'; import { ResourceEvent, StackEventPoller } from './stack-event-poller'; -import { error, info } from '../../../logging'; -import { CliIoHost, IoMessageLevel } from '../../../toolkit/cli-io-host'; -import type { ICloudFormationClient } from '../../aws-auth'; -import { RewritableBlock } from '../display'; +import { error, info } from '../../logging'; +import { CliIoHost, IoMessageLevel } from '../../toolkit/cli-io-host'; +import type { ICloudFormationClient } from '../aws-auth'; +import { RewritableBlock } from './display'; export interface StackActivity extends ResourceEvent { readonly metadata?: ResourceMetadata; diff --git a/packages/aws-cdk/lib/api/util/cloudformation/stack-event-poller.ts b/packages/aws-cdk/lib/api/stack-events/stack-event-poller.ts similarity index 98% rename from packages/aws-cdk/lib/api/util/cloudformation/stack-event-poller.ts rename to packages/aws-cdk/lib/api/stack-events/stack-event-poller.ts index d0a688e32..02f93970d 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation/stack-event-poller.ts +++ b/packages/aws-cdk/lib/api/stack-events/stack-event-poller.ts @@ -1,6 +1,6 @@ import type { StackEvent } from '@aws-sdk/client-cloudformation'; -import { formatErrorMessage } from '../../../util/error'; -import type { ICloudFormationClient } from '../../aws-auth'; +import { formatErrorMessage } from '../../util/format-error'; +import type { ICloudFormationClient } from '../aws-auth'; export interface StackEventPollerProps { /** diff --git a/packages/aws-cdk/lib/api/util/cloudformation/stack-status.ts b/packages/aws-cdk/lib/api/stack-events/stack-status.ts similarity index 100% rename from packages/aws-cdk/lib/api/util/cloudformation/stack-status.ts rename to packages/aws-cdk/lib/api/stack-events/stack-status.ts diff --git a/packages/aws-cdk/lib/api/util/template-body-parameter.ts b/packages/aws-cdk/lib/api/util/template-body-parameter.ts index 4e80b43f9..ca9b5ab02 100644 --- a/packages/aws-cdk/lib/api/util/template-body-parameter.ts +++ b/packages/aws-cdk/lib/api/util/template-body-parameter.ts @@ -5,9 +5,9 @@ import { getEndpointFromInstructions } from '@smithy/middleware-endpoint'; import * as chalk from 'chalk'; import * as fs from 'fs-extra'; import { debug, error } from '../../logging'; -import { toYAML } from '../../serialize'; import { ToolkitError } from '../../toolkit/error'; import { contentHash } from '../../util/content-hash'; +import { toYAML } from '../../util/serialize'; import { type AssetManifestBuilder } from '../deployments'; import { EnvironmentResources } from '../environment'; diff --git a/packages/aws-cdk/lib/api/work-graph/index.ts b/packages/aws-cdk/lib/api/work-graph/index.ts new file mode 100644 index 000000000..f06d9a3b5 --- /dev/null +++ b/packages/aws-cdk/lib/api/work-graph/index.ts @@ -0,0 +1,3 @@ +export * from './work-graph'; +export * from './work-graph-builder'; +export * from './work-graph-types'; diff --git a/packages/aws-cdk/lib/util/work-graph-builder.ts b/packages/aws-cdk/lib/api/work-graph/work-graph-builder.ts similarity index 98% rename from packages/aws-cdk/lib/util/work-graph-builder.ts rename to packages/aws-cdk/lib/api/work-graph/work-graph-builder.ts index 1c6888754..f7ce8c6b6 100644 --- a/packages/aws-cdk/lib/util/work-graph-builder.ts +++ b/packages/aws-cdk/lib/api/work-graph/work-graph-builder.ts @@ -1,9 +1,9 @@ import * as cxapi from '@aws-cdk/cx-api'; import { AssetManifest, type IManifestEntry } from 'cdk-assets'; -import { contentHashAny } from './content-hash'; import { WorkGraph } from './work-graph'; import { DeploymentState, AssetBuildNode, WorkNode } from './work-graph-types'; -import { ToolkitError } from '../toolkit/error'; +import { ToolkitError } from '../../toolkit/error'; +import { contentHashAny } from '../../util/content-hash'; export class WorkGraphBuilder { /** diff --git a/packages/aws-cdk/lib/util/work-graph-types.ts b/packages/aws-cdk/lib/api/work-graph/work-graph-types.ts similarity index 100% rename from packages/aws-cdk/lib/util/work-graph-types.ts rename to packages/aws-cdk/lib/api/work-graph/work-graph-types.ts diff --git a/packages/aws-cdk/lib/util/work-graph.ts b/packages/aws-cdk/lib/api/work-graph/work-graph.ts similarity index 98% rename from packages/aws-cdk/lib/util/work-graph.ts rename to packages/aws-cdk/lib/api/work-graph/work-graph.ts index ad5d4065a..451cf6386 100644 --- a/packages/aws-cdk/lib/util/work-graph.ts +++ b/packages/aws-cdk/lib/api/work-graph/work-graph.ts @@ -1,7 +1,7 @@ -import { parallelPromises } from './parallel'; import { WorkNode, DeploymentState, StackNode, AssetBuildNode, AssetPublishNode } from './work-graph-types'; -import { debug, trace } from '../logging'; -import { ToolkitError } from '../toolkit/error'; +import { debug, trace } from '../../logging'; +import { ToolkitError } from '../../toolkit/error'; +import { parallelPromises } from '../../util/parallel'; export type Concurrency = number | Record; diff --git a/packages/aws-cdk/lib/cli/cdk-toolkit.ts b/packages/aws-cdk/lib/cli/cdk-toolkit.ts index 53fc91273..1909023d9 100644 --- a/packages/aws-cdk/lib/cli/cdk-toolkit.ts +++ b/packages/aws-cdk/lib/cli/cdk-toolkit.ts @@ -25,9 +25,10 @@ import { HotswapMode, HotswapPropertyOverrides, EcsHotswapProperties } from '../ import { findCloudWatchLogGroups } from '../api/logs/find-cloudwatch-logs'; import { CloudWatchLogEventMonitor } from '../api/logs/logs-monitor'; import { ResourceImporter, removeNonImportResources, ResourceMigrator } from '../api/resource-import'; +import { StackActivityProgress } from '../api/stack-events'; import { tagsForStack, type Tag } from '../api/tags'; -import { StackActivityProgress } from '../api/util/cloudformation/stack-activity-monitor'; -import { formatTime } from '../api/util/string-manipulation'; +import { type AssetBuildNode, type AssetPublishNode, type Concurrency, type StackNode, WorkGraph } from '../api/work-graph'; +import { WorkGraphBuilder } from '../api/work-graph/work-graph-builder'; import { generateCdkApp, generateStack, @@ -49,15 +50,13 @@ import { import { printSecurityDiff, printStackDiff, RequireApproval } from '../diff'; import { listStacks } from '../list-stacks'; import { result as logResult, debug, error, highlight, info, success, warning } from '../logging'; -import { deserializeStructure, obscureTemplate, serializeStructure } from '../serialize'; import { CliIoHost } from '../toolkit/cli-io-host'; import { ToolkitError } from '../toolkit/error'; import { numberFromBool, partition } from '../util'; -import { formatErrorMessage } from '../util/error'; -import { validateSnsTopicArn } from '../util/validate-notification-arn'; -import { Concurrency, WorkGraph } from '../util/work-graph'; -import { WorkGraphBuilder } from '../util/work-graph-builder'; -import { AssetBuildNode, AssetPublishNode, StackNode } from '../util/work-graph-types'; +import { validateSnsTopicArn } from '../util/cloudformation'; +import { formatErrorMessage } from '../util/format-error'; +import { deserializeStructure, obscureTemplate, serializeStructure } from '../util/serialize'; +import { formatTime } from '../util/string-manipulation'; // Must use a require() otherwise esbuild complains about calling a namespace // eslint-disable-next-line @typescript-eslint/no-require-imports diff --git a/packages/aws-cdk/lib/cli/cli-config.ts b/packages/aws-cdk/lib/cli/cli-config.ts index 2bed63e1b..200305095 100644 --- a/packages/aws-cdk/lib/cli/cli-config.ts +++ b/packages/aws-cdk/lib/cli/cli-config.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line import/no-extraneous-dependencies import { CliHelpers, type CliConfig } from '@aws-cdk/user-input-gen'; import * as cdk_from_cfn from 'cdk-from-cfn'; -import { StackActivityProgress } from '../api/util/cloudformation/stack-activity-monitor'; +import { StackActivityProgress } from '../api/stack-events'; import { RequireApproval } from '../diff'; import { availableInitLanguages } from '../init'; diff --git a/packages/aws-cdk/lib/util/tables.ts b/packages/aws-cdk/lib/cli/tables.ts similarity index 100% rename from packages/aws-cdk/lib/util/tables.ts rename to packages/aws-cdk/lib/cli/tables.ts diff --git a/packages/aws-cdk/lib/commands/context.ts b/packages/aws-cdk/lib/commands/context.ts index f2a6f1a19..9b7f7f4fd 100644 --- a/packages/aws-cdk/lib/commands/context.ts +++ b/packages/aws-cdk/lib/commands/context.ts @@ -1,11 +1,11 @@ import * as chalk from 'chalk'; import { minimatch } from 'minimatch'; import { Context } from '../api/context'; +import { renderTable } from '../cli/tables'; import { PROJECT_CONFIG, PROJECT_CONTEXT, USER_DEFAULTS } from '../cli/user-configuration'; import * as version from '../cli/version'; import { error, warning, info, result } from '../logging'; import { ToolkitError } from '../toolkit/error'; -import { renderTable } from '../util'; /** * Options for the context command diff --git a/packages/aws-cdk/lib/context-providers/index.ts b/packages/aws-cdk/lib/context-providers/index.ts index f385aa505..ed5ae723a 100644 --- a/packages/aws-cdk/lib/context-providers/index.ts +++ b/packages/aws-cdk/lib/context-providers/index.ts @@ -16,7 +16,7 @@ import { ContextProviderPlugin } from '../api/plugin/context-provider-plugin'; import { replaceEnvPlaceholders } from '../api/util/placeholders'; import { debug } from '../logging'; import { ContextProviderError } from '../toolkit/error'; -import { formatErrorMessage } from '../util/error'; +import { formatErrorMessage } from '../util/format-error'; export type ContextProviderFactory = ((sdk: SdkProvider) => ContextProviderPlugin); export type ProviderMap = {[name: string]: ContextProviderFactory}; diff --git a/packages/aws-cdk/lib/init-hooks.ts b/packages/aws-cdk/lib/init-hooks.ts index 14e2c4c09..ec2306150 100644 --- a/packages/aws-cdk/lib/init-hooks.ts +++ b/packages/aws-cdk/lib/init-hooks.ts @@ -1,7 +1,7 @@ import * as path from 'path'; import { shell } from './os'; import { ToolkitError } from './toolkit/error'; -import { formatErrorMessage } from './util/error'; +import { formatErrorMessage } from './util/format-error'; export type SubstitutePlaceholders = (...fileNames: string[]) => Promise; diff --git a/packages/aws-cdk/lib/init.ts b/packages/aws-cdk/lib/init.ts index 7e3d496e2..ab3e3a5df 100644 --- a/packages/aws-cdk/lib/init.ts +++ b/packages/aws-cdk/lib/init.ts @@ -7,7 +7,7 @@ import { invokeBuiltinHooks } from './init-hooks'; import { error, info, warning } from './logging'; import { ToolkitError } from './toolkit/error'; import { cdkHomeDir, rootDir } from './util/directories'; -import { formatErrorMessage } from './util/error'; +import { formatErrorMessage } from './util/format-error'; import { rangeFromSemver } from './util/version-range'; /* eslint-disable @typescript-eslint/no-var-requires */ // Packages don't have @types module diff --git a/packages/aws-cdk/lib/legacy-exports-source.ts b/packages/aws-cdk/lib/legacy-exports-source.ts index c7c3bf043..4182ebbef 100644 --- a/packages/aws-cdk/lib/legacy-exports-source.ts +++ b/packages/aws-cdk/lib/legacy-exports-source.ts @@ -17,7 +17,7 @@ export { Bootstrapper } from './api/bootstrap'; export { CloudExecutable } from './api/cxapp/cloud-executable'; export { execProgram } from './api/cxapp/exec'; export { RequireApproval } from './diff'; -export { leftPad } from './api/util/string-manipulation'; +export { leftPad } from './util/string-manipulation'; export { formatAsBanner } from './cli/util/console-formatters'; export { setSdkTracing as enableTracing } from './api/aws-auth/tracing'; export { aliases, command, describe } from './commands/docs'; diff --git a/packages/aws-cdk/lib/notices.ts b/packages/aws-cdk/lib/notices.ts index 3939ae5c6..ebeec4d06 100644 --- a/packages/aws-cdk/lib/notices.ts +++ b/packages/aws-cdk/lib/notices.ts @@ -14,7 +14,7 @@ import { ToolkitError } from './toolkit/error'; import { loadTreeFromDir, some } from './tree'; import { flatMap } from './util'; import { cdkCacheDir } from './util/directories'; -import { formatErrorMessage } from './util/error'; +import { formatErrorMessage } from './util/format-error'; const CACHE_FILE_PATH = path.join(cdkCacheDir(), 'notices.json'); diff --git a/packages/aws-cdk/lib/util/archive.ts b/packages/aws-cdk/lib/util/archive.ts index c5f1b74b0..8e502d198 100644 --- a/packages/aws-cdk/lib/util/archive.ts +++ b/packages/aws-cdk/lib/util/archive.ts @@ -2,7 +2,7 @@ import { error } from 'console'; import { createWriteStream, promises as fs } from 'fs'; import * as path from 'path'; import * as glob from 'glob'; -import { formatErrorMessage } from './error'; +import { formatErrorMessage } from './format-error'; // eslint-disable-next-line @typescript-eslint/no-require-imports const archiver = require('archiver'); diff --git a/packages/aws-cdk/lib/util/validate-notification-arn.ts b/packages/aws-cdk/lib/util/cloudformation.ts similarity index 100% rename from packages/aws-cdk/lib/util/validate-notification-arn.ts rename to packages/aws-cdk/lib/util/cloudformation.ts diff --git a/packages/aws-cdk/lib/util/error.ts b/packages/aws-cdk/lib/util/format-error.ts similarity index 100% rename from packages/aws-cdk/lib/util/error.ts rename to packages/aws-cdk/lib/util/format-error.ts diff --git a/packages/aws-cdk/lib/util/index.ts b/packages/aws-cdk/lib/util/index.ts index 5597b4b21..32db74c09 100644 --- a/packages/aws-cdk/lib/util/index.ts +++ b/packages/aws-cdk/lib/util/index.ts @@ -1,5 +1,15 @@ +export * from './archive'; export * from './arrays'; export * from './bool'; +export * from './bytes'; +export * from './cloudformation'; +export * from './content-hash'; +export * from './format-error'; export * from './objects'; +export * from './parallel'; +export * from './serialize'; +export * from './string-manipulation'; +export * from './type-brands'; export * from './types'; -export * from './tables'; +export * from './version-range'; +export * from './yaml-cfn'; diff --git a/packages/aws-cdk/lib/serialize.ts b/packages/aws-cdk/lib/util/serialize.ts similarity index 96% rename from packages/aws-cdk/lib/serialize.ts rename to packages/aws-cdk/lib/util/serialize.ts index 7a6e83626..c46b24001 100644 --- a/packages/aws-cdk/lib/serialize.ts +++ b/packages/aws-cdk/lib/util/serialize.ts @@ -1,6 +1,6 @@ import * as fs from 'fs-extra'; -import { formatBytes } from './util/bytes'; -import * as yaml_cfn from './util/yaml-cfn'; +import { formatBytes } from './bytes'; +import * as yaml_cfn from './yaml-cfn'; /** * Stringify to YAML diff --git a/packages/aws-cdk/lib/api/util/string-manipulation.ts b/packages/aws-cdk/lib/util/string-manipulation.ts similarity index 100% rename from packages/aws-cdk/lib/api/util/string-manipulation.ts rename to packages/aws-cdk/lib/util/string-manipulation.ts diff --git a/packages/aws-cdk/test/api/console-listener.ts b/packages/aws-cdk/test/api/_helpers/console-listener.ts similarity index 100% rename from packages/aws-cdk/test/api/console-listener.ts rename to packages/aws-cdk/test/api/_helpers/console-listener.ts diff --git a/packages/aws-cdk/test/api/fake-cloudformation-stack.ts b/packages/aws-cdk/test/api/_helpers/fake-cloudformation-stack.ts similarity index 82% rename from packages/aws-cdk/test/api/fake-cloudformation-stack.ts rename to packages/aws-cdk/test/api/_helpers/fake-cloudformation-stack.ts index cb41f5004..63c53db3b 100644 --- a/packages/aws-cdk/test/api/fake-cloudformation-stack.ts +++ b/packages/aws-cdk/test/api/_helpers/fake-cloudformation-stack.ts @@ -1,7 +1,7 @@ -import { ICloudFormationClient } from '../../lib/api'; -import { CloudFormationStack, Template } from '../../lib/api/deployments'; -import { StackStatus } from '../../lib/api/util/cloudformation/stack-status'; -import { MockSdk } from '../util/mock-sdk'; +import { ICloudFormationClient } from '../../../lib/api'; +import { CloudFormationStack, Template } from '../../../lib/api/deployments'; +import { StackStatus } from '../../../lib/api/stack-events'; +import { MockSdk } from '../../util/mock-sdk'; export interface FakeCloudFormationStackProps { readonly stackName: string; diff --git a/packages/aws-cdk/test/api/hotswap/hotswap-test-setup.ts b/packages/aws-cdk/test/api/_helpers/hotswap-test-setup.ts similarity index 98% rename from packages/aws-cdk/test/api/hotswap/hotswap-test-setup.ts rename to packages/aws-cdk/test/api/_helpers/hotswap-test-setup.ts index 6272b9f05..5ea31c57d 100644 --- a/packages/aws-cdk/test/api/hotswap/hotswap-test-setup.ts +++ b/packages/aws-cdk/test/api/_helpers/hotswap-test-setup.ts @@ -14,7 +14,7 @@ import { restoreSdkMocksToDefault, setDefaultSTSMocks, } from '../../util/mock-sdk'; -import { FakeCloudformationStack } from '../fake-cloudformation-stack'; +import { FakeCloudformationStack } from './fake-cloudformation-stack'; const STACK_NAME = 'withouterrors'; export const STACK_ID = 'stackId'; diff --git a/packages/aws-cdk/test/api/aws-auth/fake-sts.ts b/packages/aws-cdk/test/api/aws-auth/fake-sts.ts index 3b82986c9..d93a7ff77 100644 --- a/packages/aws-cdk/test/api/aws-auth/fake-sts.ts +++ b/packages/aws-cdk/test/api/aws-auth/fake-sts.ts @@ -2,7 +2,7 @@ import { Tag } from '@aws-sdk/client-sts'; import * as nock from 'nock'; import * as uuid from 'uuid'; import * as xmlJs from 'xml-js'; -import { formatErrorMessage } from '../../../lib/util/error'; +import { formatErrorMessage } from '../../../lib/util/format-error'; interface RegisteredIdentity { readonly account: string; diff --git a/packages/aws-cdk/test/api/bootstrap/bootstrap.test.ts b/packages/aws-cdk/test/api/bootstrap/bootstrap.test.ts index 8975b75fb..6c0777dae 100644 --- a/packages/aws-cdk/test/api/bootstrap/bootstrap.test.ts +++ b/packages/aws-cdk/test/api/bootstrap/bootstrap.test.ts @@ -12,7 +12,7 @@ import { import { parse } from 'yaml'; import { Bootstrapper } from '../../../lib/api/bootstrap'; import { legacyBootstrapTemplate } from '../../../lib/api/bootstrap/legacy-template'; -import { deserializeStructure, serializeStructure, toYAML } from '../../../lib/serialize'; +import { deserializeStructure, serializeStructure, toYAML } from '../../../lib/util/serialize'; import { CliIoHost } from '../../../lib/toolkit/cli-io-host'; import { MockSdkProvider, mockCloudFormationClient, restoreSdkMocksToDefault } from '../../util/mock-sdk'; diff --git a/packages/aws-cdk/test/api/assembly-versions.ts b/packages/aws-cdk/test/api/cxapp/assembly-versions.ts similarity index 95% rename from packages/aws-cdk/test/api/assembly-versions.ts rename to packages/aws-cdk/test/api/cxapp/assembly-versions.ts index ae2ffe955..bea78a77f 100644 --- a/packages/aws-cdk/test/api/assembly-versions.ts +++ b/packages/aws-cdk/test/api/cxapp/assembly-versions.ts @@ -1,6 +1,6 @@ import * as fs from 'fs'; import * as cxapi from '@aws-cdk/cx-api'; -import { CloudAssembly } from '../../lib/api/cxapp/cloud-assembly'; +import { CloudAssembly } from '../../../lib/api/cxapp/cloud-assembly'; /** * The cloud-assembly-schema in the new monorepo will use its own package version as the schema version, which is always `0.0.0` when tests are running. diff --git a/packages/aws-cdk/test/api/cloud-assembly.test.ts b/packages/aws-cdk/test/api/cxapp/cloud-assembly.test.ts similarity index 98% rename from packages/aws-cdk/test/api/cloud-assembly.test.ts rename to packages/aws-cdk/test/api/cxapp/cloud-assembly.test.ts index 3000646a1..03daf6b9d 100644 --- a/packages/aws-cdk/test/api/cloud-assembly.test.ts +++ b/packages/aws-cdk/test/api/cxapp/cloud-assembly.test.ts @@ -1,7 +1,7 @@ /* eslint-disable import/order */ import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { DefaultSelection } from '../../lib/api/cxapp/cloud-assembly'; -import { MockCloudExecutable } from '../util'; +import { DefaultSelection } from '../../../lib/api/cxapp/cloud-assembly'; +import { MockCloudExecutable } from '../../util'; import { cliAssemblyWithForcedVersion } from './assembly-versions'; test('select all top level stacks in the presence of nested assemblies', async () => { diff --git a/packages/aws-cdk/test/api/cloud-executable.test.ts b/packages/aws-cdk/test/api/cxapp/cloud-executable.test.ts similarity index 93% rename from packages/aws-cdk/test/api/cloud-executable.test.ts rename to packages/aws-cdk/test/api/cxapp/cloud-executable.test.ts index 796ea7181..33f6881f4 100644 --- a/packages/aws-cdk/test/api/cloud-executable.test.ts +++ b/packages/aws-cdk/test/api/cxapp/cloud-executable.test.ts @@ -1,8 +1,8 @@ /* eslint-disable import/order */ import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { DefaultSelection } from '../../lib/api/cxapp/cloud-assembly'; -import { registerContextProvider } from '../../lib/context-providers'; -import { MockCloudExecutable } from '../util'; +import { DefaultSelection } from '../../../lib/api/cxapp/cloud-assembly'; +import { registerContextProvider } from '../../../lib/context-providers'; +import { MockCloudExecutable } from '../../util'; describe('AWS::CDK::Metadata', () => { test('is not generated for new frameworks', async () => { diff --git a/packages/aws-cdk/test/api/exec.test.ts b/packages/aws-cdk/test/api/cxapp/exec.test.ts similarity index 95% rename from packages/aws-cdk/test/api/exec.test.ts rename to packages/aws-cdk/test/api/cxapp/exec.test.ts index 7c5241fd7..5eb6471e8 100644 --- a/packages/aws-cdk/test/api/exec.test.ts +++ b/packages/aws-cdk/test/api/cxapp/exec.test.ts @@ -6,14 +6,14 @@ import * as cdk from 'aws-cdk-lib'; import * as semver from 'semver'; import * as sinon from 'sinon'; import { ImportMock } from 'ts-mock-imports'; -import { execProgram } from '../../lib/api/cxapp/exec'; -import { Configuration } from '../../lib/cli/user-configuration'; -import { testAssembly } from '../util'; -import { mockSpawn } from '../util/mock-child_process'; -import { MockSdkProvider } from '../util/mock-sdk'; -import { RWLock } from '../../lib/api/util/rwlock'; +import { execProgram } from '../../../lib/api/cxapp/exec'; +import { Configuration } from '../../../lib/cli/user-configuration'; +import { testAssembly } from '../../util'; +import { mockSpawn } from '../../util/mock-child_process'; +import { MockSdkProvider } from '../../util/mock-sdk'; +import { RWLock } from '../../../lib/api/util/rwlock'; import { rewriteManifestVersion } from './assembly-versions'; -import { CliIoHost } from '../../lib/toolkit/cli-io-host'; +import { CliIoHost } from '../../../lib/toolkit/cli-io-host'; let sdkProvider: MockSdkProvider; let config: Configuration; diff --git a/packages/aws-cdk/test/api/deployments/cloudformation-deployments.test.ts b/packages/aws-cdk/test/api/deployments/cloudformation-deployments.test.ts index 0cfaf945a..4043a7163 100644 --- a/packages/aws-cdk/test/api/deployments/cloudformation-deployments.test.ts +++ b/packages/aws-cdk/test/api/deployments/cloudformation-deployments.test.ts @@ -27,7 +27,7 @@ import { restoreSdkMocksToDefault, setDefaultSTSMocks, } from '../../util/mock-sdk'; -import { FakeCloudformationStack } from '../fake-cloudformation-stack'; +import { FakeCloudformationStack } from '../_helpers/fake-cloudformation-stack'; jest.mock('../../../lib/api/deployments/deploy-stack'); jest.mock('../../../lib/api/deployments/asset-publishing'); diff --git a/packages/aws-cdk/test/util/cloudformation.test.ts b/packages/aws-cdk/test/api/deployments/cloudformation.test.ts similarity index 96% rename from packages/aws-cdk/test/util/cloudformation.test.ts rename to packages/aws-cdk/test/api/deployments/cloudformation.test.ts index 841bba1df..47d0b4070 100644 --- a/packages/aws-cdk/test/util/cloudformation.test.ts +++ b/packages/aws-cdk/test/api/deployments/cloudformation.test.ts @@ -1,8 +1,8 @@ import { SSMPARAM_NO_INVALIDATE } from '@aws-cdk/cx-api'; import { DescribeStacksCommand, GetTemplateCommand, StackStatus } from '@aws-sdk/client-cloudformation'; -import { MockSdk, mockCloudFormationClient } from './mock-sdk'; -import type { ICloudFormationClient } from '../../lib/api/aws-auth'; -import { CloudFormationStack, TemplateParameters } from '../../lib/api/deployments'; +import { MockSdk, mockCloudFormationClient } from '../../util/mock-sdk'; +import type { ICloudFormationClient } from '../../../lib/api/aws-auth'; +import { CloudFormationStack, TemplateParameters } from '../../../lib/api/deployments'; const PARAM = 'TheParameter'; const DEFAULT = 'TheDefault'; diff --git a/packages/aws-cdk/test/api/deployments/hotswap-deployments.test.ts b/packages/aws-cdk/test/api/deployments/hotswap-deployments.test.ts index 4ec540e8a..b43c8ca90 100644 --- a/packages/aws-cdk/test/api/deployments/hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/deployments/hotswap-deployments.test.ts @@ -5,7 +5,7 @@ import { CfnEvaluationException } from '../../../lib/api/evaluate-cloudformation import { HotswapMode } from '../../../lib/api/hotswap/common'; import { MockSdk, mockCloudFormationClient, mockLambdaClient, mockStepFunctionsClient } from '../../util/mock-sdk'; import { silentTest } from '../../util/silent'; -import * as setup from '../hotswap/hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; jest.mock('@aws-sdk/client-lambda', () => { const original = jest.requireActual('@aws-sdk/client-lambda'); diff --git a/packages/aws-cdk/test/api/garbage-collection.test.ts b/packages/aws-cdk/test/api/garbage-collection/garbage-collection.test.ts similarity index 98% rename from packages/aws-cdk/test/api/garbage-collection.test.ts rename to packages/aws-cdk/test/api/garbage-collection/garbage-collection.test.ts index d43e95828..1315721b4 100644 --- a/packages/aws-cdk/test/api/garbage-collection.test.ts +++ b/packages/aws-cdk/test/api/garbage-collection/garbage-collection.test.ts @@ -6,8 +6,8 @@ import { ListStacksCommand, Stack, } from '@aws-sdk/client-cloudformation'; -import { ECR_ISOLATED_TAG, GarbageCollector, S3_ISOLATED_TAG, ToolkitInfo } from '../../lib/api'; -import { mockBootstrapStack, mockCloudFormationClient, mockECRClient, mockS3Client, MockSdk, MockSdkProvider } from '../util/mock-sdk'; +import { ECR_ISOLATED_TAG, GarbageCollector, S3_ISOLATED_TAG, ToolkitInfo } from '../../../lib/api'; +import { mockBootstrapStack, mockCloudFormationClient, mockECRClient, mockS3Client, MockSdk, MockSdkProvider } from '../../util/mock-sdk'; import { DeleteObjectsCommand, DeleteObjectTaggingCommand, @@ -19,8 +19,8 @@ import { ActiveAssetCache, BackgroundStackRefresh, BackgroundStackRefreshProps, -} from '../../lib/api/garbage-collection/stack-refresh'; -import { ProgressPrinter } from '../../lib/api/garbage-collection/progress-printer'; +} from '../../../lib/api/garbage-collection/stack-refresh'; +import { ProgressPrinter } from '../../../lib/api/garbage-collection/progress-printer'; import { BatchDeleteImageCommand, BatchGetImageCommand, @@ -28,7 +28,7 @@ import { ListImagesCommand, PutImageCommand, } from '@aws-sdk/client-ecr'; -import { CliIoHost } from '../../lib/toolkit/cli-io-host'; +import { CliIoHost } from '../../../lib/toolkit/cli-io-host'; let garbageCollector: GarbageCollector; diff --git a/packages/aws-cdk/test/api/hotswap/appsync-mapping-templates-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/appsync-mapping-templates-hotswap-deployments.test.ts index f4c89d634..ddae8d7fd 100644 --- a/packages/aws-cdk/test/api/hotswap/appsync-mapping-templates-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/appsync-mapping-templates-hotswap-deployments.test.ts @@ -9,7 +9,7 @@ import { } from '@aws-sdk/client-appsync'; import { GetObjectCommand } from '@aws-sdk/client-s3'; import { sdkStreamMixin } from '@smithy/util-stream'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { mockAppSyncClient, mockS3Client } from '../../util/mock-sdk'; import { silentTest } from '../../util/silent'; diff --git a/packages/aws-cdk/test/api/hotswap/code-build-projects-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/code-build-projects-hotswap-deployments.test.ts index 42bf66af2..371d1b76f 100644 --- a/packages/aws-cdk/test/api/hotswap/code-build-projects-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/code-build-projects-hotswap-deployments.test.ts @@ -1,5 +1,5 @@ import { UpdateProjectCommand } from '@aws-sdk/client-codebuild'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { mockCodeBuildClient } from '../../util/mock-sdk'; import { silentTest } from '../../util/silent'; diff --git a/packages/aws-cdk/test/api/hotswap/ecs-services-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/ecs-services-hotswap-deployments.test.ts index f80efa385..8ee2a4aac 100644 --- a/packages/aws-cdk/test/api/hotswap/ecs-services-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/ecs-services-hotswap-deployments.test.ts @@ -1,5 +1,5 @@ import { DescribeServicesCommand, RegisterTaskDefinitionCommand, UpdateServiceCommand } from '@aws-sdk/client-ecs'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { EcsHotswapProperties, HotswapMode, HotswapPropertyOverrides } from '../../../lib/api/hotswap/common'; import { Configuration } from '../../../lib/cli/user-configuration'; import { mockECSClient } from '../../util/mock-sdk'; diff --git a/packages/aws-cdk/test/api/hotswap/iam-policy-hotswap-deployment.test.ts b/packages/aws-cdk/test/api/hotswap/iam-policy-hotswap-deployment.test.ts index ee454ec40..4371c4ad0 100644 --- a/packages/aws-cdk/test/api/hotswap/iam-policy-hotswap-deployment.test.ts +++ b/packages/aws-cdk/test/api/hotswap/iam-policy-hotswap-deployment.test.ts @@ -1,5 +1,5 @@ import { StackStatus } from '@aws-sdk/client-cloudformation'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { silentTest } from '../../util/silent'; diff --git a/packages/aws-cdk/test/api/hotswap/lambda-functions-docker-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/lambda-functions-docker-hotswap-deployments.test.ts index 855c33f0a..df4e5c23f 100644 --- a/packages/aws-cdk/test/api/hotswap/lambda-functions-docker-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/lambda-functions-docker-hotswap-deployments.test.ts @@ -9,7 +9,7 @@ jest.mock('@aws-sdk/client-lambda', () => { }); import { UpdateFunctionCodeCommand, waitUntilFunctionUpdatedV2 } from '@aws-sdk/client-lambda'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { mockLambdaClient } from '../../util/mock-sdk'; import { silentTest } from '../../util/silent'; diff --git a/packages/aws-cdk/test/api/hotswap/lambda-functions-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/lambda-functions-hotswap-deployments.test.ts index cf354a1aa..74906bf9c 100644 --- a/packages/aws-cdk/test/api/hotswap/lambda-functions-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/lambda-functions-hotswap-deployments.test.ts @@ -3,7 +3,7 @@ import { UpdateFunctionConfigurationCommand, waitUntilFunctionUpdatedV2, } from '@aws-sdk/client-lambda'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { mockLambdaClient } from '../../util/mock-sdk'; import { silentTest } from '../../util/silent'; diff --git a/packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts index 7c9cfdbe3..7adc4c007 100644 --- a/packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts @@ -1,6 +1,6 @@ import { UpdateFunctionCodeCommand } from '@aws-sdk/client-lambda'; import { Runtime } from 'aws-cdk-lib/aws-lambda'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { mockLambdaClient } from '../../util/mock-sdk'; import { silentTest } from '../../util/silent'; diff --git a/packages/aws-cdk/test/api/hotswap/lambda-versions-aliases-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/lambda-versions-aliases-hotswap-deployments.test.ts index 4356124de..5524339c7 100644 --- a/packages/aws-cdk/test/api/hotswap/lambda-versions-aliases-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/lambda-versions-aliases-hotswap-deployments.test.ts @@ -1,5 +1,5 @@ import { PublishVersionCommand, UpdateAliasCommand } from '@aws-sdk/client-lambda'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { mockLambdaClient } from '../../util/mock-sdk'; import { silentTest } from '../../util/silent'; diff --git a/packages/aws-cdk/test/api/hotswap/nested-stacks-hotswap.test.ts b/packages/aws-cdk/test/api/hotswap/nested-stacks-hotswap.test.ts index 37c142996..2235832a5 100644 --- a/packages/aws-cdk/test/api/hotswap/nested-stacks-hotswap.test.ts +++ b/packages/aws-cdk/test/api/hotswap/nested-stacks-hotswap.test.ts @@ -1,5 +1,5 @@ import { PublishVersionCommand, UpdateFunctionCodeCommand } from '@aws-sdk/client-lambda'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { testStack } from '../../util'; import { mockLambdaClient } from '../../util/mock-sdk'; diff --git a/packages/aws-cdk/test/api/hotswap/s3-bucket-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/s3-bucket-hotswap-deployments.test.ts index e27c92062..f6db9495f 100644 --- a/packages/aws-cdk/test/api/hotswap/s3-bucket-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/s3-bucket-hotswap-deployments.test.ts @@ -1,5 +1,5 @@ import { InvokeCommand } from '@aws-sdk/client-lambda'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { REQUIRED_BY_CFN } from '../../../lib/api/hotswap/s3-bucket-deployments'; import { mockLambdaClient } from '../../util/mock-sdk'; diff --git a/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts index bff830e00..60427a458 100644 --- a/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts @@ -1,5 +1,5 @@ import { UpdateStateMachineCommand } from '@aws-sdk/client-sfn'; -import * as setup from './hotswap-test-setup'; +import * as setup from '../_helpers/hotswap-test-setup'; import { HotswapMode } from '../../../lib/api/hotswap/common'; import { mockStepFunctionsClient } from '../../util/mock-sdk'; import { silentTest } from '../../util/silent'; diff --git a/packages/aws-cdk/test/api/util/display.test.ts b/packages/aws-cdk/test/api/stack-events/display.test.ts similarity index 93% rename from packages/aws-cdk/test/api/util/display.test.ts rename to packages/aws-cdk/test/api/stack-events/display.test.ts index 2473bb891..9bd375e48 100644 --- a/packages/aws-cdk/test/api/util/display.test.ts +++ b/packages/aws-cdk/test/api/stack-events/display.test.ts @@ -1,6 +1,6 @@ /* eslint-disable import/order */ -import { RewritableBlock } from '../../../lib/api/util/display'; -import { stderr } from '../console-listener'; +import { RewritableBlock } from '../../../lib/api/stack-events/display'; +import { stderr } from '../_helpers/console-listener'; describe('Rewritable Block Tests', () => { let block: RewritableBlock; diff --git a/packages/aws-cdk/test/api/stack-activity-monitor.test.ts b/packages/aws-cdk/test/api/stack-events/stack-activity-monitor.test.ts similarity index 98% rename from packages/aws-cdk/test/api/stack-activity-monitor.test.ts rename to packages/aws-cdk/test/api/stack-events/stack-activity-monitor.test.ts index 9bed97683..b760dda02 100644 --- a/packages/aws-cdk/test/api/stack-activity-monitor.test.ts +++ b/packages/aws-cdk/test/api/stack-events/stack-activity-monitor.test.ts @@ -1,9 +1,9 @@ /* eslint-disable import/order */ import * as chalk from 'chalk'; -import { stderr } from './console-listener'; -import { HistoryActivityPrinter } from '../../lib/api/util/cloudformation/stack-activity-monitor'; +import { stderr } from '../_helpers/console-listener'; +import { HistoryActivityPrinter } from '../../../lib/api/stack-events'; import { ResourceStatus } from '@aws-sdk/client-cloudformation'; -import { CliIoHost } from '../../lib/toolkit/cli-io-host'; +import { CliIoHost } from '../../../lib/toolkit/cli-io-host'; let TIMESTAMP: number; let HUMAN_TIME: string; diff --git a/packages/aws-cdk/test/api/util/cloudformation/stack-event-poller.test.ts b/packages/aws-cdk/test/api/stack-events/stack-event-poller.test.ts similarity index 92% rename from packages/aws-cdk/test/api/util/cloudformation/stack-event-poller.test.ts rename to packages/aws-cdk/test/api/stack-events/stack-event-poller.test.ts index 6ff65e4eb..1c4abd3fd 100644 --- a/packages/aws-cdk/test/api/util/cloudformation/stack-event-poller.test.ts +++ b/packages/aws-cdk/test/api/stack-events/stack-event-poller.test.ts @@ -1,6 +1,6 @@ import { DescribeStackEventsCommand, DescribeStackEventsCommandInput, StackEvent } from '@aws-sdk/client-cloudformation'; -import { StackEventPoller } from '../../../../lib/api/util/cloudformation/stack-event-poller'; -import { MockSdk, mockCloudFormationClient } from '../../../util/mock-sdk'; +import { StackEventPoller } from '../../../lib/api/stack-events'; +import { MockSdk, mockCloudFormationClient } from '../../util/mock-sdk'; beforeEach(() => { jest.resetAllMocks(); diff --git a/packages/aws-cdk/test/util/stack-monitor.test.ts b/packages/aws-cdk/test/api/stack-events/stack-monitor.test.ts similarity index 98% rename from packages/aws-cdk/test/util/stack-monitor.test.ts rename to packages/aws-cdk/test/api/stack-events/stack-monitor.test.ts index ef01a30ad..50a8ab4df 100644 --- a/packages/aws-cdk/test/util/stack-monitor.test.ts +++ b/packages/aws-cdk/test/api/stack-events/stack-monitor.test.ts @@ -4,12 +4,12 @@ import { type StackEvent, StackStatus, } from '@aws-sdk/client-cloudformation'; -import { MockSdk, mockCloudFormationClient, restoreSdkMocksToDefault } from './mock-sdk'; +import { MockSdk, mockCloudFormationClient, restoreSdkMocksToDefault } from '../../util/mock-sdk'; import { StackActivityMonitor, type IActivityPrinter, type StackActivity, -} from '../../lib/api/util/cloudformation/stack-activity-monitor'; +} from '../../../lib/api/stack-events'; let sdk: MockSdk; let printer: FakePrinter; diff --git a/packages/aws-cdk/test/work-graph-builder.test.ts b/packages/aws-cdk/test/api/work-graph/work-graph-builder.test.ts similarity index 98% rename from packages/aws-cdk/test/work-graph-builder.test.ts rename to packages/aws-cdk/test/api/work-graph/work-graph-builder.test.ts index eb40873d3..6154515b1 100644 --- a/packages/aws-cdk/test/work-graph-builder.test.ts +++ b/packages/aws-cdk/test/api/work-graph/work-graph-builder.test.ts @@ -5,9 +5,8 @@ import * as cxapi from '@aws-cdk/cx-api'; import { CloudAssemblyBuilder } from '@aws-cdk/cx-api'; // eslint-disable-next-line import/no-extraneous-dependencies import { expect } from '@jest/globals'; -import { WorkGraph } from '../lib/util/work-graph'; -import { WorkGraphBuilder } from '../lib/util/work-graph-builder'; -import { AssetBuildNode, AssetPublishNode, StackNode, WorkNode } from '../lib/util/work-graph-types'; +import { WorkGraph, WorkGraphBuilder } from '../../../lib/api/work-graph'; +import type { AssetBuildNode, AssetPublishNode, StackNode, WorkNode } from '../../../lib/api/work-graph'; let rootBuilder: CloudAssemblyBuilder; beforeEach(() => { diff --git a/packages/aws-cdk/test/work-graph.test.ts b/packages/aws-cdk/test/api/work-graph/work-graph.test.ts similarity index 99% rename from packages/aws-cdk/test/work-graph.test.ts rename to packages/aws-cdk/test/api/work-graph/work-graph.test.ts index 0ac789729..301850b8d 100644 --- a/packages/aws-cdk/test/work-graph.test.ts +++ b/packages/aws-cdk/test/api/work-graph/work-graph.test.ts @@ -1,5 +1,5 @@ -import { WorkGraph } from '../lib/util/work-graph'; -import { AssetBuildNode, AssetPublishNode, DeploymentState, StackNode } from '../lib/util/work-graph-types'; +import { WorkGraph, DeploymentState } from '../../../lib/api/work-graph'; +import type { AssetBuildNode, AssetPublishNode, StackNode } from '../../../lib/api/work-graph'; const DUMMY: any = 'DUMMY'; diff --git a/packages/aws-cdk/test/util/yargs-helpers.test.ts b/packages/aws-cdk/test/cli/yargs-helpers.test.ts similarity index 100% rename from packages/aws-cdk/test/util/yargs-helpers.test.ts rename to packages/aws-cdk/test/cli/yargs-helpers.test.ts diff --git a/packages/aws-cdk/test/serialize.test.ts b/packages/aws-cdk/test/serialize.test.ts deleted file mode 100644 index e465f1c8f..000000000 --- a/packages/aws-cdk/test/serialize.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* eslint-disable import/order */ -import { toYAML, obscureTemplate } from '../lib/serialize'; - -describe(toYAML, () => { - test('does not wrap lines', () => { - const longString = 'Long string is long!'.repeat(1_024); - expect(toYAML({ longString })).toEqual(`longString: ${longString}\n`); - }); -}); - -describe(obscureTemplate, () => { - test('removes CheckBootstrapVersion rule only', () => { - const template = { - Rules: { - CheckBootstrapVersion: { Assertions: [{ AssertDescription: 'bootstrap' }] }, - MyOtherRule: { Assertions: [{ AssertDescription: 'other' }] }, - }, - }; - - const obscured = obscureTemplate(template); - expect(obscured).not.toHaveProperty('Rules.CheckBootstrapVersion'); - expect(obscured).toHaveProperty('Rules.MyOtherRule.Assertions.0.AssertDescription', 'other'); - }); - - test('removes all rules when CheckBootstrapVersion is the only rule', () => { - const template = { - Rules: { - CheckBootstrapVersion: { Assertions: [{ AssertDescription: 'bootstrap' }] }, - }, - }; - - const obscured = obscureTemplate(template); - expect(obscured).not.toHaveProperty('Rules.CheckBootstrapVersion'); - expect(obscured).not.toHaveProperty('Rules'); - }); -}); diff --git a/packages/aws-cdk/test/util.ts b/packages/aws-cdk/test/util.ts index b9552bf77..3b23cdaa4 100644 --- a/packages/aws-cdk/test/util.ts +++ b/packages/aws-cdk/test/util.ts @@ -2,7 +2,7 @@ import * as fs from 'fs'; import * as path from 'path'; import { ArtifactMetadataEntryType, ArtifactType, type AssetManifest, type AssetMetadataEntry, type AwsCloudFormationStackProperties, type MetadataEntry, type MissingContext } from '@aws-cdk/cloud-assembly-schema'; import { type CloudAssembly, CloudAssemblyBuilder, type CloudFormationStackArtifact, type StackMetadata } from '@aws-cdk/cx-api'; -import { cxapiAssemblyWithForcedVersion } from './api/assembly-versions'; +import { cxapiAssemblyWithForcedVersion } from './api/cxapp/assembly-versions'; import { MockSdkProvider } from './util/mock-sdk'; import { CloudExecutable } from '../lib/api/cxapp/cloud-executable'; import { Configuration } from '../lib/cli/user-configuration'; diff --git a/packages/aws-cdk/test/api/util/error.test.ts b/packages/aws-cdk/test/util/error.test.ts similarity index 92% rename from packages/aws-cdk/test/api/util/error.test.ts rename to packages/aws-cdk/test/util/error.test.ts index 2454e74c6..3735357fc 100644 --- a/packages/aws-cdk/test/api/util/error.test.ts +++ b/packages/aws-cdk/test/util/error.test.ts @@ -1,4 +1,4 @@ -import { formatErrorMessage } from '../../../lib/util/error'; +import { formatErrorMessage } from '../../lib/util/format-error'; describe('formatErrorMessage', () => { test('should return the formatted message for a regular Error object', () => { diff --git a/packages/aws-cdk/test/util/serialize.test.ts b/packages/aws-cdk/test/util/serialize.test.ts index 65eab98b0..a5b605c21 100644 --- a/packages/aws-cdk/test/util/serialize.test.ts +++ b/packages/aws-cdk/test/util/serialize.test.ts @@ -1,7 +1,41 @@ -import { replacerBufferWithInfo } from '../../lib/serialize'; +import { toYAML, obscureTemplate, replacerBufferWithInfo } from '../../lib/util/serialize'; +describe(toYAML, () => { + test('does not wrap lines', () => { + const longString = 'Long string is long!'.repeat(1_024); + expect(toYAML({ longString })).toEqual(`longString: ${longString}\n`); + }); +}); + +describe(obscureTemplate, () => { + test('removes CheckBootstrapVersion rule only', () => { + const template = { + Rules: { + CheckBootstrapVersion: { Assertions: [{ AssertDescription: 'bootstrap' }] }, + MyOtherRule: { Assertions: [{ AssertDescription: 'other' }] }, + }, + }; + + const obscured = obscureTemplate(template); + expect(obscured).not.toHaveProperty('Rules.CheckBootstrapVersion'); + expect(obscured).toHaveProperty('Rules.MyOtherRule.Assertions.0.AssertDescription', 'other'); + }); + + test('removes all rules when CheckBootstrapVersion is the only rule', () => { + const template = { + Rules: { + CheckBootstrapVersion: { Assertions: [{ AssertDescription: 'bootstrap' }] }, + }, + }; + + const obscured = obscureTemplate(template); + expect(obscured).not.toHaveProperty('Rules.CheckBootstrapVersion'); + expect(obscured).not.toHaveProperty('Rules'); + }); +}); test('converts buffer to information', () => { const res = JSON.stringify({ data: Buffer.from('test data') }, replacerBufferWithInfo); expect(res).toEqual('{"data":""}'); }); + diff --git a/packages/aws-cdk/test/util/validate-notification-arn.test.ts b/packages/aws-cdk/test/util/validate-notification-arn.test.ts index d418546ed..d8bd5b3f7 100644 --- a/packages/aws-cdk/test/util/validate-notification-arn.test.ts +++ b/packages/aws-cdk/test/util/validate-notification-arn.test.ts @@ -1,5 +1,5 @@ /* eslint-disable import/order */ -import { validateSnsTopicArn } from '../../lib/util/validate-notification-arn'; +import { validateSnsTopicArn } from '../../lib/util/cloudformation'; describe('validate sns arns', () => { test('empty string', () => { diff --git a/packages/aws-cdk/test/yaml.test.ts b/packages/aws-cdk/test/util/yaml.test.ts similarity index 96% rename from packages/aws-cdk/test/yaml.test.ts rename to packages/aws-cdk/test/util/yaml.test.ts index f7cfc8fd7..33a7b66c7 100644 --- a/packages/aws-cdk/test/yaml.test.ts +++ b/packages/aws-cdk/test/util/yaml.test.ts @@ -1,5 +1,5 @@ /* eslint-disable import/order */ -import { deserializeStructure, toYAML } from '../lib/serialize'; +import { deserializeStructure, toYAML } from '../../lib/util/serialize'; // Preferred quote of the YAML library const q = '"';