From 560d8fb5dc82d96dbfafa0eb37b2f52ef5cf5333 Mon Sep 17 00:00:00 2001 From: charlie Date: Sat, 13 Aug 2022 13:13:16 +0800 Subject: [PATCH 1/4] fix(plugin): initial pluign core with fatal argument of empty plugin root path --- src/electron/electron/utils.cljs | 2 +- src/main/frontend/handler/plugin.cljs | 139 +++++++++++++------------- 2 files changed, 73 insertions(+), 68 deletions(-) diff --git a/src/electron/electron/utils.cljs b/src/electron/electron/utils.cljs index a311392834..6d9ef56d8a 100644 --- a/src/electron/electron/utils.cljs +++ b/src/electron/electron/utils.cljs @@ -35,7 +35,7 @@ [] (let [lg-dir (str (.getPath app "home") "/.logseq")] (if-not (fs/existsSync lg-dir) - (and (fs/mkdirSync lg-dir) lg-dir) + (do (fs/mkdirSync lg-dir) lg-dir) lg-dir))) (defn get-ls-default-plugins diff --git a/src/main/frontend/handler/plugin.cljs b/src/main/frontend/handler/plugin.cljs index f046d6cb85..3b5dee1413 100644 --- a/src/main/frontend/handler/plugin.cljs +++ b/src/main/frontend/handler/plugin.cljs @@ -591,89 +591,94 @@ (let [el (js/document.createElement "div")] (.appendChild js/document.body el) (rum/mount - (lsp-indicator) el)) + (lsp-indicator) el)) (state/set-state! :plugin/indicator-text "LOADING") - (p/then - (p/let [root (get-ls-dotdir-root) - _ (.setupPluginCore js/LSPlugin (bean/->js {:localUserConfigRoot root :dotConfigRoot root})) + (-> (p/let [root (get-ls-dotdir-root) + _ (.setupPluginCore js/LSPlugin (bean/->js {:localUserConfigRoot root :dotConfigRoot root})) - clear-commands! (fn [pid] - ;; commands - (unregister-plugin-slash-command pid) - (invoke-exported-api "unregister_plugin_simple_command" pid) - (invoke-exported-api "uninstall_plugin_hook" pid) - (unregister-plugin-ui-items pid) - (unregister-plugin-resources pid)) + clear-commands! (fn [pid] + ;; commands + (unregister-plugin-slash-command pid) + (invoke-exported-api "unregister_plugin_simple_command" pid) + (invoke-exported-api "uninstall_plugin_hook" pid) + (unregister-plugin-ui-items pid) + (unregister-plugin-resources pid)) - _ (doto js/LSPluginCore - (.on "registered" - (fn [^js pl] - (register-plugin - (bean/->clj (.parse js/JSON (.stringify js/JSON pl)))))) + _ (doto js/LSPluginCore + (.on "registered" + (fn [^js pl] + (register-plugin + (bean/->clj (.parse js/JSON (.stringify js/JSON pl)))))) - (.on "reloaded" - (fn [^js pl] - (register-plugin - (bean/->clj (.parse js/JSON (.stringify js/JSON pl)))))) + (.on "reloaded" + (fn [^js pl] + (register-plugin + (bean/->clj (.parse js/JSON (.stringify js/JSON pl)))))) - (.on "unregistered" (fn [pid] - (let [pid (keyword pid)] - ;; effects - (unregister-plugin-themes pid) - ;; plugins - (swap! state/state medley/dissoc-in [:plugin/installed-plugins pid]) - ;; commands - (clear-commands! pid)))) + (.on "unregistered" (fn [pid] + (let [pid (keyword pid)] + ;; effects + (unregister-plugin-themes pid) + ;; plugins + (swap! state/state medley/dissoc-in [:plugin/installed-plugins pid]) + ;; commands + (clear-commands! pid)))) - (.on "unlink-plugin" (fn [pid] - (let [pid (keyword pid)] - (ipc/ipc "uninstallMarketPlugin" (name pid))))) + (.on "unlink-plugin" (fn [pid] + (let [pid (keyword pid)] + (ipc/ipc "uninstallMarketPlugin" (name pid))))) - (.on "beforereload" (fn [^js pl] - (let [pid (.-id pl)] - (clear-commands! pid) - (unregister-plugin-themes pid false)))) + (.on "beforereload" (fn [^js pl] + (let [pid (.-id pl)] + (clear-commands! pid) + (unregister-plugin-themes pid false)))) - (.on "disabled" (fn [pid] - (clear-commands! pid) - (unregister-plugin-themes pid))) + (.on "disabled" (fn [pid] + (clear-commands! pid) + (unregister-plugin-themes pid))) - (.on "themes-changed" (fn [^js themes] - (swap! state/state assoc :plugin/installed-themes - (vec (mapcat (fn [[pid vs]] (mapv #(assoc % :pid pid) (bean/->clj vs))) (bean/->clj themes)))))) + (.on "themes-changed" (fn [^js themes] + (swap! state/state assoc :plugin/installed-themes + (vec (mapcat (fn [[pid vs]] (mapv #(assoc % :pid pid) (bean/->clj vs))) (bean/->clj themes)))))) - (.on "theme-selected" (fn [^js theme] - (let [theme (bean/->clj theme) - url (:url theme) - mode (:mode theme)] - (when mode - (state/set-custom-theme! mode theme) - (state/set-theme-mode! mode)) - (hook-plugin-app :theme-changed theme) - (state/set-state! :plugin/selected-theme url)))) + (.on "theme-selected" (fn [^js theme] + (let [theme (bean/->clj theme) + url (:url theme) + mode (:mode theme)] + (when mode + (state/set-custom-theme! mode theme) + (state/set-theme-mode! mode)) + (hook-plugin-app :theme-changed theme) + (state/set-state! :plugin/selected-theme url)))) - (.on "reset-custom-theme" (fn [^js themes] - (let [themes (bean/->clj themes) - custom-theme (dissoc themes :mode) - mode (:mode themes)] - (state/set-custom-theme! {:light (if (nil? (:light custom-theme)) {:mode "light"} (:light custom-theme)) - :dark (if (nil? (:dark custom-theme)) {:mode "dark"} (:dark custom-theme))}) - (state/set-theme-mode! mode)))) + (.on "reset-custom-theme" (fn [^js themes] + (let [themes (bean/->clj themes) + custom-theme (dissoc themes :mode) + mode (:mode themes)] + (state/set-custom-theme! {:light (if (nil? (:light custom-theme)) {:mode "light"} (:light custom-theme)) + :dark (if (nil? (:dark custom-theme)) {:mode "dark"} (:dark custom-theme))}) + (state/set-theme-mode! mode)))) - (.on "settings-changed" (fn [id ^js settings] - (let [id (keyword id)] - (when (and settings - (contains? (:plugin/installed-plugins @state/state) id)) - (update-plugin-settings-state id (bean/->clj settings))))))) + (.on "settings-changed" (fn [id ^js settings] + (let [id (keyword id)] + (when (and settings + (contains? (:plugin/installed-plugins @state/state) id)) + (update-plugin-settings-state id (bean/->clj settings))))))) - default-plugins (get-user-default-plugins) + default-plugins (get-user-default-plugins) - _ (.register js/LSPluginCore (bean/->js (if (seq default-plugins) default-plugins [])) true)]) - #(do - (state/set-state! :plugin/indicator-text "END") - (callback)))) + _ (.register js/LSPluginCore (bean/->js (if (seq default-plugins) default-plugins [])) true)]) + + (p/then + (fn [] + (state/set-state! :plugin/indicator-text "END") + (callback))) + (p/catch + (fn [^js e] + (log/error :setup-plugin-system-error e) + (state/set-state! :plugin/indicator-text (str "Fatal: " e)))))) (defn setup! "setup plugin core handler" From da11d8cb3076cb29b226141d326c759f78a85b2e Mon Sep 17 00:00:00 2001 From: Andelf Date: Sun, 14 Aug 2022 19:13:52 +0800 Subject: [PATCH 2/4] refactor(ci): add checks for ci release (#6350) --- .github/workflows/build-android.yml | 14 ++++++++- .github/workflows/build-desktop-release.yml | 32 ++++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index a464e60cae..56ff1f84dc 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -19,11 +19,19 @@ on: description: "Build from Git Ref(master)" required: true default: "master" + enable-file-sync: + description: 'Build with file sync support' + type: boolean + required: true + default: false workflow_call: inputs: build-target: type: string required: true + enable-file-sync: + description: 'Build with file sync support' + type: boolean secrets: ANDROID_KEYSTORE: required: true @@ -93,11 +101,15 @@ jobs: sed -i 's/defonce version ".*"/defonce version "${{ steps.ref.outputs.version }}"/g' src/main/frontend/version.cljs sed -i 's/versionName ".*"/versionName "${{ steps.ref.outputs.version }}"/g' android/app/build.gradle + - name: Set Build Environment Variables + run: | + echo "ENABLE_FILE_SYNC=${{ inputs.enable-file-sync == 'true' || github.event.inputs.enable-file-sync == 'true' }}" >> $GITHUB_ENV + - name: Compile CLJS - android variant, use es6 instead of es-next run: yarn install && yarn release-android-app - name: Upload Sentry Sourcemaps (beta only) - if: ${{ inputs.build-target == 'beta' || github.event.inputs.build-target == 'beta' }} + if: ${{ github.repository == 'logseq/logseq' && (inputs.build-target == 'beta' || github.event.inputs.build-target == 'beta') }} run: | curl -sL https://sentry.io/get-cli/ | bash release_name="logseq-android@${{ steps.ref.outputs.version }}" diff --git a/.github/workflows/build-desktop-release.yml b/.github/workflows/build-desktop-release.yml index 265868d249..31ed0be663 100644 --- a/.github/workflows/build-desktop-release.yml +++ b/.github/workflows/build-desktop-release.yml @@ -38,6 +38,11 @@ on: type: boolean required: true default: true + build-android: + description: 'Build Android App' + type: boolean + required: true + default: true schedule: # Every workday at the 2 P.M. (UTC) we run a scheduled nightly build - cron: '0 14 * * MON-FRI' @@ -49,6 +54,12 @@ jobs: compile-cljs: runs-on: ubuntu-18.04 steps: + - name: Check build options + if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.build-target == 'nightly' || github.event.inputs.build-target == 'beta') && github.event.inputs.git-ref != 'master' }} + run: | + echo "::error title=CheckFail::Nightly and Beta Release MUST be built from master" + exit 1 + - name: Check out Git repository uses: actions/checkout@v2 with: @@ -96,6 +107,14 @@ jobs: pkgver=$(node ./scripts/get-pkg-version.js "${{ github.event.inputs.build-target }}") echo ::set-output name=version::$pkgver + - name: Do Not Overwrite Existing Release + if: ${{ github.event.inputs.build-target == 'beta' }} + run: | + if curl -f "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.ref.outputs.version }}" &>/dev/null; then + echo "::error title=CheckFail::Release already exists" + exit 1 + fi + - name: Update Nightly APP Version if: ${{ github.event.inputs.build-target == 'nightly' || github.event_name == 'schedule' }} run: | @@ -128,7 +147,7 @@ jobs: working-directory: ./static - name: Upload Sentry Sourcemaps (beta only) - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.build-target == 'beta' }} + if: ${{ github.repository == 'logseq/logseq' && github.event_name == 'workflow_dispatch' && github.event.inputs.build-target == 'beta' }} run: | curl -sL https://sentry.io/get-cli/ | bash release_name="logseq@${{ steps.ref.outputs.version }}" @@ -284,6 +303,7 @@ jobs: ${{ runner.os }}-yarn- - name: Signing By Apple Developer ID + if: ${{ github.repository == 'logseq/logseq' }} uses: apple-actions/import-codesign-certs@v1 with: p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }} @@ -351,6 +371,7 @@ jobs: ${{ runner.os }}-arm64-yarn- - name: Signing By Apple Developer ID + if: ${{ github.repository == 'logseq/logseq' }} uses: apple-actions/import-codesign-certs@v1 with: p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }} @@ -389,9 +410,11 @@ jobs: # reuse workflow via workflow_call build-android: - uses: logseq/logseq/.github/workflows/build-android.yml@master + uses: ./.github/workflows/build-android.yml + if: ${{ github.event_name == 'schedule' || github.event.inputs.build-android == 'true' }} with: build-target: "${{ github.event.inputs.build-target }}" + enable-file-sync: "${{ github.event.inputs.enable-file-sync == 'true' }}" secrets: ANDROID_KEYSTORE: "${{ secrets.ANDROID_KEYSTORE }}" ANDROID_KEYSTORE_PASSWORD: "${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" @@ -466,8 +489,8 @@ jobs: release: # NOTE: For now, we only have beta channel to be released on Github if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.build-target == 'beta' }} - needs: [ build-macos-x64, build-macos-arm64, build-linux, build-windows, build-android ] - runs-on: ubuntu-18.04 + needs: [ build-macos-x64, build-macos-arm64, build-linux, build-windows ] + runs-on: ubuntu-latest steps: - name: Download MacOS x64 Artifacts uses: actions/download-artifact@v2 @@ -495,6 +518,7 @@ jobs: - name: Download Android Artifacts uses: actions/download-artifact@v2 + if: ${{ github.event_name == 'schedule' || github.event.inputs.build-android == 'true' }} with: name: logseq-android-builds path: ./ From 6f2a80a3e430b1b4f38721481b3e0bed5ac6c471 Mon Sep 17 00:00:00 2001 From: Aryan Sawhney <80150109+sawhney17@users.noreply.github.com> Date: Sun, 14 Aug 2022 19:02:07 +0400 Subject: [PATCH 3/4] Update onboarding.cljs --- src/main/frontend/components/onboarding.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/frontend/components/onboarding.cljs b/src/main/frontend/components/onboarding.cljs index a347b85135..db7ac0b78f 100644 --- a/src/main/frontend/components/onboarding.cljs +++ b/src/main/frontend/components/onboarding.cljs @@ -34,7 +34,7 @@ {:title "Development" :children [[(t :help/roadmap) "https://trello.com/b/8txSM12G/roadmap"] [(t :help/bug) "https://github.com/logseq/logseq/issues/new?labels=from:in-app&template=bug_report.yaml"] - [(t :help/feature) "https://github.com/logseq/logseq/issues/new?assignees=&labels=&template=feature_request.md&title="] + [(t :help/feature) "https://discuss.logseq.com/c/feature-requests/"] [(t :help/changelog) "https://docs.logseq.com/#/page/changelog"]]} {:title "About" From b1ce56c55697b6258266d21a08fe51fb265d5987 Mon Sep 17 00:00:00 2001 From: Junyi Du Date: Mon, 15 Aug 2022 01:08:50 +0800 Subject: [PATCH 4/4] fix: roam export error caused by typo --- src/main/frontend/external/roam_export.cljs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/frontend/external/roam_export.cljs b/src/main/frontend/external/roam_export.cljs index 2c786457da..af03b7a648 100644 --- a/src/main/frontend/external/roam_export.cljs +++ b/src/main/frontend/external/roam_export.cljs @@ -23,10 +23,10 @@ (defn uuid->uid-map [] (let [db (db/get-db (state/get-current-repo))] (->> - (d/q db '[:find (pull ?r [:block/uuid]) - :in $ - :where - [?b :block/refs ?r]]) + (d/q '[:find (pull ?r [:block/uuid]) + :in $ + :where + [?b :block/refs ?r]] db) (map (comp :block/uuid first)) (distinct) (map (fn [uuid] [uuid (nano-id)]))