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.
122 lines
3.0 KiB
JavaScript
122 lines
3.0 KiB
JavaScript
/**
|
|
* @typedef {import('./types').Jiti} Jiti
|
|
* @typedef {import('./types').JitiOptions} JitiOptions
|
|
*/
|
|
|
|
const isDeno = "Deno" in globalThis;
|
|
|
|
/**
|
|
* @param {string|URL} [parentURL]
|
|
* @param {JitiOptions} [jitiOptions]
|
|
* @returns {Jiti}
|
|
*/
|
|
export function createJiti(parentURL, jitiOptions) {
|
|
parentURL = normalizeParentURL(parentURL);
|
|
|
|
/** @type {Jiti} */
|
|
function jiti() {
|
|
throw unsupportedError(
|
|
"`jiti()` is not supported in native mode, use `jiti.import()` instead.",
|
|
);
|
|
}
|
|
|
|
jiti.resolve = () => {
|
|
throw unsupportedError("`jiti.resolve()` is not supported in native mode.");
|
|
};
|
|
|
|
jiti.esmResolve = (id, opts) => {
|
|
try {
|
|
const importMeta = jitiOptions?.importMeta || import.meta;
|
|
if (isDeno) {
|
|
// Deno throws TypeError: Invalid arguments when passing parentURL
|
|
return importMeta.resolve(id);
|
|
}
|
|
const parent = normalizeParentURL(opts?.parentURL || parentURL);
|
|
return importMeta.resolve(id, parent);
|
|
} catch (error) {
|
|
if (opts?.try) {
|
|
return undefined;
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
};
|
|
|
|
jiti.import = async function (id, opts) {
|
|
for (const suffix of ["", "/index"]) {
|
|
// prettier-ignore
|
|
for (const ext of ["", ".js", ".mjs", ".cjs", ".ts", ".tsx", ".mts", ".cts"]) {
|
|
try {
|
|
const resolved = this.esmResolve(id + suffix + ext, opts);
|
|
if (!resolved) {
|
|
continue;
|
|
}
|
|
let importAttrs = undefined
|
|
if (resolved.endsWith('.json')) {
|
|
importAttrs = { with: { type: 'json'}}
|
|
}
|
|
return await import(resolved, importAttrs);
|
|
} catch (error) {
|
|
if (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {
|
|
continue
|
|
}
|
|
if (opts?.try) {
|
|
return undefined;
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
if (!opts?.try) {
|
|
const parent = normalizeParentURL(opts?.parentURL || parentURL);
|
|
const error = new Error(
|
|
`[jiti] [ERR_MODULE_NOT_FOUND] Cannot import '${id}' from '${parent}'.`,
|
|
);
|
|
error.code = "ERR_MODULE_NOT_FOUND";
|
|
throw error;
|
|
}
|
|
};
|
|
|
|
jiti.transform = () => {
|
|
throw unsupportedError(
|
|
"`jiti.transform()` is not supported in native mode.",
|
|
);
|
|
};
|
|
|
|
jiti.evalModule = () => {
|
|
throw unsupportedError(
|
|
"`jiti.evalModule()` is not supported in native mode.",
|
|
);
|
|
};
|
|
|
|
jiti.main = undefined;
|
|
jiti.extensions = Object.create(null);
|
|
jiti.cache = Object.create(null);
|
|
|
|
return jiti;
|
|
}
|
|
|
|
export default createJiti;
|
|
|
|
/**
|
|
* @param {string} message
|
|
*/
|
|
function unsupportedError(message) {
|
|
throw new Error(
|
|
`[jiti] ${message} (import or require 'jiti' instead of 'jiti/native' for more features).`,
|
|
);
|
|
}
|
|
|
|
function normalizeParentURL(input) {
|
|
if (!input) {
|
|
return "file:///";
|
|
}
|
|
if (typeof filename !== "string" || input.startsWith("file://")) {
|
|
return input;
|
|
}
|
|
if (input.endsWith("/")) {
|
|
input += "_"; // append a dummy filename
|
|
}
|
|
return `file://${input}`;
|
|
}
|