omar-dulaimi / prisma-trpc-generator

Prisma 2+ generator to emit fully implemented tRPC routers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong import path

aske02 opened this issue · comments

commented

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

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

@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!