RYP-E2 and SP-E6, dispatch 4.2 PY2.1 (Railyard side): - lib/flags: flag environments per app environment (a Scribase environment or branch), each with a public client key that reads that one environment. Two backends, one surface: the unmodified Flagsmith server (one Flagsmith organisation per Railyard org, a project per app, an environment per env; FLAGS_API_URL + FLAGS_ADMIN_TOKEN) and, as the fallback the dispatch names when the box 2 gate keeps Flagsmith down, the console's own tables (migration 0005). An environment keeps the backend it was made on. - A branch environment starts with its parent's flags (copy_from), then changes alone. - GET /api/v1/flags/client?key=: CORS-open, cached 15 s when keyed by URL; the first read by an app is the slot's proof (first_flag_read). - Bridge route flags (contract: id_format, three cases, flags_item_keys); BRIDGE_SLOTS.flags landed. - The Flags screen (nav item) flips with one click and adds a flag by key; POST /api/flags writes only the signed-in org's environments. - packages/openfeature-railyard: a zero-dependency polling client (30 s, offline start from storage, back-off) and OpenFeature client and server providers, with Expo and Next.js examples. Tests: flags core 11/11 (both backends, a fake of the Flagsmith API, tenant isolation, branch copies, a 502 that leaves nothing half made), bridge 19/19, contract 3/3, migration 6/6 (0005 twice on a scratch cluster), console 85/85 with the bundle build, tsc clean, SDK 7/7 (a flip reaches the app within 60 s in the worst cache timing on a fake clock; copy lint on docs and the screen). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.8 KiB
JavaScript
36 lines
1.8 KiB
JavaScript
// The flags package docs and every customer-facing flags string (the console
|
|
// screen, its messages and the API errors) pass the vendored copy denylist.
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } 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 HERE = dirname(fileURLToPath(import.meta.url));
|
|
const R = (p) => readFileSync(join(HERE, "..", p), "utf8");
|
|
const strings = (src) => [...src.matchAll(/["`]([^"`\n]{12,})["`]/g)].map((m) => m[1]).filter((s) => !/^[\^[/.]|^ry_|https?:|\$\{/.test(s));
|
|
|
|
test("README and examples pass the copy lint (docs surface)", () => {
|
|
const units = [
|
|
...markdownUnits(R("README.md"), { where: "README.md" }),
|
|
...["examples/expo/App.tsx", "examples/next/app/page.tsx", "src/client.mjs", "src/provider.mjs"].flatMap((f) => strings(R(f)).map((text) => ({ text, surface: "docs", where: f }))),
|
|
];
|
|
const found = errors(lintUnits(units));
|
|
assert.deepEqual(found, [], formatFindings(found));
|
|
});
|
|
|
|
test("the console Flags screen and the flags messages pass the copy lint (app-ui surface)", () => {
|
|
const files = [
|
|
"../../apps/console/app/(app)/flags/page.tsx",
|
|
"../../apps/console/components/FlagsPanel.tsx",
|
|
"../../apps/console/lib/flags/service.ts",
|
|
"../../apps/console/lib/flags/http.ts",
|
|
];
|
|
const units = files.flatMap((f) => strings(R(f)).map((text) => ({ text, surface: "app-ui", where: f })));
|
|
assert.ok(units.length > 10);
|
|
const found = errors(lintUnits(units));
|
|
assert.deepEqual(found, [], formatFindings(found));
|
|
for (const f of files) assert.doesNotMatch(R(f).replace(/^\/\/.*$/gm, ""), /Flagsmith/, `${f}: no engine name outside comments`);
|
|
});
|