mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore(monorepo/edit-docs): port files
This commit is contained in:
parent
df7e7b4d95
commit
b750920832
@ -21,7 +21,6 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "cross-env NODE_OPTIONS=\"--import tsx\" TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev electron ./src/electron-main.ts --inspect=5858 .",
|
"start": "cross-env NODE_OPTIONS=\"--import tsx\" TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev electron ./src/electron-main.ts --inspect=5858 .",
|
||||||
"start-prod": "npm run build:prepare-dist && npx electron-rebuild -m build && cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=prod electron ./build/src/electron-main.js --inspect=5858 .",
|
"start-prod": "npm run build:prepare-dist && npx electron-rebuild -m build && cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=prod electron ./build/src/electron-main.js --inspect=5858 .",
|
||||||
"postinstall": "electron-rebuild",
|
|
||||||
|
|
||||||
"build:clean": "rimraf ./dist ./build",
|
"build:clean": "rimraf ./dist ./build",
|
||||||
"build:copy-dist": "tsx ./scripts/copy-dist.ts",
|
"build:copy-dist": "tsx ./scripts/copy-dist.ts",
|
||||||
|
24
apps/edit-docs/package.json
Normal file
24
apps/edit-docs/package.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "@triliumnext/edit-demo",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Desktop version of Trilium which imports the demo database (presented to new users at start-up) or the user guide and other documentation and saves the modifications for committing.",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/TriliumNext/Notes.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "AGPL-3.0-only",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/TriliumNext/Notes/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/TriliumNext/Notes#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"@triliumnext/client": "0.0.1",
|
||||||
|
"@triliumnext/electron": "0.0.1",
|
||||||
|
"@triliumnext/server": "0.0.1"
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,18 @@
|
|||||||
import fs from "fs/promises";
|
import fs from "fs/promises";
|
||||||
import fsExtra from "fs-extra";
|
import fsExtra from "fs-extra";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import type NoteMeta from "./src/services/meta/note_meta.js";
|
import type NoteMeta from "@triliumnext/server/src/services/meta/note_meta.js";
|
||||||
import type { NoteMetaFile } from "./src/services/meta/note_meta.js";
|
import type { NoteMetaFile } from "@triliumnext/server/src/services/meta/note_meta.js";
|
||||||
import { initializeTranslations } from "./src/services/i18n.js";
|
import { initializeTranslations } from "@triliumnext/server/src/services/i18n.js";
|
||||||
import archiver, { type Archiver } from "archiver";
|
import archiver, { type Archiver } from "archiver";
|
||||||
import type { WriteStream } from "fs";
|
import type { WriteStream } from "fs";
|
||||||
import debounce from "./src/public/app/services/debounce.js";
|
import debounce from "@triliumnext/client/src/services/debounce.js";
|
||||||
import { extractZip, initializeDatabase, startElectron } from "./electron-utils.js";
|
import { extractZip, initializeDatabase, startElectron } from "./electron-utils.js";
|
||||||
import cls from "./src/services/cls.js";
|
import cls from "@triliumnext/server/src/services/cls.js";
|
||||||
import type { AdvancedExportOptions } from "./src/services/export/zip.js";
|
import type { AdvancedExportOptions } from "@triliumnext/server/src/services/export/zip.js";
|
||||||
import TaskContext from "./src/services/task_context.js";
|
import TaskContext from "@triliumnext/server/src/services/task_context.js";
|
||||||
import { deferred } from "./src/services/utils.js";
|
import { deferred } from "@triliumnext/server/src/services/utils.js";
|
||||||
import { parseNoteMetaFile } from "./src/services/in_app_help.js";
|
import { parseNoteMetaFile } from "@triliumnext/server/src/services/in_app_help.js";
|
||||||
|
|
||||||
interface NoteMapping {
|
interface NoteMapping {
|
||||||
rootNoteId: string;
|
rootNoteId: string;
|
||||||
@ -70,7 +70,7 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function setOptions() {
|
async function setOptions() {
|
||||||
const optionsService = (await import("./src/services/options.js")).default;
|
const optionsService = (await import("@triliumnext/server/src/services/options.js")).default;
|
||||||
optionsService.setOption("eraseUnusedAttachmentsAfterSeconds", 10);
|
optionsService.setOption("eraseUnusedAttachmentsAfterSeconds", 10);
|
||||||
optionsService.setOption("eraseUnusedAttachmentsAfterTimeScale", 60);
|
optionsService.setOption("eraseUnusedAttachmentsAfterTimeScale", 60);
|
||||||
optionsService.setOption("compressImages", "false");
|
optionsService.setOption("compressImages", "false");
|
||||||
@ -78,9 +78,9 @@ async function setOptions() {
|
|||||||
|
|
||||||
async function importData(path: string) {
|
async function importData(path: string) {
|
||||||
const buffer = await createImportZip(path);
|
const buffer = await createImportZip(path);
|
||||||
const importService = (await import("./src/services/import/zip.js")).default;
|
const importService = (await import("@triliumnext/server/src/services/import/zip.js")).default;
|
||||||
const context = new TaskContext("no-progress-reporting", "import", false);
|
const context = new TaskContext("no-progress-reporting", "import", false);
|
||||||
const becca = (await import("./src/becca/becca.js")).default;
|
const becca = (await import("@triliumnext/server/src/becca/becca.js")).default;
|
||||||
|
|
||||||
const rootNote = becca.getRoot();
|
const rootNote = becca.getRoot();
|
||||||
if (!rootNote) {
|
if (!rootNote) {
|
||||||
@ -126,7 +126,7 @@ async function exportData(noteId: string, format: "html" | "markdown", outputPat
|
|||||||
await fsExtra.mkdir(outputPath);
|
await fsExtra.mkdir(outputPath);
|
||||||
|
|
||||||
// First export as zip.
|
// First export as zip.
|
||||||
const { exportToZipFile } = (await import("./src/services/export/zip.js")).default;
|
const { exportToZipFile } = (await import("@triliumnext/server/src/services/export/zip.js")).default;
|
||||||
|
|
||||||
const exportOpts: AdvancedExportOptions = {};
|
const exportOpts: AdvancedExportOptions = {};
|
||||||
if (format === "html") {
|
if (format === "html") {
|
||||||
@ -213,8 +213,8 @@ async function cleanUpMeta(outputPath: string, minify: boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function registerHandlers() {
|
async function registerHandlers() {
|
||||||
const events = (await import("./src/services/events.js")).default;
|
const events = (await import("@triliumnext/server/src/services/events.js")).default;
|
||||||
const eraseService = (await import("./src/services/erase.js")).default;
|
const eraseService = (await import("@triliumnext/server/src/services/erase.js")).default;
|
||||||
const debouncer = debounce(async () => {
|
const debouncer = debounce(async () => {
|
||||||
eraseService.eraseUnusedAttachmentsNow();
|
eraseService.eraseUnusedAttachmentsNow();
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
import { extractZip, initializeDatabase, startElectron } from "./electron-utils.js";
|
import { extractZip, initializeDatabase, startElectron } from "./electron-utils.js";
|
||||||
import { initializeTranslations } from "./src/services/i18n.js";
|
import { initializeTranslations } from "@triliumnext/server/src/services/i18n.js";
|
||||||
import debounce from "./src/public/app/services/debounce.js";
|
import debounce from "@triliumnext/client/src/services/debounce.js";
|
||||||
import fs from "fs/promises";
|
import fs from "fs/promises";
|
||||||
|
|
||||||
const DEMO_ZIP_PATH = "db/demo.zip";
|
const DEMO_ZIP_PATH = "db/demo.zip";
|
||||||
@ -14,8 +14,8 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function registerHandlers() {
|
async function registerHandlers() {
|
||||||
const events = (await import("./src/services/events.js")).default;
|
const events = (await import("@triliumnext/server/src/services/events.js")).default;
|
||||||
const eraseService = (await import("./src/services/erase.js")).default;
|
const eraseService = (await import("@triliumnext/server/src/services/erase.js")).default;
|
||||||
const debouncer = debounce(async () => {
|
const debouncer = debounce(async () => {
|
||||||
console.log("Exporting data");
|
console.log("Exporting data");
|
||||||
eraseService.eraseUnusedAttachmentsNow();
|
eraseService.eraseUnusedAttachmentsNow();
|
||||||
@ -36,7 +36,7 @@ async function registerHandlers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function exportData() {
|
async function exportData() {
|
||||||
const { exportToZipFile } = (await import("./src/services/export/zip.js")).default;
|
const { exportToZipFile } = (await import("@triliumnext/server/src/services/export/zip.js")).default;
|
||||||
await exportToZipFile("root", "html", DEMO_ZIP_PATH);
|
await exportToZipFile("root", "html", DEMO_ZIP_PATH);
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
import cls from "./src/services/cls.js";
|
import cls from "@triliumnext/server/src/services/cls.js";
|
||||||
import fs from "fs/promises";
|
import fs from "fs/promises";
|
||||||
import fsExtra from "fs-extra";
|
import fsExtra from "fs-extra";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
export function initializeDatabase(skipDemoDb: boolean) {
|
export function initializeDatabase(skipDemoDb: boolean) {
|
||||||
return new Promise<void>(async (resolve) => {
|
return new Promise<void>(async (resolve) => {
|
||||||
const sqlInit = (await import("./src/services/sql_init.js")).default;
|
const sqlInit = (await import("@triliumnext/server/src/services/sql_init.js")).default;
|
||||||
cls.init(async () => {
|
cls.init(async () => {
|
||||||
if (!sqlInit.isDbInitialized()) {
|
if (!sqlInit.isDbInitialized()) {
|
||||||
await sqlInit.createInitialDatabase(skipDemoDb);
|
await sqlInit.createInitialDatabase(skipDemoDb);
|
||||||
@ -16,16 +16,16 @@ export function initializeDatabase(skipDemoDb: boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function startElectron() {
|
export async function startElectron() {
|
||||||
await import("./electron-main.js");
|
await import("@triliumnext/electron/src/electron-main.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function extractZip(zipFilePath: string, outputPath: string, ignoredFiles?: Set<string>) {
|
export async function extractZip(zipFilePath: string, outputPath: string, ignoredFiles?: Set<string>) {
|
||||||
const deferred = (await import("./src/services/utils.js")).deferred;
|
const deferred = (await import("@triliumnext/server/src/services/utils.js")).deferred;
|
||||||
|
|
||||||
const promise = deferred<void>()
|
const promise = deferred<void>()
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
// Then extract the zip.
|
// Then extract the zip.
|
||||||
const { readZipFile, readContent } = (await import("./src/services/import/zip.js"));
|
const { readZipFile, readContent } = (await import("@triliumnext/server/src/services/import/zip.js"));
|
||||||
await readZipFile(await fs.readFile(zipFilePath), async (zip, entry) => {
|
await readZipFile(await fs.readFile(zipFilePath), async (zip, entry) => {
|
||||||
// We ignore directories since they can appear out of order anyway.
|
// We ignore directories since they can appear out of order anyway.
|
||||||
if (!entry.fileName.endsWith("/") && !ignoredFiles?.has(entry.fileName)) {
|
if (!entry.fileName.endsWith("/") && !ignoredFiles?.has(entry.fileName)) {
|
8425
package-lock.json
generated
8425
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user