From 3206a7fe73aa7a5647c84f91eb61e57a01b217b2 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Mon, 20 Jan 2025 21:46:25 +0100 Subject: [PATCH 1/2] chore: move generate_documents to bin folder this file is never called in production code and wouldn't even run, even if it was: the `lorem-ipsum` dependency is in devDependencies, so never gets installed in any dist builds move the file to a place where it makes more sense and avoid it getting packaged without any reason. --- {src/tools => bin}/generate_document.ts | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) rename {src/tools => bin}/generate_document.ts (88%) diff --git a/src/tools/generate_document.ts b/bin/generate_document.ts similarity index 88% rename from src/tools/generate_document.ts rename to bin/generate_document.ts index 8c2286dda..1ccbb96c0 100644 --- a/src/tools/generate_document.ts +++ b/bin/generate_document.ts @@ -3,13 +3,13 @@ * will create 1000 new notes and some clones into the current document.db */ -import sqlInit from "../services/sql_init.js"; -import noteService from "../services/notes.js"; -import attributeService from "../services/attributes.js"; -import cls from "../services/cls.js"; -import cloningService from "../services/cloning.js"; +import sqlInit from "../src/services/sql_init.js"; +import noteService from "../src/services/notes.js"; +import attributeService from "../src/services/attributes.js"; +import cls from "../src/services/cls.js"; +import cloningService from "../src/services/cloning.js"; import loremIpsum from "lorem-ipsum"; -import "../becca/entity_constructor.js"; +import "../src/becca/entity_constructor.js"; const noteCount = parseInt(process.argv[2]); diff --git a/package.json b/package.json index a492db6fb..b33580ff5 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "integration-edit-db": "cross-env TRILIUM_INTEGRATION_TEST=edit TRILIUM_PORT=8081 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", "integration-mem-db": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", "integration-mem-db-dev": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", - "generate-document": "cross-env nodemon src/tools/generate_document.ts 1000", + "generate-document": "cross-env nodemon ./bin/generate_document.ts 1000", "ci-update-nightly-version": "tsx ./bin/update-nightly-version.ts", "prettier-check": "prettier . --check", "prettier-fix": "prettier . --write" From 1d0381833757b8c1fb965dfafdf5d1b31e0dfac2 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Mon, 20 Jan 2025 22:54:12 +0100 Subject: [PATCH 2/2] chore(generate_documents): add note about script being broken currently --- bin/generate_document.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/generate_document.ts b/bin/generate_document.ts index 1ccbb96c0..f9d327116 100644 --- a/bin/generate_document.ts +++ b/bin/generate_document.ts @@ -1,5 +1,5 @@ /** - * Usage: node src/tools/generate_document.js 1000 + * Usage: tsx ./generate_document.ts 1000 * will create 1000 new notes and some clones into the current document.db */ @@ -90,4 +90,6 @@ async function start() { process.exit(0); } -sqlInit.dbReady.then(cls.wrap(start)); +// @TriliumNextTODO sqlInit.dbReady never seems to resolve so program hangs +// see https://github.com/TriliumNext/Notes/issues/1020 +sqlInit.dbReady.then(cls.wrap(start)).catch((err) => console.error(err));