Skip to content

Commit 6b8cceb

Browse files
authored
chore(toolkit): cleanup public interfaces (#105)
Clean-up public interface and docs generation in preparation of the release. This mostly moves some previously public interfaces to be private, renames interface and removes unused options. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
1 parent f25e658 commit 6b8cceb

34 files changed

+314
-253
lines changed

.projenrc.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { yarn, CdkCliIntegTestsWorkflow } from 'cdklabs-projen-project-types';
22
import * as pj from 'projen';
33
import { Stability } from 'projen/lib/cdk';
4+
import { AdcPublishing } from './projenrc/adc-publishing';
45
import { BundleCli } from './projenrc/bundle';
6+
import { CodeCovWorkflow } from './projenrc/codecov';
57
import { ESLINT_RULES } from './projenrc/eslint';
68
import { JsiiBuild } from './projenrc/jsii';
7-
import { CodeCovWorkflow } from './projenrc/codecov';
8-
import { AdcPublishing } from './projenrc/adc-publishing';
99

1010
// 5.7 sometimes gives a weird error in `ts-jest` in `@aws-cdk/cli-lib-alpha`
1111
// https://github.com/microsoft/TypeScript/issues/60159
@@ -1148,13 +1148,16 @@ toolkitLib.postCompileTask.exec('node ./lib/api/aws-cdk.js >/dev/null 2>/dev/nul
11481148

11491149
// Do include all .ts files inside init-templates
11501150
toolkitLib.npmignore?.addPatterns(
1151+
'build-tools',
1152+
'docs',
1153+
'typedoc.json',
1154+
'*.d.ts.map',
11511155
// Explicitly allow all required files
11521156
'!build-info.json',
11531157
'!db.json.gz',
11541158
'!lib/api/bootstrap/bootstrap-template.yaml',
1155-
'*.d.ts',
1156-
'*.d.ts.map',
11571159
'!lib/*.js',
1160+
'!lib/*.d.ts',
11581161
'!LICENSE',
11591162
'!NOTICE',
11601163
'!THIRD_PARTY_LICENSES',
@@ -1179,7 +1182,7 @@ for (const tsconfig of [toolkitLib.tsconfigDev]) {
11791182
}
11801183

11811184
toolkitLib.addTask('docs', {
1182-
exec: 'typedoc lib/index.ts --excludeExternals --excludePrivate --excludeProtected --excludeInternal',
1185+
exec: 'typedoc lib/index.ts',
11831186
});
11841187
toolkitLib.addTask('publish-local', {
11851188
exec: './build-tools/package.sh',

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

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/toolkit-lib/.projen/tasks.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/toolkit-lib/lib/actions/deploy/index.ts

+14-76
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { StackActivityProgress } from '../../api/aws-cdk';
2-
import type { StackSelector } from '../../api/cloud-assembly';
1+
import type { BaseDeployOptions } from './private/deploy-options';
2+
import type { StackActivityProgress, Tag } from '../../api/aws-cdk';
33

44
export type DeploymentMethod = DirectDeploymentMethod | ChangeSetDeploymentMethod;
55

@@ -48,14 +48,18 @@ export enum AssetBuildTime {
4848
JUST_IN_TIME = 'just-in-time',
4949
}
5050

51-
export interface Tag {
52-
readonly Key: string;
53-
readonly Value: string;
54-
}
55-
5651
export enum RequireApproval {
52+
/**
53+
* Never require any security approvals
54+
*/
5755
NEVER = 'never',
56+
/**
57+
* Any security changes require an approval
58+
*/
5859
ANY_CHANGE = 'any-change',
60+
/**
61+
* Require approval only for changes that are access broadening
62+
*/
5963
BROADENING = 'broadening',
6064
}
6165

@@ -107,84 +111,18 @@ export class StackParameters {
107111
}
108112
}
109113

110-
export interface BaseDeployOptions {
111-
/**
112-
* Criteria for selecting stacks to deploy
113-
*
114-
* @default - all stacks
115-
*/
116-
readonly stacks?: StackSelector;
117-
118-
/**
119-
* Role to pass to CloudFormation for deployment
120-
*/
121-
readonly roleArn?: string;
122-
123-
/**
124-
* @TODO can this be part of `DeploymentMethod`
125-
*
126-
* Always deploy, even if templates are identical.
127-
*
128-
* @default false
129-
* @deprecated
130-
*/
131-
readonly force?: boolean;
132-
133-
/**
134-
* Deployment method
135-
*/
136-
readonly deploymentMethod?: DeploymentMethod;
137-
138-
/**
139-
* @TODO can this be part of `DeploymentMethod`
140-
*
141-
* Whether to perform a 'hotswap' deployment.
142-
* A 'hotswap' deployment will attempt to short-circuit CloudFormation
143-
* and update the affected resources like Lambda functions directly.
144-
*
145-
* @default - no hotswap
146-
*/
147-
readonly hotswap?: HotswapMode;
148-
149-
/**
150-
* Rollback failed deployments
151-
*
152-
* @default true
153-
*/
154-
readonly rollback?: boolean;
155-
156-
/**
157-
* Reuse the assets with the given asset IDs
158-
*/
159-
readonly reuseAssets?: string[];
160-
161-
/**
162-
* Maximum number of simultaneous deployments (dependency permitting) to execute.
163-
* The default is '1', which executes all deployments serially.
164-
*
165-
* @default 1
166-
*/
167-
readonly concurrency?: number;
168-
169-
/**
170-
* Whether to send logs from all CloudWatch log groups in the template
171-
* to the IoHost
172-
*
173-
* @default - false
174-
*/
175-
readonly traceLogs?: boolean;
176-
}
177-
178114
export interface DeployOptions extends BaseDeployOptions {
179115
/**
180116
* ARNs of SNS topics that CloudFormation will notify with stack related events
181117
*/
182118
readonly notificationArns?: string[];
183119

184120
/**
185-
* What kind of security changes require approval
121+
* Require a confirmation for security relevant changes before continuing with the deployment
186122
*
187123
* @default RequireApproval.NEVER
124+
* @deprecated in future a message containing the full diff will be emitted and a response requested.
125+
* Approval workflows should be implemented in the `IIoHost`.
188126
*/
189127
readonly requireApproval?: RequireApproval;
190128

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { DeploymentMethod, DeployOptions, HotswapMode } from '..';
2+
import type { CloudWatchLogEventMonitor } from '../../../api/aws-cdk';
3+
import type { StackSelector } from '../../../api/cloud-assembly';
4+
5+
export interface BaseDeployOptions {
6+
/**
7+
* Criteria for selecting stacks to deploy
8+
*
9+
* @default - all stacks
10+
*/
11+
readonly stacks?: StackSelector;
12+
13+
/**
14+
* Role to pass to CloudFormation for deployment
15+
*/
16+
readonly roleArn?: string;
17+
18+
/**
19+
* Always deploy, even if templates are identical.
20+
*
21+
* @default false
22+
* @deprecated the options currently covers multiple different functionalities and will be split out in future
23+
*/
24+
readonly force?: boolean;
25+
26+
/**
27+
* Deployment method
28+
*/
29+
readonly deploymentMethod?: DeploymentMethod;
30+
31+
/**
32+
* Whether to perform a 'hotswap' deployment.
33+
* A 'hotswap' deployment will attempt to short-circuit CloudFormation
34+
* and update the affected resources like Lambda functions directly.
35+
*
36+
* @default - no hotswap
37+
*/
38+
readonly hotswap?: HotswapMode;
39+
40+
/**
41+
* Rollback failed deployments
42+
*
43+
* @default true
44+
*/
45+
readonly rollback?: boolean;
46+
47+
/**
48+
* Reuse the assets with the given asset IDs
49+
*/
50+
readonly reuseAssets?: string[];
51+
52+
/**
53+
* Maximum number of simultaneous deployments (dependency permitting) to execute.
54+
* The default is '1', which executes all deployments serially.
55+
*
56+
* @default 1
57+
*/
58+
readonly concurrency?: number;
59+
60+
/**
61+
* Whether to send logs from all CloudWatch log groups in the template
62+
* to the IoHost
63+
*
64+
* @default - false
65+
*/
66+
readonly traceLogs?: boolean;
67+
}
68+
69+
/**
70+
* Deploy options needed by the watch command.
71+
* Intentionally not exported because these options are not
72+
* meant to be public facing.
73+
*/
74+
export interface ExtendedDeployOptions extends DeployOptions {
75+
/**
76+
* The extra string to append to the User-Agent header when performing AWS SDK calls.
77+
*
78+
* @default - nothing extra is appended to the User-Agent header
79+
*/
80+
readonly extraUserAgent?: string;
81+
82+
/**
83+
* Allows adding CloudWatch log groups to the log monitor via
84+
* cloudWatchLogMonitor.setLogGroups();
85+
*
86+
* @default - not monitoring CloudWatch logs
87+
*/
88+
readonly cloudWatchLogMonitor?: CloudWatchLogEventMonitor;
89+
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
import { DeployOptions } from '..';
2-
import { CloudWatchLogEventMonitor } from '../../../api/aws-cdk';
3-
1+
export * from './deploy-options';
42
export * from './helpers';
53

6-
/**
7-
* Deploy options needed by the watch command.
8-
* Intentionally not exported because these options are not
9-
* meant to be public facing.
10-
*/
11-
export interface ExtendedDeployOptions extends DeployOptions {
12-
/**
13-
* The extra string to append to the User-Agent header when performing AWS SDK calls.
14-
*
15-
* @default - nothing extra is appended to the User-Agent header
16-
*/
17-
readonly extraUserAgent?: string;
18-
19-
/**
20-
* Allows adding CloudWatch log groups to the log monitor via
21-
* cloudWatchLogMonitor.setLogGroups();
22-
*
23-
* @default - not monitoring CloudWatch logs
24-
*/
25-
readonly cloudWatchLogMonitor?: CloudWatchLogEventMonitor;
26-
}

packages/@aws-cdk/toolkit-lib/lib/actions/import/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BaseDeployOptions } from '../deploy';
1+
import type { BaseDeployOptions } from '../deploy/private';
22

33
export interface ImportOptions extends Omit<BaseDeployOptions, 'reuseAssets' | 'hotswap'> {
44
/**
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export * from './deploy';
22
export * from './destroy';
3-
export * from './diff';
4-
export * from './import';
53
export * from './list';
4+
export * from './rollback';
65
export * from './synth';
76
export * from './watch';

packages/@aws-cdk/toolkit-lib/lib/actions/watch/index.ts

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BaseDeployOptions, HotswapMode } from '../deploy';
1+
import type { BaseDeployOptions } from '../deploy/private';
22

33
export interface WatchOptions extends BaseDeployOptions {
44
/**
@@ -37,23 +37,4 @@ export interface WatchOptions extends BaseDeployOptions {
3737
* @default 'cdk.out'
3838
*/
3939
readonly outdir?: string;
40-
41-
/**
42-
* @TODO can this be part of `DeploymentMethod`
43-
*
44-
* Whether to perform a 'hotswap' deployment.
45-
* A 'hotswap' deployment will attempt to short-circuit CloudFormation
46-
* and update the affected resources like Lambda functions directly.
47-
*
48-
* @default HotswapMode.HOTSWAP_ONLY
49-
*/
50-
readonly hotswap?: HotswapMode;
51-
}
52-
53-
export function patternsArrayForWatch(
54-
patterns: string | string[] | undefined,
55-
options: { rootDir: string; returnRootDirIfEmpty: boolean },
56-
): string[] {
57-
const patternsArray: string[] = patterns !== undefined ? (Array.isArray(patterns) ? patterns : [patterns]) : [];
58-
return patternsArray.length > 0 ? patternsArray : options.returnRootDirIfEmpty ? [options.rootDir] : [];
5940
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function patternsArrayForWatch(
2+
patterns: string | string[] | undefined,
3+
options: { rootDir: string; returnRootDirIfEmpty: boolean },
4+
): string[] {
5+
const patternsArray: string[] = patterns !== undefined ? (Array.isArray(patterns) ? patterns : [patterns]) : [];
6+
return patternsArray.length > 0 ? patternsArray : options.returnRootDirIfEmpty ? [options.rootDir] : [];
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './helpers';

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

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@
22
/**
33
* Options for the default SDK provider
44
*/
5-
export interface SdkOptions {
5+
export interface SdkConfig {
66
/**
77
* Profile to read from ~/.aws
88
*
99
* @default - No profile
1010
*/
1111
readonly profile?: string;
1212

13-
/**
14-
* Proxy address to use
15-
*
16-
* @default No proxy
17-
*/
18-
readonly region?: string;
19-
2013
/**
2114
* HTTP options for SDK
2215
*/

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export { formatSdkLoggerContent, SdkProvider } from '../../../../aws-cdk/lib/api
55
export { Context, PROJECT_CONTEXT } from '../../../../aws-cdk/lib/api/context';
66
export { Deployments, type SuccessfulDeployStackResult } from '../../../../aws-cdk/lib/api/deployments';
77
export { Settings } from '../../../../aws-cdk/lib/api/settings';
8-
export { tagsForStack } from '../../../../aws-cdk/lib/api/tags';
8+
export { tagsForStack, Tag } from '../../../../aws-cdk/lib/api/tags';
99
export { DEFAULT_TOOLKIT_STACK_NAME } from '../../../../aws-cdk/lib/api/toolkit-info';
1010
export { ResourceMigrator } from '../../../../aws-cdk/lib/api/resource-import';
1111
export { StackActivityProgress } from '../../../../aws-cdk/lib/api/stack-events';

0 commit comments

Comments
 (0)