typeorm-extension
typeorm-extension copied to clipboard
Bug: CLI not recognizing data-source files if they have a different name
Versions
- Node: 8.12.2
- OS: Ubuntu 20.04
Reproduction
Steps to reproduce
I'm using NestJs.
Configure your package.json like this:
"seed": "ts-node ./node_modules/typeorm-extension/dist/cli/index.js seed -- -d src/database/database.config.ts"
Add a database.config.ts under src/database in your project with the following code:
import { DataSource, DataSourceOptions } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { config } from 'dotenv';
import { SeederOptions } from 'typeorm-extension';
config();
const configService = new ConfigService();
const options: DataSourceOptions & SeederOptions = {
type: 'mysql',
host: configService.get<string>('MYSQL_HOST'),
port: configService.get<number>('MYSQL_PORT'),
username: configService.get<string>('MYSQL_USER'),
password: configService.get<string>('MYSQL_PASSWORD'),
database: configService.get<string>('MYSQL_DB_NAME'),
entities: ['dist/**/*.entity{.ts,.js}'],
migrations: ['dist/migrations/**/*{.ts,.js}'],
timezone: 'Z',
logging: true,
migrationsRun: true,
synchronize: false,
ssl: {
rejectUnauthorized: false,
},
seeds: ['src/database/seeds/**/*{.ts,.js}'],
factories: ['src/database/factories/**/*{.ts,.js}'],
};
export const AppDataSource = new DataSource(options);
Now, if you run the seed script the following error will occur:
TypeORMError: No connection options were found in any orm configuration files.
at ConnectionOptionsReader.all (/home/jph/zenbit/HiveIn_be/node_modules/src/connection/ConnectionOptionsReader.ts:46:19)
at async ConnectionOptionsReader.get (/home/jph/zenbit/HiveIn_be/node_modules/src/connection/ConnectionOptionsReader.ts:58:28)
What is Expected?
It would be expected to connect with the database, if I change the file to data-source.ts it will find the connection file.
What is actually happening?
Can't run the CLI script if I have a configuration file with a name that isn't data-source.ts