mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
* docs: new help built with vitepress. * docs: improve docs home ui Added a Go to Docs button on homepage Added a searchbar for directly searching what you are looking for in the docs * docs(help): wire up with build system & setup proper ci * Clean up new documentation (#10174) * Docs: Cleanup pass 1 Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net> * docs: cleanup pass 2 Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net> * docs: Fix vscode's manglement that I missed. Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net> * Update docs/help/contents/plans-and-limits.md Co-authored-by: Abdullah Atta <thecodrr@protonmail.com> Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net> * Update docs/help/contents/rich-text-editor/outline-lists.md Co-authored-by: Abdullah Atta <thecodrr@protonmail.com> Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net> * docs: Remove self-hosting guide from sidebar, and comments for reviewer. Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net> --------- Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net> Co-authored-by: Abdullah Atta <thecodrr@protonmail.com> * docs: some fixes * ci: do not publish help on push * docs(help): improve regional pricing & free trials * docs: improve sidebar * docs: some more fixes after re-review * docs: improve search and nav * docs: a few more fixes * docs: fix tabs formatting compat with prettier * docs: fix tabs formatting in various places * docs: show correct plus button image for mobile * docs: disable notesnook self hosting docs * docs: update help docs with fixes --------- Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net> Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co> Co-authored-by: Chloe Oletto <NeedsChloesure@riseup.net> Co-authored-by: Abdullah Atta <thecodrr@protonmail.com>
90 lines
3.6 KiB
JavaScript
90 lines
3.6 KiB
JavaScript
/**
|
|
* Guards against stale generated inputs.
|
|
*
|
|
* Two packages feed the docs and both are consumed as *built* output:
|
|
*
|
|
* @notesnook/intl -> the `{{key}}` labels resolved at build time
|
|
* @notesnook/common -> the keybinding registry keyboard-shortcuts.md is generated from
|
|
*
|
|
* Edit either package's source without rebuilding it and the site quietly keeps
|
|
* rendering the previous version — the exact drift this setup exists to prevent.
|
|
* (Not hypothetical: a keybinding fix was regenerated once against a stale build
|
|
* and silently produced the old shortcut.)
|
|
*
|
|
* The check compares *content*, not timestamps: mtimes are rewritten by npm
|
|
* install, git checkouts and CI caches, so they produce false alarms. Instead we
|
|
* take a sample of values out of the source and confirm the build contains them.
|
|
*/
|
|
import { readFileSync, existsSync } from "node:fs";
|
|
import { join, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const HELP = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
const PACKAGES = join(HELP, "..", "..", "packages");
|
|
|
|
const problems = [];
|
|
|
|
/* ------------------------------------------------- @notesnook/common (keys) */
|
|
|
|
const kbSource = join(PACKAGES, "common", "src", "utils", "keybindings.ts");
|
|
const kbBuilt = join(PACKAGES, "common", "dist", "esm", "utils", "keybindings.js");
|
|
|
|
if (!existsSync(kbBuilt)) {
|
|
problems.push(
|
|
`@notesnook/common has not been built, and keyboard-shortcuts.md is generated from it.\n` +
|
|
` cd packages/common && npm run build`
|
|
);
|
|
} else {
|
|
const src = readFileSync(kbSource, "utf8");
|
|
const built = readFileSync(kbBuilt, "utf8");
|
|
const missing = [...src.matchAll(/keys:\s*"([^"]+)"/g)]
|
|
.map((m) => m[1])
|
|
.filter((keys) => !built.includes(`"${keys}"`));
|
|
if (missing.length)
|
|
problems.push(
|
|
`@notesnook/common is stale — these bindings exist in src but not in dist: ` +
|
|
`${[...new Set(missing)].slice(0, 5).join(", ")}.\n` +
|
|
`keyboard-shortcuts.md is generated from the build, so it would keep the old keys.\n` +
|
|
` cd packages/common && npm run build && (cd ../../docs/help && npm run document-keyboard-shortcuts)`
|
|
);
|
|
}
|
|
|
|
/* --------------------------------------------------- @notesnook/intl (text) */
|
|
|
|
const intlSource = join(PACKAGES, "intl", "src", "strings.ts");
|
|
const catalogue = join(PACKAGES, "intl", "dist", "locales", "$en.json");
|
|
|
|
if (!existsSync(catalogue)) {
|
|
problems.push(
|
|
`@notesnook/intl has not been built, and the docs resolve UI labels from it.\n` +
|
|
` cd packages/intl && npm install && npm run build`
|
|
);
|
|
} else {
|
|
const src = readFileSync(intlSource, "utf8");
|
|
const messages = JSON.parse(readFileSync(catalogue, "utf8")).messages;
|
|
const known = new Set(
|
|
Object.values(messages).flatMap((v) =>
|
|
typeof v === "string" ? [v] : Array.isArray(v) ? v.filter((p) => typeof p === "string") : []
|
|
)
|
|
);
|
|
// Plain single-line `key: () => t`Some text`` entries, no interpolation.
|
|
const sourceTexts = [...src.matchAll(/^\s*[a-zA-Z0-9_]+: \(\) =>\s*t`([^`${]+)`/gm)].map(
|
|
(m) => m[1]
|
|
);
|
|
const missing = sourceTexts.filter((text) => !known.has(text));
|
|
if (missing.length > sourceTexts.length * 0.02)
|
|
problems.push(
|
|
`@notesnook/intl is stale — ${missing.length} strings exist in strings.ts but not in the ` +
|
|
`compiled catalogue (e.g. ${missing.slice(0, 3).map((s) => JSON.stringify(s)).join(", ")}).\n` +
|
|
`The docs would render the previous wording.\n` +
|
|
` cd packages/intl && npm run build`
|
|
);
|
|
}
|
|
|
|
if (problems.length) {
|
|
console.error("\n" + problems.join("\n\n") + "\n");
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log("Generated inputs (intl, common) match their source.");
|