Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(aws-cdk-lib): strip out deprecated symbols from public API #13815

Merged
merged 3 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/@aws-cdk/aws-lambda/lib/log-retention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { Construct } from 'constructs';

/**
* Retry options for all AWS API calls.
*
* @deprecated use `LogRetentionRetryOptions` from '@aws-cdk/aws-logs' instead
*/
export interface LogRetentionRetryOptions extends logs.LogRetentionRetryOptions {
}
Expand Down
9 changes: 8 additions & 1 deletion packages/@aws-cdk/aws-lambda/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,23 @@ export class Runtime {
public readonly family?: RuntimeFamily;

/**
* The bundling Docker image for this runtime.
* DEPRECATED
* @deprecated use `bundlingImage`
*/
public readonly bundlingDockerImage: BundlingDockerImage;

/**
* The bundling Docker image for this runtime.
*/
public readonly bundlingImage: DockerImage;

constructor(name: string, family?: RuntimeFamily, props: LambdaRuntimeProps = { }) {
this.name = name;
this.supportsInlineCode = !!props.supportsInlineCode;
this.family = family;
const imageName = props.bundlingDockerImage ?? `amazon/aws-sam-cli-build-image-${name}`;
this.bundlingDockerImage = DockerImage.fromRegistry(imageName);
this.bundlingImage = this.bundlingDockerImage;
this.supportsCodeGuruProfiling = props.supportsCodeGuruProfiling ?? false;

Runtime.ALL.push(this);
Expand Down
8 changes: 7 additions & 1 deletion packages/@aws-cdk/core/lib/construct-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,17 @@ export class ConstructNode {
return this._actualNode.tryGetContext(key);
}

/**
* DEPRECATED
* @deprecated use `metadataEntry`
*/
public get metadata() { return this._actualNode.metadata as cxapi.MetadataEntry[]; }

/**
* An immutable array of metadata objects associated with this construct.
* This can be used, for example, to implement support for deprecation notices, source mapping, etc.
*/
public get metadata() { return this._actualNode.metadata as cxapi.MetadataEntry[]; }
public get metadataEntry() { return this._actualNode.metadata; }

/**
* Adds a metadata entry to this construct.
Expand Down
18 changes: 13 additions & 5 deletions packages/@aws-cdk/core/lib/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,17 @@ export class Stack extends CoreConstruct implements ITaggable {
return CloudFormationLang.toJSON(obj, space).toString();
}

/**
* DEPRECATED
* @deprecated use `reportMissingContextKey()`
*/
public reportMissingContext(report: cxapi.MissingContext) {
if (!Object.values(cxschema.ContextProvider).includes(report.provider as cxschema.ContextProvider)) {
throw new Error(`Unknown context provider requested in: ${JSON.stringify(report)}`);
}
Comment on lines +432 to +434
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As-is, these checks will be removed in v2. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is only needed because cxapi.MissingContext needs to be converted into cxschema.MissingContext.
Specifically, the provider prop is a string in the former and an enum in the latter.
Hence not required in the new API.

cc @rix0rrr to confirm who introduced the change.

this.reportMissingContextKey(report as cxschema.MissingContext);
}

/**
* Indicate that a context key was expected
*
Expand All @@ -432,11 +443,8 @@ export class Stack extends CoreConstruct implements ITaggable {
*
* @param report The set of parameters needed to obtain the context
*/
public reportMissingContext(report: cxapi.MissingContext) {
if (!Object.values(cxschema.ContextProvider).includes(report.provider as cxschema.ContextProvider)) {
throw new Error(`Unknown context provider requested in: ${JSON.stringify(report)}`);
}
this._missingContext.push(report as cxschema.MissingContext);
public reportMissingContextKey(report: cxschema.MissingContext) {
this._missingContext.push(report);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"cdk-build": {
"eslint": {
"disable": true
}
},
"stripDeprecated": true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why this is not in the jsii config. @RomainMuller?

},
"pkglint": {
"exclude": [
Expand Down
2 changes: 1 addition & 1 deletion tools/cdk-build-tools/lib/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Timers } from './timer';
*/
export async function compileCurrentPackage(options: CDKBuildOptions, timers: Timers, compilers: CompilerOverrides = {}): Promise<void> {
const env = options.env;
await shell(packageCompiler(compilers), { timers, env });
await shell(packageCompiler(compilers, options), { timers, env });

// Find files in bin/ that look like they should be executable, and make them so.
const scripts = currentPackageJson().bin || {};
Expand Down
14 changes: 12 additions & 2 deletions tools/cdk-build-tools/lib/package-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ export interface CompilerOverrides {
/**
* Return the compiler for this package (either tsc or jsii)
*/
export function packageCompiler(compilers: CompilerOverrides): string[] {
export function packageCompiler(compilers: CompilerOverrides, options?: CDKBuildOptions): string[] {
if (isJsii()) {
return [compilers.jsii || require.resolve('jsii/bin/jsii'), '--silence-warnings=reserved-word'];
const args = ['--silence-warnings=reserved-word'];
if (options?.stripDeprecated) {
args.push('--strip-deprecated');
}
return [compilers.jsii || require.resolve('jsii/bin/jsii'), ...args];
} else {
return [compilers.tsc || require.resolve('typescript/bin/tsc'), '--build'];
}
Expand Down Expand Up @@ -148,6 +152,12 @@ export interface CDKBuildOptions {
* Environment variables to be passed to 'cdk-build' and all of its child processes.
*/
env?: NodeJS.ProcessEnv;

/**
* Whether deprecated symbols should be stripped from the jsii assembly and typescript declaration files.
* @see https://aws.github.io/jsii/user-guides/lib-author/toolchain/jsii/#-strip-deprecated
*/
stripDeprecated?: boolean;
}

/**
Expand Down