fix: close durable queue and runtime gaps
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "@wrnexus/cli",
|
||||
"version": "0.8.59",
|
||||
"version": "0.8.60",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./workspace": "./src/workspace.ts"
|
||||
"./workspace": "./src/workspace.ts",
|
||||
"./test-setup": "./src/test-setup.ts"
|
||||
},
|
||||
"bin": {
|
||||
"wrnexus": "src/index.ts"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { registerDb, setDb } from "@wrnexus/db";
|
||||
import { connectFromConfig } from "@wrnexus/db/connect";
|
||||
import { loadAppConfig, loadEnv } from "@wrnexus/styles";
|
||||
|
||||
const root = process.env.WRNEXUS_TEST_ROOT;
|
||||
if (root) {
|
||||
const profile = process.env.WRNEXUS_PROFILE || "test";
|
||||
loadEnv(root, profile);
|
||||
const config = await loadAppConfig(root, profile);
|
||||
if (config.db) setDb(connectFromConfig(config.db, root));
|
||||
for (const [name, database] of Object.entries(config.databases ?? {})) {
|
||||
registerDb(name, connectFromConfig(database, root));
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ export interface TestCommandPlan {
|
||||
level?: TestLevel;
|
||||
files: string[];
|
||||
setup?: { command: string; args: string[] };
|
||||
env?: Record<string, string>;
|
||||
}
|
||||
|
||||
function shardFiles(files: string[], value?: string): string[] {
|
||||
@@ -69,6 +70,9 @@ export function createTestPlan(appRoot: string, args: string[]): TestCommandPlan
|
||||
const root = resolve(appRoot);
|
||||
const level = args.find((value): value is TestLevel => TEST_LEVELS.includes(value as TestLevel));
|
||||
const watch = args.includes("--watch");
|
||||
const profile = args.find((value) => value.startsWith("--profile="))?.slice(10) || "test";
|
||||
const setupSource = join(import.meta.dir, "test-setup.ts");
|
||||
const setupModule = existsSync(setupSource) ? setupSource : join(import.meta.dir, "test-setup.js");
|
||||
const shard = args.find((value) => value.startsWith("--shard="))?.slice(8);
|
||||
const browsers = (args.find((value) => value.startsWith("--browsers="))?.slice(11) ?? "chromium")
|
||||
.split(",")
|
||||
@@ -120,10 +124,18 @@ export function createTestPlan(appRoot: string, args: string[]): TestCommandPlan
|
||||
);
|
||||
return {
|
||||
command: process.execPath,
|
||||
args: ["test", ...(watch ? ["--watch"] : []), ...(pattern ? files : []), ...passthrough],
|
||||
args: [
|
||||
"test",
|
||||
"--preload",
|
||||
setupModule,
|
||||
...(watch ? ["--watch"] : []),
|
||||
...(pattern ? files : []),
|
||||
...passthrough,
|
||||
],
|
||||
cwd: root,
|
||||
level,
|
||||
files,
|
||||
env: { WRNEXUS_TEST_ROOT: root, WRNEXUS_PROFILE: profile },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -136,7 +148,12 @@ export function runTests(appRoot: string, args: string[]): ChildProcess | null {
|
||||
process.exitCode = 1;
|
||||
return null;
|
||||
}
|
||||
const launch = () => spawn(plan.command, plan.args, { stdio: "inherit", cwd: plan.cwd });
|
||||
const launch = () =>
|
||||
spawn(plan.command, plan.args, {
|
||||
stdio: "inherit",
|
||||
cwd: plan.cwd,
|
||||
env: { ...process.env, ...plan.env },
|
||||
});
|
||||
if (plan.setup) {
|
||||
const setup = spawn(plan.setup.command, plan.setup.args, { stdio: "inherit", cwd: plan.cwd });
|
||||
setup.on("exit", (code, signal) => {
|
||||
|
||||
@@ -50,6 +50,15 @@ describe("test command planning", () => {
|
||||
test("keeps the unfiltered legacy command", async () => {
|
||||
const plan = createTestPlan(await fixture(), ["--watch"]);
|
||||
expect(plan.level).toBeUndefined();
|
||||
expect(plan.args).toEqual(["test", "--watch"]);
|
||||
expect(plan.args[0]).toBe("test");
|
||||
expect(plan.args).toContain("--preload");
|
||||
expect(plan.args.at(-1)).toBe("--watch");
|
||||
expect(plan.env?.WRNEXUS_PROFILE).toBe("test");
|
||||
});
|
||||
|
||||
test("passes the selected profile to automatic database setup", async () => {
|
||||
const plan = createTestPlan(await fixture(), ["--profile=ci"]);
|
||||
expect(plan.env?.WRNEXUS_PROFILE).toBe("ci");
|
||||
expect(plan.args).not.toContain("--profile=ci");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user