refactor(build): use env flags to control feature gate

pull/5857/head
Andelf 2022-06-28 12:20:44 +08:00
parent e92af35954
commit fb92e64967
5 changed files with 30 additions and 3 deletions

View File

@ -24,6 +24,16 @@ on:
type: boolean
required: true
default: true
enable-file-sync:
description: 'Build with file sync support'
type: boolean
required: true
default: false
enable-plugins:
description: 'Build with plugin system support'
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'
@ -87,6 +97,12 @@ jobs:
run: |
sed -i 's/defonce version ".*"/defonce version "${{ steps.ref.outputs.version }}"/g' src/main/frontend/version.cljs
- name: Set Build Environment Variables (only when workflow_dispath)
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "ENABLE_FILE_SYNC=${{ github.event.inputs.enable-file-sync }}" >> $GITHUB_ENV
echo "ENABLE_PLUGINS=${{ github.event.inputs.enable-plugins }}" >> $GITHUB_ENV
- name: Compile CLJS
run: yarn install && gulp build && yarn cljs:release-electron

View File

@ -31,7 +31,9 @@
"externs.js"]
:warnings {:fn-deprecated false
:redef false}}
:closure-defines {goog.debug.LOGGING_ENABLED true}
:closure-defines {goog.debug.LOGGING_ENABLED true
frontend.config/ENABLE-FILE-SYNC #shadow/env ["ENABLE_FILE_SYNC" :as :bool :default false]
frontend.config/ENABLE-PLUGINS #shadow/env ["ENABLE_PLUGINS" :as :bool :default true]}
;; NOTE: electron, browser/mobile-app use different asset-paths.
;; For browser/mobile-app devs, assets are located in /static/js(via HTTP root).

View File

@ -619,7 +619,7 @@
(when (and util/mac? (util/electron?)) (app-auto-update-row t))
(usage-diagnostics-row t instrument-disabled?)
(when-not (mobile-util/native-platform?) (developer-mode-row t developer-mode?))
(when (util/electron?) (plugin-system-switcher-row))
(when (and (util/electron?) config/enable-plugins?) (plugin-system-switcher-row))
(flashcards-switcher-row enable-flashcards?)
(when (util/electron?) (https-user-agent-row https-agent-opts))
(clear-cache-row t)

View File

@ -33,6 +33,15 @@
(goog-define API-DOMAIN "api.logseq.com")
(goog-define WS-URL "wss://og96xf1si7.execute-api.us-east-2.amazonaws.com/production?graphuuid=%s")
;; feature flags
(goog-define ENABLE-FILE-SYNC false)
(defonce enable-file-sync? (or ENABLE-FILE-SYNC dev?)) ;; always enable file-sync when dev
(goog-define ENABLE-PLUGINS true)
(defonce enable-plugins? ENABLE-PLUGINS)
(swap! state/state assoc :plugin/enabled enable-plugins?)
;; :TODO: How to do this?
;; (defonce desktop? ^boolean goog.DESKTOP)

View File

@ -15,7 +15,7 @@
[frontend.handler.user :as user]
[frontend.fs :as fs]))
(def hiding-login&file-sync (not config/dev?))
(def hiding-login&file-sync (not config/enable-file-sync?))
(def refresh-file-sync-component (atom false))
(defn graph-txid-exists?