kysely-ctl
Advanced tools
Comparing version 0.8.1 to 0.8.2
123
dist/bin.js
@@ -11,3 +11,3 @@ #!/usr/bin/env node | ||
getConsumerPackageJSON | ||
} from "./chunk-DWZAIC2G.js"; | ||
} from "./chunk-S7U4KRWW.js"; | ||
@@ -345,5 +345,7 @@ // src/bin.mts | ||
// src/kysely/get-migrator.mts | ||
import { Migrator } from "kysely"; | ||
import { join as join2 } from "pathe"; | ||
// src/kysely/get-migrations.mts | ||
var migrations; | ||
async function getMigrations(migrator) { | ||
return migrations ||= await migrator.getMigrations(); | ||
} | ||
@@ -402,5 +404,16 @@ // src/kysely/get-kysely.mts | ||
// src/kysely/using-kysely.mts | ||
async function usingKysely(config, callback) { | ||
const kysely = await getKysely(config); | ||
try { | ||
return await callback(kysely); | ||
} finally { | ||
await kysely.destroy(); | ||
} | ||
} | ||
// src/kysely/get-migrator.mts | ||
async function getMigrator(config) { | ||
const kysely = await getKysely(config); | ||
import { Migrator } from "kysely"; | ||
import { join as join2 } from "pathe"; | ||
function getMigrator(kysely, config) { | ||
const { migrationFolder, migrator, provider, ...migrations2 } = config.migrations; | ||
@@ -416,6 +429,9 @@ return migrator || new Migrator({ | ||
// src/kysely/get-migrations.mts | ||
var migrations; | ||
async function getMigrations(migrator) { | ||
return migrations ||= await migrator.getMigrations(); | ||
// src/kysely/using-migrator.mts | ||
async function usingMigrator(args12, callback) { | ||
const config = await getConfigOrFail(args12); | ||
return await usingKysely(config, async (kysely) => { | ||
const migrator = getMigrator(kysely, config); | ||
return await callback(migrator); | ||
}); | ||
} | ||
@@ -435,5 +451,3 @@ | ||
consola5.debug(context, []); | ||
const config = await getConfigOrFail(context.args); | ||
const migrator = await getMigrator(config); | ||
const migrations2 = await getMigrations(migrator); | ||
const migrations2 = await usingMigrator(context.args, getMigrations); | ||
consola5.debug(migrations2); | ||
@@ -523,7 +537,7 @@ if (!migrations2.length) { | ||
consola7.debug(context, []); | ||
const config = await getConfigOrFail(context.args); | ||
const migrator = await getMigrator(config); | ||
consola7.start("Starting migration to latest"); | ||
const resultSet = await migrator.migrateToLatest(); | ||
await processMigrationResultSet(resultSet, "up", migrator); | ||
await usingMigrator(context.args, async (migrator) => { | ||
consola7.start("Starting migration to latest"); | ||
const resultSet = await migrator.migrateToLatest(); | ||
await processMigrationResultSet(resultSet, "up", migrator); | ||
}); | ||
} | ||
@@ -557,7 +571,7 @@ }; | ||
consola8.debug(context, []); | ||
const config = await getConfigOrFail(context.args); | ||
const migrator = await getMigrator(config); | ||
consola8.start("Starting migration rollback"); | ||
const resultSet = await migrator.migrateTo(NO_MIGRATIONS); | ||
await processMigrationResultSet(resultSet, "down", migrator); | ||
await usingMigrator(context.args, async (migrator) => { | ||
consola8.start("Starting migration rollback"); | ||
const resultSet = await migrator.migrateTo(NO_MIGRATIONS); | ||
await processMigrationResultSet(resultSet, "down", migrator); | ||
}); | ||
} | ||
@@ -603,12 +617,12 @@ }; | ||
consola9.debug(context, []); | ||
const config = await getConfigOrFail(args12); | ||
const migrator = await getMigrator(config); | ||
if (await isWrongDirection(migration_name, "up", migrator)) { | ||
return consola9.info( | ||
`Migration skipped: migration "${migration_name}" has already been run` | ||
); | ||
} | ||
consola9.start("Starting migration up"); | ||
const resultSet = migration_name ? await migrator.migrateTo(migration_name) : await migrator.migrateUp(); | ||
await processMigrationResultSet(resultSet, "up", migrator); | ||
await usingMigrator(args12, async (migrator) => { | ||
if (await isWrongDirection(migration_name, "up", migrator)) { | ||
return consola9.info( | ||
`Migration skipped: migration "${migration_name}" has already been run` | ||
); | ||
} | ||
consola9.start("Starting migration up"); | ||
const resultSet = migration_name ? await migrator.migrateTo(migration_name) : await migrator.migrateUp(); | ||
await processMigrationResultSet(resultSet, "up", migrator); | ||
}); | ||
} | ||
@@ -635,12 +649,12 @@ }; | ||
consola10.debug(context, []); | ||
const config = await getConfigOrFail(args12); | ||
const migrator = await getMigrator(config); | ||
if (await isWrongDirection(migration_name, "down", migrator)) { | ||
return consola10.info( | ||
`Migration skipped: "${migration_name}" has not been run yet` | ||
); | ||
} | ||
consola10.start("Starting migration down"); | ||
const resultSet = migration_name ? await migrator.migrateTo(migration_name) : await migrator.migrateDown(); | ||
await processMigrationResultSet(resultSet, "down", migrator); | ||
await usingMigrator(args12, async (migrator) => { | ||
if (await isWrongDirection(migration_name, "down", migrator)) { | ||
return consola10.info( | ||
`Migration skipped: "${migration_name}" has not been run yet` | ||
); | ||
} | ||
consola10.start("Starting migration down"); | ||
const resultSet = migration_name ? await migrator.migrateTo(migration_name) : await migrator.migrateDown(); | ||
await processMigrationResultSet(resultSet, "down", migrator); | ||
}); | ||
} | ||
@@ -777,4 +791,3 @@ }; | ||
import { join as join5 } from "pathe"; | ||
async function getSeeder(config) { | ||
const kysely = await getKysely(config); | ||
function getSeeder(kysely, config) { | ||
const { seedFolder, seeder, provider, ...seeds } = config.seeds; | ||
@@ -790,2 +803,11 @@ return seeder || new Seeder({ | ||
// src/seeds/using-seeder.mts | ||
async function usingSeeder(args12, callback) { | ||
const config = await getConfigOrFail(args12); | ||
return await usingKysely(config, async (kysely) => { | ||
const seeder = getSeeder(kysely, config); | ||
return await callback(seeder); | ||
}); | ||
} | ||
// src/commands/seed/list.mts | ||
@@ -804,5 +826,6 @@ var args9 = { | ||
consola14.debug(context, []); | ||
const config = await getConfigOrFail(context.args); | ||
const seeder = await getSeeder(config); | ||
const seeds = await seeder.getSeeds(); | ||
const seeds = await usingSeeder( | ||
context.args, | ||
(seeder) => seeder.getSeeds() | ||
); | ||
consola14.debug(seeds); | ||
@@ -840,6 +863,4 @@ if (!seeds.length) { | ||
consola15.debug(context, []); | ||
const config = await getConfigOrFail(args12); | ||
const seeder = await getSeeder(config); | ||
consola15.start("Starting seed run"); | ||
const resultSet = specific ? await seeder.run(specific) : await seeder.run(); | ||
const resultSet = await usingSeeder(args12, (seeder) => seeder.run(specific)); | ||
consola15.debug(resultSet); | ||
@@ -846,0 +867,0 @@ const { error, results } = resultSet; |
@@ -5,3 +5,3 @@ import { | ||
TSFileMigrationProvider | ||
} from "./chunk-DWZAIC2G.js"; | ||
} from "./chunk-S7U4KRWW.js"; | ||
@@ -8,0 +8,0 @@ // src/config/define-config.mts |
{ | ||
"name": "kysely-ctl", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"type": "module", | ||
@@ -59,3 +59,3 @@ "bin": { | ||
"kysely-postgres-js": "^2.0.0", | ||
"mysql2": "^3.9.7", | ||
"mysql2": "^3.9.8", | ||
"pg": "^8.11.5", | ||
@@ -62,0 +62,0 @@ "postgres": "^3.4.4", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91879
2586