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
12 changes: 6 additions & 6 deletions .generated/sdk-docs/browser-sdk/v2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions .generated/sdk-docs/node-sdk/v2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions .generated/sdk-docs/react-sdk/v2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions .generated/sdk-docs/vue-sdk/v2.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .generated/sdk-readmes/dotnet-sdk.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .generated/sdk-readmes/python-sdk.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .gitbook/assets/dotnet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions .gitbook/assets/python.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .gitbook/includes/sdks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
title: SDKs
---

<table data-view="cards" data-full-width="false"><thead><tr><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>React</td><td><a href="../assets/react.svg">react.svg</a></td><td><a href="../../supported-languages/react-sdk/">react-sdk</a></td></tr><tr><td>React Native</td><td><a href="../assets/react.svg">react.svg</a></td><td><a href="../../supported-languages/react-native-sdk/">react-native-sdk</a></td></tr><tr><td>Vue.js</td><td><a href="../assets/vue-logo.svg">vue-logo.svg</a></td><td><a href="../../supported-languages/vue-sdk/">vue-sdk</a></td></tr><tr><td>Client-side</td><td><a href="../assets/ts-js.svg">ts-js.svg</a></td><td><a href="../../supported-languages/browser-sdk/">browser-sdk</a></td></tr><tr><td>Server-side</td><td><a href="../assets/node-js.svg">node-js.svg</a></td><td><a href="../../supported-languages/node-sdk/">node-sdk</a></td></tr><tr><td>Next.js</td><td><a href="../assets/next-js.svg">next-js.svg</a></td><td><a href="../../supported-languages/next.js.md">next.js.md</a></td></tr><tr><td>Reflag supports OpenFeature</td><td><a href="../assets/openfeature.svg">openfeature.svg</a></td><td><a href="../../supported-languages/openfeature.md">openfeature.md</a></td></tr><tr><td>Don't use these languages or frameworks? Use our API</td><td><a href="../assets/api.svg">api.svg</a></td><td><a href="../../api/public-api/">public-api</a></td></tr></tbody></table>
<table data-view="cards" data-full-width="false"><thead><tr><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>React</td><td><a href="../assets/react.svg">react.svg</a></td><td><a href="../../supported-languages/react-sdk/">react-sdk</a></td></tr><tr><td>React Native</td><td><a href="../assets/react.svg">react.svg</a></td><td><a href="../../supported-languages/react-native-sdk/">react-native-sdk</a></td></tr><tr><td>Vue.js</td><td><a href="../assets/vue-logo.svg">vue-logo.svg</a></td><td><a href="../../supported-languages/vue-sdk/">vue-sdk</a></td></tr><tr><td>Client-side</td><td><a href="../assets/ts-js.svg">ts-js.svg</a></td><td><a href="../../supported-languages/browser-sdk/">browser-sdk</a></td></tr><tr><td>Server-side</td><td><a href="../assets/node-js.svg">node-js.svg</a></td><td><a href="../../supported-languages/node-sdk/">node-sdk</a></td></tr><tr><td>Next.js</td><td><a href="../assets/next-js.svg">next-js.svg</a></td><td><a href="../../supported-languages/next.js.md">next.js.md</a></td></tr><tr><td>Python</td><td><a href="../assets/python.svg">python.svg</a></td><td><a href="../../supported-languages/python-sdk.md">python-sdk.md</a></td></tr><tr><td>.NET</td><td><a href="../assets/dotnet.svg">dotnet.svg</a></td><td><a href="../../supported-languages/dotnet-sdk.md">dotnet-sdk.md</a></td></tr><tr><td>Reflag supports OpenFeature</td><td><a href="../assets/openfeature.svg">openfeature.svg</a></td><td><a href="../../supported-languages/openfeature.md">openfeature.md</a></td></tr><tr><td>Don't use these languages or frameworks? Use our API</td><td><a href="../assets/api.svg">api.svg</a></td><td><a href="../../api/public-api/">public-api</a></td></tr></tbody></table>
19 changes: 9 additions & 10 deletions .github/scripts/check-sdk-docs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";

import {
currentVersionNote,
currentVersionNotePattern,
docsPath,
hash,
webSDKs,
documentedPackages,
versionedDocsReady,
} from "./sdk-docs.mjs";
import { checkReadmeManifests } from "./sdk-readme.mjs";

export const root = path.resolve(fileURLToPath(new URL("../../", import.meta.url)));
const read = (base, file) => fs.readFileSync(path.join(base, file), "utf8");
Expand Down Expand Up @@ -101,18 +102,14 @@ export function sourceMatrix(base = root) {
}

export function checkCurrentPagePresentation(content, file) {
const notes = [...content.matchAll(/^Using v1\? .+$/gm)];
assert.equal(notes.length, 1, `Expected one succinct version note: ${file}`);
assert(content.trimEnd().endsWith(notes[0][0]), `Legacy link must be at the end: ${file}`);
assert(!/^Using v1\? /m.test(content), `The v1 link belongs in the scope note: ${file}`);
const body = prose(content);
assert.equal(
body.split("\n").filter((line) => line === currentVersionNote).length,
1,
`Expected one SDK v2 scope note: ${file}`,
);
const lines = body.split("\n");
const notes = lines.filter((line) => currentVersionNotePattern.test(line));
assert.equal(notes.length, 1, `Expected one SDK v2 scope note linking to v1: ${file}`);
const title = /^# .+$/m.exec(body);
const firstSection = /^#{2,6} /m.exec(body);
const scope = body.indexOf(currentVersionNote);
const scope = body.indexOf(notes[0]);
assert(
title && scope > title.index + title[0].length && scope < (firstSection?.index ?? body.length),
`SDK v2 scope note must be in the introduction: ${file}`,
Expand Down Expand Up @@ -256,6 +253,8 @@ export function checkSDKDocs(base = root) {
].includes(file),
),
]);
for (const file of checkReadmeManifests(base))
assert(navigation.includes(file), `SDK page missing from navigation: ${file}`);
return { generatedPages: generated.size, navigationPages: navigation.length };
}

Expand Down
71 changes: 71 additions & 0 deletions .github/scripts/sdk-docs-readme.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import test from "node:test";

import { applyReadme, checkReadmeManifests, planReadme, renderReadme } from "./sdk-readme.mjs";

const commit = "a".repeat(40);

test("README pages point relative links at the released commit and keep code untouched", () => {
const page = renderReadme({
name: "dotnet-sdk",
commit,
readme: [
"# Reflag .NET SDK",
"",
"See [LICENSE](LICENSE), [examples](./examples/Web/README.md#run) and [docs](https://docs.reflag.com).",
'![Diagram](docs/flow.png) <img src="docs/logo.svg"> <a href="#install">Install</a>',
"<!-- x-release-please-start-version -->",
"```md",
"[Not a link](LICENSE)",
"```",
"<!-- x-release-please-end -->",
].join("\n"),
});
assert(page.startsWith("---\ndescription: Use Reflag feature flags in .NET applications.\n---\n"));
assert.match(page, /\(https:\/\/github\.com\/reflagcom\/dotnet-sdk\/blob\/a{40}\/LICENSE\)/);
assert.match(page, /blob\/a{40}\/examples\/Web\/README\.md#run\)/);
assert.match(page, /\(https:\/\/docs\.reflag\.com\)/);
assert.match(page, /raw\.githubusercontent\.com\/reflagcom\/dotnet-sdk\/a{40}\/docs\/flow\.png\)/);
assert.match(page, /src="https:\/\/raw\.githubusercontent\.com\/reflagcom\/dotnet-sdk\/a{40}\/docs\/logo\.svg"/);
assert.match(page, /href="#install"/);
assert.match(page, /```md\n\[Not a link\]\(LICENSE\)\n```/);
assert(!page.includes("x-release-please"));
assert.throws(
() => renderReadme({ name: "dotnet-sdk", commit, readme: "[Up](../other)" }),
/leaves the repository/,
);
assert.throws(() => renderReadme({ name: "go-sdk", commit, readme: "" }), /Unknown README SDK/);
});

test("only a release tag syncs, and hand edits to synced pages fail the check", (t) => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "sdk-readme-"));
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
const source = path.join(root, "source");
const destination = path.join(root, "docs");
fs.mkdirSync(source);
const git = (...args) =>
execFileSync("git", ["-C", source, "-c", "user.name=t", "-c", "user.email=t@t", ...args]);
git("init", "-q");
fs.writeFileSync(path.join(source, "README.md"), "# Reflag Python SDK\n");
fs.writeFileSync(path.join(source, ".release-please-manifest.json"), '{ ".": "0.2.0" }\n');
git("add", ".");
git("commit", "-qm", "release");
assert.throws(() => planReadme({ name: "python-sdk", source }), /not the v0\.2\.0 release tag/);
git("tag", "v0.2.0");

const files = planReadme({ name: "python-sdk", source });
applyReadme(files, destination);
applyReadme(files, destination, { check: true });
assert.deepEqual(checkReadmeManifests(destination), ["supported-languages/python-sdk.md"]);
const manifest = JSON.parse(files.get(".generated/sdk-readmes/python-sdk.json"));
assert.equal(manifest.version, "0.2.0");
assert.match(manifest.sourceCommit, /^[a-f\d]{40}$/);

fs.appendFileSync(path.join(destination, "supported-languages/python-sdk.md"), "Edited.\n");
assert.throws(() => checkReadmeManifests(destination), /Change the SDK README instead/);
assert.throws(() => applyReadme(files, destination, { check: true }), /README page drift/);
});
Loading
Loading