Skip to content

Commit b4577be

Browse files
committed
v0fix: consolidated logger type, removed nuxt-logger from peer dep
1 parent f1fce13 commit b4577be

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

package.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,8 @@
3737
},
3838
"@comments": {
3939
"dependencies": {
40-
"pglite": "This is because of https://github.com/electric-sql/pglite/issues/603 and also was getting some errors about unreachable wasm when not getting this error."
41-
}
42-
},
43-
"peerDependencies": {
44-
"@witchcraft/nuxt-logger": "^0.0.2"
45-
},
46-
"peerDependenciesMeta": {
47-
"@witchcraft/nuxt-logger": {
48-
"optional": true
40+
"pglite": "This is because of https://github.com/electric-sql/pglite/issues/603 and also was getting some errors about unreachable wasm when not getting this error.",
41+
"@witchcraft/nuxt-logger": "This is only for some types for the logger, but is otherwise unused."
4942
}
5043
},
5144
"dependencies": {

src/module.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import type { PGliteOptions } from "@electric-sql/pglite"
33
import {
44
addImportsDir,
5-
addServerPlugin,
65
addServerScanDir,
76
addTypeTemplate,
87
createResolver,
@@ -206,9 +205,6 @@ export default defineNuxtModule<ModuleOptions>({
206205
aliasServerImport: "~~/server/postgres"
207206
},
208207
moduleDependencies: {
209-
"@witchcraft/nuxt-logger": {
210-
version: pkg.dependencies["@witchcraft/nuxt-logger"]
211-
}
212208
},
213209
async setup(options, nuxt) {
214210
const { resolve } = createResolver(import.meta.url)

src/runtime/utils/clientDatabaseManager.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ type AllOptions = Partial<Omit<ClientPostgresOptions, "clientMigrationConfig"> &
6969
type InitOptions = {
7070
bypassEnvCheck?: boolean
7171
addToWindowInDev?: boolean
72-
logger?: {
73-
info: (...args: any[]) => void
74-
error: (...args: any[]) => void
75-
debug: (...args: any[]) => void
76-
}
72+
logger?: BaseLogger
7773
}
7874
export type ClientDatabaseEntry = {
7975
client?: PGlite | PGliteWorker
@@ -230,7 +226,7 @@ export class ClientDatabaseManager {
230226
if (conf.autoMigrateClientDb && migrationOpts.migrationJson) {
231227
await ClientDatabaseManager.migrate(entry.db, opts.clientMigrationOptions ?? {}, entry.migrationState, name)
232228
} else if (!entry.migrationState.skip) {
233-
logger.debug({
229+
logger.debug?.({
234230
ns: "postgres:client:migrate:skip",
235231
msg: "Skipping migration because no migrationJson passed or autoMigrateClientDb is false.",
236232
migrationJson: !!migrationOpts.migrationJson,
@@ -301,14 +297,14 @@ export class ClientDatabaseManager {
301297
preMigrationScript,
302298
force,
303299
storageMigrationHashKey = "db:lastMigrationHash",
304-
migrationsLogger = console,
300+
migrationsLogger = console as any as BaseLogger,
305301
storage = undefined
306302
} = opts
307303

308304
if (!state.attemptedMigration && !force) {
309305
try {
310306
const start = performance.now()
311-
migrationsLogger.debug({
307+
migrationsLogger.debug?.({
312308
ns: "postgres:pglite:migrate:start"
313309
})
314310

@@ -318,7 +314,7 @@ export class ClientDatabaseManager {
318314
const lastMigrationHash = !force && await storage?.getItem(storageMigrationHashKey + (name ? `:${name}` : ""))
319315

320316
if (!force && lastItem.hash === lastMigrationHash && !state.skip) {
321-
migrationsLogger.debug({
317+
migrationsLogger.debug?.({
322318
ns: "postgres:pglite:migrate:skip",
323319
msg: "Skipping migration because hash in storage matches migrationJson hash.",
324320
hash: lastItem.hash,
@@ -345,14 +341,14 @@ export class ClientDatabaseManager {
345341
await storage?.setItem(storageMigrationHashKey, lastItem.hash)
346342
}
347343

348-
migrationsLogger.debug({
344+
migrationsLogger.debug?.({
349345
ns: "postgres:pglite:migrate:end",
350346
hash: lastItem.hash,
351347
duration: performance.now() - start
352348
})
353349
} catch (error) {
354350
if (!(error instanceof Error)) { throw error }
355-
migrationsLogger.error({
351+
migrationsLogger.error?.({
356352
ns: "postgres:pglite:migrate:error",
357353
error: { message: error.message, stack: error.stack, opts }
358354
})

0 commit comments

Comments
 (0)