chore(individual-pkg-gen): remove L1s from alpha modules#16354
chore(individual-pkg-gen): remove L1s from alpha modules#16354madeline-k wants to merge 7 commits intoaws:v2-mainfrom
Conversation
njlynch
left a comment
There was a problem hiding this comment.
It's unfortunate the individual-pkg-gen package doesn't currently have tests, but can you add a test for the rewrite changes in aws-cdk-migration?
| // The following line takes the 2nd to last item in modulePathSplit, which will always be the basename of the module e.g. api-gatewayv2. | ||
| return `aws-cdk-lib/aws-${modulePathSplit[modulePathSplit.length-2].replace('-canned-metrics', '')}`; |
There was a problem hiding this comment.
A bit too hacky for my taste. I think I'm leaning towards Nick's suggestion.
There was a problem hiding this comment.
I've removed the .replace('-canned-metrics','') part now based on Nick's suggestion. I agree with you this was hacky, and it still is a little bit. Open to any other suggestions you have to improve it!
| readonly customModules?: { [moduleName: string]: string }; | ||
|
|
||
| /** | ||
| * Optional flag to set for rewriting imports in alpha packages. When true, this will rewrite imports of generated L1s to reference aws-cdk-lib. |
There was a problem hiding this comment.
Would be nice to provide a tiny example in the tsdoc.
| /** | ||
| * Optional flag to set for rewriting imports in alpha packages. When true, this will rewrite imports of generated L1s to reference aws-cdk-lib. | ||
| */ | ||
| readonly isInAlphaPackage?: boolean; |
There was a problem hiding this comment.
Name feels leaky. Not sure aws-cdk-migration should be aware of alpha packages.
A more direct name for what this feature does would be better.
Something like useCfnConstructs or useBaseCfnConstructs?
There was a problem hiding this comment.
I opted for rewriteCfnImports to keep it as specific as possible. Let me know what you think
|
I am running into an issue now with imports like this: https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-redshift/test/cluster.test.ts#L6 This one is currently failing the PR Build, and there are probably more. I see two solutions here:
I think option 2 would be ideal, but I am concerned that changing one line into two in the v2 rewrite tools will get messy. |
It appears there are 11 usages of loading % git grep "import .*\bCfn.*" | grep -v generated | grep -v '@aws-cdk/core'
packages/@aws-cdk/aws-appmesh/lib/header-match.ts:import { CfnRoute } from './index';
packages/@aws-cdk/aws-athena/test/athena.test.ts:import { CfnWorkGroup } from '../lib';
packages/@aws-cdk/aws-athena/test/integ.workgroup.ts:import { CfnWorkGroup } from '../lib';
packages/@aws-cdk/aws-cloudfront/test/test-origin.ts:import { CfnDistribution, IOrigin, OriginBase, OriginBindConfig, OriginBindOptions, OriginProps, OriginProtocolPolicy } from '../lib';
packages/@aws-cdk/aws-iam/test/policy.test.ts:import { AnyPrincipal, CfnPolicy, Group, Policy, PolicyDocument, PolicyStatement, Role, ServicePrincipal, User } from '../lib';
packages/@aws-cdk/aws-msk/lib/cluster.ts:import { CfnCluster, KafkaVersion } from './';
packages/@aws-cdk/aws-redshift/test/cluster.test.ts:import { CfnCluster, Cluster, ClusterParameterGroup, ClusterSubnetGroup, ClusterType } from '../lib';
packages/@aws-cdk/aws-sam/test/application.test.ts:import { CfnApplication } from '../lib';
packages/@aws-cdk/cfnspec/lib/index.ts:import { CfnLintFileSchema } from './_private_schema/cfn-lint';
packages/awslint/lib/rules/module.ts:import { CfnResourceReflection } from './cfn-resource';
packages/awslint/lib/rules/resource.ts:import { CfnResourceReflection } from './cfn-resource';Of those, 7 are only importing the L1s, so there's only 4 statements that would conflict with the proposed rule (as long as we exclude imports from However, I worry a bit about us dodging this problem for named imports and missing the complexity of module imports: import * as foo from '@aws-cdk/aws-foo';
/// ...
new foo.Flubber(...);
new foo.CfnFizzBuzz(...);
///The above case will also require us to create the new import statements. If we're going to have to do it for that case, we might just want to handle it for both cases. So Option 2 is probably preferable in the long run. |
…e-k/aws-cdk into v2/remove-l1s-from-alpha-modules
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
After a lot of investigation into the options here, I think the best thing is to require that the L1 imports that we support rewriting in this tool are in a "normal" format. The three options are:
I think we should go with option 1. @njlynch, @rix0rrr, @nija-at, thoughts? Closing this PR in favor of one of the above 3 :) |
|
Option 1 seems the best to me. Trying to manipulate typescript text or nodes is just going to make this harder. Option 3 if it is simple and clean. Option 2 just sounds bad. |
The PR contains the following changes:
These imports come in the following formats:
./<service>.generated,../<service>.generated,../lib/<service>.generated,./<service>-canned-metrics.generated. All of these formats get converted toaws-cdk-lib/aws-<service>index.tsfiles of the alpha modules.Closes #15587
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license