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

Wrong import path #32

Closed
aske02 opened this issue Sep 10, 2022 · 2 comments · Fixed by #35
Closed

Wrong import path #32

aske02 opened this issue Sep 10, 2022 · 2 comments · Fixed by #35
Assignees
Labels
bug Something isn't working

Comments

@aske02
Copy link

aske02 commented Sep 10, 2022

Bug description

It might just be my machine, but anyways.
When running npx prisma generate I have the issue that the trpc-generator (with trpc-shield) makes an invalid include in routers/helpers/createRouter.ts. The line that is outputted will use \ as separators which I believe causes an issue where my import for example will look like: import { permissions } from "X:\Gamer 2\test-npm\prisma/shield/shield" when a path with \\ is expected.

How to reproduce

  1. Create a simple test project with a prisma client and trcp-shield
  2. Enable withShield in your prisma schema
  3. Run 'npx prisma generate'
  4. Check the file routers/helpers/createRouter.ts in your generated folder
  5. See that in the import it will have used single back slash instead of double back slash

Expected behavior

The import path should include the correct path to shield permissions

Prisma information

generator client {
    provider = "prisma-client-js"
}

generator trpc {
    provider = "prisma-trpc-generator"
    output   = "./trpc"
	withMiddleware = true
	withShield     = true
	contextPath    = "../../../../src/context"
}

datasource db {
    provider = "mysql"
    url      = env("DATABASE_URL")
}

model User {
    id        Int      @id @default(autoincrement())
    email     String   @unique(map: "email")
    password  String
    name      String
    rank      Rank
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
}

enum Rank {
    Admin
    Moderator
    User
}

Environment & setup

  • OS: Windows 10 Home
  • Database: MySQL
  • Node.js version: 16.14.2

Prisma Version

Environment variables loaded from .env
prisma                  : 4.3.1
@prisma/client          : 4.3.1
Current platform        : windows
Query Engine (Node-API) : libquery-engine c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Format Wasm             : @prisma/prisma-fmt-wasm 4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b
Default Engines Hash    : c875e43600dfe042452e0b868f7a48b817b9640b
Studio                  : 0.473.0
@websaid
Copy link

websaid commented Sep 11, 2022

Push! Face same issue. Shouldn't be to hard to fix.

@omar-dulaimi omar-dulaimi self-assigned this Sep 19, 2022
@omar-dulaimi omar-dulaimi added the bug Something isn't working label Sep 19, 2022
@omar-dulaimi omar-dulaimi linked a pull request Sep 19, 2022 that will close this issue
@omar-dulaimi
Copy link
Owner

@aske02 @Westsaid Should be fixed in https://github.com/omar-dulaimi/prisma-trpc-generator/releases/tag/0.4.4

Also, feel free to star this project if you find it useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants