Skip to content
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

Bug: cli seed:create creates unrecognized import #936

Closed
calteran opened this issue Mar 29, 2024 · 2 comments · Fixed by #954
Closed

Bug: cli seed:create creates unrecognized import #936

calteran opened this issue Mar 29, 2024 · 2 comments · Fixed by #954
Labels

Comments

@calteran
Copy link

Versions

  • Node: Node 21
  • OS: macOS 14.4.1

Reproduction

When running ts-node-esm ./node_modules/typeorm-extension/bin/cli.mjs seed:create -n src/database/seeds/test the resulting file imports typeorm-extension.js on line 2. This is an unrecognized import and should be typeorm-extension (without the .js extension).

Additional Details
// generated seed file
import { DataSource } from 'typeorm';
import { Seeder, SeederFactoryManager } from 'typeorm-extension.js'; // <-- shouldn't have the extension here

export class Test1711706973402 implements Seeder {
    track = false;

    public async run(
        dataSource: DataSource,
        factoryManager: SeederFactoryManager
    ): Promise<any> {

    }
}
// tsconfig.json
{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    },
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"],
  "ts-node": {
    "esm": true,
    "compilerOptions": {
      // compilerOptions specified here will override those declared below,
      // but *only* in ts-node.  Useful if you want ts-node and tsc to use
      // different options with a single tsconfig.json.
      "module": "commonjs",
      "moduleResolution": "node"
    }
  }
}
// package.json
{
  "name": "a-project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "db:create": "dotenvx run --env-file=.env.local -- ts-node-esm ./node_modules/typeorm-extension/bin/cli.mjs db:create -d src/database/connection.ts",
    "db:drop": "dotenvx run --env-file=.env.local -- ts-node-esm ./node_modules/typeorm-extension/bin/cli.mjs db:drop -d src/database/connection.ts",
    "seed:run": "dotenvx run --env-file=.env.local -- ts-node-esm ./node_modules/typeorm-extension/bin/cli.mjs seed:run -d src/database/connection.ts",
    "seed:create": "dotenvx run --env-file=.env.local -- ts-node-esm ./node_modules/typeorm-extension/bin/cli.mjs seed:create"
  },
  "dependencies": {
    "@emotion/cache": "^11.11",
    "@emotion/react": "^11.11",
    "@emotion/styled": "^11.11",
    "@mdx-js/loader": "^3.0",
    "@mdx-js/react": "^3.0",
    "@mui/icons-material": "^5.15",
    "@mui/material": "^5.15",
    "@mui/material-nextjs": "^5.15",
    "@next/mdx": "^14.1",
    "@types/mdx": "^2.0",
    "next": "14.1",
    "pg": "^8.11",
    "react": "^18",
    "react-dom": "^18",
    "reflect-metadata": "^0.2",
    "typeorm": "^0.3.20"
  },
  "devDependencies": {
    "@dotenvx/dotenvx": "^0.27.1",
    "@types/node": "^20.11",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10.0",
    "eslint": "^8",
    "eslint-config-next": "14.1",
    "postcss": "^8",
    "tailwindcss": "^3.3",
    "ts-node": "^10.9.2",
    "typeorm-extension": "^3.5.0",
    "typescript": "^5"
  }
}

Steps to reproduce

  1. Setup a new project
  2. Run ts-node-esm ./node_modules/typeorm-extension/bin/cli.mjs seed:create -n src/database/seeds/test

What is Expected?

In the generated Seed module, the import on Line 2 should be from typeorm-extension without a .js extension

What is actually happening?

The .js extension is added.

Note: in reviewing src/seeder/utils/template.ts I don't see how this extension is getting added.

@tada5hi
Copy link
Owner

tada5hi commented Apr 9, 2024

good catch! thanks

Copy link

github-actions bot commented Apr 9, 2024

🎉 This issue has been resolved in version 3.5.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants