fix(medusa): Use default logger in plugin:develop (#13375)
**What** Use default logger for plugin command, since there is no `medusa-config.ts` to load the container with (the container that holds the custom logger)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): Use default logger in plugin:develop
|
||||
@@ -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
|
||||
|
||||
+1
-18
@@ -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 () => {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user