import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { test } from "vitest";

const packageJsonPath = resolve(import.meta.dirname, "../../package.json");
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8")) as {
	scripts?: Record<string, string>;
};

test("sf:server starts the daemon-backed development server", () => {
	const script = packageJson.scripts?.["sf:server"];
	assert.ok(script, "package.json must define a sf:server script");
	assert.match(
		script,
		/node scripts\/dev-server\.js/,
		"sf:server must run the daemon-backed server entrypoint",
	);
	assert.equal(packageJson.scripts?.["sf:web"], undefined);
});
