Skip to content

Commit

Permalink
docs(core): make examples compile (#11273)
Browse files Browse the repository at this point in the history
Add support in `cdk-build` to actually run `jsii-rosetta --compile --fail`
in packages that declare supporting "strict" mode for `jsii-rosetta`.
This enables a "quick" feedback loop for detecting "now-invalid" code
examples.

Turned on this feature on `@aws-cdk/core` and made the necessary
adjustments to fixtures and examples so that they now compile. In
particular:
- Made all `import` statements implicit from the examples, as they are
  all moved to the fixture. Imports from the library itself are *always
  unqualified*, and external ones are *always qualified*.
- Used `declare` statements in the fixtures to avoid having to come
  up with "real" values that compile. This is way less brittle than actually
  coming up with an initializer, especially for external types.

Also turned on this feature on `@aws-cdk/aws-iam` and made the
ajustement to fixtures and examples so that they now compile. In
particular:
- All imports to `@aws-cdk/core` are nominal and un-qualified.
- All imports to other libraries are always qualified.

Fixes #11624.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
RomainMuller authored Nov 30, 2020
1 parent ece9b23 commit 5bf5ecc
Show file tree
Hide file tree
Showing 199 changed files with 954 additions and 853 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ Work your magic. Here are some guidelines:
Feel free to start your contribution by copy&pasting files from that project,
and then edit and rename them as appropriate -
it might be easier to get started that way.
* If your change includes code examples (in the `README.md` file or as part of regular TSDoc tags),
you should probably validate those examples can be successfully compiled and trans-literated by
running `yarn rosetta:extract` (this requires other packages used by code examples are built).

#### Integration Tests

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"fs-extra": "^9.0.1",
"graceful-fs": "^4.2.4",
"jest-junit": "^12.0.0",
"jsii-diff": "^1.14.1",
"jsii-pacmak": "^1.14.1",
"jsii-rosetta": "^1.14.1",
"jsii-diff": "^1.15.0",
"jsii-pacmak": "^1.15.0",
"jsii-rosetta": "^1.15.0",
"lerna": "^3.22.1",
"standard-version": "^9.0.0",
"typescript": "~3.9.7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@
},
"maturity": "stable",
"stability": "stable"
}
}
3 changes: 2 additions & 1 deletion packages/@aws-cdk/alexa-ask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "Alexa::ASK",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/app-delivery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This library includes a *CodePipeline* composite Action for deploying AWS CDK Ap
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.


# Replacement recommended
### Replacement recommended

This library has been deprecated. We recommend you use the
[@aws-cdk/pipelines](https://docs.aws.amazon.com/cdk/api/latest/docs/pipelines-readme.html) module instead.
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/app-delivery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"awslint": "cdk-awslint",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"dependencies": {
"@aws-cdk/aws-cloudformation": "0.0.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"awslint": "cdk-awslint",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"pre": [
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-accessanalyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"compat": "cdk-compat",
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::AccessAnalyzer",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-acmpca/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::ACMPCA",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-amazonmq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::AmazonMQ",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::Amplify",
Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-apigateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ to configure these.
There are a number of limitations in using OpenAPI definitions in API Gateway. Read the [Amazon API Gateway important
notes for REST APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html#api-gateway-known-issues-rest-apis)
for more details.
**Note:** When starting off with an OpenAPI definition using `SpecRestApi`, it is not possible to configure some
properties that can be configured directly in the OpenAPI specification file. This is to prevent people duplication
of these properties and potential confusion.
Expand All @@ -1050,10 +1050,10 @@ const api = new apigateway.SpecRestApi(this, 'ExampleRestApi', {
});
```
**Note:** For private endpoints you will still need to provide the
[`x-amazon-apigateway-policy`](https://docs.aws.amazon.com/apigateway/latest/developerguide/openapi-extensions-policy.html) and
[`x-amazon-apigateway-endpoint-configuration`](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-endpoint-configuration.html)
in your openApi file.
**Note:** For private endpoints you will still need to provide the
[`x-amazon-apigateway-policy`](https://docs.aws.amazon.com/apigateway/latest/developerguide/openapi-extensions-policy.html) and
[`x-amazon-apigateway-endpoint-configuration`](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-endpoint-configuration.html)
in your openApi file.
## Metrics
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::ApiGateway",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2-integrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"watch": "cdk-watch",
"compat": "cdk-compat",
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package"
"build+test+package": "npm run build+test && npm run package",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"jest": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigatewayv2/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## AWS::APIGatewayv2 Construct Library
# AWS::APIGatewayv2 Construct Library
<!--BEGIN STABILITY BANNER-->
---

Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigatewayv2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"compat": "cdk-compat",
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::ApiGatewayV2",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-appconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::AppConfig",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-appflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::AppFlow",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-applicationautoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::ApplicationAutoScaling",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-applicationinsights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::ApplicationInsights",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-appmesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::AppMesh",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-appstream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::AppStream",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::AppSync",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-athena/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"keywords": [
"aws",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-autoscaling-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"awslint": "cdk-awslint",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"keywords": [
"aws",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-autoscaling-hooktargets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"awslint": "cdk-awslint",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"keywords": [
"aws",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-autoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::AutoScaling",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-autoscalingplans/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::AutoScalingPlans",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-backup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test": "npm run build && npm test",
"build+test+package": "npm run build+test && npm run package",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::Backup",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-batch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::Batch",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-budgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::Budgets",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cassandra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::Cassandra",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-ce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::CE",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-certificatemanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::CertificateManager",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-chatbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::Chatbot",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloud9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::Cloud9",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloudformation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::CloudFormation"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloudfront-origins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"awslint": "cdk-awslint",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat"
"compat": "cdk-compat",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"jest": true,
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloudfront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test",
"compat": "cdk-compat",
"gen": "cfn2ts"
"gen": "cfn2ts",
"rosetta:extract": "yarn --silent jsii-rosetta extract"
},
"cdk-build": {
"cloudformation": "AWS::CloudFront",
Expand Down
Loading

0 comments on commit 5bf5ecc

Please sign in to comment.