diff --git a/.changeset/slow-moons-fetch.md b/.changeset/slow-moons-fetch.md new file mode 100644 index 0000000000..1e5932aac1 --- /dev/null +++ b/.changeset/slow-moons-fetch.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +fix(medusa): Use default logger in plugin:develop diff --git a/packages/medusa/src/commands/plugin/db/generate.ts b/packages/medusa/src/commands/plugin/db/generate.ts index 534f76e3ef..7e60db9760 100644 --- a/packages/medusa/src/commands/plugin/db/generate.ts +++ b/packages/medusa/src/commands/plugin/db/generate.ts @@ -1,18 +1,16 @@ +import { logger } from "@medusajs/framework" import type { Logger } from "@medusajs/framework/types" import { - ContainerRegistrationKeys, defineMikroOrmCliConfig, DmlEntity, dynamicImport, isFileSkipped, toUnixSlash, } from "@medusajs/framework/utils" -import { glob } from "glob" -import { dirname, join } from "path" - import { MetadataStorage } from "@mikro-orm/core" import { MikroORM } from "@mikro-orm/postgresql" -import { initializeContainer } from "../../../loaders" +import { glob } from "glob" +import { dirname, join } from "path" const TERMINAL_SIZE = process.stdout.columns @@ -20,11 +18,6 @@ const TERMINAL_SIZE = process.stdout.columns * Generate migrations for all scanned modules in a plugin */ const main = async function ({ directory }) { - const container = await initializeContainer(directory, { - skipDbConnection: true, - }) - const logger = container.resolve(ContainerRegistrationKeys.LOGGER) - try { const moduleDescriptors = [] as { serviceName: string diff --git a/packages/medusa/src/commands/plugin/db/integration-tests/__tests__/plugin-generate.spec.ts b/packages/medusa/src/commands/plugin/db/integration-tests/__tests__/plugin-generate.spec.ts index 28be2bb689..7554b6fbe5 100644 --- a/packages/medusa/src/commands/plugin/db/integration-tests/__tests__/plugin-generate.spec.ts +++ b/packages/medusa/src/commands/plugin/db/integration-tests/__tests__/plugin-generate.spec.ts @@ -1,24 +1,9 @@ +import { logger } from "@medusajs/framework" import { FileSystem } from "@medusajs/framework/utils" import { join } from "path" import main from "../../generate" -const logger = { - log: jest.fn(), - info: jest.fn(), - error: jest.fn(), - warn: jest.fn(), -} - jest.mock("@medusajs/framework/logger") -jest.mock("../../../../../loaders", () => { - return { - initializeContainer: jest.fn().mockImplementation(() => { - return { - resolve: jest.fn(() => logger), - } - }), - } -}) describe("plugin-generate", () => { beforeEach(() => { @@ -28,8 +13,6 @@ describe("plugin-generate", () => { .mockImplementation((code?: string | number | null) => { return code as never }) - - jest.mock("@medusajs/framework/logger") }) afterEach(async () => { diff --git a/packages/medusa/src/commands/plugin/develop.ts b/packages/medusa/src/commands/plugin/develop.ts index 8c4146231f..d8aff6889d 100644 --- a/packages/medusa/src/commands/plugin/develop.ts +++ b/packages/medusa/src/commands/plugin/develop.ts @@ -1,18 +1,14 @@ import { Compiler } from "@medusajs/framework/build-tools" -import { ContainerRegistrationKeys } from "@medusajs/framework/utils" +import { logger } from "@medusajs/framework/logger" import * as swcCore from "@swc/core" import { execFile } from "child_process" import path from "path" -import { initializeContainer } from "../../loaders" export default async function developPlugin({ directory, }: { directory: string }) { - const container = await initializeContainer(directory) - const logger = container.resolve(ContainerRegistrationKeys.LOGGER) - let isBusy = false const compiler = new Compiler(directory, logger) const parsedConfig = await compiler.loadTSConfigFile()