-
-
Notifications
You must be signed in to change notification settings - Fork 28
feat(tls-securepair-to-tlssocket): introduce #286
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
base: main
Are you sure you want to change the base?
Conversation
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 are some copy pasta
|
Pr title should be updated + the architecture need to fit with the good way to create a codemod |
|
@AugustinMauroy I have addressed the comments. Could you please review the code again? If the architecture is still not correct, could you please clarify the expected approach so I can be sure I understand? |
| The tls.TLSSocket constructor requires an existing socket instance (net.Socket) as an argument. This codemod automatically inserts socket as the argument: | ||
| JavaScript | ||
|
|
||
| ``` |
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.
| ``` | |
| ```js | |
| ``` |
| - Supports both `new tls.SecurePair()` and `new SecurePair()`. | ||
|
|
||
| ## Examples | ||
|
|
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.
you can have on code snippets here that use diff
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 file isn't needed codemod cli furnish us the needed tooling
| ## Test | ||
|
|
||
| The test.sh script runs all the tests located in the tests folder. All input files are temporarily copied to a new folder and compared against their expected results found in the expected folder. This helps identify which tests failed and why. Feel free to add new tests if necessary. No newline at end of file |
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.
| ## Test | |
| The test.sh script runs all the tests located in the tests folder. All input files are temporarily copied to a new folder and compared against their expected results found in the expected folder. This helps identify which tests failed and why. Feel free to add new tests if necessary. |
| let current = node.parent(); | ||
| while (current) { | ||
| if (kinds.includes(current.kind())) { | ||
| return current; | ||
| } | ||
| current = current.parent(); | ||
| } | ||
| return null; |
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 current = node.parent(); | |
| while (current) { | |
| if (kinds.includes(current.kind())) { | |
| return current; | |
| } | |
| current = current.parent(); | |
| } | |
| return null; | |
| let current = node.parent(); | |
| while (current) { | |
| if (kinds.includes(current.kind())) { | |
| return current; | |
| } | |
| current = current.parent(); | |
| } | |
| return null; |
some code format
| const edits: Edit[] = []; | ||
| const linesToRemove: Range[] = []; | ||
|
|
||
| const importNodes = rootNode.findAll({ |
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 have utilities for that plz read that https://github.com/nodejs/userland-migrations/blob/main/utils/README.md
| let sourceCode = rootNode.commitEdits(edits); | ||
| sourceCode = removeLines(sourceCode, linesToRemove); | ||
| return sourceCode; |
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 sourceCode = rootNode.commitEdits(edits); | |
| sourceCode = removeLines(sourceCode, linesToRemove); | |
| return sourceCode; | |
| const sourceCode = rootNode.commitEdits(edits); | |
| return removeLines(sourceCode, linesToRemove); |
This PR introduces a new codemod to migrate the deprecated tls.SecurePair class to tls.TLSSocket.
Key features of this codemod:
Testing: I have added comprehensive test cases covering:
Tests were verified locally using a custom test script ensuring input/output matches expectations.