chore: dependecies reorg (#8535)
This commit is contained in:
@@ -41,20 +41,19 @@
|
||||
"serve": "node dist/app.js",
|
||||
"test": "jest --silent --bail --maxWorkers=50% --forceExit"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"awilix": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@inquirer/checkbox": "^2.3.11",
|
||||
"@medusajs/admin-sdk": "0.0.1",
|
||||
"@medusajs/core-flows": "^0.0.9",
|
||||
"@medusajs/framework": "^0.0.1",
|
||||
"@medusajs/link-modules": "^0.2.11",
|
||||
"@medusajs/medusa-cli": "^1.3.22",
|
||||
"@medusajs/modules-sdk": "^1.12.11",
|
||||
"@medusajs/orchestration": "^0.5.7",
|
||||
"@medusajs/utils": "^1.11.9",
|
||||
"@medusajs/workflows-sdk": "^0.1.6",
|
||||
"@swc/core": "1.5.7",
|
||||
"@swc/helpers": "^0.5.11",
|
||||
"awilix": "^8.0.0",
|
||||
"body-parser": "^1.19.0",
|
||||
"boxen": "^5.0.1",
|
||||
"chalk": "^4.0.0",
|
||||
@@ -62,9 +61,7 @@
|
||||
"compression": "^1.7.4",
|
||||
"connect-redis": "^5.0.0",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"core-js": "^3.6.5",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.18.2",
|
||||
"express-session": "^1.17.3",
|
||||
"fs-exists-cached": "^1.0.0",
|
||||
@@ -76,13 +73,7 @@
|
||||
"morgan": "^1.9.1",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"node-schedule": "^2.1.1",
|
||||
"passport": "^0.6.0",
|
||||
"passport-custom": "^1.1.1",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"passport-local": "^1.0.0",
|
||||
"qs": "^6.11.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"regenerator-runtime": "^0.13.11",
|
||||
"request-ip": "^3.3.0",
|
||||
"uuid": "^9.0.0",
|
||||
"zod": "3.22.4"
|
||||
|
||||
@@ -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