#!/usr/bin/env node // Totems install helper. No packages needed. `plan` only reads. `apply` adds one line. `check` asks Totems about one public page. import fs from "node:fs"; import path from "node:path"; const skip = new Set(["node_modules", ".git", ".next", "dist", "build", "out", ".astro", "vendor", "coverage", ".vercel"]); export function readArgs(a) { const o = {}; for (let i = 0; i < a.length; i++) if (a[i].startsWith("--")) o[a[i].slice(2)] = a[++i] ?? ""; return o; } export function checkInput({ src, key }) { let u; try { u = new URL(src); } catch { throw new Error("The script address is not a web address."); } if (u.protocol !== "https:" || u.username || u.password || u.search || u.hash || !u.pathname.endsWith("/t.js")) throw new Error("The script address must start with https:// and end with /t.js."); if (!/^mk_[A-Za-z0-9_-]{6,80}$/.test(key ?? "")) throw new Error("The site key starts with mk_. Never use an API key here."); } export const line = ({ src, key }) => ``; const jsx = ({ src, key }) => `