Lines 260-300javascript
260/** A team's effective tier (mirrors lib/access.ts tierOf: invalid ⇒ 1). */
262 return Number.isInteger(t.tier) && t.tier >= 1 ? t.tier : 1;
265/** Parse a --tier value or a positional tier arg into an int ≥ 1, or die. */
266function parseTier(raw) {
267 const n = Number(raw);
268 if (!Number.isInteger(n) || n < 1) die(`tier must be an integer ≥ 1, got ${JSON.stringify(raw)}`);
272/** The counterparty's event stream on PostHog (the /events tab, not the empty
273 * Profile notebook the bare group URL lands on). Defaults to a 24h window in the
274 * UI — widen the date dropdown there for sparse viewers. */
275function phGroupUrl(org) {
276 return `${PH_HOST}/project/${PH_PROJECT}/groups/${PH_GROUP_TYPE}/${encodeURIComponent(org)}/events`;
279/** Run a HogQL query, or null if no personal API key is configured. */
280async function phQuery(sql) {
281 const key = process.env.POSTHOG_PERSONAL_API_KEY;
282 if (!key) return null;
283 const res = await fetch(`${PH_HOST}/api/projects/${PH_PROJECT}/query/`, {
285 headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
286 body: JSON.stringify({ query: { kind: "HogQLQuery", query: sql } }),
288 if (!res.ok) die(`PostHog query failed: ${res.status} ${(await res.text()).slice(0, 300)}`);
289 return (await res.json()).results ?? [];
292/** Open a URL in the default browser. */
293function openInBrowser(url) {
294 const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
295 spawnSync(cmd, [url], { stdio: "ignore" });
296}
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
template/scripts/portal.mjsView on unpkg · L280 298// ─── commands ────────────────────────────────────────────────────────────────
300function cmdLs(flags) {