Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ The launcher installs frozen dependencies, migrates/seeds persistent local D1,
watches and temporarily links the local contract, and starts CMS then web.
Ctrl+C stops its processes and restores the pinned package. Each service can
also run separately: start CMS there, then set `CMS_ORIGIN` when starting web
(default `http://127.0.0.1:8787`). `scripts/review.sh` runs checks and browser
tests before starting the same stack; `--serve` starts it without checks.
(default `http://127.0.0.1:8787`).
Comment thread
jacksteamdev marked this conversation as resolved.
Resolved

Before committing: `bun run sync`, `bun run check`, `bun run check:ts`,
`bun run lint`, `bun run format:check`, `node --test scripts/*.test.mjs`,
Expand Down
60 changes: 13 additions & 47 deletions scripts/dev-stack.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,15 @@ const port = (value, fallback) => {
return number;
};

export const runStack = async ({ review = false, serveOnly = false } = {}) => {
const runStack = async () => {
const root = fileURLToPath(new URL("..", import.meta.url));
const cms = cmsRepoPath();
const wp = port(process.env.WEB_PORT ?? process.env.REVIEW_WEB_PORT, 5173);
const cp = port(process.env.CMS_PORT ?? process.env.REVIEW_CMS_PORT, 8787);
const tp = port(process.env.PLAYWRIGHT_PORT, 4173);
const ports = [
wp,
cp,
cp + 10000,
...(review && !serveOnly
? [tp, tp + 1, tp + 2, tp + 4614, tp + 4615, tp + 14614, tp + 14615]
: []),
];
if (new Set([wp, cp, cp + 10000]).size !== 3 || ports.some((p) => p > 65535))
throw new Error(
"Stack and browser-test ports must be distinct and at most 65535",
);
for (const p of new Set(ports)) await availablePort(p);
const wp = port(process.env.WEB_PORT, 5173);
const cp = port(process.env.CMS_PORT, 8787);
const ports = [wp, cp, cp + 10000];
if (new Set(ports).size !== ports.length || ports.some((p) => p > 65535))
throw new Error("Stack ports must be distinct and at most 65535");
for (const p of ports) await availablePort(p);
const releaseLock = await acquireStackLock(root);
const supervisor = createSupervisor();
let linkSetup, seedWatcher, stopping;
Expand Down Expand Up @@ -61,9 +51,9 @@ export const runStack = async ({ review = false, serveOnly = false } = {}) => {
assertRunning();
return supervisor.start(...args);
};
const run = async (args, cwd = root, vars = env) => {
const run = async (args, cwd = root) => {
assertRunning();
await supervisor.run("bun", args, cwd, vars);
await supervisor.run("bun", args, cwd, env);
assertRunning();
};
try {
Expand All @@ -74,24 +64,6 @@ export const runStack = async ({ review = false, serveOnly = false } = {}) => {
linkSetup = linkLocalContract({ root, cms });
await linkSetup;
assertRunning();
if (review && !serveOnly) {
if (!process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE)
await run(["x", "playwright", "install", "chromium"]);
for (const check of ["sync", "check", "check:ts", "lint", "format:check"])
await run(["run", check]);
await supervisor.run(
"bash",
["-c", "node --test scripts/*.test.mjs"],
root,
env,
);
await run(["test", "verification"]);
await run(["run", "validate"], cms);
await run(["run", "build"]);
const localEnv = { ...env };
delete localEnv.E2E_BASE_URL;
await run(["run", "test:browser"], root, localEnv);
}
await run(["run", "migrate:local"], cms);
await run(["run", "seed:local"], cms);
const contract = start("bun", ["run", "contract:watch"], cms, env);
Expand Down Expand Up @@ -144,10 +116,6 @@ export const runStack = async ({ review = false, serveOnly = false } = {}) => {
console.log(
`\nWeb: ${wu}\nCMS: ${cu}\nLocal data persists in the CMS checkout. Ctrl+C stops this stack.`,
);
const tasks = JSON.parse(process.env.REVIEW_MANUAL_TASKS_JSON || "[]");
tasks.forEach((task, i) =>
console.log(`${i + 1}. ${task.replaceAll("{WEB}", wu)}`),
);
const name = await Promise.race(
[
["CMS", cs],
Expand All @@ -163,9 +131,7 @@ export const runStack = async ({ review = false, serveOnly = false } = {}) => {
}
};

if (process.argv[1] === fileURLToPath(import.meta.url)) {
runStack().catch((error) => {
console.error(error.message);
process.exitCode = 1;
});
}
runStack().catch((error) => {
console.error(error.message);
process.exitCode = 1;
});
70 changes: 70 additions & 0 deletions scripts/home-chart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Generates the homepage's sample chart (src/lib/home/chart.json) with the
// app's engine and settings. The moment is anonymous on the page; it was
// chosen so a few major planets sit in the visible bottom-left quarter.
//
// bun scripts/home-chart.ts
import { spawnSync } from "node:child_process";
import { readFileSync, writeFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { chartSchema, deriveAstrology } from "../src/lib/calculation/chart";
import { initialSettings } from "../src/lib/domain";

export const SAMPLE = {
utc: "2014-06-06T03:00:00Z",
latitude: 51.5074,
longitude: -0.1278,
};

const root = fileURLToPath(new URL("../static/engine/", import.meta.url));
const engine = await import(`${root}chart.js`);
engine.initSync({ module: readFileSync(`${root}chart_bg.wasm`) });
const index = JSON.parse(
readFileSync(`${root}ephemeris/index.json`, "utf8"),
) as { segments: { year: number; url: string }[] };
const slices = new Map<number, Uint8Array>();
const slice = (year: number) => {
let bytes = slices.get(year);
if (!bytes) {
const segment = index.segments.find((s) => s.year === year);
if (!segment) throw new Error(`No ephemeris for ${year}`);
bytes = readFileSync(`${root}ephemeris/${segment.url}`);
slices.set(year, bytes);
}
return bytes;
};

/** The chart and aspects the app would show for this moment and place. */
export const calculate = ({ utc, latitude, longitude }: typeof SAMPLE) => {
const { reference, divisions, houses } = initialSettings;
const chart = chartSchema.parse(
JSON.parse(
engine.calculate(
slice(new Date(utc).getUTCFullYear()),
JSON.stringify({
instant: { scale: "utc", value: utc },
latitude,
longitude,
house_system: houses,
configuration: { reference, divisions, ophiuchus: null },
}),
),
),
);
const { aspects } = deriveAstrology(chart, chart, initialSettings.atmakaraka);
return { chart, aspects };
};

if (import.meta.main) {
const out = fileURLToPath(
new URL("../src/lib/home/chart.json", import.meta.url),
);
writeFileSync(out, JSON.stringify(calculate(SAMPLE)) + "\n");
// Keep the file in the repository's format.
const format = spawnSync(
"bun",
["x", "oxfmt", "--disable-nested-config", out],
{ stdio: "inherit" },
);
if (format.status !== 0) throw new Error("oxfmt failed");
console.log(`Wrote ${out}`);
}
4 changes: 1 addition & 3 deletions scripts/processes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ export const availablePort = (port) =>
const server = createServer();
server.once("error", () =>
reject(
new Error(
`Port ${port} is unavailable; set WEB_PORT, CMS_PORT or PLAYWRIGHT_PORT.`,
),
new Error(`Port ${port} is unavailable; set WEB_PORT or CMS_PORT.`),
),
);
server.listen(port, "127.0.0.1", () => server.close(resolve));
Expand Down
55 changes: 0 additions & 55 deletions scripts/review.sh

This file was deleted.

17 changes: 6 additions & 11 deletions src/lib/ExplorerChart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -202,24 +202,19 @@
<MobileWheel {measurement}
><Wheel
{chart}
{astrology}
selectedBody={body?.name ?? null}
selectedSign={selection?.kind === "sign" ? selection.name : null}
selectedHouse={selection?.kind === "house" ? selection.number : null}
selectedAngle={selection?.kind === "angle" ? selection.name : null}
onselect={selectBody}
onselectSign={selectSign}
onselectHouse={selectHouse}
onselectAngle={selectAngle}
aspects={astrology.aspects}
selected={selection}
onglyphclick={({ glyph, origin, keyboard }) =>
choose(glyph, origin, keyboard)}
onexposeGroup={() => measurement?.expose("body_picker")}
onopenGroup={() => {
measurement?.use("body_picker");
measurement?.interaction("navigation");
}}
onselectAspects={(near, target) =>
onaspectclick={({ aspects: near, origin }) =>
openPicker(
near,
target,
origin,
body &&
near.some((a) => a.planetA === body.name || a.planetB === body.name)
? body.name
Expand Down
Loading
Loading