railyard/packages/cli/test/copy.test.mjs
caelum0x 15c88e452b feat(ship): deploy from a Scribase project with its URL and anon key, link-scribase, and the deploy slot on the bridge (PY1.2)
Railyard side of PY1.2 (SC-E2, SP-F2). Acceptance:
1. packages/cli/src/scribase/env.mjs: in a Scribase project folder,
   `railyard deploy` reads the public URL and anon key `scribase init` wrote
   (.env, .env.local; NEXT_PUBLIC_/VITE_/EXPO_PUBLIC_/PUBLIC_ variants) into
   the build env and onto the Worker (--var), prints their names only, and
   leaves secrets out by name (service role key, SECRET/PASSWORD names, a
   service-role JWT under any name). `railyard link-scribase` reads a one-time
   claim from stdin (no flag takes it), exchanges it once and saves the token
   0600; nothing is printed.
2. A git branch with Scribase branch settings (.scribase/branches/<branch>.env,
   written by the PS2.0 hook) deploys its <app>-<branch> preview against that
   branch (fixture test).
3. Bridge: deploy slot landed; proof is the latest successful deploy; new
   route POST /api/v1/bridge/scribase/deploys lists the bound org's deploys for
   the Scribase Deploy tab (org isolation test). Contract cases added.
4. Real Cloudflare end-to-end stays owner-run (tests use the fake wrangler).

Tests: packages/cli 13/13, console bridge + deploys 15/15, tests/contract 3/3,
tsc clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 20:42:19 +03:00

28 lines
1.4 KiB
JavaScript

// The README and every string the CLI prints pass the vendored copy denylist (docs surface).
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync, readdirSync, statSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { errors, formatFindings, lintUnits, markdownUnits } from "../../../policy/copy-lint.mjs";
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
test("README passes the copy lint", () => {
const found = errors(lintUnits(markdownUnits(readFileSync(join(ROOT, "README.md"), "utf8"), { where: "README.md" })));
assert.deepEqual(found, [], formatFindings(found));
});
test("CLI output strings pass the copy lint", () => {
// Every source file, including src/scribase/ (PY1.2).
const files = (dir) => readdirSync(dir).flatMap((f) => (statSync(join(dir, f)).isDirectory() ? files(join(dir, f)).map((x) => join(f, x)) : [f]));
const units = files(join(ROOT, "src")).flatMap((f) => {
const src = readFileSync(join(ROOT, "src", f), "utf8");
return [...src.matchAll(/(["`])((?:(?!\1)[^\\\n]|\\.){12,})\1/g)].filter((m) => !/^@?[a-z0-9./-]+@[\d.]+$/.test(m[2])) // package specifiers are commands, not copy
.map((m) => ({ text: m[2].replace(/\$\{[^}]*\}/g, "x"), surface: "docs", where: f }));
});
assert.ok(units.length > 20);
const found = errors(lintUnits(units));
assert.deepEqual(found, [], formatFindings(found));
});