Problem: the hexagonal refactor churns the backend tree for nine more phases; the UI delivery stack (web/ SPA, cmd/desktop Wails wrapper, compose/web image) must move to its own repo first so doc/layout rewrites land once on a backend-only tree. Change: - New repo git.hubris.network/dtoro/oikos-web (v0.33.0): web/, desktop/ (updateURL repointed to oikos-web releases), compose/, own CI (web + desktop jobs), own deploy script (CI-green gate, TOCTOU guard, version-tagged images, prune-to-3), own webhook receiver on :9798 + launchd unit, own compose project publishing the same 8091:80. - Cutover executed on mac-mini in order: oikos stack's web service stopped+removed, oikos-web project brought up on 8091; outer Caddy untouched (targets the published port) — serving + Authentik flow + /wails 404 quirk verified post-cutover. - Stripped from oikos: web/, cmd/desktop/, compose/web/, desktop CI workflow, ci.yml web job, Makefile ui/desktop/desktop-package/install targets, the compose web service, oikos-web from deploy.sh's fallback prune list; wails + go-keyring dropped from go.mod, vendor synced. - README / CONTRIBUTING / AGENTS.md / .agents dev+operations docs now point at the new repo; mbse + mascot design docs carry a path note. Risk: production SPA serving depends on the new pipeline now; rollback is versioned-image re-up of the old web service from a pre-split checkout (port 8091). Desktop builds installed before the split still check dtoro/oikos releases — one manual reinstall, noted in the oikos-web release notes. Verification: go vet, make test (race), make generate-check, golangci (no new findings; baseline down 400→365); post-cutover curls — localhost:8091 200, /wails/runtime.js 404, outer Caddy 302 Authentik.
78 lines
2.3 KiB
JavaScript
78 lines
2.3 KiB
JavaScript
import { getSafeTimers } from '@vitest/utils';
|
|
|
|
const NAME_WORKER_STATE = "__vitest_worker__";
|
|
function getWorkerState() {
|
|
const workerState = globalThis[NAME_WORKER_STATE];
|
|
if (!workerState) {
|
|
const errorMsg = 'Vitest failed to access its internal state.\n\nOne of the following is possible:\n- "vitest" is imported directly without running "vitest" command\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
|
|
throw new Error(errorMsg);
|
|
}
|
|
return workerState;
|
|
}
|
|
function provideWorkerState(context, state) {
|
|
Object.defineProperty(context, NAME_WORKER_STATE, {
|
|
value: state,
|
|
configurable: true,
|
|
writable: true,
|
|
enumerable: false
|
|
});
|
|
return state;
|
|
}
|
|
function getCurrentEnvironment() {
|
|
const state = getWorkerState();
|
|
return state?.environment.name;
|
|
}
|
|
function isChildProcess() {
|
|
return typeof process !== "undefined" && !!process.send;
|
|
}
|
|
function setProcessTitle(title) {
|
|
try {
|
|
process.title = `node (${title})`;
|
|
} catch {
|
|
}
|
|
}
|
|
function resetModules(modules, resetMocks = false) {
|
|
const skipPaths = [
|
|
// Vitest
|
|
/\/vitest\/dist\//,
|
|
/\/vite-node\/dist\//,
|
|
// yarn's .store folder
|
|
/vitest-virtual-\w+\/dist/,
|
|
// cnpm
|
|
/@vitest\/dist/,
|
|
// don't clear mocks
|
|
...!resetMocks ? [/^mock:/] : []
|
|
];
|
|
modules.forEach((mod, path) => {
|
|
if (skipPaths.some((re) => re.test(path))) {
|
|
return;
|
|
}
|
|
modules.invalidateModule(mod);
|
|
});
|
|
}
|
|
function waitNextTick() {
|
|
const { setTimeout } = getSafeTimers();
|
|
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
}
|
|
async function waitForImportsToResolve() {
|
|
await waitNextTick();
|
|
const state = getWorkerState();
|
|
const promises = [];
|
|
let resolvingCount = 0;
|
|
for (const mod of state.moduleCache.values()) {
|
|
if (mod.promise && !mod.evaluated) {
|
|
promises.push(mod.promise);
|
|
}
|
|
if (mod.resolving) {
|
|
resolvingCount++;
|
|
}
|
|
}
|
|
if (!promises.length && !resolvingCount) {
|
|
return;
|
|
}
|
|
await Promise.allSettled(promises);
|
|
await waitForImportsToResolve();
|
|
}
|
|
|
|
export { getCurrentEnvironment as a, getWorkerState as g, isChildProcess as i, provideWorkerState as p, resetModules as r, setProcessTitle as s, waitForImportsToResolve as w };
|