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.
120 lines
2.8 KiB
JavaScript
120 lines
2.8 KiB
JavaScript
function toArr(any) {
|
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
}
|
|
|
|
function toVal(out, key, val, opts) {
|
|
var x, old=out[key], nxt=(
|
|
!!~opts.string.indexOf(key) ? (val == null || val === true ? '' : String(val))
|
|
: typeof val === 'boolean' ? val
|
|
: !!~opts.boolean.indexOf(key) ? (val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val),!!val))
|
|
: (x = +val,x * 0 === 0) ? x : val
|
|
);
|
|
out[key] = old == null ? nxt : (Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
|
|
}
|
|
|
|
module.exports = function (args, opts) {
|
|
args = args || [];
|
|
opts = opts || {};
|
|
|
|
var k, arr, arg, name, val, out={ _:[] };
|
|
var i=0, j=0, idx=0, len=args.length;
|
|
|
|
const alibi = opts.alias !== void 0;
|
|
const strict = opts.unknown !== void 0;
|
|
const defaults = opts.default !== void 0;
|
|
|
|
opts.alias = opts.alias || {};
|
|
opts.string = toArr(opts.string);
|
|
opts.boolean = toArr(opts.boolean);
|
|
|
|
if (alibi) {
|
|
for (k in opts.alias) {
|
|
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
for (i=0; i < arr.length; i++) {
|
|
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
for (i=opts.boolean.length; i-- > 0;) {
|
|
arr = opts.alias[opts.boolean[i]] || [];
|
|
for (j=arr.length; j-- > 0;) opts.boolean.push(arr[j]);
|
|
}
|
|
|
|
for (i=opts.string.length; i-- > 0;) {
|
|
arr = opts.alias[opts.string[i]] || [];
|
|
for (j=arr.length; j-- > 0;) opts.string.push(arr[j]);
|
|
}
|
|
|
|
if (defaults) {
|
|
for (k in opts.default) {
|
|
name = typeof opts.default[k];
|
|
arr = opts.alias[k] = opts.alias[k] || [];
|
|
if (opts[name] !== void 0) {
|
|
opts[name].push(k);
|
|
for (i=0; i < arr.length; i++) {
|
|
opts[name].push(arr[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const keys = strict ? Object.keys(opts.alias) : [];
|
|
|
|
for (i=0; i < len; i++) {
|
|
arg = args[i];
|
|
|
|
if (arg === '--') {
|
|
out._ = out._.concat(args.slice(++i));
|
|
break;
|
|
}
|
|
|
|
for (j=0; j < arg.length; j++) {
|
|
if (arg.charCodeAt(j) !== 45) break; // "-"
|
|
}
|
|
|
|
if (j === 0) {
|
|
out._.push(arg);
|
|
} else if (arg.substring(j, j + 3) === 'no-') {
|
|
name = arg.substring(j + 3);
|
|
if (strict && !~keys.indexOf(name)) {
|
|
return opts.unknown(arg);
|
|
}
|
|
out[name] = false;
|
|
} else {
|
|
for (idx=j+1; idx < arg.length; idx++) {
|
|
if (arg.charCodeAt(idx) === 61) break; // "="
|
|
}
|
|
|
|
name = arg.substring(j, idx);
|
|
val = arg.substring(++idx) || (i+1 === len || (''+args[i+1]).charCodeAt(0) === 45 || args[++i]);
|
|
arr = (j === 2 ? [name] : name);
|
|
|
|
for (idx=0; idx < arr.length; idx++) {
|
|
name = arr[idx];
|
|
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
|
toVal(out, name, (idx + 1 < arr.length) || val, opts);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (defaults) {
|
|
for (k in opts.default) {
|
|
if (out[k] === void 0) {
|
|
out[k] = opts.default[k];
|
|
}
|
|
}
|
|
}
|
|
|
|
if (alibi) {
|
|
for (k in out) {
|
|
arr = opts.alias[k] || [];
|
|
while (arr.length > 0) {
|
|
out[arr.shift()] = out[k];
|
|
}
|
|
}
|
|
}
|
|
|
|
return out;
|
|
}
|