chore: dependecies reorg (#8535)
This commit is contained in:
committed by
GitHub
parent
59599ac237
commit
058378970a
@@ -1,7 +1,7 @@
|
||||
import { LinkDefinition } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
BatchMethodResponse,
|
||||
HttpTypes,
|
||||
LinkDefinition,
|
||||
MedusaContainer,
|
||||
PriceDTO,
|
||||
ProductDTO,
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../../../types/routing"
|
||||
import {
|
||||
deleteCustomerAddressesWorkflow,
|
||||
updateCustomerAddressesWorkflow,
|
||||
} from "@medusajs/core-flows"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../../../types/routing"
|
||||
|
||||
import { DeleteResponse, HttpTypes, MedusaContainer } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
MedusaError,
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/utils"
|
||||
import { MedusaContainer } from "@medusajs/modules-sdk"
|
||||
import { refetchCustomer } from "../../../helpers"
|
||||
import {
|
||||
StoreGetCustomerAddressParamsType,
|
||||
StoreUpdateCustomerAddressType,
|
||||
} from "../../../validators"
|
||||
import { refetchCustomer } from "../../../helpers"
|
||||
import { DeleteResponse, HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<StoreGetCustomerAddressParamsType>,
|
||||
|
||||
@@ -5,7 +5,7 @@ import Store from "medusa-telemetry/dist/store"
|
||||
import { EOL } from "os"
|
||||
import path from "path"
|
||||
|
||||
import { logger } from "@medusajs/framework"
|
||||
import { logger, MEDUSA_CLI_PATH } from "@medusajs/framework"
|
||||
|
||||
const defaultConfig = {
|
||||
padding: 5,
|
||||
@@ -27,12 +27,7 @@ export default async function ({ port, directory }) {
|
||||
* Re-constructing the path to Medusa CLI to execute the
|
||||
* start command.
|
||||
*/
|
||||
const cliPath = path.resolve(
|
||||
require.resolve("@medusajs/medusa-cli"),
|
||||
"..",
|
||||
"..",
|
||||
"cli.js"
|
||||
)
|
||||
const cliPath = path.resolve(MEDUSA_CLI_PATH, "..", "..", "cli.js")
|
||||
|
||||
const devServer = {
|
||||
childProcess: null as ChildProcess | null,
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import "core-js/stable"
|
||||
import "regenerator-runtime/runtime"
|
||||
|
||||
import cluster from "cluster"
|
||||
import express from "express"
|
||||
import { track } from "medusa-telemetry"
|
||||
import { scheduleJob } from "node-schedule"
|
||||
import os from "os"
|
||||
|
||||
import loaders from "../loaders"
|
||||
import { logger } from "@medusajs/framework"
|
||||
import { GracefulShutdownServer, isPresent } from "@medusajs/utils"
|
||||
import loaders from "../loaders"
|
||||
|
||||
const EVERY_SIXTH_HOUR = "0 */6 * * *"
|
||||
const CRON_SCHEDULE = EVERY_SIXTH_HOUR
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import "core-js/stable"
|
||||
import "regenerator-runtime/runtime"
|
||||
|
||||
import express from "express"
|
||||
import { track } from "medusa-telemetry"
|
||||
import { scheduleJob } from "node-schedule"
|
||||
|
||||
import loaders from "../loaders"
|
||||
import { logger } from "@medusajs/framework"
|
||||
import { GracefulShutdownServer } from "@medusajs/utils"
|
||||
import loaders from "../loaders"
|
||||
|
||||
const EVERY_SIXTH_HOUR = "0 */6 * * *"
|
||||
const CRON_SCHEDULE = EVERY_SIXTH_HOUR
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import "core-js/stable"
|
||||
import "regenerator-runtime/runtime"
|
||||
|
||||
import express from "express"
|
||||
import { track } from "medusa-telemetry"
|
||||
|
||||
import { logger } from "@medusajs/framework"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import loaders from "../loaders"
|
||||
import { logger } from "@medusajs/framework"
|
||||
|
||||
export default async function ({
|
||||
directory,
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
import { MedusaModule, registerMedusaModule } from "@medusajs/modules-sdk"
|
||||
import glob from "glob"
|
||||
import { isDefined } from "@medusajs/utils"
|
||||
|
||||
export function getInternalModules(configModule) {
|
||||
const modules = []
|
||||
const moduleResolutions = {}
|
||||
|
||||
Object.entries(configModule.modules ?? {}).forEach(([moduleKey, module]) => {
|
||||
moduleResolutions[moduleKey] = registerMedusaModule(moduleKey, module)[
|
||||
moduleKey
|
||||
]
|
||||
})
|
||||
|
||||
for (const moduleResolution of Object.values(moduleResolutions)) {
|
||||
if (
|
||||
!moduleResolution.resolutionPath ||
|
||||
moduleResolution.moduleDeclaration.scope !== "internal"
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
let loadedModule = null
|
||||
try {
|
||||
loadedModule = require(moduleResolution.resolutionPath).default
|
||||
} catch (error) {
|
||||
console.log("Error loading Module", error)
|
||||
continue
|
||||
}
|
||||
|
||||
modules.push({
|
||||
moduleDeclaration: moduleResolution.moduleDeclaration,
|
||||
loadedModule,
|
||||
})
|
||||
}
|
||||
|
||||
return modules
|
||||
}
|
||||
|
||||
export const getEnabledMigrations = (migrationDirs, isFlagEnabled) => {
|
||||
const allMigrations = migrationDirs.flatMap((dir) => {
|
||||
return glob.sync(dir)
|
||||
})
|
||||
return allMigrations
|
||||
.map((file) => {
|
||||
const loaded = require(file)
|
||||
if (!isDefined(loaded.featureFlag) || isFlagEnabled(loaded.featureFlag)) {
|
||||
delete loaded.featureFlag
|
||||
return Object.values(loaded)
|
||||
}
|
||||
})
|
||||
.flat()
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
export const getModuleMigrations = (configModule, isFlagEnabled) => {
|
||||
const loadedModules = getInternalModules(configModule)
|
||||
|
||||
const allModules = []
|
||||
|
||||
for (const loadedModule of loadedModules) {
|
||||
const mod = loadedModule.loadedModule
|
||||
|
||||
const moduleMigrations = (mod.migrations ?? [])
|
||||
.map((migration) => {
|
||||
if (
|
||||
!isDefined(migration.featureFlag) ||
|
||||
isFlagEnabled(migration.featureFlag)
|
||||
) {
|
||||
delete migration.featureFlag
|
||||
return Object.values(migration)
|
||||
}
|
||||
})
|
||||
.flat()
|
||||
.filter(Boolean)
|
||||
|
||||
allModules.push({
|
||||
moduleDeclaration: loadedModule.moduleDeclaration,
|
||||
models: mod.models ?? [],
|
||||
migrations: moduleMigrations,
|
||||
})
|
||||
}
|
||||
|
||||
return allModules
|
||||
}
|
||||
|
||||
export const getModuleSharedResources = (configModule, featureFlagsRouter) => {
|
||||
const isFlagEnabled = (flag) =>
|
||||
featureFlagsRouter && featureFlagsRouter.isFeatureEnabled(flag)
|
||||
|
||||
const loadedModules = getModuleMigrations(configModule, isFlagEnabled)
|
||||
|
||||
let migrations = []
|
||||
let models = []
|
||||
|
||||
for (const mod of loadedModules) {
|
||||
if (mod.moduleDeclaration.resources !== "shared") {
|
||||
continue
|
||||
}
|
||||
|
||||
migrations = migrations.concat(mod.migrations)
|
||||
|
||||
models = models.concat(mod.models ?? [])
|
||||
}
|
||||
|
||||
return {
|
||||
models,
|
||||
migrations,
|
||||
}
|
||||
}
|
||||
|
||||
export const runIsolatedModulesMigration = async (configModule) => {
|
||||
const moduleResolutions = {}
|
||||
Object.entries(configModule.modules ?? {}).forEach(([moduleKey, module]) => {
|
||||
moduleResolutions[moduleKey] = registerMedusaModule(moduleKey, module)[
|
||||
moduleKey
|
||||
]
|
||||
})
|
||||
|
||||
for (const moduleResolution of Object.values(moduleResolutions)) {
|
||||
if (
|
||||
!moduleResolution.resolutionPath ||
|
||||
moduleResolution.moduleDeclaration.scope !== "internal" ||
|
||||
moduleResolution.moduleDeclaration.resources !== "isolated"
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
await MedusaModule.migrateUp({
|
||||
moduleKey: moduleResolution.definition.key,
|
||||
modulePath: moduleResolution.resolutionPath,
|
||||
options: moduleResolution.options,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const revertIsolatedModulesMigration = async (configModule) => {
|
||||
const moduleResolutions = {}
|
||||
Object.entries(configModule.modules ?? {}).forEach(([moduleKey, module]) => {
|
||||
moduleResolutions[moduleKey] = registerMedusaModule(moduleKey, module)[
|
||||
moduleKey
|
||||
]
|
||||
})
|
||||
|
||||
for (const moduleResolution of Object.values(moduleResolutions)) {
|
||||
if (
|
||||
!moduleResolution.resolutionPath ||
|
||||
moduleResolution.moduleDeclaration.scope !== "internal" ||
|
||||
moduleResolution.moduleDeclaration.resources !== "isolated"
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
await MedusaModule.migrateDown({
|
||||
moduleKey: moduleResolution.definition.key,
|
||||
modulePath: moduleResolution.resolutionPath,
|
||||
options: moduleResolution.options,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import "reflect-metadata"
|
||||
|
||||
export interface FindConfig<Entity> {
|
||||
select?: (keyof Entity)[]
|
||||
skip?: number
|
||||
|
||||
Reference in New Issue
Block a user