-
Notifications
You must be signed in to change notification settings - Fork 459
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
feat(cli): update TypeScript template to match aws-cdk layout #3179
Conversation
*.d.ts | ||
bundle |
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.
The bundle contains the TS templates, which include invalid TS.
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.
This is nice because the test setup file is no longer at the root of the directory. It's neatly contained in the test
folder.
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.
CDK uses the test
folder, not __tests__
.
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.
Now, the stack is stored in lib
and the app is defined in bin
, just like CDK.
import { Construct } from "constructs"; | ||
import { TerraformStack } from "cdktf"; | ||
|
||
export class {{basePascal}}Stack extends TerraformStack { |
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.
For an app named foo MyStack
becomes FooStack
, just like CDK.
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.
Updating this file to use a TypeScript config vs. JS. I retained all the existing values.
clearMocks: true, | ||
coverageProvider: "v8", | ||
moduleFileExtensions: ["ts", "js", "json", "node"], | ||
setupFilesAfterEnv: ["<rootDir>/test/setup.js"], |
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.
Updated from <rootDir>/setup.js
moduleFileExtensions: ["ts", "js", "json", "node"], | ||
setupFilesAfterEnv: ["<rootDir>/test/setup.js"], | ||
testEnvironment: "node", | ||
testMatch: ["**/test/**/*.ts", "**/?(*.)+(spec|test).ts"], |
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.
Updated from **/__tests__/**/*.ts
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.
Now, just the app is created here. The stack is created in a separate file, as with CDK.
|
||
# ignore templates, since they're not valid TypeScript | ||
templates |
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.
Now that we're using syntax like:
export class {{basePascal}}Stack extends TerraformStack {
We have invalid TS, so eslint blows up.
Ah, I need to update the website docs. Taking back to draft. |
I think I'll need to update at least:
to complete this PR. Since that'd be a decent time commitment, @DanielMSchmidt, is this a PR the team would consider merging? If not, I'll save the time and close it. If so, I'm happy to complete it. |
Hi @blimmer: Thank you for the effort you put into this PR! We discussed it as a team and we agreed that while there are a couple of valid arguments for making this change, overall, this is a bigger refactor than we're willing to take on; if we were going to proceed with this, we would also want to make sure that all of our tutorials and example projects outside of this repo get updated to the new format as well so that we're being consistent across-the-board. That additional effort outweighs the benefits of making this change from our perspective. Again, we do acknowledge your contribution and appreciate the time you spent on this! |
I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Related issue
Fixes #3006
Description
This PR adjusts the output format for CDKTF TypeScript projects created by
cdktf init --template typescript
to better match CDK. This makes it simpler for new CDKTF users with CDK experience to understand where the files are located.You can see the current CDK layout here: https://github.com/aws/aws-cdk/tree/06bea3159e137a8e85e362795ef2cf7e219e381c/packages/aws-cdk/lib/init-templates/app/typescript
or, generate a new CDK project for comparison
Checklist