chore(framework,medusa): load custom flags before medusa config (#13312)
* chore(framework,medusa): load custom flags before medusa config * test * test runner * changeset * check manager featureFlags * discover and register flags * rm comments * update changeset * changeset * use local cli * execute from local medusa command --------- Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
This commit is contained in:
committed by
GitHub
parent
2a94dbd243
commit
b4c0f131b7
@@ -1,3 +1,7 @@
|
||||
import { InputConfigModules } from "@medusajs/types"
|
||||
import { FeatureFlag } from "@medusajs/utils"
|
||||
import { EnvFeatureFlag } from "./src/feature-flags/env-ff"
|
||||
|
||||
const { defineConfig } = require("@medusajs/framework/utils")
|
||||
|
||||
const DB_HOST = process.env.DB_HOST
|
||||
@@ -8,6 +12,16 @@ const DB_URL = `postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}`
|
||||
|
||||
process.env.DATABASE_URL = DB_URL
|
||||
|
||||
const modules = [] as InputConfigModules
|
||||
|
||||
// The custom feature is available here and has default value set to true
|
||||
if (FeatureFlag.isFeatureEnabled(EnvFeatureFlag.key)) {
|
||||
modules.push({
|
||||
key: "custom",
|
||||
resolve: "src/modules/custom",
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = defineConfig({
|
||||
admin: {
|
||||
disable: true,
|
||||
@@ -17,10 +31,5 @@ module.exports = defineConfig({
|
||||
jwtSecret: "secret",
|
||||
},
|
||||
},
|
||||
modules: [
|
||||
{
|
||||
key: "custom",
|
||||
resolve: "src/modules/custom",
|
||||
},
|
||||
],
|
||||
modules,
|
||||
})
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { FlagSettings } from "@medusajs/framework/feature-flags"
|
||||
|
||||
export const EnvFeatureFlag: FlagSettings = {
|
||||
key: "env_ff",
|
||||
default_val: true,
|
||||
env_key: "ENV_FF",
|
||||
description: "Environment feature flag",
|
||||
}
|
||||
Reference in New Issue
Block a user