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
17 changes: 17 additions & 0 deletions .github/workflows/publisher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publisher attribution
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci --prefix tools/publisher --ignore-scripts
- run: npm run check --prefix tools/publisher
4 changes: 4 additions & 0 deletions README.ko.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# FlowLinq

<!-- publisher:start -->
Published by [데브스랩(DevsLab)](https://devslab.kr/).
<!-- publisher:end -->

🌐 [English](README.md)

**AI-powered Document Operations Platform — 인도 SMB를 위한 WhatsApp-native EDMS.**
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# FlowLinq

<!-- publisher:start -->
Published by [데브스랩(DevsLab)](https://devslab.kr/).
<!-- publisher:end -->

🌐 [한국어](README.ko.md)

**AI-powered Document Operations Platform — WhatsApp-native EDMS for Indian SMBs.**
Expand Down
1 change: 1 addition & 0 deletions tools/publisher/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
9 changes: 9 additions & 0 deletions tools/publisher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Publisher attribution

Documentation-only tooling; this dependency is not shipped with the library.

`npm ci --prefix tools/publisher` installs the pinned shared publisher helper.
`npm run sync --prefix tools/publisher` regenerates the marked README and public HTML attribution from `@devslab/site-kit/devslab`.
`npm run check --prefix tools/publisher` detects drift without writing files.

Edit the product URL or repository in `config.json`; update the shared preset in site-kit for company-wide identity changes. Do not hand-edit generated publisher blocks.
12 changes: 12 additions & 0 deletions tools/publisher/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "flowlinq",
"kind": "readme",
"url": "https://github.com/devslab-kr/flowlinq",
"repository": "https://github.com/devslab-kr/flowlinq",
"pages": [],
"readmes": [
"README.md",
"README.ko.md"
],
"attributionLabel": "Published by"
}
118 changes: 118 additions & 0 deletions tools/publisher/package-lock.json

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

12 changes: 12 additions & 0 deletions tools/publisher/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "flowlinq-publisher-docs",
"private": true,
"type": "module",
"scripts": {
"sync": "node sync.mjs",
"check": "node sync.mjs --check"
},
"devDependencies": {
"@devslab/site-kit": "0.8.0"
}
}
50 changes: 50 additions & 0 deletions tools/publisher/sync.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { readFile, writeFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { buildPublisher, renderPublisherHtml, serializeJsonLd } from "@devslab/site-kit";
import { DEVSLAB_PUBLISHER } from "@devslab/site-kit/devslab";

const root = new URL("../../", import.meta.url);
const config = JSON.parse(await readFile(new URL("./config.json", import.meta.url), "utf8"));
const check = process.argv.includes("--check");
const { link, reference } = buildPublisher(DEVSLAB_PUBLISHER);
const start = "<!-- publisher:start -->";
const end = "<!-- publisher:end -->";
const markdown = `${start}\n${config.attributionLabel ?? "Open source by"} [${link.label}](${link.href}).\n${end}`;
const source = {
"@context": "https://schema.org",
"@type": "SoftwareSourceCode",
"@id": `${config.repository}#software`,
name: config.name,
url: config.url,
codeRepository: config.repository,
publisher: reference,
};
const html = `${start}\n<p class="publisher-attribution">Open source by ${renderPublisherHtml(DEVSLAB_PUBLISHER)}</p>\n<script type="application/ld+json">${serializeJsonLd(source)}</script>\n${end}`;

async function update(relative, transform) {
const url = new URL(relative, root);
const current = (await readFile(url, "utf8").catch((error) => {
if (error.code === "ENOENT") return "";
throw error;
})).replaceAll("\r\n", "\n");
const next = transform(current);
if (current === next) return;
if (check) throw new Error(`Publisher output is stale: ${fileURLToPath(url)}; run npm run sync --prefix tools/publisher`);
await writeFile(url, next);
}
function replaceBlock(text, value) {
const from = text.indexOf(start);
const to = text.indexOf(end);
if (from < 0 || to < from) throw new Error("Missing publisher markers");
return text.slice(0, from) + value + text.slice(to + end.length);
}
for (const path of config.readmes ?? ["README.md", "README.ko.md"]) {
await update(path, (text) => replaceBlock(text, markdown));
}
if (config.kind === "mkdocs") {
await update("docs/overrides/publisher.html", () => html + "\n");
}
for (const path of config.pages) {
await update(path, (text) => replaceBlock(text, html));
}
console.log(check ? "Publisher output is current." : "Publisher output synchronized.");
Loading