Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
release scripts + check of version compatibility
zadam8cf44780ceec
diff --git a/bin/release-chrome.sh b/bin/release-chrome.shnew file mode 100755index 0000000000..1ca4c75927--- /dev/null+++ b/bin/release-chrome.sh@@ -0,0 +1,25 @@+#!/usr/bin/env bash++VERSION=$(jq -r ".version" manifest.json)+CHROME_EXTENSION_ID=dfhgmnfclbebfobmblelddiejjcijbjm++BUILD_DIR=trilium-web-clipper-chrome++rm -rf dist+mkdir -p "dist/$BUILD_DIR"++cp -r icons lib options popup *.js manifest.json "dist/$BUILD_DIR"++cd dist/"${BUILD_DIR}" || exit++jq '.name = "Trilium Web Clipper"' manifest.json | sponge manifest.json+jq 'del(.browser_specific_settings)' manifest.json | sponge manifest.json++EXT_FILE_NAME=trilium_web_clipper-${VERSION}-chrome.crx++zip -r ../${EXT_FILE_NAME} *++cd ..+rm -r "${BUILD_DIR}"++webstore upload --source ${EXT_FILE_NAME} --auto-publish --extension-id "${CHROME_EXTENSION_ID}" --client-id "${CHROME_CLIENT_ID}" --client-secret "${CHROME_CLIENT_SECRET}" --refresh-token "${CHROME_REFRESH_TOKEN}"\ No newline at end of filediff --git a/bin/build-firefox.sh b/bin/release-firefox.shsimilarity index 75%rename from bin/build-firefox.shrename to bin/release-firefox.shindex c459fe978e..daa1c30b2a 100755--- a/bin/build-firefox.sh+++ b/bin/release-firefox.sh@@ -2,8 +2,6 @@WEB_EXT_ID="{1410742d-b377-40e7-a9db-63dc9c6ec99c}"-VERSION=$(jq -r ".version" manifest.json)-ARTIFACT_NAME=trilium-web-clipper-firefoxBUILD_DIR=dist/$ARTIFACT_NAME@@ -16,7 +14,7 @@ cd dist/"${ARTIFACT_NAME}" || exitjq '.name = "Trilium Web Clipper"' manifest.json | sponge manifest.json-web-ext sign --id ${WEB_EXT_ID} --artifacts-dir ../+web-ext sign --id ${WEB_EXT_ID} --artifacts-dir ../ --channel=listedcd ..rm -r "${ARTIFACT_NAME}"\ No newline at end of filediff --git a/bin/release.sh b/bin/release.shindex 176df3b8f6..83bd8b0bb3 100755--- a/bin/release.sh+++ b/bin/release.sh@@ -42,9 +42,10 @@ echo "Tagging commit with $TAG"git tag "$TAG"git push origin "$TAG"-bin/build-firefox.sh+bin/release-firefox.shFIREFOX_BUILD=trilium_web_clipper-$VERSION-an+fx.xpi+CHROME_BUILD=trilium_web_clipper-${VERSION}-chrome.crxecho "Creating release in GitHub"@@ -52,11 +53,18 @@ github-release release \--tag "$TAG" \--name "$TAG release"-echo "Uploading build package"+echo "Uploading firefox build package"github-release upload \--tag "$TAG" \--name "$FIREFOX_BUILD" \--file "dist/$FIREFOX_BUILD"+echo "Uploading chrome build package"++github-release upload \+ --tag "$TAG" \+ --name "$CHROME_BUILD" \+ --file "dist/$CHROME_BUILD"+echo "Release finished!"\ No newline at end of filediff --git a/manifest.json b/manifest.jsonindex 174e2648d0..f233d2aff3 100644--- a/manifest.json+++ b/manifest.json@@ -1,7 +1,7 @@{"manifest_version": 2,"name": "Trilium Web Clipper (dev)",- "version": "0.1.0",+ "version": "0.0.1","description": "Save web clippings to Trilium Notes.","homepage_url": "https://github.com/zadam/trilium-web-clipper","content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",diff --git a/popup/popup.js b/popup/popup.jsindex bb0cdd5d6f..ff61ca423f 100644--- a/popup/popup.js+++ b/popup/popup.js@@ -105,6 +105,12 @@ browser.runtime.onMessage.addListener(request => {statusText = `<span style="color: red">Not found</span>`;isConnected = false;}+ else if (triliumSearch.status === 'version-mismatch') {+ const whatToUpgrade = triliumSearch.extensionMajor > triliumSearch.triliumMajor ? "Trilium Notes" : "this extension";++ statusText = `<span style="color: orange">Trilium instance found, but it is not compatible with this extension version. Please update ${whatToUpgrade} to the latest version.</span>`;+ isConnected = true;+ }else if (triliumSearch.status === 'found-desktop') {statusText = `<span style="color: green">Connected on port ${triliumSearch.port}</span>`;isConnected = true;diff --git a/trilium_server_facade.js b/trilium_server_facade.jsindex 8228e76e9c..1205544c2c 100644--- a/trilium_server_facade.js+++ b/trilium_server_facade.js@@ -1,3 +1,5 @@+const PROTOCOL_VERSION_MAJOR = 2;+function isDevEnv() {const manifest = browser.runtime.getManifest();@@ -28,11 +30,31 @@ class TriliumServerFacade {this.sendTriliumSearchStatusToPopup();}+ setTriliumSearchWithVersionCheck(json, resp) {+ const [major, minor] = json.protocolVersion+ .split(".")+ .map(chunk => parseInt(chunk));++ // minor version is intended to be used to dynamically limit features provided by extension+ // if some specific Trilium API is not supported. So far not needed.++ if (major !== PROTOCOL_VERSION_MAJOR) {+ this.setTriliumSearch({+ status: 'version-mismatch',+ extensionMajor: PROTOCOL_VERSION_MAJOR,+ triliumMajor: major+ });+ }+ else {+ this.setTriliumSearch(resp);+ }+ }+async triggerSearchForTrilium() {this.setTriliumSearch({ status: 'searching' });const startingPort = await this.getStartingPort();-+for (let testedPort = startingPort; testedPort < startingPort + 10; testedPort++) {try {console.debug('Trying port ' + testedPort);@@ -46,7 +68,7 @@ class TriliumServerFacade {const json = JSON.parse(text);if (json.appName === 'trilium') {- this.setTriliumSearch({+ this.setTriliumSearchWithVersionCheck(json, {status: 'found-desktop',port: testedPort,url: 'http://127.0.0.1:' + testedPort@@ -78,11 +100,12 @@ class TriliumServerFacade {const json = JSON.parse(text);if (json.appName === 'trilium') {- this.setTriliumSearch({+ this.setTriliumSearchWithVersionCheck(json, {status: 'found-server',url: triliumServerUrl,token: authToken});+return;}}