From e41a5a995d258fadb88c0ec380898233b2f402d4 Mon Sep 17 00:00:00 2001 From: ThArGos Date: Thu, 12 Sep 2024 13:56:00 +0200 Subject: Audit fix and usage of environment variables --- local.sh | 7 ++++--- package-lock.json | 45 ++++++++++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/local.sh b/local.sh index 0d1cda4..e6dc7ee 100755 --- a/local.sh +++ b/local.sh @@ -1,7 +1,8 @@ #!/bin/bash -read -p "Enter the ROAM_PATH: " ROAM_PATH -read -p "Enter the ROAM_DB_FILE: " ROAM_DB_FILE +# export ROAM_PATH=/path/to/org-roam/src +# export ROAM_DB_FILE=org-roam.db + ROAM_DB_PATH=$ROAM_PATH/$ROAM_DB_FILE ROAM_IMG_PATH=$ROAM_PATH/img @@ -31,4 +32,4 @@ if [ -d "../../out" ]; then fi mv out ../../ popd -popd \ No newline at end of file +popd diff --git a/package-lock.json b/package-lock.json index ac10db0..fdffa2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -607,11 +607,18 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" }, - "node_modules/ip": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", - "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==", - "optional": true + "node_modules/ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "optional": true, + "dependencies": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "engines": { + "node": ">= 12" + } }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", @@ -645,6 +652,12 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "optional": true }, + "node_modules/jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "optional": true + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -1157,16 +1170,16 @@ } }, "node_modules/socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", + "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", "optional": true, "dependencies": { - "ip": "^2.0.0", + "ip-address": "^9.0.5", "smart-buffer": "^4.2.0" }, "engines": { - "node": ">= 10.13.0", + "node": ">= 10.0.0", "npm": ">= 3.0.0" } }, @@ -1184,6 +1197,12 @@ "node": ">= 10" } }, + "node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", + "optional": true + }, "node_modules/sqlite3": { "version": "5.1.7", "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.7.tgz", @@ -1262,9 +1281,9 @@ } }, "node_modules/tar": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", - "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", -- cgit From 2c6f5c08beaa73b9d166370a605f9b505f29b480 Mon Sep 17 00:00:00 2001 From: ThArGos Date: Fri, 13 Sep 2024 02:32:03 +0200 Subject: Build the index and copy it next to the search data --- .gitignore | 5 ++++- action.yml | 8 ++++++++ build-index.js | 11 +++++++++++ local.sh | 9 ++++++--- package-lock.json | 9 +++++++++ package.json | 1 + 6 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 build-index.js diff --git a/.gitignore b/.gitignore index b63e158..e8028e3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,7 @@ graphdata.json searchdata.json notes/ org-roam-ui/ -out/ \ No newline at end of file +out/ + +# Fuse.js index +fuse-index.json diff --git a/action.yml b/action.yml index af51b3b..b3437df 100644 --- a/action.yml +++ b/action.yml @@ -72,6 +72,14 @@ runs: working-directory: action run: cp --force searchdata.json ../ui/components/Search/ shell: bash + - name: Create Search index + working-directory: action + run: node build-index.js + shell: bash + - name: Copy fuse-index.json to ../ui/components/Search + working-directory: action + run: cp --force fuse-index.json ../ui/components/Search/ + shell: bash - name: Copy org/img to ui/public/ working-directory: action run: | diff --git a/build-index.js b/build-index.js new file mode 100644 index 0000000..e8a8bae --- /dev/null +++ b/build-index.js @@ -0,0 +1,11 @@ +// build-index.js + +const Fuse = require('fuse.js') +const fs = require('fs') +const data = require('./searchdata.json') + +// Create the Fuse index +const myIndex = Fuse.createIndex(['tags', 'title', 'content'], data) + +// Serialize and save it +fs.writeFileSync('fuse-index.json', JSON.stringify(myIndex.toJSON())) diff --git a/local.sh b/local.sh index e6dc7ee..d1be019 100755 --- a/local.sh +++ b/local.sh @@ -1,8 +1,7 @@ #!/bin/bash -# export ROAM_PATH=/path/to/org-roam/src -# export ROAM_DB_FILE=org-roam.db - +read -p "Enter the ROAM_PATH: " ROAM_PATH +read -p "Enter the ROAM_DB_FILE: " ROAM_DB_FILE ROAM_DB_PATH=$ROAM_PATH/$ROAM_DB_FILE ROAM_IMG_PATH=$ROAM_PATH/img @@ -16,9 +15,13 @@ npm install npm run generate:graphdata --script_params=$ROAM_DB_PATH ./create_notes.sh $ROAM_PATH npm run generate:search +npm install fuse.js +node build-index.js # Copy files to the org-roam-ui directory cp -f searchdata.json org-roam-ui/components/Search/ +cp -f fuse-index.json org-roam-ui/components/Search/ + if [ -d $ROAM_IMG_PATH ]; then cp -r $ROAM_IMG_PATH org-roam-ui/public fi diff --git a/package-lock.json b/package-lock.json index fdffa2d..59bc553 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "fuse.js": "^7.0.0", "orgast-util-to-string": "^1.0.1", "sqlite3": "^5.1.7", "unified": "^11.0.4", @@ -434,6 +435,14 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "optional": true }, + "node_modules/fuse.js": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.0.0.tgz", + "integrity": "sha512-14F4hBIxqKvD4Zz/XjDc3y94mNZN6pRv3U13Udo0lNLCWRBUsrMv2xwcF/y/Z5sV6+FQW+/ow68cHpm4sunt8Q==", + "engines": { + "node": ">=10" + } + }, "node_modules/gauge": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", diff --git a/package.json b/package.json index 44e9bf3..735367d 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "author": "", "license": "ISC", "dependencies": { + "fuse.js": "^7.0.0", "orgast-util-to-string": "^1.0.1", "sqlite3": "^5.1.7", "unified": "^11.0.4", -- cgit