chore: rewrite imports in READMEs for aws-cdk-lib#14255
Conversation
For the v2 (aws-cdk-lib) docs, the imports scattered throughout the READMEs need
to be re-written. We could hand-edit all of the READMEs on the v2-main branch,
but this is not an ongoing mechanism and may also introduce forward-merge pain.
Instead, we're going to take the cheap option of rewriting the import statements
as part of `ubergen` when building the `aws-cdk-lib` package.
I aimed to capture as many import types as I found in the live READMEs.
As an example, the code transforms these imports as seen below:
```ts
// BEFORE
import * as cdk from '@aws-cdk/core';
import * as cloudfront from '@aws-cdk/aws-cloudfront';
import codeartifact = require('@aws-cdk/aws-codeartifact');
import { VpcEndpointServiceDomainName } from '@aws-cdk/aws-route53';
import { Construct, Stage, Stack, StackProps, StageProps } from '@aws-cdk/core';
// AFTER
import * as cdk from 'aws-cdk-lib';
import { aws_cloudfront as cloudfront } from 'aws-cdk-lib';
import { aws_codeartifact as codeartifact } from 'aws-cdk-lib';
import { VpcEndpointServiceDomainName } from 'aws-cdk-lib/aws-route53';
import { Construct, Stage, Stack, StackProps, StageProps } from 'aws-cdk-lib';
```
|
PR could do with a motivation not to use the |
I was going to ask about this too. |
Simplicity and laziness. To reuse |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Imports in READMEs are now rewritten from '@aws-cdk/...' to 'aws-cdk-lib'. This change was introduced in #14255, but no validation was included in the original PR. This change introduces a post-build validation step for aws-cdk-lib to ensure that the module rewrites were properly done.
Imports in READMEs are now rewritten from '@aws-cdk/...' to 'aws-cdk-lib'. This change was introduced in #14255, but no validation was included in the original PR. This change introduces a post-build validation step for aws-cdk-lib to ensure that the module rewrites were properly done.
…#14302) Imports in READMEs are now rewritten from '@aws-cdk/...' to 'aws-cdk-lib'. This change was introduced in #14255, but no validation was included in the original PR. This change introduces a post-build validation step for aws-cdk-lib to ensure that the module rewrites were properly done. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
For the v2 (aws-cdk-lib) docs, the imports scattered throughout the READMEs need
to be re-written. We could hand-edit all of the READMEs on the v2-main branch,
but this is not an ongoing mechanism and may also introduce forward-merge pain.
Instead, we're going to take the cheap option of rewriting the import statements
as part of `ubergen` when building the `aws-cdk-lib` package.
I aimed to capture as many import types as I found in the live READMEs.
As an example, the code transforms these imports as seen below:
```ts
// BEFORE
import * as cdk from '@aws-cdk/core';
import * as cloudfront from '@aws-cdk/aws-cloudfront';
import codeartifact = require('@aws-cdk/aws-codeartifact');
import { VpcEndpointServiceDomainName } from '@aws-cdk/aws-route53';
import { Construct, Stage, Stack, StackProps, StageProps } from '@aws-cdk/core';
// AFTER
import * as cdk from 'aws-cdk-lib';
import { aws_cloudfront as cloudfront } from 'aws-cdk-lib';
import { aws_codeartifact as codeartifact } from 'aws-cdk-lib';
import { VpcEndpointServiceDomainName } from 'aws-cdk-lib/aws-route53';
import { Construct, Stage, Stack, StackProps, StageProps } from 'aws-cdk-lib';
```
Note: Doesn't use the existing `rewrite-imports` method as that would require parsing the Markdown (requiring an extra dependency) and potentially guarding against malformed inputs. This approach was chosen as a simple, pragmatic solution. We can revisit this in the future if necessary.
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
For the v2 (aws-cdk-lib) docs, the imports scattered throughout the READMEs need
to be re-written. We could hand-edit all of the READMEs on the v2-main branch,
but this is not an ongoing mechanism and may also introduce forward-merge pain.
Instead, we're going to take the cheap option of rewriting the import statements
as part of `ubergen` when building the `aws-cdk-lib` package.
I aimed to capture as many import types as I found in the live READMEs.
As an example, the code transforms these imports as seen below:
```ts
// BEFORE
import * as cdk from '@aws-cdk/core';
import * as cloudfront from '@aws-cdk/aws-cloudfront';
import codeartifact = require('@aws-cdk/aws-codeartifact');
import { VpcEndpointServiceDomainName } from '@aws-cdk/aws-route53';
import { Construct, Stage, Stack, StackProps, StageProps } from '@aws-cdk/core';
// AFTER
import * as cdk from 'aws-cdk-lib';
import { aws_cloudfront as cloudfront } from 'aws-cdk-lib';
import { aws_codeartifact as codeartifact } from 'aws-cdk-lib';
import { VpcEndpointServiceDomainName } from 'aws-cdk-lib/aws-route53';
import { Construct, Stage, Stack, StackProps, StageProps } from 'aws-cdk-lib';
```
Note: Doesn't use the existing `rewrite-imports` method as that would require parsing the Markdown (requiring an extra dependency) and potentially guarding against malformed inputs. This approach was chosen as a simple, pragmatic solution. We can revisit this in the future if necessary.
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…aws#14302) Imports in READMEs are now rewritten from '@aws-cdk/...' to 'aws-cdk-lib'. This change was introduced in aws#14255, but no validation was included in the original PR. This change introduces a post-build validation step for aws-cdk-lib to ensure that the module rewrites were properly done. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
For the v2 (aws-cdk-lib) docs, the imports scattered throughout the READMEs need
to be re-written. We could hand-edit all of the READMEs on the v2-main branch,
but this is not an ongoing mechanism and may also introduce forward-merge pain.
Instead, we're going to take the cheap option of rewriting the import statements
as part of `ubergen` when building the `aws-cdk-lib` package.
I aimed to capture as many import types as I found in the live READMEs.
As an example, the code transforms these imports as seen below:
```ts
// BEFORE
import * as cdk from '@aws-cdk/core';
import * as cloudfront from '@aws-cdk/aws-cloudfront';
import codeartifact = require('@aws-cdk/aws-codeartifact');
import { VpcEndpointServiceDomainName } from '@aws-cdk/aws-route53';
import { Construct, Stage, Stack, StackProps, StageProps } from '@aws-cdk/core';
// AFTER
import * as cdk from 'aws-cdk-lib';
import { aws_cloudfront as cloudfront } from 'aws-cdk-lib';
import { aws_codeartifact as codeartifact } from 'aws-cdk-lib';
import { VpcEndpointServiceDomainName } from 'aws-cdk-lib/aws-route53';
import { Construct, Stage, Stack, StackProps, StageProps } from 'aws-cdk-lib';
```
Note: Doesn't use the existing `rewrite-imports` method as that would require parsing the Markdown (requiring an extra dependency) and potentially guarding against malformed inputs. This approach was chosen as a simple, pragmatic solution. We can revisit this in the future if necessary.
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…aws#14302) Imports in READMEs are now rewritten from '@aws-cdk/...' to 'aws-cdk-lib'. This change was introduced in aws#14255, but no validation was included in the original PR. This change introduces a post-build validation step for aws-cdk-lib to ensure that the module rewrites were properly done. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Adds `rewriteImports` and helper functions `rewriteReadmeImports` and `rewriteMonoPackageImports` to `aws-cdk-migration` package. - `individual-package-gen` consumes `rewriteReadmeImports` for alpha modules. - `individual-package-gen` treats rosetta fixtures as source files and rewrites imports there as well. - Adds `aws-cdk-migration` as a dependency to `ubergen`. - Refactors `rewriteImports` in `ubergen` to use the API in `aws-cdk-migration`. Has the side affect of removing the string-replace function that was introduced in this [PR](#14255). This changes the readme import style from `import { blah as blah } from 'aws-cdk-lib';` to `import * as blah from 'aws-cdk-lib/blah';`. - fixes error in `cfnspec` that generated invalid import names for L1 module readmes. - fixes bug in `cdk-build` that only executed one `post` command. - fixes `verify-imports` scripts typo introduced previously (that was not caught due to the `cdk-build` bug). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Adds `rewriteImports` and helper functions `rewriteReadmeImports` and `rewriteMonoPackageImports` to `aws-cdk-migration` package. - `individual-package-gen` consumes `rewriteReadmeImports` for alpha modules. - `individual-package-gen` treats rosetta fixtures as source files and rewrites imports there as well. - Adds `aws-cdk-migration` as a dependency to `ubergen`. - Refactors `rewriteImports` in `ubergen` to use the API in `aws-cdk-migration`. Has the side affect of removing the string-replace function that was introduced in this [PR](#14255). This changes the readme import style from `import { blah as blah } from 'aws-cdk-lib';` to `import * as blah from 'aws-cdk-lib/blah';`. - fixes error in `cfnspec` that generated invalid import names for L1 module readmes. - fixes bug in `cdk-build` that only executed one `post` command. - fixes `verify-imports` scripts typo introduced previously (that was not caught due to the `cdk-build` bug). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* (cherry picked from commit 66e37cc) # Conflicts: # packages/@aws-cdk/cfnspec/lib/library-creation.ts
For the v2 (aws-cdk-lib) docs, the imports scattered throughout the READMEs need
to be re-written. We could hand-edit all of the READMEs on the v2-main branch,
but this is not an ongoing mechanism and may also introduce forward-merge pain.
Instead, we're going to take the cheap option of rewriting the import statements
as part of
ubergenwhen building theaws-cdk-libpackage.I aimed to capture as many import types as I found in the live READMEs.
As an example, the code transforms these imports as seen below:
Note: Doesn't use the existing
rewrite-importsmethod as that would require parsing the Markdown (requiring an extra dependency) and potentially guarding against malformed inputs. This approach was chosen as a simple, pragmatic solution. We can revisit this in the future if necessary.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license