Oak-Digital / types-4-strapi-2

Automate the creation of typescript interfaces for your strapi 4 projects
MIT License
24 stars 4 forks source link

Unknown dialect undefined #32

Closed davidbesteltunts closed 10 months ago

davidbesteltunts commented 10 months ago

Hi, I'm getting an error when trying to generate the types, but this error only occurs in the bitbucket pipeline, I have tried to simulate the error locally but I always get success.

Error: Failed to spawn remote strapi: /usr/app/node_modules/@strapi/database/lib/dialects/index.js:36
throw new Error(`Unknown dialect ${client}`);

This error only appeared now, when I updated the library version to 1.0.2. I used to use version 0.5.5, but this also started generating an error (so I updated to 1.0.2):

Error from 0.5.5: TypeError: Cannot read properties of null (reading 'attributes')

Command used in 0.5.5: "t4s -i ../../apps/cms/src -o src/generated --prefix=''" Command used in 1.0.2: "t4s -i ../../apps/cms -o src/generated --prefix='' --reader=load-strapi"

Strapi Version: 4.11.1 Node Version: 16

Strapi Database:

export default ({ env }) => {
  return {
    connection: {
      client: 'postgres',
      connection: {
        host: env('DATABASE_HOST', ''),
        port: env.int('DATABASE_PORT', 5432),
        database: env('DATABASE_NAME', ''),
        user: env('DATABASE_USERNAME', ''),
        password: env('DATABASE_PASSWORD'),
        ssl: env.bool('DATABASE_SSL', false),
      },
    },
    pool: {
      min: 0,
      max: 10,
    },
  };
};

Can you help me? it doesn't matter which version, I just need to be able to generate the types the way they already work, thank you in advance.

Alexnortung commented 10 months ago

Short answer:

To make it work like it used to in <v1, try setting the flag --reader by-file.

Long answer

Try falling back to using a sqlite database. The problem is probably that your pipeline cannot connect/create a database and the way it works right now is by temporarily starting the strapi server to extract all the content types from your app and plugins.


I hope this helps, let me know if it doesn't work

davidbesteltunts commented 10 months ago

@Alexnortung Thanks for the reply, the "Short answer" option worked.