* feat: add feature flag loading in projects * fix: make feature flag consume itself * fix: rename container registration to featureFlagRouter * fix: refactor * behavioral feature flags * add environment to server * limit "useTemplateDb" to non feature flagged migrations * filter migrations and entities according to those which are enabled in the environment * run only migrations that are enabled when running 'medusa migrations run' * add logging to the featureflag loader * initial implementation of featureFlagEntity * column descriptors * initial startServerWithEnv (to be refactored) * update commands * final touches * update loaders to fix unit tests * enable all batch job tests * update seed method * add api test capabilities * revert batch job test * revert formatting changes * pr feedback * pr feedback * remove unused imports * rename feature flag decorators * pr feedback Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
const path = require("path")
|
|
const { spawn } = require("child_process")
|
|
const { setPort } = require("./use-api")
|
|
|
|
module.exports = ({ cwd, redisUrl, uploadDir, verbose, env }) => {
|
|
const serverPath = path.join(__dirname, "test-server.js")
|
|
|
|
// in order to prevent conflicts in redis, use a different db for each worker
|
|
// same fix as for databases (works with up to 15)
|
|
// redis dbs are 0-indexed and jest worker ids are indexed from 1
|
|
const workerId = parseInt(process.env.JEST_WORKER_ID || "1")
|
|
const redisUrlWithDatabase = `${redisUrl}/${workerId - 1}`
|
|
|
|
return new Promise((resolve, reject) => {
|
|
const medusaProcess = spawn("node", [path.resolve(serverPath)], {
|
|
cwd,
|
|
env: {
|
|
...process.env,
|
|
NODE_ENV: "development",
|
|
JWT_SECRET: "test",
|
|
COOKIE_SECRET: "test",
|
|
REDIS_URL: redisUrl ? redisUrlWithDatabase : undefined, // If provided, will use a real instance, otherwise a fake instance
|
|
UPLOAD_DIR: uploadDir, // If provided, will be used for the fake local file service
|
|
...env,
|
|
},
|
|
stdio: verbose
|
|
? ["inherit", "inherit", "inherit", "ipc"]
|
|
: ["ignore", "ignore", "ignore", "ipc"],
|
|
})
|
|
|
|
medusaProcess.on("uncaughtException", (err) => {
|
|
medusaProcess.kill()
|
|
})
|
|
|
|
medusaProcess.on("message", (port) => {
|
|
setPort(port)
|
|
resolve(medusaProcess)
|
|
})
|
|
})
|
|
}
|