Skip to content

Commit 2154a5e

Browse files
committed
Merge remote-tracking branch 'origin/main' into renovate/major-vitest-monorepo
2 parents dbe51cc + ba61ab1 commit 2154a5e

File tree

339 files changed

+9886
-5233
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

339 files changed

+9886
-5233
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
paths:
1111
- 'docs/**'
1212
- 'apps/edit-docs/**'
13+
- 'apps/build-docs/**'
1314
- 'packages/share-theme/**'
1415

1516
# Allow manual triggering from Actions tab
@@ -23,6 +24,7 @@ on:
2324
paths:
2425
- 'docs/**'
2526
- 'apps/edit-docs/**'
27+
- 'apps/build-docs/**'
2628
- 'packages/share-theme/**'
2729

2830
jobs:
@@ -60,6 +62,8 @@ jobs:
6062
- name: Validate Built Site
6163
run: |
6264
test -f site/index.html || (echo "ERROR: site/index.html not found" && exit 1)
65+
test -f site/developer-guide/index.html || (echo "ERROR: site/developer-guide/index.html not found" && exit 1)
66+
echo "✓ User Guide and Developer Guide built successfully"
6367
6468
- name: Deploy
6569
uses: ./.github/actions/deploy-to-cloudflare-pages

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22.21.0
1+
24.11.0

_regroup/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,17 @@
3838
"@playwright/test": "1.56.1",
3939
"@stylistic/eslint-plugin": "5.5.0",
4040
"@types/express": "5.0.5",
41-
"@types/node": "24.9.1",
41+
"@types/node": "24.10.0",
4242
"@types/yargs": "17.0.34",
4343
"@vitest/coverage-v8": "4.0.6",
44-
"eslint": "9.38.0",
44+
"eslint": "9.39.1",
4545
"eslint-plugin-simple-import-sort": "12.1.1",
4646
"esm": "3.2.25",
4747
"jsdoc": "4.0.5",
4848
"lorem-ipsum": "2.0.8",
4949
"rcedit": "4.0.1",
50-
"rimraf": "6.0.1",
51-
"tslib": "2.8.1",
52-
"typedoc": "0.28.14",
53-
"typedoc-plugin-missing-exports": "4.1.2"
50+
"rimraf": "6.1.0",
51+
"tslib": "2.8.1"
5452
},
5553
"optionalDependencies": {
5654
"appdmg": "0.6.6"

_regroup/typedoc.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/build-docs/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "build-docs",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "src/main.ts",
6+
"scripts": {
7+
"start": "tsx ."
8+
},
9+
"keywords": [],
10+
"author": "Elian Doran <[email protected]>",
11+
"license": "AGPL-3.0-only",
12+
"packageManager": "[email protected]",
13+
"devDependencies": {
14+
"@redocly/cli": "2.11.0",
15+
"archiver": "7.0.1",
16+
"fs-extra": "11.3.2",
17+
"react": "19.2.0",
18+
"react-dom": "19.2.0",
19+
"typedoc": "0.28.14",
20+
"typedoc-plugin-missing-exports": "4.1.2"
21+
}
22+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* The backend script API is accessible to code notes with the "JS (backend)" language.
3+
*
4+
* The entire API is exposed as a single global: {@link api}
5+
*
6+
* @module Backend Script API
7+
*/
8+
9+
/**
10+
* This file creates the entrypoint for TypeDoc that simulates the context from within a
11+
* script note on the server side.
12+
*
13+
* Make sure to keep in line with backend's `script_context.ts`.
14+
*/
15+
16+
export type { default as AbstractBeccaEntity } from "../../server/src/becca/entities/abstract_becca_entity.js";
17+
export type { default as BAttachment } from "../../server/src/becca/entities/battachment.js";
18+
export type { default as BAttribute } from "../../server/src/becca/entities/battribute.js";
19+
export type { default as BBranch } from "../../server/src/becca/entities/bbranch.js";
20+
export type { default as BEtapiToken } from "../../server/src/becca/entities/betapi_token.js";
21+
export type { BNote };
22+
export type { default as BOption } from "../../server/src/becca/entities/boption.js";
23+
export type { default as BRecentNote } from "../../server/src/becca/entities/brecent_note.js";
24+
export type { default as BRevision } from "../../server/src/becca/entities/brevision.js";
25+
26+
import BNote from "../../server/src/becca/entities/bnote.js";
27+
import BackendScriptApi, { type Api } from "../../server/src/services/backend_script_api.js";
28+
29+
export type { Api };
30+
31+
const fakeNote = new BNote();
32+
33+
/**
34+
* The `api` global variable allows access to the backend script API, which is documented in {@link Api}.
35+
*/
36+
export const api: Api = new BackendScriptApi(fakeNote, {});

apps/edit-docs/src/build-docs.ts renamed to apps/build-docs/src/build-docs.ts

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@ process.env.NODE_ENV = "development";
44

55
import cls from "@triliumnext/server/src/services/cls.js";
66
import { dirname, join, resolve } from "path";
7-
import fs, { copyFile } from "fs/promises";
8-
import fsExtra, { createWriteStream, type WriteStream } from "fs-extra";
7+
import * as fs from "fs/promises";
8+
import * as fsExtra from "fs-extra";
99
import archiver from "archiver";
10+
import { WriteStream } from "fs";
11+
import { execSync } from "child_process";
12+
import BuildContext from "./context.js";
1013

1114
const DOCS_ROOT = "../../../docs";
1215
const OUTPUT_DIR = "../../site";
1316

14-
async function main() {
15-
const i18n = await import("@triliumnext/server/src/services/i18n.js");
16-
await i18n.initializeTranslations();
17-
18-
const sqlInit = (await import("../../server/src/services/sql_init.js")).default;
19-
await sqlInit.createInitialDatabase(true);
20-
21-
const note = await importData(join(__dirname, DOCS_ROOT, "User Guide"));
17+
async function importAndExportDocs(sourcePath: string, outputSubDir: string) {
18+
const note = await importData(sourcePath);
2219

23-
// Export
24-
const zipFilePath = "output.zip";
20+
// Use a meaningful name for the temporary zip file
21+
const zipName = outputSubDir || "user-guide";
22+
const zipFilePath = `output-${zipName}.zip`;
2523
try {
2624
const { exportToZip } = (await import("@triliumnext/server/src/services/export/zip.js")).default;
2725
const branch = note.getParentBranches()[0];
@@ -30,28 +28,53 @@ async function main() {
3028
"export",
3129
null
3230
);
33-
const fileOutputStream = createWriteStream(zipFilePath);
31+
const fileOutputStream = fsExtra.createWriteStream(zipFilePath);
3432
await exportToZip(taskContext, branch, "share", fileOutputStream);
3533
await waitForStreamToFinish(fileOutputStream);
36-
await extractZip(zipFilePath, OUTPUT_DIR);
34+
35+
// Output to root directory if outputSubDir is empty, otherwise to subdirectory
36+
const outputPath = outputSubDir ? join(OUTPUT_DIR, outputSubDir) : OUTPUT_DIR;
37+
await extractZip(zipFilePath, outputPath);
3738
} finally {
3839
if (await fsExtra.exists(zipFilePath)) {
3940
await fsExtra.rm(zipFilePath);
4041
}
4142
}
43+
}
44+
45+
async function buildDocsInner() {
46+
const i18n = await import("@triliumnext/server/src/services/i18n.js");
47+
await i18n.initializeTranslations();
48+
49+
const sqlInit = (await import("../../server/src/services/sql_init.js")).default;
50+
await sqlInit.createInitialDatabase(true);
51+
52+
// Wait for becca to be loaded before importing data
53+
const beccaLoader = await import("../../server/src/becca/becca_loader.js");
54+
await beccaLoader.beccaLoaded;
55+
56+
// Build User Guide
57+
console.log("Building User Guide...");
58+
await importAndExportDocs(join(__dirname, DOCS_ROOT, "User Guide"), "user-guide");
59+
60+
// Build Developer Guide
61+
console.log("Building Developer Guide...");
62+
await importAndExportDocs(join(__dirname, DOCS_ROOT, "Developer Guide"), "developer-guide");
4263

4364
// Copy favicon.
44-
await copyFile("../../apps/website/src/assets/favicon.ico", join(OUTPUT_DIR, "favicon.ico"));
65+
await fs.copyFile("../../apps/website/src/assets/favicon.ico", join(OUTPUT_DIR, "favicon.ico"));
66+
await fs.copyFile("../../apps/website/src/assets/favicon.ico", join(OUTPUT_DIR, "user-guide", "favicon.ico"));
67+
await fs.copyFile("../../apps/website/src/assets/favicon.ico", join(OUTPUT_DIR, "developer-guide", "favicon.ico"));
4568

4669
console.log("Documentation built successfully!");
4770
}
4871

4972
export async function importData(path: string) {
5073
const buffer = await createImportZip(path);
51-
const importService = (await import("@triliumnext/server/src/services/import/zip.js")).default;
52-
const TaskContext = (await import("@triliumnext/server/src/services/task_context.js")).default;
74+
const importService = (await import("../../server/src/services/import/zip.js")).default;
75+
const TaskContext = (await import("../../server/src/services/task_context.js")).default;
5376
const context = new TaskContext("no-progress-reporting", "importNotes", null);
54-
const becca = (await import("@triliumnext/server/src/becca/becca.js")).default;
77+
const becca = (await import("../../server/src/becca/becca.js")).default;
5578

5679
const rootNote = becca.getRoot();
5780
if (!rootNote) {
@@ -106,4 +129,19 @@ export async function extractZip(zipFilePath: string, outputPath: string, ignore
106129
});
107130
}
108131

109-
cls.init(main);
132+
export default async function buildDocs({ gitRootDir }: BuildContext) {
133+
// Build the share theme.
134+
execSync(`pnpm run --filter share-theme build`, {
135+
stdio: "inherit",
136+
cwd: gitRootDir
137+
});
138+
139+
// Trigger the actual build.
140+
await new Promise((res, rej) => {
141+
cls.init(() => {
142+
buildDocsInner()
143+
.catch(rej)
144+
.then(res);
145+
});
146+
});
147+
}

apps/build-docs/src/context.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default interface BuildContext {
2+
gitRootDir: string;
3+
baseDir: string;
4+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* The front script API is accessible to code notes with the "JS (frontend)" language.
3+
*
4+
* The entire API is exposed as a single global: {@link api}
5+
*
6+
* @module Frontend Script API
7+
*/
8+
9+
/**
10+
* This file creates the entrypoint for TypeDoc that simulates the context from within a
11+
* script note.
12+
*
13+
* Make sure to keep in line with frontend's `script_context.ts`.
14+
*/
15+
16+
export type { default as BasicWidget } from "../../client/src/widgets/basic_widget.js";
17+
export type { default as FAttachment } from "../../client/src/entities/fattachment.js";
18+
export type { default as FAttribute } from "../../client/src/entities/fattribute.js";
19+
export type { default as FBranch } from "../../client/src/entities/fbranch.js";
20+
export type { default as FNote } from "../../client/src/entities/fnote.js";
21+
export type { Api } from "../../client/src/services/frontend_script_api.js";
22+
export type { default as NoteContextAwareWidget } from "../../client/src/widgets/note_context_aware_widget.js";
23+
export type { default as RightPanelWidget } from "../../client/src/widgets/right_panel_widget.js";
24+
25+
import FrontendScriptApi, { type Api } from "../../client/src/services/frontend_script_api.js";
26+
27+
//@ts-expect-error
28+
export const api: Api = new FrontendScriptApi();

apps/build-docs/src/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="refresh" content="0; url=/user-guide">
5+
<title>Redirecting...</title>
6+
</head>
7+
<body>
8+
<p>If you are not redirected automatically, <a href="/user-guide">click here</a>.</p>
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)