Giter Site home page Giter Site logo

nicoalbanese / kirimase Goto Github PK

View Code? Open in Web Editor NEW
2.2K 21.0 98.0 664 KB

Build full-stack Next.js apps, incredibly fast

Home Page: https://kirimase.dev

License: MIT License

TypeScript 99.61% JavaScript 0.39%
authjs cli drizzle drizzleorm nextauth nextjs rails shadcn shadcn-ui clerk

kirimase's Introduction

Logo for Kirimase

Kirimase

npm_version

Kirimase is a command-line tool for building full-stack Next.js apps faster. It supercharges your development workflow, allowing you to quickly integrate packages and scaffold resources for your application with best practices in mind.


Kirimase Demo

Watch the most recent demo here

Check out the official tutorial here

Features

  1. Initialization and Configuration: quickly add and set up essential packages to jump-start your Next.js project.
  2. Code Generation: scaffold models, views, and controllers directly from the CLI.

Quick Start

Install Kirimase CLI globally:

npm install -g kirimase

If you don't already have a Nextjs app, run create-next-app with your preferred package manager.

Then run the following command within the directory of your project:

kirimase init

Note: Kirimase is not compatible with the the pages directory.

Commands

Run these commands within the directory of your Nextjs app:

1. kirimase add

Initializes and configures the following packages for your Next.js project, categorized into:

ORM

Drizzle-ORM

  • Based on your chosen database type (PostgreSQL, MySQL, SQLite), Kirimase sets up the required files for Drizzle-ORM, drizzle-zod for validations and and drizzle-kit to manage migrations.
  • Scripts are auto-added to package.json for immediate use of drizzle-kit.

Prisma


Authentication

Auth.js

  • Generates files for Auth.js (Next-Auth), including the latest Drizzle adapter. (For PlanetScale, references are excluded as it doesn't support foreign keys).
  • Generates a generic sign-in component for immediate use within your Next.js project.
  • Wraps the root layout with the auth provider and generates utilities for auth checks and redirects in your Next.js routes.

Clerk

  • Generates files for Clerk including all necessary config.
  • Wraps the root layout with the auth provider and generates utilities for auth checks and redirects in your Next.js routes.

Lucia

  • Generates files for Lucia including all necessary config.
  • Generates UI and API routes for sign-in and sign-up

Kinde

  • Generates files for Kinde including all necessary config.
  • Generates sign in component and route handler

Other

tRPC

  • Generates files to configure tRPC with the app router.
  • Provides client-side tRPC and scaffolds server-side configuration using the experimental server-invoker pattern.
  • Wraps the root layout in the tRPC provider.

Shadcn-UI

  • Installs and configures Shadcn-UI including button and toast components.
  • Inserts the toast-provider (<Toaster />) to the root layout for instant toast notifications in your Next.js app.

Stripe

  • Installs and configures Stripe within your Next.js project so you can start accepting subscription payments.

Resend

  • Installs and configures Resend

Kirimase also adds relevant keys to your .env which you'll need to provide values for.


2. kirimase generate

Akin to rails scaffold but for Next.js:

Kirimase generates:

a) Model:

  • Generates a drizzle schema with column types based on your SQL flavor and database provider.
  • Uses drizzle-zod to generate Zod schemas for frontend and backend validation.
  • Generates queries and mutations for CRUD operations, fully typed and optimized for consumption via a Next.js front-end.

b) Controller:

  • Gives you an option to scaffold tRPC, Server Actions and/or API routes.
  • Uses Zod schemas from models for request validation.
  • Includes built-in error handling for API routes and auto-adding of tRPC routes to the root router.

c) Views:

  • Scaffolds views using Shadcn-UI to enable immediate CRUD operations (including select fields for adding relations and datepickers for dates).
  • Option to use either React Hook Form with tRPC or plain React (useOptimistic and useValidated Form hooks)

Run in non-interactive mode

As of v0.0.23, you can run kirimase init and kirimase add entirely via the command line as follows:

kirimase init -sf yes -pm bun --orm prisma -db pg -a next-auth -ap github discord -mp trpc stripe resend -cl shadcn-ui -ie yes
Command Short Flag Long Option Description Argument
init - - initialise and configure kirimase -
- -sf --src-folder use a src folder yes or no
- -pm --package-manager package manager <pm>
- -cl --component-lib component library <component-lib>
- -o --orm orm <orm>
- -db --db database ("pg", "mysql", "sqlite") <db>
- -dbp --db-provider database provider - important if using drizzle <dbp>
- -a --auth auth <auth>
- -ap --auth-providers auth providers (if using next-auth) <providers>
- -mp --misc-packages packages ("trpc", "shadcn-ui", "resend") <packages>
- -ie --include-example include example yes or no

Contributing

Keen on enhancing Kirimase? Contributions, bug reports, and feature requests are always welcome. Feel free to open an issue or submit a pull request.

To run locally:

pnpm i
pnpm run dev

npm install -g . (in a second terminal - this will then make kirimase available across your machine using "kirimase *command*")

License

MIT

kirimase's People

Contributors

afogel avatar blupandaman avatar codeagencybe avatar dinhkhanh avatar dugjason avatar elie222 avatar josephdburdick avatar kairedblue avatar kddige avatar martinnormark avatar nicoalbanese avatar osterkraft avatar pjholmes avatar sa-ar avatar sooditk avatar yursky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kirimase's Issues

Fix: Clerk redirect

Clerk was giving me a 404 on redirect to '/' (and other routes) after trying to use OAuth.

The fix was to change the folder structure for Clerk sign-in and sign-up to include a catch-all segment.

The following replacements needed to be made:
src/app/sign-in/page.tsx -> src/app/sign-in/[[...sign-in]]/page.tsx
src/app/sign-up/page.tsx -> src/app/sign-up/[[...sign-up]]/page.tsx

See the Clerk quick start for more info: https://clerk.com/docs/quickstarts/nextjs#build-your-sign-in-page

Model file is missing import for uniqueIndex with Drizzle

If the user selects an index and is using Drizzle, the generated model code is missing the import for uniqueIndex from drizzle-orm/pg-core.

I came up with the following code, but did not submit a PR because it differs significantly from your style. But perhaps it can be of some use. (I also did not test it).

This is in src/commands/generate/generators/model/schema/index.ts

if (orm === "drizzle") {
    const usedTypes = getUsedTypes(fields, mappings);
    const referenceImports = getReferenceImports(fields);
    const uniqueTypes = getUniqueTypes(usedTypes, belongsToUser, dbType);

    const names = [
      ...uniqueTypes, 
      schema.index ? 'uniqueIndex' : null,
      mappings.tableFunc
    ].filter(name => !!name).join(', ')

    const imports = [
      `import { ${names} } from "drizzle-orm/${dbType}-core";`,
      'import { createInsertSchema, createSelectSchema } from "drizzle-zod";',
      `import { z } from "zod";`,
      ...referenceImports,
      belongsToUser && provider !== "planetscale" && authType === "next-auth" ? 'import { users } from "./auth";' : null,
      `import { get${tableNameCapitalised} } from "@/lib/api/${tableNameCamelCase}/queries";`,
    ].filter(stmt => !!stmt).join("\n")
  }

Add support for Prisma ORM

Hey there! I'm really excited about the CLI package, but I've been thinking, it would be awesome if we could add support for Prisma. Right now, it's all about Drizzle ORM, but having Prisma as an option would give users more freedom to choose what suits them best.

After Intializing a project using Kirimase i get this error when i execute npx prisma generate

I configured the project to use NextAuth ,Planetscale , MySQL , Shadcn ui , trpc , tailwindcss , typescript , resend

Repo : https://github.com/abdou6666/coachini-app


Error when i execute npx prisma generate :

Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Error: Get config: Schema Parsing P1012

error: Error validating: This line is not a valid definition within a generator.
--> schema.prisma:10
|
9 | provider = "zod-prisma"
10 | output = "./zod" // (default) the directory where generated zod schemas will be saved
11 | relationModel = true // (default) Create and export both plain and related models.
|
error: Error validating: This line is not a valid definition within a generator.
--> schema.prisma:11
|
10 | output = "./zod" // (default) the directory where generated zod schemas will be saved
11 | relationModel = true // (default) Create and export both plain and related models.
12 | modelCase = "camelCase" // Output models using camel case (ex. userModel, postModel)
|
error: Error validating: This line is not a valid definition within a generator.
--> schema.prisma:12
|
11 | relationModel = true // (default) Create and export both plain and related models.
12 | modelCase = "camelCase" // Output models using camel case (ex. userModel, postModel)
13 | modelSuffix = "Schema" // (default) Suffix to apply to your prisma models when naming Zod schemas
|
error: Error validating: This line is not a valid definition within a generator.
--> schema.prisma:13
|
12 | modelCase = "camelCase" // Output models using camel case (ex. userModel, postModel)
13 | modelSuffix = "Schema" // (default) Suffix to apply to your prisma models when naming Zod schemas
14 | useDecimalJs = true // represent the prisma Decimal type using Decimal.js (as Prisma does)
|
error: Error validating: This line is not a valid definition within a generator.
--> schema.prisma:14
|
13 | modelSuffix = "Schema" // (default) Suffix to apply to your prisma models when naming Zod schemas
14 | useDecimalJs = true // represent the prisma Decimal type using Decimal.js (as Prisma does)
15 | prismaJsonNullability = true // (default) uses prisma's scheme for JSON field nullability
|
error: Error validating: This line is not a valid definition within a generator.
--> schema.prisma:15
|
14 | useDecimalJs = true // represent the prisma Decimal type using Decimal.js (as Prisma does)
15 | prismaJsonNullability = true // (default) uses prisma's scheme for JSON field nullability
16 | }
|

Validation Error Count: 6

Prisma CLI Version : 3.15.2

When selecting mysql2, a sqlite connector is created instead.

As the title says. Kirimase creates the wrong connector for mysql2.

image

image

I replaced it with this and it works fine. But i'm not sure if it's the best way to do it. Maybe it should be a pool connection.

image

A separate issue: Migrating does not work with maria db. I know they are different, but yeah. Just to let you know.

image

BUG: SQlite+SignIn !

Hello and thank you for this promissing project!
Followed the Demo but picked Sqlite and no third party auth provider (assuming it will simply use the sqlite for authentication).
Importing the provided SignIn and using it on the Home page works well (as shown in the DEMO).
However, clicking on the SignIn button leads to "the" error page: http://localhost:3000/api/auth/error
No info in the console log. Inspecting the Network tab shows a 200 OK request to http://localhost:3000/**api/auth/providers** followed immediately by redirection to the error page: http://localhost:3000/**api/auth/error**
image

Add CredentialProvider option for Auth.js

Hi,

I love this project, it saves time through the setup and giving a proper folder structure.

In this setup when i choose Auth.js i see Discord, Google, GitHub, but no Credentials Provider option.

Auth.js official website states that they are discouraging "Credentials Provider" as part of there providers setup but in real world most people still use UserName/Email and Password login.

At the end of the day developer have to do what CLIENT wants, but not the other way around. Can you please provide Credentials option in Auth.js,
since setting up Credentials option is not as easy as setting up google.

404 error

When I install from

$ pnpm create next-app

$ kirimase init

? Are you using a 'src' folder? Yes
? Please pick your preferred package manager PNPM
✔ File created at ./kirimase.config.json 
✔ Kirimase initialized! 
ℹ You can now add packages.
? Select a package to add : Drizzle, TRPC, Auth.js (NextAuth), Shadcn UI
? Please choose your DB type : SQLite
? Please choose your DB Provider : better-sqlite3
? Would you like to include an example model? (suggested for new users) yes

Select a provider to add : discord

✔ Would you like to use TypeScript (recommended)? … yes
✔ Which style would you like to use? › Default
✔ Which color would you like to use as base color? › Slate
✔ Where is your global CSS file? … app/globals.css
✔ Would you like to use CSS variables for colors? … yes
✔ Where is your tailwind.config.js located? … tailwind.config.js
✔ Configure the import alias for components: … @/components
✔ Configure the import alias for utils: … @/lib/utils
✔ Are you using React Server Components? … yes
✔ Write configuration to components.json. Proceed? … yes

$ pnpm run dev

-> error 404 page

It works before kirimase init

Dependency Installation Fails Using Bun with Certain Options

Description:
When using bun as a package manager in conjunction with certain package and database options, the dependency installation occasionally fails.

Steps to reproduce:

  1. Execute the command kirimase init.
  2. When prompted to choose a package manager, select bun.
  3. When prompted to add packages, choose drizzle.
  4. For DB Type, opt for mysql.
  5. For the provider, pick Mysql2.
  6. During the dependency installation phase, the process breaks with the following error:
bun add v0.8.1 (16b4bf34)
error: unrecognised dependency format: 
An error occurred: command "bun add -D drizzle-kit tsx dotenv " exited with code undefined

Possible Cause and Solution:
I suspect that the underlying issue might stem from the trailing space at the end of the command. A potential fix could involve trimming the command string before execution.

Next Steps:
I'm currently looking into this problem. I'll open a PR once I've found a solution.

small issue with mysql/planetscale

I saw on the drizzle-orm docs that MySQL doesn't support returning an updated record. So I guess that's why this part of the generated code is giving errors.

import { db } from "@/lib/db";
import { eq } from "drizzle-orm";
import { NewComputer, insertComputerSchema, computers, computerIdSchema, ComputerId } from "@/lib/db/schema/computers";

export const createComputer = async (computer: NewComputer) => {
  const newComputer = insertComputerSchema.parse(computer);
  try {
    const [c] = await db.insert(computers).values(newComputer).returning();
    return { computer: c };
  } catch (err) {
    return { error: (err as Error).message ?? "Error, please try again" };
  }
};

export const updateComputer = async (id: ComputerId, computer: NewComputer) => {
  const { id: computerId } = computerIdSchema.parse({ id });
  const newComputer = insertComputerSchema.parse(computer);
  try {
    const [c] = await db
     .update(computers)
     .set(newComputer)
     .where(eq(computers.id, computerId!))
     .returning();
    return { computer: c };
  } catch (err) {
    return { error: (err as Error).message ?? "Error, please try again" };
  }
};

export const deleteComputer = async (id: ComputerId) => {
  const { id: computerId } = computerIdSchema.parse({ id });
  try {
    const [c] = await db.delete(computers).where(eq(computers.id, computerId!)).returning();
    return { computer: c };
  } catch (err) {
    return { error: (err as Error).message ?? "Error, please try again" };
  }
};

Throws this
Screenshot 2023-09-06 at 10 55 36

Alternative ways to perform the generate command

Schemas are really hard to define in the CLI. If we really need relations to exist in the application that we're developing it would be cool if we could implement the following

  1. Create all schemas in a separate file, say schemas.prisma, we declare all the relations, and all fields.
  2. When kirimase generate runs, it can detect all the schemas in schemas.prisma, we can feed in the option to convert one of these schemas into a TRPC, API or App Route.
  3. Accordingly the form will also help us add data to the database, with their relations declared. These relations can be viewed in the form of tables, like it is shown in this tutorial. Ecommerce Admin Dashboard.

feature add: update package.json so that it has script for prisma generate for development and production

when we try to do pnpm dev, if we don't do npx prisma db push && npx prisma generate we face some db issue,
so this is manually done by developer, if we can update our dev script
from: "dev": "next dev"
to: "dev": "npx prisma db push && npx prisma generate && next dev"

the developer no longer needs to db push and the db generate

but that was not the big deal

when we deploy our app we must have this script in our build script
else while deploying prisma/db will complain us that something is missing

so basically cli should update the build script
from: "build": "next dev"
to: "build": "npx prisma db push && npx prisma generate && next build",

if the cli could update tha package.json for dev and build scripts some pain can be taken away, with this automatically people will not face issue while production in case they forget about this part.

Turbo Repo Kirimase 👀

Is it possible to release a version but with turbo repo, to be able to share components / ui / trpc / db ....

Dev build errors on local & vercel, on a fresh 'kirimase init'

Hello, so I've been trying to get this to run for the past week, heres the error:

It occurs whenever i call const data = api.computers.getComputers.query(); from the index page.tsx server-side.
This does not occur if i callconst data = trpc.computers.getComputers.useQuery(); from client-side.
It does not crash the dev environment (won't build), but error still shows in terminal.
Anybody else encounter this?

revalidating cache with key: async (_cachebuster)=>{
                        //   // _cachebuster is not used by us but to make sure
                        //   // that calls with different tags are properly separated
                        //   // @link https://github.com/trpc/trpc/issues/4622
                        const procedureResult = await (0,_trpc_server__WEBPACK_IMPORTED_MODULE_1__.callProcedure)({
                            procedures: opts.router._def.procedures,
                            path,
                            rawInput: input,
                            ctx: ctx,
                            type
                        });
                        // We need to serialize cause the cache only accepts JSON
                        return runtime.transformer.serialize(procedureResult);
                    }-computers,getComputers-["computers.getComputers"] Error: cache: 'force-cache' used on fetch for https://aws.connect.psdb.cloud/psdb.v1alpha1.Database/Execute with 'export const fetchCache = 'only-no-store'
    at /Users/philipp/Code/delphox/node_modules/next/dist/server/lib/patch-fetch.js:187:27
    ... 14 lines matching cause stack trace ...
    at QueryPromise.then (webpack-internal:///(rsc)/./node_modules/drizzle-orm/alias-cf8e03cd.mjs:504:21) {
  code: 'INTERNAL_SERVER_ERROR',
  name: 'TRPCError',
  [cause]: Error: cache: 'force-cache' used on fetch for https://aws.connect.psdb.cloud/psdb.v1alpha1.Database/Execute with 'export const fetchCache = 'only-no-store'
      at /Users/philipp/Code/delphox/node_modules/next/dist/server/lib/patch-fetch.js:187:27
      at /Users/philipp/Code/delphox/node_modules/next/dist/server/lib/trace/tracer.js:117:36
      at NoopContextManager.with (/Users/philipp/Code/delphox/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)
      at ContextAPI.with (/Users/philipp/Code/delphox/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)
      at NoopTracer.startActiveSpan (/Users/philipp/Code/delphox/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)
      at ProxyTracer.startActiveSpan (/Users/philipp/Code/delphox/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)
      at /Users/philipp/Code/delphox/node_modules/next/dist/server/lib/trace/tracer.js:106:107
      at NoopContextManager.with (/Users/philipp/Code/delphox/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)
      at ContextAPI.with (/Users/philipp/Code/delphox/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)
      at NextTracerImpl.trace (/Users/philipp/Code/delphox/node_modules/next/dist/server/lib/trace/tracer.js:106:32)
      at globalThis.fetch (/Users/philipp/Code/delphox/node_modules/next/dist/server/lib/patch-fetch.js:93:47)
      at postJSON (webpack-internal:///(rsc)/./node_modules/@planetscale/database/dist/index.js:147:28)
      at Connection.execute (webpack-internal:///(rsc)/./node_modules/@planetscale/database/dist/index.js:99:29)
      at PlanetScalePreparedQuery.execute (webpack-internal:///(rsc)/./node_modules/drizzle-orm/planetscale-serverless/index.mjs:40:39)
      at MySqlSelect.execute (webpack-internal:///(rsc)/./node_modules/drizzle-orm/view-23898f21.mjs:1314:35)
      at QueryPromise.then (webpack-internal:///(rsc)/./node_modules/drizzle-orm/alias-cf8e03cd.mjs:504:21)
}

not from the package but need help

I'm getting this error when trying to use this

// RSC page 
const checkOnboard = await api.user.checkOnboarding.query();
Screenshot 2023-09-09 at 17 33 24

not sure if it's related to TRPC or planetscale itself 😢

I'm using the default implementation from kirimase for trpc on rsc

Generated model that belongs to user doesn't import userId type

Config kirimase.config.json:

{
  "driver": "pg",
  "hasSrc": false,
  "provider": "postgresjs",
  "packages": [
    "drizzle",
    "trpc",
    "next-auth",
    "shadcn-ui"
  ],
  "preferredPackageManager": "npm"
}

Command:

$ npx kirimase@latest generate

ℹ Quickly generate your Model (Drizzle schema + queries / mutations), Controllers (API Routes and TRPC Routes), and Views                                                 7:47:09 PM
? Please select the resources you would like to generate: Model, API Route, TRPC Route, Views + Components (with Shadcn UI, requires TRPC route)
? Please enter the table name (plural and in snake_case): errors
? Please select the type of this field: boolean
? Please enter the field name (in snake_case): applied
? Is this field required? yes
? Would you like to add another field? no
? Would you like to set up an index? no
? Does this model belong to the user? yes
✔ File created at lib/db/schema/errors.ts                                                                                                                                 7:47:35 PM
✔ File created at lib/api/errors/queries.ts                                                                                                                               7:47:35 PM
✔ File created at lib/api/errors/mutations.ts                                                                                                                             7:47:35 PM
✔ File created at app/api/errors/route.ts                                                                                                                                 7:47:35 PM
✔ File created at lib/server/routers/errors.ts                                                                                                                            7:47:35 PM
✔ File replaced at lib/server/routers/_app.ts                                                                                                                             7:47:35 PM
✔ Added errors router to root router successfully.                                                                                                                        7:47:35 PM
✔ File created at app/errors/page.tsx                                                                                                                                     7:47:35 PM
✔ File created at components/errors/ErrorList.tsx                                                                                                                         7:47:35 PM
✔ File created at components/errors/ErrorForm.tsx                                                                                                                         7:47:35 PM
✔ File created at components/errors/ErrorModal.tsx                                                                                                                        7:47:35 PM
ℹ All items already installed.                                                                                                                                            7:47:35 PM

Model lib/db/schema/errors.ts:
Screenshot 2023-09-04 at 19 51 23

Model with reference to another table causes issues in view

Generating a model that references another table causes the model view to use wrong types.

$ npx kirimase@latest generate

ℹ Quickly generate your Model (Drizzle schema + queries / mutations), Controllers (API Routes and TRPC Routes), and Views   9:12:44 PM
? Please select the resources you would like to generate: Model, TRPC Route
? Please enter the table name (plural and in snake_case): posts
? Please select the type of this field: text
? Please enter the field name (in snake_case): content
? Is this field required? yes
? Would you like to add another field? yes
? Please select the type of this field: varchar
? Please enter the field name (in snake_case): title
? Is this field required? yes
? Would you like to add another field? yes
? Please select the type of this field: number
? Please enter the field name (in snake_case): likes
? Is this field required? yes
? Would you like to add another field? yes
? Please select the type of this field: references
? Which table does it reference? (in snake_case if more than one word) categories
? Would you like to cascade on delete? no
? Would you like to add another field? no
? Would you like to set up an index? no
? Does this model belong to the user? yes
✔ File created at lib/db/schema/posts.ts                                                                                    9:13:55 PM
✔ File created at lib/api/posts/queries.ts                                                                                  9:13:55 PM
✔ File created at lib/api/posts/mutations.ts                                                                                9:13:55 PM
✔ File created at lib/server/routers/posts.ts                                                                               9:13:55 PM
✔ File replaced at lib/server/routers/_app.ts                                                                               9:13:55 PM
✔ Added posts router to root router successfully.                                                                           9:13:55 PM

Error in model view page file:

image

Type '{ posts: { id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }; categories: { id: number; name: string; } | null; }[]' is not assignable to type '{ id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }[]'.
  Type '{ posts: { id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }; categories: { id: number; name: string; } | null; }' is missing the following properties from type '{ id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }': id, content, title, likes, and 2 more.ts(2322)
PostList.tsx(6, 47): The expected type comes from property 'posts' which is declared here on type 'IntrinsicAttributes & { posts: { id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }[]; }'

Error in model list component:

image

No overload matches this call.
  Overload 1 of 2, '(input: void | undefined, opts: DefinedUseTRPCQueryOptions<"posts.getPosts", void | undefined, { posts: { posts: { id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }; categories: { ...; } | null; }[]; }, { ...; }, TRPCClientErrorLike<...>, { ...; }>): DefinedUseTRPCQueryResult<...>', gave the following error.
    Type '{ id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }[]' is not assignable to type '{ posts: { id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }; categories: { id: number; name: string; } | null; }[]'.
      Type '{ id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }' is missing the following properties from type '{ posts: { id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }; categories: { id: number; name: string; } | null; }': posts, categories
  Overload 2 of 2, '(input: void | undefined, opts?: UseTRPCQueryOptions<"posts.getPosts", void | undefined, { posts: { posts: { id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }; categories: { ...; } | null; }[]; }, { ...; }, TRPCClientErrorLike<...>, { ...; }> | undefined): UseTRPCQueryResult<...>', gave the following error.
    Type '{ id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }[]' is not assignable to type '{ posts: { id: number; content: string; title: string; likes: number; categorieId: number; userId: string; }; categories: { id: number; name: string; } | null; }[]'.ts(2769)

Google Auth Erroring out

Started with a fresh project.

I've used Nextauth + Google provider a handful of times before.

Added my Google client id and google client secret to the .env but still having issues.

Dying to get this working because I can't imagine how fast you can move with that generate function.

SCR-20230918-suop image

Google OAuth is not compatible with MySQL accounts table

Using MySQL and Google OAuth causes issues because the column id_token of table accounts is too short.
See this comment.

Error:

$ next dev

- info Loaded env from /Users/marvinkaunda/Desktop/cocktailanddinner-next-app/.env
- ready started server on [::]:3000, url: http://localhost:3000
- event compiled client and server successfully in 241 ms (20 modules)
- wait compiling...
- event compiled client and server successfully in 87 ms (20 modules)
- info Loaded env from /Users/marvinkaunda/Desktop/cocktailanddinner-next-app/.env
- info Loaded env from /Users/marvinkaunda/Desktop/cocktailanddinner-next-app/.env
- wait compiling /page (client and server)...
- event compiled client and server successfully in 867 ms (645 modules)
- wait compiling...
- event compiled successfully in 107 ms (351 modules)
- wait compiling /api/auth/[...nextauth]/route (client and server)...
- event compiled client and server successfully in 545 ms (918 modules)
[next-auth][warn][NEXTAUTH_URL] 
https://next-auth.js.org/warnings#nextauth_url
[next-auth][error][adapter_error_linkAccount] 
https://next-auth.js.org/errors#adapter_error_linkaccount target: cocktailanddinner-next-app.-.primary: vttablet: rp
https://next-auth.js.org/errors#adapter_error_linkaccount target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (C
https://next-auth.js.org/errors#adapter_error_linkaccount target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, 
https://next-auth.js.org/errors#adapter_error_linkaccount target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR 
https://next-auth.js.org/errors#adapter_error_linkaccount target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, 
https://next-auth.js.org/errors#adapter_error_linkaccount target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED} {
  message: `target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data to
  message: `target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert i
  message: `target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, i
  message: `target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, 
  message: `target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, defa
  message: `target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED}`,
  stack: `DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument d
  stack: `DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): S
  stack: `DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_t
  stack: `DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /*
  stack: `DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VAR
  stack: `DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED}\n` +
    '    at Connection.execute (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_mod
    '    at Connection.execute (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:108:19)\n' +
    '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
    '    at async linkAccount (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modul
    '    at async linkAccount (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@auth/drizzle-adapter/lib/mysql.js:142:13)',
  name: 'DatabaseError'
}
[next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR] 
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet:
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001)
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_toke
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCH
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR *
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED} DatabaseError: target: cocktailanddinne
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED} DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED} DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, 
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED} DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED} DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 
https://next-auth.js.org/errors#oauth_callback_handler_error target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED} DatabaseError: target: cocktailanddinner-next-app.-.primary: vttablet: rpc error: code = InvalidArgument desc = Data too long for column 'id_token' at row 1 (errno 1406) (sqlstate 22001) (CallerID: lbc4zarfslylp19daqo0): Sql: "insert into account(userId, type, provider, providerAccountId, refresh_token, access_token, expires_at, token_type, scope, id_token, session_state) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* VARCHAR */, :vtg4 /* VARCHAR */, default, :vtg5 /* VARCHAR */, :vtg6 /* INT64 */, :vtg7 /* VARCHAR */, :vtg8 /* VARCHAR */, :vtg9 /* VARCHAR */, default)", BindVars: {REDACTED}
    at Connection.execute (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/
    at Connection.execute (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:108:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async linkAccount (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@a
    at async linkAccount (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@auth/drizzle-adapter/lib/mysql.js:142:13) {
  name: 'LinkAccountError',
  code: undefined
}

use src/app/globals.css if "src" folder was already indicated

The cli asks if I'm using an src folder. iIf I answer yes, it will still default to app/globals.css later when it asks where my globals.css is.

It seems sensible that the cli assumes src/app/globals.css when its told that src/ is being used.

Repro:

  • create-next-app with default settings (or however)
  • kirimase init
  • answer yes when asked if using src/
  • when asked where globals.css is, it will still assume app/globals.css without the parent dir src/

Regeneration of the same model name causes issues

When I generate a model with the same name twice then the model gets imported twice in _app root router.

image

Either disallow generating models with the same name twice or allow overwriting (notify the user) with only one import in _app root router.

Non-interactive mode for CLI

As a user I would like to pass command line arguments to set up a new project non-interactively.

That allows users to initialize kirimase using command line arguments e.g. these:
--src-dir/--no-src-dir
--use-npm/--use-pnpm/--use-yarn
--packages
--use-postgres /--use-mysql /--use-sqllite
--include-example-model
...

That allows users to generate models using command line arguments e.g. these:
--resources
--table-name
--fields
--setup-index
--belongs-to-user
....

[Feature] Add User Role

It would be nice to add the user role as an enum {'admin', 'user'}, and it should reflect in the NextAuth Sessions and the DB

Feature request: Support of Kysely

Hi.

I love your project and have used it quite a lot. I'm using a lot of geospatial data in my projects and found that Drizzle is not really the best query builder for this but that https://kysely.dev/ actually works a little bit better because it's a tiny bit more mature.
Since those 2 projects are relatively similar, I wonder if it might be interesting for you to support them both?

Type 'Date' is not assignable to type 'string'.

Hey in the Form component when creating a new schema that contains a date:

`const form = useForm<z.infer<typeof insertAmenitieParams>>({
    // latest Zod release has introduced a TS error with zodResolver
    // open issue: https://github.com/colinhacks/zod/issues/2663
    // errors locally but not in production
    resolver: zodResolver(insertAmenitieParams),
    defaultValues: amenitie ?? {
      name: "",
     imageUrl: "",
     listingId: "",
     category: "",
     createdAt: "",
     updatedAt: ""
    },`

throws a typescript error, which I fixed with:

const form = useForm<z.infer<typeof insertAmenitieParams>>({
    resolver: zodResolver(insertAmenitieParams),
    defaultValues: amenitie
      ? {
          ...amenitie,
          createdAt: amenitie.createdAt.toISOString(),
          updatedAt: amenitie.updatedAt.toISOString(),
        }
      : {
          name: "",
          imageUrl: "",
          listingId: "",
          category: "",
          createdAt: new Date().toISOString(),
          updatedAt: new Date().toISOString(),
        },
  });

Errors when running generate

Every time i run generate I get the error
ENOENT: no such file or directory, open 'src/app/layout.tsx'

Error: ENOENT: no such file or directory, open 'src/app/layout.tsx'
    at Object.openSync (node:fs:601:3)
    at Object.readFileSync (node:fs:469:35)
    at addContextProviderToLayout (file:///nvm/versions/node/v18.16.1/lib/node_modules/kirimase/dist/commands/add/utils.js:17:28)
    at addNextAuth (file:///nvm/versions/node/v18.16.1/lib/node_modules/kirimase/dist/commands/add/auth/next-auth/index.js:67:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async addPackage (file:///nvm/versions/node/v18.16.1/lib/node_modules/kirimase/dist/commands/add/index.js:36:17) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'src/app/layout.tsx'
}

Error while trying to use TRPC serverside

I'm trying to use serverside TRPC client, I think it should be used like so:

import { api } from "@/lib/trpc/api";

export default async function Home() {
  const data = await api.computers.getComputers.query();

but it's giving me the error of:

Error: cache: 'force-cache' used on fetch for https://localhost:3306/psdb.v1alpha1.Database/Execute with 'export const fetchCache = 'only-no-store'

I can't seem to find any solution for that, Am I using it wrong?

TypeError while running kirimase generate

I get this error when running generate.

(main⚡) » kirimase generate
ℹ Quickly generate your Model (Drizzle schema + queries / mutations), Controllers (API Routes and TRPC Routes), and Views 12:40:26 AM
? Please select the resources you would like to generate: Model, TRPC Route, Views + Components (with Shadcn UI, requires TRPC route)
? Please enter the table name (plural and in snake_case): drills
file:///usr/local/lib/node_modules/kirimase/node_modules/@inquirer/core/dist/esm/lib/use-prefix.mjs:17
const frame = tick % spinner.frames.length;
^

TypeError: Cannot read properties of undefined (reading 'frames')
at usePrefix (file:///usr/local/lib/node_modules/kirimase/node_modules/@inquirer/core/dist/esm/lib/use-prefix.mjs:17:38)
at file:///usr/local/lib/node_modules/kirimase/node_modules/@inquirer/input/dist/esm/index.mjs:9:20
at workLoop (file:///usr/local/lib/node_modules/kirimase/node_modules/@inquirer/core/dist/esm/lib/create-prompt.mjs:74:42)
at store.handleChange (file:///usr/local/lib/node_modules/kirimase/node_modules/@inquirer/core/dist/esm/lib/create-prompt.mjs:72:48)
at ReadStream.wrapped (file:///usr/local/lib/node_modules/kirimase/node_modules/@inquirer/core/dist/esm/lib/hook-engine.mjs:43:13)
at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
at ReadStream.bound (node:async_hooks:235:16)
at ReadStream.emit (node:events:525:35)
at emitKeys (node:internal/readline/utils:357:14)
at emitKeys.next ()

TypeError: Property 'readonly' is missing

The example db schema src/lib/db/schema/computers.ts produces a TypeScript error when trying to infer the type from the generated schema as in z.infer<typeof selectComputerSchema>.

Not a major issue, but causes build failure which is unfortunate. Any help is much appreciated!

The error:

Type 'ZodObject<{ id: ZodNumber; brand: ZodString; cores: ZodNumber; }, UnknownKeysParam, ZodTypeAny, { id: number; brand: string; cores: number; }, { ...; }>' does not satisfy the constraint 'ZodType<any, any, any>'.

Property 'readonly' is missing in type 'ZodObject<{ id: ZodNumber; brand: ZodString; cores: ZodNumber; }, UnknownKeysParam, ZodTypeAny, { id: number; brand: string; cores: number; }, { ...; }>' but required in type 'ZodType<any, any, any>'.ts(2344)

types.d.ts(91, 5): 'readonly' is declared here.

I guess the readonly aspect is an issue with Zod. I found something kinda similar here that adds as const, but trying that yields:

A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.ts(1355)

I'll keep investigating, but I'm just a TypeScript novice.

My kirimase.config.json:

{
  "hasSrc": true,
  "packages": [
    "drizzle",
    "clerk",
    "trpc"
  ],
  "preferredPackageManager": "bun",
  "rootPath": "src/",
  "driver": "pg",
  "provider": "supabase",
  "orm": "drizzle",
  "auth": "clerk"
}

SignIn component added by `kirimase init` even when nextauth wasn't selected

Repro:

  • I'm using pnpm
  • from fresh create-next-app starter with the default options
  • ran kirimase init and selected shadcn, trpc, and drizzle but NOT nextauth
  • src/components/auth/SignIn.tsx file created, looks like this
"use client";
import { useSession, signIn, signOut } from "next-auth/react";
import { Button } from "../ui/button";

export default function SignIn() {
  const { data: session, status } = useSession();

  if (status === "loading") return <div>Loading...</div>;

  if (session) {
    return (
      <>
        Signed in as {session.user?.email} <br />
        <Button variant={"destructive"} onClick={() => signOut()}>Sign out</Button>
      </>
    );
  }
  return (
    <>
      Not signed in <br />
      <Button onClick={() => signIn()}>Sign in</Button>
    </>
  );
}

Unable to install dependencies

Great project, I will be saving a lot of time using it.

kirimase add had issues while trying to install dependencies. When I use shadcn-ui cli package to install deps it works fine to call pnpm.

Error:

$ pnpm kirimase add
? Select a package to add
Auth.js (NextAuth)
? Select a provider to add
github
[15:22:42] ✔ File created at src/app/api/auth/[...nextauth]/route.ts
[15:22:42] ✔ File created at src/lib/auth/Provider.tsx
[15:22:42] ✔ File created at src/lib/auth/utils.ts
[15:22:42] ✔ File created at src/lib/db/schema/auth.ts        
[15:22:42] ✔ File created at src/components/auth/SignIn.tsx   
[15:22:42] ◐ Installing packages: @auth/core @auth/drizzle-adapter next-auth ...
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: spawn pnpm ENOENT       
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn pnpm',       
  path: 'pnpm',
  spawnargs: [ 'install', '@auth/core', '@auth/drizzle-adapter', 'next-auth' ]
}

Node.js v18.16.0

Can't resolve 'lucide-react' when generating model view

It seems like the lucide-react icon library doesn't get automatically installed when generating model views.

$ npx kirimase@latest generate

ℹ Quickly generate your Model (Drizzle schema + queries / mutations), Controllers (API Routes and TRPC Routes), and Views   8:41:43 PM
? Please select the resources you would like to generate: Model, API Route, TRPC Route, Views + Components (with Shadcn UI, requires TRPC
 route)
? Please enter the table name (plural and in snake_case): posts
? Please select the type of this field: text
? Please enter the field name (in snake_case): content
? Is this field required? yes
? Would you like to add another field? yes
? Please select the type of this field: varchar
? Please enter the field name (in snake_case): title
? Is this field required? yes
? Would you like to add another field? yes
? Please select the type of this field: number
? Please enter the field name (in snake_case): likes
? Is this field required? yes
? Would you like to add another field? no
? Would you like to set up an index? no
? Does this model belong to the user? yes
✔ File created at lib/db/schema/posts.ts                                                                                    8:43:22 PM
✔ File created at lib/api/posts/queries.ts                                                                                  8:43:22 PM
✔ File created at lib/api/posts/mutations.ts                                                                                8:43:22 PM
✔ File created at app/api/posts/route.ts                                                                                    8:43:22 PM
✔ File created at lib/server/routers/posts.ts                                                                               8:43:22 PM
✔ File replaced at lib/server/routers/_app.ts                                                                               8:43:22 PM
✔ Added posts router to root router successfully.                                                                           8:43:22 PM
✔ File created at app/posts/page.tsx                                                                                        8:43:22 PM
✔ File created at components/posts/PostList.tsx                                                                             8:43:22 PM
✔ File created at components/posts/PostForm.tsx                                                                             8:43:22 PM
✔ File created at components/posts/PostModal.tsx                                                                            8:43:22 PM
◐ Installing shadcn-ui components: dialog, form, input, label                                                                8:43:22 PM
Packages: +197
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 197, reused 197, downloaded 0, added 197, done
✔ Ready to install components and dependencies. Proceed? … yes
✔ Done.
✔ Installed components: dialog, form, input, label                                                                          8:43:41 PM

Make it easily extensible

Would be cool if there was a way to add to this without having to make a PR.
With each project being able to add pieces that fit their own workflow even if it doesn't help the wider public.

Sort of like VS Code snippets. You can use a package from someone else. Or write your own.

Error in setting up project

I am facing several issues while starting the project. I checked on every option while setting up the project.

Here is error:

\Codes\next-apps\vaibkart> npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Error: Get config: Schema Parsing P1012

error: Error validating: This line is not a valid definition within a generator.
  -->  schema.prisma:15
   | 
14 |   provider              = "zod-prisma"
15 |   output                = "./zod" // (default) the directory where generated zod schemas will be saved
16 |   relationModel         = true // (default) Create and export both plain and related models.
   | 
error: Error validating: This line is not a valid definition within a generator.
  -->  schema.prisma:16
   | 
15 |   output                = "./zod" // (default) the directory where generated zod schemas will be saved
16 |   relationModel         = true // (default) Create and export both plain and related models.
17 |   modelCase             = "camelCase" // Output models using camel case (ex. userModel, postModel)
   | 
error: Error validating: This line is not a valid definition within a generator.
  -->  schema.prisma:17
   | 
16 |   relationModel         = true // (default) Create and export both plain and related models.
17 |   modelCase             = "camelCase" // Output models using camel case (ex. userModel, postModel)
18 |   modelSuffix           = "Schema" // (default) Suffix to apply to your prisma models when naming Zod schemas      
   | 
error: Error validating: This line is not a valid definition within a generator.
  -->  schema.prisma:18
   | 
17 |   modelCase             = "camelCase" // Output models using camel case (ex. userModel, postModel)
18 |   modelSuffix           = "Schema" // (default) Suffix to apply to your prisma models when naming Zod schemas      
19 |   useDecimalJs          = true // represent the prisma Decimal type using Decimal.js (as Prisma does)
   | 
error: Error validating: This line is not a valid definition within a generator.
  -->  schema.prisma:19
   | 
18 |   modelSuffix           = "Schema" // (default) Suffix to apply to your prisma models when naming Zod schemas      
19 |   useDecimalJs          = true // represent the prisma Decimal type using Decimal.js (as Prisma does)
20 |   prismaJsonNullability = true // (default) uses prisma's scheme for JSON field nullability
   | 
error: Error validating: This line is not a valid definition within a generator.
  -->  schema.prisma:20
   | 
19 |   useDecimalJs          = true // represent the prisma Decimal type using Decimal.js (as Prisma does)
20 |   prismaJsonNullability = true // (default) uses prisma's scheme for JSON field nullability
21 | }
   | 

Validation Error Count: 6


Prisma CLI Version : 3.15.2

schema.prima

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

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

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

generator zod {
  provider              = "zod-prisma"
  output                = "./zod" // (default) the directory where generated zod schemas will be saved
  relationModel         = true // (default) Create and export both plain and related models.
  modelCase             = "camelCase" // Output models using camel case (ex. userModel, postModel)
  modelSuffix           = "Schema" // (default) Suffix to apply to your prisma models when naming Zod schemas
  useDecimalJs          = true // represent the prisma Decimal type using Decimal.js (as Prisma does)
  prismaJsonNullability = true // (default) uses prisma's scheme for JSON field nullability
}

model Computer {
  id    String @id @default(cuid())
  brand String
  cores Int
}

model Account {
  id                String  @id @default(cuid())
  userId            String
  type              String
  provider          String
  providerAccountId String
  refresh_token     String? @db.Text
  access_token      String? @db.Text
  expires_at        Int?
  token_type        String?
  scope             String?
  id_token          String? @db.Text
  session_state     String?

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model Session {
  id           String   @id @default(cuid())
  sessionToken String   @unique
  userId       String
  expires      DateTime
  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
  id            String    @id @default(cuid())
  name          String?
  email         String?   @unique
  emailVerified DateTime?
  image         String?
  accounts      Account[]
  sessions      Session[]
}

model VerificationToken {
  identifier String
  token      String   @unique
  expires    DateTime

  @@unique([identifier, token])
}

Error @ lib\db\schema\computers.ts:1
Cannot find module '@/zodAutoGenSchemas' or its corresponding type declarations.ts

lib\db\schema\computers.ts

import { computerSchema } from "@/zodAutoGenSchemas";
import { z } from "zod";

export const insertComputerSchema = computerSchema;
export const insertComputerParams = computerSchema.omit({
  id: true,
});

export const updateComputerSchema = computerSchema.extend({
  id: z.string().cuid(),
});
export const updateComputerParams = updateComputerSchema.extend({
  brand: z.string().min(2),
  cores: z.coerce.number().min(2),
});
export const computerIdSchema = updateComputerSchema.pick({ id: true });

// Types for computers - used to type API request params and within Components
export type Computer = z.infer<typeof updateComputerSchema>;
export type NewComputer = z.infer<typeof computerSchema>;
export type NewComputerParams = z.infer<typeof insertComputerParams>;
export type UpdateComputerParams = z.infer<typeof updateComputerParams>;
export type ComputerId = z.infer<typeof computerIdSchema>["id"];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.