Files
notesnook/docs/help/scripts/new-version.mjs
Ammar Ahmed 52d6044e73 docs(help): rebuild the help site with VitePress (#10169)
* 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>
2026-08-14 08:57:51 +05:00

74 lines
2.2 KiB
JavaScript

/**
* Starts a new docs version.
*
* npm run version -- 3.4
*
* Nothing is copied. The current docs simply become the newest archived version
* — they are shared with the root until a page actually changes, at which point
* `npm run fork` records the old text for that one page.
*/
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
import { dirname, join } from "path";
import { fileURLToPath, pathToFileURL } from "url";
const HELP = dirname(dirname(fileURLToPath(import.meta.url)));
const versionsPath = join(HELP, ".vitepress", "versions.mjs");
const next = process.argv[2];
if (!next || !/^\d+\.\d+$/.test(next)) {
console.error("Usage: npm run version -- <version> (e.g. 3.4)");
process.exit(1);
}
const { LATEST, ARCHIVED } = await import(
pathToFileURL(versionsPath).href + `?t=${Date.now()}`
);
if (next === LATEST || ARCHIVED.includes(next)) {
console.error(`v${next} already exists.`);
process.exit(1);
}
const overridesDir = join(HELP, "contents", "_versions", LATEST);
if (!existsSync(overridesDir)) {
mkdirSync(overridesDir, { recursive: true });
writeFileSync(
join(overridesDir, "_excluded.txt"),
[
`# Pages that do not exist in v${LATEST}.`,
"# One page path per line, relative to contents/, e.g.:",
"# organizing-notes/some-new-feature.md",
""
].join("\n")
);
}
writeFileSync(
versionsPath,
readFileSync(versionsPath, "utf8")
.replace(/export const LATEST = "[^"]+";/, `export const LATEST = "${next}";`)
.replace(
/export const ARCHIVED = \[[^\]]*\];/,
`export const ARCHIVED = [${[LATEST, ...ARCHIVED].map((v) => `"${v}"`).join(", ")}];`
)
.replace(/npm run version -- [\d.]+/, `npm run version -- ${bumpMinor(next)}`)
.replace(/npm run fork -- [\d.]+ /, `npm run fork -- ${next} `)
);
function bumpMinor(v) {
const [major, minor] = v.split(".").map(Number);
return `${major}.${minor + 1}`;
}
console.log(
[
`The site root now describes v${next}. v${LATEST} is archived at /v${LATEST}/.`,
"",
"No pages were copied — every page is shared until it changes. Before you",
`edit a page in a way that does not apply to v${LATEST}, run:`,
"",
` npm run fork -- ${LATEST} <page>`,
""
].join("\n")
);