@lifeaitools/clauth 2.10.0 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli/commands/serve.js
CHANGED
|
@@ -103,6 +103,16 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
103
103
|
const CLAUTH_ROOT_DIR = path.join(__dirname, "../..");
|
|
104
104
|
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "../../package.json"), "utf8"));
|
|
105
105
|
const VERSION = pkg.version;
|
|
106
|
+
// Computed ONCE per daemon process, at module load -- never polled. Answers
|
|
107
|
+
// "what am I looking at": this build's commit date, and whether this
|
|
108
|
+
// process is the live daemon (LIVE_PORT, not staged) or a dev/test instance.
|
|
109
|
+
// A prior version of this polled a per-request HTTP route with a live git
|
|
110
|
+
// shell-out every 30s, which is exactly the wrong shape for a fact that
|
|
111
|
+
// only changes when the daemon itself restarts.
|
|
112
|
+
let BUILD_DATE = null;
|
|
113
|
+
try {
|
|
114
|
+
BUILD_DATE = execSyncTop("git log -1 --format=%cs HEAD", { cwd: CLAUTH_ROOT_DIR, encoding: "utf8", windowsHide: true }).trim() || null;
|
|
115
|
+
} catch { /* not a git checkout, or git unavailable -- BUILD_DATE stays null */ }
|
|
106
116
|
|
|
107
117
|
// Dashboard client CSS/JS ship as static assets (../dashboard/) rather than
|
|
108
118
|
// inlined in dashboardHtml()'s template literal — read once at module load,
|
|
@@ -946,6 +956,8 @@ export function dashboardHtml(port, whitelist, isStaged = false, initWriteToken
|
|
|
946
956
|
<script>
|
|
947
957
|
window.__CLAUTH_VERSION__ = ${JSON.stringify(VERSION)};
|
|
948
958
|
window.__CLAUTH_INIT_WRITE_TOKEN__ = ${JSON.stringify(initWriteToken)};
|
|
959
|
+
window.__CLAUTH_BUILD_DATE__ = ${JSON.stringify(BUILD_DATE)};
|
|
960
|
+
window.__CLAUTH_IS_LIVE__ = ${JSON.stringify(port === LIVE_PORT && !isStaged)};
|
|
949
961
|
</script>
|
|
950
962
|
<script src="/dashboard/panel-element.js"></script>
|
|
951
963
|
<script src="/dashboard/panels/panel-registry.js"></script>
|
|
@@ -1814,32 +1826,6 @@ function createServer(initPassword, whitelist, port, tunnelHostnameInit = null,
|
|
|
1814
1826
|
}
|
|
1815
1827
|
});
|
|
1816
1828
|
registerReadOnlyRoute("GET", "/builds", async (req, res) => ok(res, buildStatus));
|
|
1817
|
-
// GET /deploy-status — this daemon's own environment identity, NOT the
|
|
1818
|
-
// regen-root build pipeline /builds surfaces. Two independent axes:
|
|
1819
|
-
// live vs test -- is this the daemon Dave uses directly (LIVE_PORT,
|
|
1820
|
-
// not staged), or a test/isolated/staged instance?
|
|
1821
|
-
// local vs develop -- does the running checkout's HEAD match
|
|
1822
|
-
// origin/develop with a clean working tree (what's
|
|
1823
|
-
// actually published), or does it diverge (uncommitted
|
|
1824
|
-
// changes, or a different commit)?
|
|
1825
|
-
// Answers the dashboard's own "what am I looking at" question -- the
|
|
1826
|
-
// thing that previously read as an unrelated, confusing status pulled
|
|
1827
|
-
// from Supabase's regen-root build_status blob.
|
|
1828
|
-
registerReadOnlyRoute("GET", "/deploy-status", async (req, res) => {
|
|
1829
|
-
const isLive = port === LIVE_PORT && !isStaged;
|
|
1830
|
-
let headSha = null;
|
|
1831
|
-
let synced = null;
|
|
1832
|
-
try {
|
|
1833
|
-
headSha = execSyncTop("git rev-parse --short=7 HEAD", { cwd: CLAUTH_ROOT_DIR, encoding: "utf8" }).trim();
|
|
1834
|
-
const dirty = execSyncTop("git status --porcelain", { cwd: CLAUTH_ROOT_DIR, encoding: "utf8" }).trim().length > 0;
|
|
1835
|
-
let developSha = null;
|
|
1836
|
-
try {
|
|
1837
|
-
developSha = execSyncTop("git rev-parse --short=7 origin/develop", { cwd: CLAUTH_ROOT_DIR, encoding: "utf8" }).trim();
|
|
1838
|
-
} catch { /* no origin/develop ref cached locally -- synced stays unknown */ }
|
|
1839
|
-
synced = developSha !== null ? (!dirty && headSha === developSha) : null;
|
|
1840
|
-
} catch { /* git unavailable -- headSha/synced stay null, panel shows "local" (unknown = not confirmed synced) */ }
|
|
1841
|
-
return ok(res, { is_live: isLive, is_staged: isStaged, port, synced, head_sha: headSha });
|
|
1842
|
-
});
|
|
1843
1829
|
// GET /migrations — migration registry and last run result
|
|
1844
1830
|
registerReadOnlyRoute("GET", "/migrations", async (req, res) => ok(res, {
|
|
1845
1831
|
schema_version: CURRENT_SCHEMA_VERSION,
|
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
// cli/dashboard/panels/build-status-panel.js
|
|
2
2
|
// The "Deploy" identity badge, as a real Web Component: <clauth-build-status-panel>.
|
|
3
|
-
// Answers ONE question: what am I looking at?
|
|
4
|
-
// Dave uses directly)
|
|
5
|
-
//
|
|
6
|
-
// working tree, or a different commit) vs Develop (HEAD matches
|
|
7
|
-
// origin/develop exactly, clean tree -- what's actually published).
|
|
3
|
+
// Answers ONE question: what am I looking at? Version, build date, and
|
|
4
|
+
// whether this is Live (port 52437, the daemon Dave uses directly) or a
|
|
5
|
+
// dev/test instance.
|
|
8
6
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
7
|
+
// These are all facts that only change when the daemon itself restarts --
|
|
8
|
+
// serve.js computes VERSION/BUILD_DATE/is-live ONCE at module load and
|
|
9
|
+
// injects them as window.__CLAUTH_*__ globals in the page's own inline
|
|
10
|
+
// preamble (same mechanism as window.__CLAUTH_VERSION__). This panel just
|
|
11
|
+
// reads those synchronously. An earlier version of this fetched GET
|
|
12
|
+
// /deploy-status on a 30s poll, which ran three git shell-outs per call on
|
|
13
|
+
// the server -- exactly the shape of "unexplained periodic activity" that
|
|
14
|
+
// should never exist for a fact that doesn't change between daemon
|
|
15
|
+
// restarts. No fetch, no poll, no server route.
|
|
16
|
+
//
|
|
17
|
+
// Previously (before that) this panel polled GET /builds, which is
|
|
18
|
+
// regen-root's OWN build pipeline status (borrowed from Supabase's
|
|
19
|
+
// prt_storage.build_status blob) -- unrelated to clauth's own runtime
|
|
20
|
+
// identity, and the source of "not sure what that sync message is"
|
|
21
|
+
// confusion. /builds and its backing poller are untouched in serve.js in
|
|
22
|
+
// case another consumer still needs regen-root's build status; this panel
|
|
15
23
|
// simply no longer surfaces it.
|
|
16
24
|
//
|
|
17
25
|
// Same conversion shape as every panel before it (tunnel-panel.js is the
|
|
18
26
|
// reference implementation): a class extending window.ClauthPanelElement,
|
|
19
27
|
// its own template()/mount(), instance state instead of module-level
|
|
20
|
-
// globals
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
// ClauthPanelRegistry.mountAll(), after every script has loaded.
|
|
28
|
+
// globals. connectedCallback() (panel-element.js) fires during HTML
|
|
29
|
+
// parsing, before dashboard.js has loaded -- but this panel's mount() only
|
|
30
|
+
// reads window globals the inline preamble already set before any panel
|
|
31
|
+
// script runs, so there's no "BASE is not defined" hazard here the way
|
|
32
|
+
// there was for panels that fetch.
|
|
26
33
|
//
|
|
27
|
-
// This panel owns none of WRITE_ACTIONS
|
|
28
|
-
// so it needs no write-guard bridge -- unlike tunnel-panel.js/webdav-panel.js.
|
|
34
|
+
// This panel owns none of WRITE_ACTIONS and needs no write-guard bridge.
|
|
29
35
|
//
|
|
30
36
|
// Loaded as a plain classic <script> (not type="module") BEFORE dashboard.js
|
|
31
37
|
// -- same pattern as every other panel component.
|
|
@@ -44,41 +50,23 @@ class ClauthBuildStatusPanel extends window.ClauthPanelElement {
|
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
mount() {
|
|
47
|
-
|
|
48
|
-
this
|
|
49
|
-
|
|
50
|
-
// (a fresh push or a new local edit shows up within half a minute)
|
|
51
|
-
// without polling as aggressively as a per-request build/test pipeline
|
|
52
|
-
// status would need.
|
|
53
|
-
this.pollTimer = setInterval(() => this.updateDeployStatus(), 30000);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async updateDeployStatus() {
|
|
57
|
-
try {
|
|
58
|
-
const data = await fetch(BASE + "/deploy-status").then(r => r.json());
|
|
59
|
-
const dot = this.$("#deploy-dot");
|
|
60
|
-
const label = this.$("#deploy-label");
|
|
61
|
-
const sha = this.$("#deploy-sha");
|
|
53
|
+
const dot = this.$("#deploy-dot");
|
|
54
|
+
const label = this.$("#deploy-label");
|
|
55
|
+
const sha = this.$("#deploy-sha");
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const syncWord = data.synced === true ? "Develop" : "Local";
|
|
68
|
-
const text = envWord + " - " + syncWord;
|
|
57
|
+
const isLive = window.__CLAUTH_IS_LIVE__ === true;
|
|
58
|
+
const envWord = isLive ? "Live" : "Dev";
|
|
59
|
+
const version = window.__CLAUTH_VERSION__ || "?";
|
|
60
|
+
const buildDate = window.__CLAUTH_BUILD_DATE__;
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} catch {
|
|
74
|
-
const label = this.$("#deploy-label");
|
|
75
|
-
if (label) label.textContent = "unknown";
|
|
76
|
-
}
|
|
62
|
+
dot.className = "deploy-dot " + (isLive ? "live" : "test");
|
|
63
|
+
label.textContent = envWord + " · v" + version;
|
|
64
|
+
sha.textContent = buildDate ? "built " + buildDate : "";
|
|
77
65
|
}
|
|
78
66
|
|
|
79
67
|
// No data-action elements in this panel's template -- it is pure display,
|
|
80
|
-
//
|
|
81
|
-
// than implicit-via-undefined.
|
|
68
|
+
// computed once from values the page already loaded with. Declared
|
|
69
|
+
// anyway so the contract is explicit rather than implicit-via-undefined.
|
|
82
70
|
get actions() {
|
|
83
71
|
return {};
|
|
84
72
|
}
|