-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[BREAKING] Move @aws-cdk/resources
classes into L2 packages
#264
Conversation
The `create_missing_libraries.sh` script was used to bootstrap L2 packages for all the namespaces that didn't have one already. Existing L2 packages were manually edited to: - Invoke `cfn2ts` to generate the L1 class library for the service/scope - Depend on `@aws-cdk/runtime` (which used to be blended in `@aws-cdk/resources`, and was extracted out) - Export the L1 library as expected The `@aws-cdk/assert` behavior was changed to rely on `@aws-cdk/cloudformation-resource-spec` to determine the `UpdateType` of attributes, rendering the `registry` mechanism that was introduced to `@aws-cdk/resources` a while ago redundant (hence it got dropped).
86a4a83
to
dcd89bc
Compare
Can we merge |
Also, if you're asking me, this PR is trying to do too many things at once. But I understand it's going to be a bitch trying to factor those out, so never mind. |
I thought the plan was to put CFN resources into a Although I understand that might complicate export of the property types. |
I agree with there being lots in this PR, but yeas, isolating each individual change is an order of magnitude more work to just build & un-build stuff so it si buildable & all... I know it sucks. Regarding Regarding the |
echo "boostrapping..." | ||
lerna bootstrap --reject-cycles | ||
echo "building..." | ||
lerna exec --stream "npm run build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this build symlinks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, lerna bootstrap
will have done that at the install.sh
step. I can duplicate the bootstrap command, though if you feel it's better... It's incredibly cheap to run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should automatically run ./install.sh
is node_modules
doesn't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already do (L4-6 in build.sh
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
Please generate all resource types into the cloudformation
namespace.
echo "boostrapping..." | ||
lerna bootstrap --reject-cycles | ||
echo "building..." | ||
lerna exec --stream "npm run build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should automatically run ./install.sh
is node_modules
doesn't exist.
create_missing_libraries.sh
Outdated
@@ -0,0 +1,97 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use hyphens in file names create-missing-libraries.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
create_missing_libraries.sh
Outdated
echo "⏳ Creating package ${P} for scope ${S}..." | ||
mkdir -p packages/${P}/test | ||
mkdir -p packages/${P}/lib | ||
echo '*.js' >> packages/${P}/.gitignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please use HEREDOCs instead? Will be wayyyy more readable...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I find the fact that HEREDOCs require you to break indentation very disturbing, BTW).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know. Me too, but they are still way better than this 😜
packages/@aws-cdk/acm/lib/index.ts
Outdated
@@ -1,2 +1,5 @@ | |||
export * from './certificate'; | |||
export * from './certificate-ref'; | |||
|
|||
// The L1 library for AWS::CertificateManager: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the terminology AWS::CertificateManager CloudFormation resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
@@ -0,0 +1,2 @@ | |||
// The L1 Library for AWS::ApiGateway: | |||
export * from '../cfn/apigateway'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the generated code should go under lib/cloudformation/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, make sure cfn2ts creates a README file under the generated directory that says that it is generated and from which spec date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That information is already included in the generated file itself... Do we really need it repeated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you are right.
tools/cfn2ts/lib/codegen.ts
Outdated
this.code.openFile(this.outputFile); | ||
|
||
const meta = { | ||
generatedOn: new Date(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so java.... I would go with generated
and fingerprint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
tools/cfn2ts/lib/codegen.ts
Outdated
const prop = spec.Properties[pname]; | ||
if (prop.Required) { | ||
const propName = pname.toLocaleLowerCase() === 'name' ? resourceNameProperty(resourceName.specName!) : pname; | ||
this.code.line(`this.required(properties, '${genspec.cloudFormationToScriptName(propName)}');`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just about to deprecate construct.required
. Can you just add this to runtime
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
tools/cfn2ts/lib/index.ts
Outdated
|
||
generator.addSpec(spec); | ||
if (force || !await generator.upToDate(outPath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: prefer early bailout: if (!force && await upToDate) { return; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
tools/cfn2ts/package.json
Outdated
@@ -25,6 +25,7 @@ | |||
}, | |||
"license": "LicenseRef-LICENSE", | |||
"dependencies": { | |||
"@aws-cdk/cloudformation-resource-spec": "^0.7.3-beta", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call this package @aws-cdk/cloudformation-spec
or even @aws-cdk/cfnspec
. Keep 'em short!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish this was said on the two occasions I asked for naming suggestions 🤨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming to @aws-cdk/cdk-cfnspec
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Are we doing the cdk-xxx
as part of this change, or just this one for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just this one. This changeset is already bloated enough I think :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I was worried that you are crazier than I thought
}, | ||
"dependencies": { | ||
"@aws-cdk/core": "^0.7.3-beta", | ||
"@aws-cdk/runtime": "^0.7.3-beta" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just merge runtime into core? I agree with @rix0rrr - doesn't seem like a useful module. And also, the name is way too presumptuous for what it's doing 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Much prefer this than duplicating it into every generated package.
- Namespace resource and property classes under 'cloudformation' - Merge @aws-cdk/runtime into @aws-cdk/core - Rename @aws-cdk/clouformation-resource-spec to @aws-cdk/cdk-cfnspec - Generate code into lib/<ns>.generated.ts
Disabling use of '--reject-cycles' on 'lerna bootstrap' as it would blow up on the cycle created by (e.g:) how aws-cdk uses @aws-cdk/s3, which itself uses @aws-cdk/assert.
744394f
to
27dad9a
Compare
The
create_missing_libraries.sh
script was used to bootstrap L2packages for all the namespaces that didn't have one already.
Existing L2 packages were manually edited to:
cfn2ts
to generate the L1 class library for the service/scope@aws-cdk/runtime
(which used to be blended in@aws-cdk/resources
, and was extracted out)The
@aws-cdk/assert
behavior was changed to rely on@aws-cdk/cloudformation-resource-spec
to determine theUpdateType
ofattributes, rendering the
registry
mechanism that was introduced to@aws-cdk/resources
a while ago redundant (hence it got dropped).Bonus: Renamed the
prepare
command in allpackage.json
tobuild
(Fixes #197).