Skip to content

fix(cli): correctly resolve file with fake extension #3924

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

Merged

Conversation

bodinsamuel
Copy link
Collaborator

@bodinsamuel bodinsamuel commented Apr 17, 2025

Changes

Fixes https://linear.app/nango/issue/NAN-3090/cli-issue-when-detecting-lib

  • CLI: correctly resolve file with fake extension
    It was buggy when importing stuff like schema.zod. It was resolved to schema.ts instead of schema.zod.ts.

@bodinsamuel bodinsamuel self-assigned this Apr 17, 2025
@bodinsamuel bodinsamuel requested a review from a team April 17, 2025 14:16
Copy link

linear bot commented Apr 17, 2025

@@ -170,26 +170,33 @@ function compileImportedFile({

for (const importedFile of importedFiles) {
const importedFilePath = path.resolve(path.dirname(filePath), importedFile);
const importedFilePathWithoutExtension = path.join(path.dirname(importedFilePath), path.basename(importedFilePath, path.extname(importedFilePath)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow where the bug is. path.basename('a/b/c/schema.zod.ts', path.extname('ts'))) should give a/b/c/schema.zod no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because extension-less imports are valid in Typescript, so when you autocomplete, it often imports this schema.zod and since we are less smart, we think .zod is the extension.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it

@bodinsamuel bodinsamuel requested a review from TBonnin April 18, 2025 14:34
Copy link

gitguardian bot commented Apr 22, 2025

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
16627964 Triggered Username Password c870289 packages/shared/lib/utils/utils.unit.test.ts View secret
16627965 Triggered Generic Password c870289 packages/shared/lib/utils/utils.unit.test.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@bodinsamuel bodinsamuel enabled auto-merge (squash) April 22, 2025 08:34
@bodinsamuel bodinsamuel merged commit 30749da into master Apr 22, 2025
12 of 13 checks passed
@bodinsamuel bodinsamuel deleted the sam/25_04_17/fix/cli-compile-support-any-extension branch April 22, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants