Skip to content

Commit

Permalink
fix: исправлена сборка из-за ошибок зависимости useLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
LorexIQ committed Nov 14, 2024
1 parent 59d94cc commit 605babc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/runtime/autoImport.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { type Resolver, useLogger } from '@nuxt/kit';
import type { Resolver } from '@nuxt/kit';
import type { Nuxt } from '@nuxt/schema';
import { resolveAlias } from '@nuxt/kit';
import type {
Expand All @@ -16,12 +16,12 @@ import defineConnector from './composables/defineConnector';
import loadTsModule from './helpers/loadTsModule';
import getTsMorphProject from './helpers/getTsMorphProject';
import pathRelativeMove from './helpers/pathRelativeMove';
import logger from './helpers/logger';

export class Module {
private readonly rootDir: string;
private readonly debugEnabled: boolean;
private readonly project = getTsMorphProject();
private readonly logger = useLogger('AutoImport');

private readonly config: ModuleOptionsExtend;
private readonly typeGeneratorListFunc: ModuleConnectorTypeGenerator[] = [];
Expand Down Expand Up @@ -94,7 +94,7 @@ export class Module {
async readConnectors() {
for (const connectorPath of this.config.connectors) {
if (!fs.existsSync(connectorPath)) {
this.logger.warn(`Connector file wasn't found: '${connectorPath}'.`);
logger.warn(`Connector file wasn't found: '${connectorPath}'.`);
continue;
}

Expand All @@ -105,7 +105,7 @@ export class Module {
const connectorFile = (await loadTsModule(connectorPath))?.default as ModuleConnectorReturn;

if (!connectorFile) {
this.logger.warn(`Error loading connector file: '${connectorPath}'.`);
logger.warn(`Error loading connector file: '${connectorPath}'.`);
continue;
}

Expand Down Expand Up @@ -150,10 +150,6 @@ export class Module {
return this.nuxtConfig;
}

getLogger() {
return this.logger;
}

isDebug() {
return this.debugEnabled;
}
Expand Down
5 changes: 3 additions & 2 deletions src/runtime/helpers/filesSearcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
} from '../types';
import type { ModuleClass } from '../autoImport';
import loadTsModule from './loadTsModule';
import logger from './logger';

function checkIsFile(path: string) {
return path.endsWith('.ts') && !path.endsWith('.d.ts');
Expand Down Expand Up @@ -112,12 +113,12 @@ export default async function (ctx: ModuleClass, config: ModuleFSConfig): Promis
if (fs.statSync(path).isFile()) {
const fileDir = path.split(sep).slice(0, -1)!.join(sep);
const loadedFile = await pathToModuleFSReturn(_config, fileDir, path, namesCache);
if (ctx.isDebug() && loadedFile.error) ctx.getLogger().warn(`Error loading define file: '${loadedFile.path}'.`);
if (ctx.isDebug() && loadedFile.error) logger.warn(`Error loading define file: '${loadedFile.path}'.`);
files.push(loadedFile);
} else {
for (const childPath of dirsReader(path, _config.deep)) {
const loadedFile = await pathToModuleFSReturn(_config, path, childPath, namesCache);
if (ctx.isDebug() && loadedFile.error) ctx.getLogger().warn(`Error loading define file: '${loadedFile.path}'.`);
if (ctx.isDebug() && loadedFile.error) logger.warn(`Error loading define file: '${loadedFile.path}'.`);
files.push(loadedFile);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/runtime/helpers/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { useLogger } from '@nuxt/kit';

const logger = useLogger('AutoImport');

export default logger;

0 comments on commit 605babc

Please sign in to comment.