Skip to content

Commit

Permalink
refactor!: remove default exports (#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Feb 21, 2025
1 parent 7d0a4d9 commit 0fe826c
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bin/node-pg-migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { DotenvConfigOptions } from 'dotenv';
// Import as node-pg-migrate, so tsup does not self-reference as '../dist'
// otherwise this could not be imported by esm
// @ts-ignore: when a clean was made, the types are not present in the first run
import { Migration, default as migrationRunner } from 'node-pg-migrate';
import { Migration, runner as migrationRunner } from 'node-pg-migrate';
import { readFileSync } from 'node:fs';
import { register } from 'node:module';
import { join, resolve } from 'node:path';
Expand Down
4 changes: 1 addition & 3 deletions src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface DBConnection extends DB {

type ConnectionStatus = 'DISCONNECTED' | 'CONNECTED' | 'ERROR' | 'EXTERNAL';

function db(
export function db(
connection: ClientBase | string | ClientConfig,
logger: Logger = console
): DBConnection {
Expand Down Expand Up @@ -186,5 +186,3 @@ ${error}
},
};
}

export default db;
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { Migration } from './migration';
export type { default as MigrationBuilder } from './migrationBuilder';
export type { MigrationBuilder } from './migrationBuilder';
export type {
CreateCast,
CreateCastFn,
Expand Down Expand Up @@ -263,7 +263,7 @@ export type {
ViewOptions,
} from './operations/views';
export { PgType } from './pgType';
export { runner as default, runner } from './runner';
export { runner } from './runner';
export type { RunnerOption } from './runner';
export { PgLiteral, isPgLiteral } from './utils';
export type { PgLiteralValue } from './utils';
2 changes: 1 addition & 1 deletion src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { cwd } from 'node:process';
import type { QueryResult } from 'pg';
import type { DBConnection } from './db';
import type { Logger } from './logger';
import MigrationBuilder from './migrationBuilder';
import { MigrationBuilder } from './migrationBuilder';
import type { ColumnDefinitions } from './operations/tables';
import type { MigrationDirection, RunnerOption } from './runner';
import type { MigrationBuilderActions } from './sqlMigration';
Expand Down
2 changes: 1 addition & 1 deletion src/migrationBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { createSchemalize, PgLiteral } from './utils';
* and it makes inference of down migrations possible.
*/

export default class MigrationBuilder {
export class MigrationBuilder {
/**
* Install an extension.
*
Expand Down
6 changes: 2 additions & 4 deletions src/runner.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { extname } from 'node:path';
import type { ClientBase, ClientConfig } from 'pg';
import type { DBConnection } from './db';
import Db from './db';
import { db as Db } from './db';
import type { LogFn, Logger } from './logger';
import type { RunMigration } from './migration';
import { getMigrationFilePaths, Migration } from './migration';
import type { ColumnDefinitions } from './operations/tables';
import type { MigrationBuilderActions } from './sqlMigration';
import migrateSqlFile from './sqlMigration';
import { sqlMigration as migrateSqlFile } from './sqlMigration';
import { createSchemalize, getMigrationTableSchema, getSchemas } from './utils';

export interface RunnerOptionConfig {
Expand Down Expand Up @@ -487,5 +487,3 @@ export async function runner(options: RunnerOption): Promise<RunMigration[]> {
}
}
}

export default runner;
6 changes: 3 additions & 3 deletions src/sqlMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export function getActions(content: string): MigrationBuilderActions {
};
}

async function sqlMigration(sqlPath: string): Promise<MigrationBuilderActions> {
export async function sqlMigration(
sqlPath: string
): Promise<MigrationBuilderActions> {
const content = await readFile(sqlPath, 'utf8');

return getActions(content);
}

export default sqlMigration;
2 changes: 1 addition & 1 deletion test/db.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Client } from 'pg';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { DBConnection } from '../src/db';
import Db from '../src/db';
import { db as Db } from '../src/db';
import type { Logger } from '../src/logger';

const hoisted = vi.hoisted(() => ({
Expand Down

0 comments on commit 0fe826c

Please sign in to comment.