Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kysely-ctl

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kysely-ctl - npm Package Compare versions

Comparing version 0.8.7 to 0.8.8

dist/chunk-T6QJOHYD.js

102

dist/bin.js

@@ -12,3 +12,3 @@ #!/usr/bin/env node

getMillisPrefix
} from "./chunk-L52QCSVX.js";
} from "./chunk-T6QJOHYD.js";

@@ -231,28 +231,11 @@ // src/bin.mts

cwd,
dialect: config?.dialect || {
createAdapter() {
throw new Error("No dialect specified");
},
createDriver() {
throw new Error("No dialect specified");
},
createIntrospector() {
throw new Error("No dialect specified");
},
createQueryCompiler() {
throw new Error("No dialect specified");
}
},
// @ts-ignore
dialectConfig: config?.dialectConfig || {},
migrations: {
getMigrationPrefix: getMillisPrefix,
migrationFolder: "migrations",
...config?.migrations
...config?.migrations || {}
},
plugins: config?.plugins || [],
seeds: {
getSeedPrefix: getMillisPrefix,
seedFolder: "seeds",
...config?.seeds
...config?.seeds || {}
}

@@ -400,7 +383,14 @@ };

import { join as join2 } from "pathe";
function getMigrator(kysely, config) {
const { migrationFolder, migrator, provider, ...migrations2 } = config.migrations;
return migrator || new Migrator({
function getMigrator(config) {
const { kysely, migrations: migrations2 } = config;
const { migrationFolder, migrator, provider, ...migratorOptions } = migrations2;
if (migrator) {
return migrator;
}
if (!kysely) {
throw new Error("kysely instance is required to create a migrator");
}
return new Migrator({
...migratorOptions,
db: kysely,
...migrations2,
provider: provider || new TSFileMigrationProvider({

@@ -423,24 +413,27 @@ migrationFolder: join2(config.cwd, migrationFolder)

async function getDialect(config) {
const { dialect } = config;
if (dialect === "better-sqlite3") {
return new SqliteDialect(config.dialectConfig);
const { dialect, dialectConfig } = config;
if (!dialect) {
throw new Error("No dialect provided");
}
if (dialect === "mysql2") {
return new MysqlDialect(config.dialectConfig);
if (typeof dialect === "object") {
return dialect;
}
if (dialect === "pg") {
return new PostgresDialect(config.dialectConfig);
return new PostgresDialect(dialectConfig);
}
if (dialect === "mysql2") {
return new MysqlDialect(dialectConfig);
}
if (dialect === "tedious") {
return new (await import("kysely")).MssqlDialect(dialectConfig);
}
if (dialect === "better-sqlite3") {
return new SqliteDialect(dialectConfig);
}
if (dialect === "postgres") {
return new (await import("kysely-postgres-js")).PostgresJSDialect(
config.dialectConfig
dialectConfig
);
}
if (dialect === "tedious") {
return new (await import("kysely")).MssqlDialect(config.dialectConfig);
}
if (typeof dialect === "object") {
return config.dialect;
}
throw new Error(`Unknown dialect: ${config.dialect}`);
throw new Error(`Unknown dialect: ${dialect}`);
}

@@ -450,2 +443,6 @@

async function getKysely(config, debug = false) {
const { kysely } = config;
if (kysely) {
return kysely;
}
const dialect = await getDialect(config);

@@ -479,5 +476,9 @@ return new Kysely({

const config = await getConfigOrFail(args12);
const { migrator } = config.migrations;
if (migrator) {
return await callback(migrator);
}
return await usingKysely(config, async (kysely) => {
const migrator = getMigrator(kysely, config);
return await callback(migrator);
const migrator2 = getMigrator({ ...config, kysely });
return await callback(migrator2);
});

@@ -780,7 +781,14 @@ }

import { join as join5 } from "pathe";
function getSeeder(kysely, config) {
const { seedFolder, seeder, provider, ...seeds } = config.seeds;
function getSeeder(config) {
const { kysely, seeds } = config;
const { seedFolder, seeder, provider, ...seederOptions } = seeds;
if (seeder) {
return seeder;
}
if (!kysely) {
throw new Error("Kysely instance is required to create a Seeder");
}
return seeder || new Seeder({
...seederOptions,
db: kysely,
...seeds,
provider: provider || new FileSeedProvider({

@@ -795,5 +803,9 @@ seedFolder: join5(config.cwd, seedFolder)

const config = await getConfigOrFail(args12);
const { seeder } = config.seeds;
if (seeder) {
return await callback(seeder);
}
return await usingKysely(config, async (kysely) => {
const seeder = getSeeder(kysely, config);
return await callback(seeder);
const seeder2 = getSeeder({ ...config, kysely });
return await callback(seeder2);
});

@@ -800,0 +812,0 @@ }

import * as c12 from 'c12';
import { Kysely, Dialect, MigrationProvider, Migrator, KyselyPlugin, MigratorProps, SqliteDialectConfig, MysqlDialectConfig, PostgresDialectConfig, MssqlDialectConfig, Migration } from 'kysely';
import { Kysely, Dialect, KyselyPlugin, Migrator, MigrationProvider, MigratorProps, SqliteDialectConfig, MysqlDialectConfig, PostgresDialectConfig, MssqlDialectConfig, Migration } from 'kysely';
import { PostgresJSDialectConfig } from 'kysely-postgres-js';

@@ -46,62 +46,82 @@

type KyselyDialectConfig<Dialect extends KyselyDialect> = Dialect extends ResolvableKyselyDialect ? KyselyDialectConfigDictionary[Dialect] : never;
type KyselyCTLConfig<Dialect extends KyselyDialect = KyselyDialect> = KyselyCTLConfigBase & (Dialect extends ResolvableKyselyDialect ? {
/**
* Name of an underlying database driver library, or a Kysely dialect
* instance.
*
* In case of the first, you're required to also pass a suitable `dialectConfig`.
*/
type KyselyCTLConfig<Dialect extends KyselyDialect = KyselyDialect> = Dialect extends ResolvableKyselyDialect ? {
dialect: Dialect;
/**
* Configuration passed to a dialect in case a name was passed in `dialect`.
*/
dialectConfig: KyselyDialectConfig<Dialect>;
migrations: MigratorfulMigrationsConfig;
plugins?: KyselyPlugin[];
seeds?: SeederlessSeedsConfig;
} | {
dialect: Dialect;
dialectConfig: KyselyDialectConfig<Dialect>;
migrations?: MigratorlessMigrationsConfig;
plugins?: KyselyPlugin[];
seeds: SeederfulSeedsConfig;
} | {
dialect: Dialect;
dialectConfig: KyselyDialectConfig<Dialect>;
migrations?: MigratorlessMigrationsConfig;
plugins?: KyselyPlugin[];
seeds?: SeederlessSeedsConfig;
} : {
/**
* A name of an underlying database driver library, or a Kysely dialect
* instance.
*
* In case of the first, you're required to also pass a suitable `dialectConfig`.
*/
dialect: Dialect;
}) & ({
migrations: MigrationsBaseConfig & {
migrationFolder?: string;
migrator?: never;
provider?: never;
};
migrations: MigratorfulMigrationsConfig;
plugins?: KyselyPlugin[];
seeds?: SeederlessSeedsConfig;
} | {
migrations?: MigrationsBaseConfig & {
migrationFolder?: never;
migrator?: never;
provider: MigrationProvider;
};
dialect: Dialect;
migrations?: MigratorlessMigrationsConfig;
plugins?: KyselyPlugin[];
seeds: SeederfulSeedsConfig;
} | {
migrations?: Pick<MigrationsBaseConfig, 'getMigrationPrefix'> & {
migrationFolder?: never;
migrator: Migrator;
provider?: never;
};
}) & ({
seeds?: SeedsBaseConfig & {
provider?: never;
seeder?: never;
seedFolder?: string;
};
dialect: Dialect;
migrations?: MigratorlessMigrationsConfig;
plugins?: KyselyPlugin[];
seeds?: SeederlessSeedsConfig;
} | {
seeds?: SeedsBaseConfig & {
provider: SeedProvider;
seeder?: never;
seedFolder?: never;
};
kysely: Kysely<any>;
migrations: MigratorfulMigrationsConfig;
seeds?: SeederlessSeedsConfig;
} | {
seeds?: Pick<SeedsBaseConfig, 'getSeedPrefix'> & {
provider?: never;
seeder: Seeder;
seedFolder?: never;
};
kysely: Kysely<any>;
migrations?: MigratorlessMigrationsConfig;
seeds: SeederfulSeedsConfig;
} | {
kysely: Kysely<any>;
migrations?: MigratorlessMigrationsConfig;
seeds?: SeederlessSeedsConfig;
} | {
dialect?: never;
kysely?: never;
migrations: MigratorfulMigrationsConfig;
plugins?: never;
seeds: SeederfulSeedsConfig;
};
type MigratorfulMigrationsConfig = Pick<MigrationsBaseConfig, 'getMigrationPrefix'> & {
migrationFolder?: never;
migrator: Migrator;
provider?: never;
};
type MigratorlessMigrationsConfig = MigrationsBaseConfig & ({
migrationFolder?: string;
migrator?: never;
provider?: never;
} | {
migrationFolder?: never;
migrator?: never;
provider: MigrationProvider;
});
interface KyselyCTLConfigBase {
plugins?: KyselyPlugin[];
}
type SeederfulSeedsConfig = Pick<SeedsBaseConfig, 'getSeedPrefix'> & {
provider?: never;
seeder: Seeder;
seedsFolder?: never;
};
type SeederlessSeedsConfig = SeedsBaseConfig & ({
provider?: never;
seeder?: never;
seedFolder?: string;
} | {
provider: SeedProvider;
seeder?: never;
seedFolder?: never;
});
type MigrationsBaseConfig = Omit<MigratorProps, 'db' | 'provider'> & {

@@ -141,2 +161,2 @@ getMigrationPrefix?(): string | Promise<string>;

export { FileSeedProvider, type FileSeedProviderProps, type KyselyCTLConfig, type KyselyCTLConfigBase, type KyselyCoreDialect, type KyselyDialect, type KyselyDialectConfig, type KyselyOrganizationDialect, type MigrationsBaseConfig, type ResolvableKyselyDialect, type Seed, type SeedInfo, type SeedProvider, type SeedResult, type SeedResultSet, Seeder, type SeederProps, type SeedsBaseConfig, TSFileMigrationProvider, type TSFileMigrationProviderProps, defineConfig, getKnexTimestampPrefix };
export { FileSeedProvider, type FileSeedProviderProps, type KyselyCTLConfig, type KyselyCoreDialect, type KyselyDialect, type KyselyDialectConfig, type KyselyOrganizationDialect, type MigrationsBaseConfig, type ResolvableKyselyDialect, type Seed, type SeedInfo, type SeedProvider, type SeedResult, type SeedResultSet, Seeder, type SeederProps, type SeedsBaseConfig, TSFileMigrationProvider, type TSFileMigrationProviderProps, defineConfig, getKnexTimestampPrefix };

@@ -6,3 +6,3 @@ import {

getKnexTimestampPrefix
} from "./chunk-L52QCSVX.js";
} from "./chunk-T6QJOHYD.js";

@@ -9,0 +9,0 @@ // src/config/define-config.mts

{
"name": "kysely-ctl",
"version": "0.8.7",
"version": "0.8.8",
"type": "module",

@@ -53,7 +53,7 @@ "bin": {

"@arethetypeswrong/cli": "^0.15.3",
"@biomejs/biome": "1.8.1",
"@biomejs/biome": "1.8.3",
"@tsconfig/node20": "^20.1.4",
"@types/better-sqlite3": "^7.6.10",
"@types/node": "^20.14.6",
"better-sqlite3": "^11.0.0",
"@types/node": "^20.14.9",
"better-sqlite3": "^11.1.1",
"kysely": "^0.27.3",

@@ -64,3 +64,4 @@ "kysely-postgres-js": "^2.0.0",

"type-fest": "^4.20.1",
"typescript": "^5.4.5"
"typescript": "^5.5.2",
"vitest": "^1.6.0"
},

@@ -82,4 +83,5 @@ "engines": {

"check:dts": "attw --pack .",
"start": "pnpm build --watch"
"start": "pnpm build --watch",
"test": "vitest"
}
}

@@ -93,3 +93,3 @@ `kysely-ctl` is the official command-line tool for [Kysely](https://kysely.dev).

export default defineConfig({
dialect, // a Kysely dialect instance OR the name of an underlying driver library (e.g. `'pg'`).
dialect, // a `Kysely` dialect instance OR the name of an underlying driver library (e.g. `'pg'`).
dialectConfig, // optional. when `dialect` is the name of an underlying driver library, `dialectConfig` is the options passed to the Kysely dialect that matches that library.

@@ -112,2 +112,15 @@ migrations: { // optional.

Alternatively, you can pass a `Kysely` instance, instead of `dialect`, `dialectConfig` & `plugins`:
```ts
import { defineConfig } from "kysely-ctl";
import { kysely } from 'path/to/kysely/instance';
export default defineConfig({
// ...
kysely,
// ...
});
```
To use Knex's timestamp prefixes:

@@ -114,0 +127,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc