Skip to content

Commit 7329068

Browse files
authored
chore(toolkit): enforce all imports from aws-cdk are via one file (#33145)
### Reason for this change We bundle `aws-cdk` into that file and if we don't load everything through it, imports will fail. ### Description of changes Fix the wrong import and add a linter rule to enforce it. ### Describe any new or updated permissions being added n/a ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent a7cd9eb commit 7329068

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/@aws-cdk/toolkit/.eslintrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,13 @@ baseConfig.overrides.push({
1010
},
1111
});
1212

13+
// all aws-cdk files must be loaded through lib/api/aws-cdk.ts
14+
baseConfig.rules['import/no-restricted-paths'] = ['error', {
15+
zones: [{
16+
target: './',
17+
from: '../../aws-cdk',
18+
message: "All `aws-cdk` code must be used via lib/api/aws-cdk.ts",
19+
}]
20+
}];
21+
1322
module.exports = baseConfig;

packages/@aws-cdk/toolkit/lib/api/aws-cdk.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/no-restricted-paths */
2+
export { formatErrorMessage } from '../../../../aws-cdk/lib/util/error';
13
export { DEFAULT_TOOLKIT_STACK_NAME, SdkProvider } from '../../../../aws-cdk/lib/api';
24
export type { SuccessfulDeployStackResult } from '../../../../aws-cdk/lib/api';
35
export { formatSdkLoggerContent } from '../../../../aws-cdk/lib/api/aws-auth/sdk-logger';

packages/@aws-cdk/toolkit/lib/toolkit/toolkit.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as chalk from 'chalk';
44
import * as chokidar from 'chokidar';
55
import * as fs from 'fs-extra';
66
import { ToolkitServices } from './private';
7-
import { formatErrorMessage } from '../../../../aws-cdk/lib/util/error';
87
import { AssetBuildTime, DeployOptions, RequireApproval } from '../actions/deploy';
98
import { buildParameterMap, removePublishedAssets } from '../actions/deploy/private';
109
import { DestroyOptions } from '../actions/destroy';
@@ -15,7 +14,7 @@ import { RollbackOptions } from '../actions/rollback';
1514
import { SynthOptions } from '../actions/synth';
1615
import { patternsArrayForWatch, WatchOptions } from '../actions/watch';
1716
import { SdkOptions } from '../api/aws-auth';
18-
import { DEFAULT_TOOLKIT_STACK_NAME, SdkProvider, SuccessfulDeployStackResult, StackCollection, Deployments, HotswapMode, StackActivityProgress, ResourceMigrator, obscureTemplate, serializeStructure, tagsForStack, CliIoHost, validateSnsTopicArn, Concurrency, WorkGraphBuilder, AssetBuildNode, AssetPublishNode, StackNode } from '../api/aws-cdk';
17+
import { DEFAULT_TOOLKIT_STACK_NAME, SdkProvider, SuccessfulDeployStackResult, StackCollection, Deployments, HotswapMode, StackActivityProgress, ResourceMigrator, obscureTemplate, serializeStructure, tagsForStack, CliIoHost, validateSnsTopicArn, Concurrency, WorkGraphBuilder, AssetBuildNode, AssetPublishNode, StackNode, formatErrorMessage } from '../api/aws-cdk';
1918
import { CachedCloudAssemblySource, IdentityCloudAssemblySource, StackAssembly, ICloudAssemblySource, StackSelectionStrategy } from '../api/cloud-assembly';
2019
import { ALL_STACKS, CloudAssemblySourceBuilder } from '../api/cloud-assembly/private';
2120
import { ToolkitError } from '../api/errors';

0 commit comments

Comments
 (0)