kysely-ctl
Advanced tools
Comparing version 0.10.1 to 0.11.0
100
dist/bin.js
@@ -8,7 +8,9 @@ #!/usr/bin/env node | ||
__filename, | ||
assertDefined, | ||
getCTLPackageJSON, | ||
getCWD, | ||
getConsumerPackageJSON, | ||
getMillisPrefix | ||
} from "./chunk-5XDVBRLT.js"; | ||
getMillisPrefix, | ||
isObject | ||
} from "./chunk-43L4E2EU.js"; | ||
@@ -53,2 +55,9 @@ // src/bin.mts | ||
// src/arguments/jiti.mts | ||
var ExperimentalResolveTSConfigPathsArg = { | ||
"experimental-resolve-tsconfig-paths": { | ||
default: false, | ||
description: "Attempts to resolve path aliases using the tsconfig.json file.", | ||
type: "boolean" | ||
} | ||
}; | ||
var NoFilesystemCachingArg = { | ||
@@ -62,2 +71,3 @@ "no-filesystem-caching": { | ||
var JitiArgs = { | ||
...ExperimentalResolveTSConfigPathsArg, | ||
...NoFilesystemCachingArg | ||
@@ -206,3 +216,3 @@ }; | ||
import { consola as consola3 } from "consola"; | ||
import { join } from "pathe"; | ||
import { join as join2 } from "pathe"; | ||
@@ -242,2 +252,43 @@ // src/arguments/extension.mts | ||
import { consola as consola2 } from "consola"; | ||
// src/utils/jiti.ts | ||
import { join } from "pathe"; | ||
// src/utils/tsconfig.mts | ||
import { readTSConfig } from "pkg-types"; | ||
var tsconfig; | ||
async function getTSConfig() { | ||
return tsconfig ||= await readTSConfig(void 0, { | ||
startingFrom: getCWD() | ||
}); | ||
} | ||
// src/utils/jiti.ts | ||
async function getJitiAlias() { | ||
try { | ||
const tsconfig2 = await getTSConfig(); | ||
const { baseUrl, paths } = tsconfig2.compilerOptions || {}; | ||
if (!paths) { | ||
return; | ||
} | ||
const cwd = getCWD(); | ||
const jitiAlias = {}; | ||
for (const [alias, [path]] of Object.entries(paths)) { | ||
if (!path) { | ||
continue; | ||
} | ||
jitiAlias[removeWildcards(alias)] = removeWildcards( | ||
join(cwd, baseUrl || ".", path) | ||
); | ||
} | ||
return jitiAlias; | ||
} catch (error) { | ||
return {}; | ||
} | ||
} | ||
function removeWildcards(path) { | ||
return path.replace(/(\/?\*\*?)+$/, ""); | ||
} | ||
// src/config/get-config.mts | ||
async function getConfig(args12) { | ||
@@ -250,2 +301,4 @@ const cwd = getCWD(args12); | ||
jitiOptions: { | ||
alias: args12["experimental-resolve-tsconfig-paths"] ? await getJitiAlias() : void 0, | ||
debug: Boolean(args12.debug), | ||
fsCache: Boolean(args12["filesystem-caching"]) | ||
@@ -324,3 +377,3 @@ }, | ||
assertExtension(extension); | ||
const configFolderPath = join(config.cwd, ".config"); | ||
const configFolderPath = join2(config.cwd, ".config"); | ||
consola3.debug("Config folder path:", configFolderPath); | ||
@@ -333,6 +386,6 @@ const wasConfigFolderCreated = Boolean( | ||
} | ||
const filePath = join(configFolderPath, `kysely.config.${extension}`); | ||
const filePath = join2(configFolderPath, `kysely.config.${extension}`); | ||
consola3.debug("File path:", filePath); | ||
const templateExtension = await getTemplateExtension(extension); | ||
const templatePath = join( | ||
const templatePath = join2( | ||
__dirname, | ||
@@ -421,3 +474,5 @@ `templates/config-template.${templateExtension}` | ||
const migrations2 = await getMigrations(migrator); | ||
const { migrationName: firstResultMigrationName } = results[0]; | ||
const firstResult = results[0]; | ||
assertDefined(firstResult); | ||
const { migrationName: firstResultMigrationName } = firstResult; | ||
const untouchedMigrationsBefore = migrations2.slice( | ||
@@ -429,3 +484,5 @@ 0, | ||
); | ||
const { migrationName: lastResultMigrationName } = results.at(-1); | ||
const lastResult = results.at(-1); | ||
assertDefined(lastResult); | ||
const { migrationName: lastResultMigrationName } = lastResult; | ||
const untouchedMigrationsAfter = migrations2.slice( | ||
@@ -451,3 +508,3 @@ migrations2.findIndex( | ||
import { Migrator } from "kysely"; | ||
import { join as join2 } from "pathe"; | ||
import { join as join3 } from "pathe"; | ||
function getMigrator(config) { | ||
@@ -467,3 +524,3 @@ const { kysely, migrations: migrations2 } = config; | ||
allowJS, | ||
migrationFolder: join2(config.cwd, migrationFolder) | ||
migrationFolder: join3(config.cwd, migrationFolder) | ||
}) | ||
@@ -488,3 +545,3 @@ }); | ||
} | ||
if (typeof dialect === "object") { | ||
if (isObject(dialect)) { | ||
return dialect; | ||
@@ -566,2 +623,3 @@ } | ||
} | ||
// biome-ignore lint/suspicious/noExplicitAny: this is perfectly fine | ||
}; | ||
@@ -664,3 +722,3 @@ } | ||
import { consola as consola10 } from "consola"; | ||
import { join as join3 } from "pathe"; | ||
import { join as join4 } from "pathe"; | ||
var args5 = { | ||
@@ -682,3 +740,3 @@ ...CommonArgs, | ||
assertExtension(extension, config, "migrations"); | ||
const migrationsFolderPath = join3( | ||
const migrationsFolderPath = join4( | ||
config.cwd, | ||
@@ -696,6 +754,6 @@ config.migrations.migrationFolder | ||
consola10.debug("Filename:", filename); | ||
const filePath = join3(migrationsFolderPath, filename); | ||
const filePath = join4(migrationsFolderPath, filename); | ||
consola10.debug("File path:", filePath); | ||
const templateExtension = await getTemplateExtension(extension); | ||
const templatePath = join3( | ||
const templatePath = join4( | ||
__dirname, | ||
@@ -811,3 +869,3 @@ `templates/migration-template.${templateExtension}` | ||
import { consola as consola14 } from "consola"; | ||
import { join as join4 } from "pathe"; | ||
import { join as join5 } from "pathe"; | ||
var args8 = { | ||
@@ -833,3 +891,3 @@ ...CommonArgs, | ||
assertExtension(extension, config, "seeds"); | ||
const seedsFolderPath = join4(config.cwd, config.seeds.seedFolder); | ||
const seedsFolderPath = join5(config.cwd, config.seeds.seedFolder); | ||
consola14.debug("Seeds folder path:", seedsFolderPath); | ||
@@ -844,6 +902,6 @@ const wasSeedsFolderCreated = Boolean( | ||
consola14.debug("Filename:", filename); | ||
const filePath = join4(seedsFolderPath, filename); | ||
const filePath = join5(seedsFolderPath, filename); | ||
consola14.debug("File path:", filePath); | ||
const templateExtension = await getTemplateExtension(extension); | ||
const templatePath = join4( | ||
const templatePath = join5( | ||
__dirname, | ||
@@ -868,3 +926,3 @@ `templates/seed-template.${templateExtension}` | ||
// src/seeds/get-seeder.mts | ||
import { join as join5 } from "pathe"; | ||
import { join as join6 } from "pathe"; | ||
function getSeeder(config) { | ||
@@ -884,3 +942,3 @@ const { kysely, seeds } = config; | ||
allowJS, | ||
seedFolder: join5(config.cwd, seedFolder) | ||
seedFolder: join6(config.cwd, seedFolder) | ||
}) | ||
@@ -887,0 +945,0 @@ }); |
@@ -6,3 +6,3 @@ import { | ||
getKnexTimestampPrefix | ||
} from "./chunk-5XDVBRLT.js"; | ||
} from "./chunk-43L4E2EU.js"; | ||
@@ -9,0 +9,0 @@ // src/config/define-config.mts |
import type { Kysely } from 'kysely' | ||
// biome-ignore lint/suspicious/noExplicitAny: `any` is required here since migrations should be frozen in time. alternatively, keep a "snapshot" db interface. | ||
export async function up(db: Kysely<any>): Promise<void> { | ||
@@ -9,2 +10,3 @@ // up migration code goes here... | ||
// biome-ignore lint/suspicious/noExplicitAny: `any` is required here since migrations should be frozen in time. alternatively, keep a "snapshot" db interface. | ||
export async function down(db: Kysely<any>): Promise<void> { | ||
@@ -11,0 +13,0 @@ // down migration code goes here... |
import type { Kysely } from 'kysely' | ||
// biome-ignore lint/suspicious/noExplicitAny: replace `any` with your database interface. | ||
export async function seed(db: Kysely<any>): Promise<void> { | ||
@@ -4,0 +5,0 @@ // seed code goes here... |
{ | ||
"name": "kysely-ctl", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"type": "module", | ||
@@ -34,7 +34,7 @@ "bin": { | ||
"citty": "^0.1.6", | ||
"consola": "^3.2.3", | ||
"nypm": "^0.4.1", | ||
"consola": "^3.4.0", | ||
"nypm": "^0.5.2", | ||
"ofetch": "^1.4.1", | ||
"pathe": "^1.1.2", | ||
"pkg-types": "^1.2.1", | ||
"pathe": "^2.0.2", | ||
"pkg-types": "^1.3.1", | ||
"std-env": "^3.8.0", | ||
@@ -53,9 +53,9 @@ "tsx": "^4.19.2" | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "^0.17.2", | ||
"@arktype/attest": "^0.32.0", | ||
"@arethetypeswrong/cli": "^0.17.3", | ||
"@arktype/attest": "^0.41.2", | ||
"@biomejs/biome": "1.9.4", | ||
"@tsconfig/node22": "^22.0.0", | ||
"@types/better-sqlite3": "^7.6.12", | ||
"@types/node": "^22.10.2", | ||
"better-sqlite3": "^11.7.0", | ||
"@types/node": "^22.13.1", | ||
"better-sqlite3": "^11.8.1", | ||
"kysely": "^0.27.5", | ||
@@ -65,6 +65,6 @@ "kysely-postgres-js": "^2.0.0", | ||
"postgres": "^3.4.5", | ||
"tsup": "^8.3.5", | ||
"type-fest": "^4.30.2", | ||
"typescript": "^5.7.2", | ||
"vitest": "^2.1.8" | ||
"tsup": "^8.3.6", | ||
"type-fest": "^4.34.1", | ||
"typescript": "^5.7.3", | ||
"vitest": "^3.0.5" | ||
}, | ||
@@ -71,0 +71,0 @@ "engines": { |
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
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
118131
3283
28500
3
0
- Removednypm@0.4.1(transitive)
- Removedpathe@1.1.2(transitive)
Updatedconsola@^3.4.0
Updatednypm@^0.5.2
Updatedpathe@^2.0.2
Updatedpkg-types@^1.3.1