feat: consolidate local-first mnote web runtime
This commit is contained in:
@@ -8,7 +8,6 @@ const {
|
||||
isPortFree,
|
||||
resolveRuntimePlan,
|
||||
shouldStartBackend,
|
||||
shouldStartCelery,
|
||||
} = require("./desktop-hot.js");
|
||||
|
||||
function findFreePort() {
|
||||
@@ -116,83 +115,20 @@ test("ensurePortFree 在非 Windows 平台能释放后端监听进程", async (t
|
||||
await waitForExit(child);
|
||||
});
|
||||
|
||||
test("默认热启动计划只使用 mnote-web 作为 3000 owner,不启动 Next legacy upstream", () => {
|
||||
test("默认热启动计划只使用 mnote-web 作为 3000 owner", () => {
|
||||
const plan = resolveRuntimePlan({
|
||||
FRONTEND_PORT: "3000",
|
||||
NEXT_LEGACY_PORT: "3100",
|
||||
});
|
||||
|
||||
assert.equal(plan.skipGateway, false);
|
||||
assert.equal(plan.skipNextLegacy, true);
|
||||
assert.equal(plan.publicPort, 3000);
|
||||
assert.equal(plan.legacyPort, 3100);
|
||||
assert.equal(plan.frontendTaskName, null);
|
||||
assert.equal(plan.mnoteWebCommand, "cargo run -p mnote-web --bin mnote-web");
|
||||
assert.deepEqual(plan.mnoteWebEnv, {
|
||||
MNOTE_WEB_BIND: "0.0.0.0:3000",
|
||||
MNOTE_WEB_PUBLIC_BIND: "127.0.0.1:3000",
|
||||
MNOTE_WEB_ENABLE_LEGACY_NEXT_COMPAT: "0",
|
||||
});
|
||||
});
|
||||
|
||||
test("显式 legacy compat 也不再启动 Next legacy upstream", () => {
|
||||
const plan = resolveRuntimePlan({
|
||||
FRONTEND_PORT: "3000",
|
||||
NEXT_LEGACY_PORT: "3100",
|
||||
MNOTE_WEB_ENABLE_LEGACY_NEXT_COMPAT: "1",
|
||||
});
|
||||
|
||||
assert.equal(plan.skipGateway, false);
|
||||
assert.equal(plan.skipNextLegacy, true);
|
||||
assert.equal(plan.frontendTaskName, null);
|
||||
assert.equal(plan.mnoteWebCommand, "cargo run -p mnote-web --bin mnote-web");
|
||||
assert.deepEqual(plan.mnoteWebEnv, {
|
||||
MNOTE_WEB_BIND: "0.0.0.0:3000",
|
||||
MNOTE_WEB_PUBLIC_BIND: "127.0.0.1:3000",
|
||||
MNOTE_WEB_ENABLE_LEGACY_NEXT_COMPAT: "0",
|
||||
});
|
||||
});
|
||||
|
||||
test("MNOTE_WEB_SKIP_GATEWAY 可临时恢复旧 Next 3000 入口", () => {
|
||||
const plan = resolveRuntimePlan({
|
||||
FRONTEND_PORT: "3000",
|
||||
NEXT_LEGACY_PORT: "3100",
|
||||
MNOTE_WEB_SKIP_GATEWAY: "1",
|
||||
});
|
||||
|
||||
assert.equal(plan.skipGateway, true);
|
||||
assert.equal(plan.frontendTaskName, "frontend");
|
||||
assert.equal(plan.frontendCommand, "pnpm dev -p 3000");
|
||||
assert.deepEqual(plan.mnoteWebEnv, {});
|
||||
});
|
||||
|
||||
|
||||
test("SKIP_NEXT_LEGACY 保持 Rust gateway 为 3000 owner,但不启动 Next legacy upstream", () => {
|
||||
const plan = resolveRuntimePlan({
|
||||
FRONTEND_PORT: "3000",
|
||||
NEXT_LEGACY_PORT: "3100",
|
||||
SKIP_NEXT_LEGACY: "1",
|
||||
});
|
||||
|
||||
assert.equal(plan.skipGateway, false);
|
||||
assert.equal(plan.skipNextLegacy, true);
|
||||
assert.equal(plan.frontendTaskName, null);
|
||||
assert.equal(plan.mnoteWebCommand, "cargo run -p mnote-web --bin mnote-web");
|
||||
assert.deepEqual(plan.mnoteWebEnv, {
|
||||
MNOTE_WEB_BIND: "0.0.0.0:3000",
|
||||
MNOTE_WEB_PUBLIC_BIND: "127.0.0.1:3000",
|
||||
MNOTE_WEB_ENABLE_LEGACY_NEXT_COMPAT: "0",
|
||||
});
|
||||
});
|
||||
|
||||
test("默认跳过 Celery,只有显式开启时才启动", () => {
|
||||
assert.equal(shouldStartCelery({}), false);
|
||||
assert.equal(shouldStartCelery({ ENABLE_CELERY: "1" }), true);
|
||||
assert.equal(shouldStartCelery({ ENABLE_CELERY: "true" }), true);
|
||||
assert.equal(shouldStartCelery({ CELERY_CMD: "custom-celery" }), true);
|
||||
assert.equal(shouldStartCelery({ ENABLE_CELERY: "1", SKIP_CELERY: "1" }), false);
|
||||
});
|
||||
|
||||
test("默认跳过 FastAPI 后端,只有显式开启时才启动", () => {
|
||||
assert.equal(shouldStartBackend({}), false);
|
||||
assert.equal(shouldStartBackend({ ENABLE_BACKEND: "1" }), true);
|
||||
|
||||
Reference in New Issue
Block a user