feat: staging build (#3365)

* feat: move constants isElectronBuild

* feat: move constants isWebBuild

* feat: unified isDev

* feat: unified isProd

* chore: staging build

* update

* fix

* fix

* feat: staging icons

* fix
This commit is contained in:
DIYgod
2025-03-30 22:13:11 +08:00
committed by GitHub
parent 1c99cbd033
commit 2881d655ee
56 changed files with 152 additions and 141 deletions
+35 -16
View File
@@ -34,6 +34,8 @@ env:
jobs:
release:
runs-on: ${{ matrix.os }}
env:
PROD: ${{ github.event.inputs.tag_version == 'true' || github.ref_type == 'tag' }}
strategy:
fail-fast: false
@@ -51,13 +53,13 @@ jobs:
steps:
- name: Check out Git repository Fully
uses: actions/checkout@v4
if: github.event.inputs.tag_version == 'true' || github.ref_type == 'tag'
if: env.PROD == 'true'
with:
fetch-depth: 0
lfs: true
- name: Check out Git repository
uses: actions/checkout@v4
if: github.event.inputs.tag_version != 'true' && github.ref_type != 'tag'
if: env.PROD == 'false'
with:
fetch-depth: 1
lfs: true
@@ -125,13 +127,21 @@ jobs:
run: |
cd apps/desktop
pnpm update:main-hash
- name: Build
- name: Build - Vite
run: |
cd apps/desktop
pnpm build:electron-vite ${{ env.PROD == 'false' && '--mode staging' || '' }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Build - Windows and Linux
if: runner.os != 'macOS'
run: pnpm build:electron
run: |
cd apps/desktop
pnpm build:electron-forge ${{ env.PROD == 'false' && '--mode=staging' || '' }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Build (macOS)
- name: Build - macOS
if: runner.os == 'macOS' && github.event.inputs.mas != 'true'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
@@ -143,20 +153,28 @@ jobs:
with:
max_attempts: 3
timeout_minutes: 10
command: pnpm build:macos
command: |
cd apps/desktop
npx electron-forge make --arch=x64 --platform=darwin ${{ env.PROD == 'false' && '--mode=staging' || '' }}
npx electron-forge make --arch=arm64 --platform=darwin ${{ env.PROD == 'false' && '--mode=staging' || '' }}
npx tsx scripts/merge-yml.ts
- name: Build (Mac App Store)
- name: Build - Mac App Store
if: runner.os == 'macOS' && github.event.inputs.mas == 'true'
env:
OSX_SIGN_KEYCHAIN_PATH: ${{ runner.temp }}/app-signing.keychain-db
OSX_SIGN_IDENTITY: ${{ secrets.OSX_SIGN_IDENTITY_MAS }}
OSX_SIGN_PROVISIONING_PROFILE_PATH: ${{ runner.temp }}/build_pp.provisionprofile
BUILD_VERSION: ${{ github.event.inputs.build_version }}
run: pnpm build:mas
run: |
cd apps/desktop
pnpm build:electron-forge:mas ${{ env.PROD == 'false' && '--mode=staging' || '' }}
- name: Build Renderer
- name: Build - Renderer
if: runner.os == 'Linux'
run: pnpm build:render
run: |
cd apps/desktop
pnpm build:render
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
@@ -210,7 +228,7 @@ jobs:
- uses: signpath/github-action-submit-signing-request@v1.1
continue-on-error: true
if: runner.os == 'windows' && (github.ref_type == 'tag' || github.event.inputs.tag_version == 'true')
if: runner.os == 'windows' && env.PROD == 'true'
with:
api-token: "${{ secrets.SIGNPATH_API_TOKEN }}"
organization-id: "8c651516-fdaf-40a1-9fea-001dffde850e"
@@ -221,12 +239,12 @@ jobs:
output-artifact-directory: "apps/desktop/out/make/"
- name: Update latest.yml
if: runner.os == 'windows' && (github.ref_type == 'tag' || github.event.inputs.tag_version == 'true')
if: runner.os == 'windows' && env.PROD == 'true'
run: npx tsx apps/desktop/scripts/update-windows-yml.ts
- name: Upload file (windows-x64-exe signed)
uses: actions/upload-artifact@v4
if: runner.os == 'windows' && (github.ref_type == 'tag' || github.event.inputs.tag_version == 'true')
if: runner.os == 'windows' && env.PROD == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
@@ -261,7 +279,7 @@ jobs:
retention-days: 90
- name: Generate artifact attestation
if: github.ref_type == 'tag' || github.event.inputs.tag_version == 'true'
if: env.PROD == 'true'
continue-on-error: true
uses: actions/attest-build-provenance@v2
with:
@@ -275,19 +293,20 @@ jobs:
apps/desktop/dist/*.tar.gz
- run: npx changelogithub
if: github.ref_type == 'tag' || github.event.inputs.tag_version == 'true'
if: env.PROD == 'true'
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Version
if: env.PROD == 'true'
id: version
uses: ./.github/actions/setup-version
with:
type: "desktop"
- name: Create Release Draft
if: github.ref_type == 'tag' || github.event.inputs.tag_version == 'true'
if: env.PROD == 'true'
uses: softprops/action-gh-release@v2
with:
name: v${{ steps.version.outputs.APP_VERSION }}
+6 -3
View File
@@ -19,6 +19,9 @@ import yaml from "js-yaml"
import { rimraf, rimrafSync } from "rimraf"
const platform = process.argv.find((arg) => arg.startsWith("--platform"))?.split("=")[1]
const mode = process.argv.find((arg) => arg.startsWith("--mode"))?.split("=")[1]
const isStaging = mode === "staging"
const artifactRegex = /.*\.(?:exe|dmg|AppImage|zip)$/
const platformNamesMap = {
@@ -96,7 +99,7 @@ const config: ForgeConfig = {
appCategoryType: "public.app-category.news",
buildVersion: process.env.BUILD_VERSION || undefined,
appBundleId: "is.follow",
icon: "resources/icon",
icon: isStaging ? "resources/icon-staging" : "resources/icon",
extraResource: ["./resources/app-update.yml"],
protocols: [
{
@@ -178,14 +181,14 @@ const config: ForgeConfig = {
),
new MakerSquirrel({
name: "Folo",
setupIcon: "resources/icon.ico",
setupIcon: isStaging ? "resources/icon-staging.ico" : "resources/icon.ico",
iconUrl: "https://app.follow.is/favicon.ico",
}),
new MakerAppImage({
config: {
icons: [
{
file: "resources/icon.png",
file: isStaging ? "resources/icon-staging.png" : "resources/icon.png",
size: 256,
},
],
+5 -3
View File
@@ -13,9 +13,11 @@
"main": "./dist/main/index.js",
"scripts": {
"analyze:web": "cross-env analyzer=1 vite build",
"build": "electron-vite build && electron-forge make",
"build:macos": "electron-vite build && electron-forge make --arch=x64 --platform=darwin && electron-forge make --arch=arm64 --platform=darwin && tsx scripts/merge-yml.ts",
"build:mas": "electron-vite build && electron-forge make --arch=universal --platform=mas",
"build:electron": "electron-vite build && electron-forge make",
"build:electron-forge": "electron-forge make",
"build:electron-forge:macos": "electron-forge make --arch=x64 --platform=darwin && electron-forge make --arch=arm64 --platform=darwin && tsx scripts/merge-yml.ts",
"build:electron-forge:mas": "electron-forge make --arch=universal --platform=mas",
"build:electron-vite": "electron-vite build",
"build:render": "vite build -c vite.config.electron-render.ts",
"build:web": "rm -rf out/web && cross-env WEB_BUILD=1 vite build",
"bump": "vv",
Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 431 B

+2 -3
View File
@@ -1,9 +1,8 @@
import os from "node:os"
export const mode = process.env.NODE_ENV
export const isDev = mode === "development"
import { DEV } from "@follow/shared/constants"
export const channel: "development" | "beta" | "alpha" | "stable" = isDev ? "development" : "stable"
export const channel: "development" | "beta" | "alpha" | "stable" = DEV ? "development" : "stable"
const { platform } = process
export const isMacOS = platform === "darwin"
+10 -5
View File
@@ -1,21 +1,26 @@
import path from "node:path"
import { fileURLToPath, pathToFileURL } from "node:url"
import { MODE, ModeEnum } from "@follow/shared/constants"
import { isMacOS, isWindows } from "./env"
const __dirname = fileURLToPath(new URL(".", import.meta.url))
const iconMap = {
prod: path.join(__dirname, "../../resources/icon.png"),
dev: path.join(__dirname, "../../static/icon-dev.png"),
[ModeEnum.production]: path.join(__dirname, "../../resources/icon.png"),
[ModeEnum.development]: path.join(__dirname, "../../resources/icon-dev.png"),
[ModeEnum.staging]: path.join(__dirname, "../../resources/icon-staging.png"),
}
export const getIconPath = () => iconMap[process.env.NODE_ENV === "development" ? "dev" : "prod"]
export const getIconPath = () => iconMap[MODE]
export const getTrayIconPath = () => {
if (isMacOS) {
return path.join(__dirname, "../../resources/tray-icon.png")
return path.join(__dirname, "../../resources/icon-tray.png")
}
if (isWindows) {
// https://www.electronjs.org/docs/latest/api/tray#:~:text=Windows,best%20visual%20effects.
return path.join(__dirname, "../../resources/icon-no-padding.ico")
return MODE === ModeEnum.staging
? path.join(__dirname, "../../resources/icon-tray-staging.ico")
: path.join(__dirname, "../../resources/icon-tray.ico")
}
return getIconPath()
}
+3 -3
View File
@@ -1,6 +1,6 @@
import { electronApp, optimizer } from "@electron-toolkit/utils"
import { callWindowExpose } from "@follow/shared/bridge"
import { APP_PROTOCOL } from "@follow/shared/constants"
import { APP_PROTOCOL, DEV } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import { createBuildSafeHeaders } from "@follow/utils/headers"
import { IMAGE_PROXY_URL } from "@follow/utils/img-proxy"
@@ -9,7 +9,7 @@ import { app, BrowserWindow, net, protocol, session } from "electron"
import squirrelStartup from "electron-squirrel-startup"
import { DEVICE_ID } from "./constants/system"
import { isDev, isMacOS } from "./env"
import { isMacOS } from "./env"
import { initializeAppStage0, initializeAppStage1 } from "./init"
import { updateProxy } from "./lib/proxy"
import { handleUrlRouting } from "./lib/router"
@@ -26,7 +26,7 @@ import {
windowStateStoreKey,
} from "./window"
if (isDev) console.info("[main] env loaded:", env)
if (DEV) console.info("[main] env loaded:", env)
const apiURL = process.env["VITE_API_URL"] || import.meta.env.VITE_API_URL
+3 -4
View File
@@ -2,7 +2,7 @@ import path from "node:path"
import { getRendererHandlers, registerIpcMain } from "@egoist/tipc/main"
import { PushReceiver } from "@eneris/push-receiver"
import { APP_PROTOCOL } from "@follow/shared/constants"
import { APP_PROTOCOL, DEV } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import type { MessagingData } from "@follow/shared/hono"
import { app, nativeTheme, Notification, protocol, shell } from "electron"
@@ -23,13 +23,12 @@ import { createMainWindow, getMainWindow } from "./window"
if (process.argv.length === 3 && process.argv[2]!.startsWith("follow-dev:")) {
process.env.NODE_ENV = "development"
}
const isDev = process.env.NODE_ENV === "development"
/**
* Mandatory and fast initializers for the app
*/
export function initializeAppStage0() {
if (isDev) app.setPath("appData", path.join(app.getPath("appData"), "Follow (dev)"))
if (DEV) app.setPath("appData", path.join(app.getPath("appData"), "Follow (dev)"))
initializeSentry()
}
export const initializeAppStage1 = () => {
@@ -86,7 +85,7 @@ export const registerMenuAndContextMenu = () => {
showCopyLink: true,
showCopyImageAddress: true,
showCopyImage: true,
showInspectElement: isDev,
showInspectElement: DEV,
showSelectAll: true,
showCopyVideoAddress: true,
showSaveVideoAs: true,
+3 -2
View File
@@ -1,10 +1,11 @@
import { callWindowExpose } from "@follow/shared/bridge"
import { DEV } from "@follow/shared/constants"
import { dispatchEventOnWindow } from "@follow/shared/event"
import { name } from "@pkg"
import type { BrowserWindow, MenuItem, MenuItemConstructorOptions } from "electron"
import { Menu } from "electron"
import { isDev, isMacOS } from "./env"
import { isMacOS } from "./env"
import { clearAllDataAndConfirm } from "./lib/cleaner"
import { t } from "./lib/i18n"
import { revealLogFile } from "./logger"
@@ -202,7 +203,7 @@ export const registerAppMenu = () => {
},
]
if (isDev) {
if (DEV) {
menus.push({
label: t("menu.debug"),
submenu: [
+2 -2
View File
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url"
import { getRendererHandlers } from "@egoist/tipc/main"
import { callWindowExpose } from "@follow/shared/bridge"
import { DEV } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import { app, BrowserWindow, clipboard, dialog, shell } from "electron"
@@ -17,7 +18,6 @@ import { registerAppTray } from "~/lib/tray"
import { logger, revealLogFile } from "~/logger"
import { cleanupOldRender, loadDynamicRenderEntry } from "~/updater/hot-updater"
import { isDev } from "../env"
import { downloadFile } from "../lib/download"
import { i18n } from "../lib/i18n"
import { cleanBetterAuthSessionCookie, cleanUser } from "../lib/user"
@@ -279,7 +279,7 @@ ${content}
for (const window of allWindows) {
if (window === mainWindow) {
if (isDev) {
if (DEV) {
logger.verbose("[rendererUpdateReload]: skip reload in dev")
break
}
+3 -3
View File
@@ -1,11 +1,11 @@
import { isDev } from "~/env"
import { DEV } from "@follow/shared/constants"
export const appUpdaterConfig = {
// Disable renderer hot update will trigger app update when available
enableRenderHotUpdate: !isDev,
enableRenderHotUpdate: !DEV,
enableCoreUpdate: !process.mas && !process.windowsStore,
// Disable app update will also disable renderer hot update and core update
enableAppUpdate: !isDev,
enableAppUpdate: !DEV,
app: {
autoCheckUpdate: true,
+4 -3
View File
@@ -1,10 +1,11 @@
import { getRendererHandlers } from "@egoist/tipc/main"
import { DEV } from "@follow/shared/constants"
import { autoUpdater as defaultAutoUpdater } from "electron-updater"
import { GITHUB_OWNER, GITHUB_REPO } from "~/constants/app"
import { canUpdateRender, CanUpdateRenderState, hotUpdateRender } from "~/updater/hot-updater"
import { channel, isDev, isWindows } from "../env"
import { channel, isWindows } from "../env"
import { logger } from "../logger"
import type { RendererHandlers } from "../renderer-handlers"
import { destroyMainWindow, getMainWindow } from "../window"
@@ -13,7 +14,7 @@ import { CustomGitHubProvider } from "./custom-github-provider"
import { WindowsUpdater } from "./windows-updater"
// skip auto update in dev mode
// const disabled = isDev
// const disabled = DEV
const disabled = !appUpdaterConfig.enableAppUpdate
const autoUpdater = isWindows ? new WindowsUpdater() : defaultAutoUpdater
@@ -151,7 +152,7 @@ export const registerUpdater = async () => {
autoUpdater.on("error", (e) => {
logger.error("Error while updating client", e)
})
autoUpdater.forceDevUpdateConfig = isDev
autoUpdater.forceDevUpdateConfig = DEV
setInterval(() => {
if (appUpdaterConfig.app.autoCheckUpdate) {
+3 -2
View File
@@ -4,12 +4,13 @@ import { fileURLToPath } from "node:url"
import { is } from "@electron-toolkit/utils"
import { APP_PROTOCOL } from "@follow/shared"
import { callWindowExpose, WindowState } from "@follow/shared/bridge"
import { DEV } from "@follow/shared/constants"
import type { BrowserWindowConstructorOptions } from "electron"
import { app, BrowserWindow, screen, shell } from "electron"
import type { Event } from "electron/main"
import { START_IN_TRAY_ARGS } from "./constants/app"
import { isDev, isMacOS, isWindows, isWindows11 } from "./env"
import { isMacOS, isWindows, isWindows11 } from "./env"
import { filePathToAppUrl, getIconPath } from "./helper"
import { t } from "./lib/i18n"
import { store } from "./lib/store"
@@ -46,7 +47,7 @@ export function createWindow(
preload: path.join(__dirname, "../preload/index.mjs"),
sandbox: false,
webviewTag: true,
webSecurity: !isDev,
webSecurity: !DEV,
nodeIntegration: true,
contextIsolation: false,
},
@@ -1,11 +1,11 @@
import { Logo } from "@follow/components/icons/logo.jsx"
import { Button } from "@follow/components/ui/button/index.js"
import { ELECTRON_BUILD } from "@follow/shared/constants"
import { captureException } from "@sentry/react"
import { useEffect } from "react"
import type { Location } from "react-router"
import { Navigate, useLocation, useNavigate } from "react-router"
import { isElectronBuild } from "~/constants"
import { removeAppSkeleton } from "~/lib/app"
import { PoweredByFooter } from "./PoweredByFooter"
@@ -27,7 +27,7 @@ class AccessNotFoundError extends Error {
export const NotFound = () => {
const location = useLocation()
useEffect(() => {
if (!isElectronBuild) {
if (!ELECTRON_BUILD) {
return
}
captureException(
@@ -1,4 +1,5 @@
import { useIsDark } from "@follow/hooks"
import { ELECTRON_BUILD } from "@follow/shared/constants"
import { cn } from "@follow/utils/utils"
import { useIsomorphicLayoutEffect } from "foxact/use-isomorphic-layout-effect"
import type { FC } from "react"
@@ -11,7 +12,6 @@ import type {
} from "shiki"
import { useUISettingKey, useUISettingSelector } from "~/atoms/settings/ui"
import { isElectronBuild } from "~/constants"
import { tipcClient } from "~/lib/client"
import { CopyButton } from "../../button/CopyButton"
@@ -42,7 +42,7 @@ export const ShikiHighLighter: FC<ShikiProps> = (props) => {
const guessCodeLanguage = useUISettingKey("guessCodeLanguage")
useInsertionEffect(() => {
if (!guessCodeLanguage) return
if (language || !isElectronBuild) return
if (language || !ELECTRON_BUILD) return
if (!bundledLanguagesKeysSet) {
import("shiki/langs")
@@ -3,6 +3,7 @@ import { RootPortalProvider } from "@follow/components/ui/portal/provider.js"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import { ZIndexProvider } from "@follow/components/ui/z-index/index.js"
import { useRefValue } from "@follow/hooks"
import { ELECTRON_BUILD } from "@follow/shared/constants"
import { nextFrame, preventDefault, stopPropagation } from "@follow/utils/dom"
import { cn, getOS } from "@follow/utils/utils"
import * as Dialog from "@radix-ui/react-dialog"
@@ -31,7 +32,7 @@ import { AppErrorBoundary } from "~/components/common/AppErrorBoundary"
import { SafeFragment } from "~/components/common/Fragment"
import { m } from "~/components/common/Motion"
import { ErrorComponentType } from "~/components/errors/enum"
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT, isElectronBuild } from "~/constants"
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT } from "~/constants"
import { useSwitchHotKeyScope } from "~/hooks/common"
import { modalStackAtom } from "./atom"
@@ -45,7 +46,7 @@ import { useModalSubscriber } from "./internal/use-subscriber"
import { ModalOverlay } from "./overlay"
import type { ModalOverlayOptions, ModalProps } from "./types"
const DragBar = isElectronBuild ? (
const DragBar = ELECTRON_BUILD ? (
<span className="drag-region fixed left-0 right-36 top-0 h-8" />
) : null
export const ModalInternal = memo(
@@ -1,5 +0,0 @@
export const isElectronBuild = ELECTRON
export const isWebBuild = !ELECTRON
export const isDev = import.meta.env.DEV
export const isProd = import.meta.env.PROD
@@ -1,5 +1,4 @@
export * from "./app"
export * from "./copy"
export * from "./environment"
export * from "./hotkeys"
export * from "./ui"
+2 -2
View File
@@ -1,3 +1,4 @@
import { DEV } from "@follow/shared/constants"
import { Chain } from "@follow/utils/chain"
import { EventBus } from "@follow/utils/event-bus"
import { getStorageNS } from "@follow/utils/ns"
@@ -8,7 +9,6 @@ import { initReactI18next } from "react-i18next"
import { defaultNS, ns } from "./@types/constants"
import { defaultResources } from "./@types/default-resource"
import { getGeneralSettings } from "./atoms/settings/general"
import { isDev } from "./constants"
import { jotaiStore } from "./lib/jotai"
export const i18nAtom = atom(i18next)
@@ -48,7 +48,7 @@ export const initI18n = async () => {
}
let cache = null as any
if (!isDev) {
if (!DEV) {
cache = LocaleCache.shared.get(lang)
if (cache) {
mergedResources[lang] = cache
@@ -1,11 +1,10 @@
import { initializeDayjs } from "@follow/components/dayjs"
import { registerGlobalContext } from "@follow/shared/bridge"
import { IN_ELECTRON } from "@follow/shared/constants"
import { DEV, ELECTRON_BUILD, IN_ELECTRON } from "@follow/shared/constants"
import { tracker } from "@follow/tracker"
import { repository } from "@pkg"
import { enableMapSet } from "immer"
import { isDev, isElectronBuild } from "~/constants"
import { browserDB } from "~/database"
import { initI18n } from "~/i18n"
import { settingSyncQueue } from "~/modules/settings/helper/sync-queue"
@@ -45,7 +44,7 @@ declare global {
export const initializeApp = async () => {
appLog(`${APP_NAME}: Follow everything in one place`, repository.url)
if (isDev) {
if (DEV) {
const favicon = await import("/favicon-dev.ico?url")
const url = new URL(favicon.default, import.meta.url).href
@@ -70,7 +69,7 @@ export const initializeApp = async () => {
registerHistoryStack()
// Set Environment
document.documentElement.dataset.buildType = isElectronBuild ? "electron" : "web"
document.documentElement.dataset.buildType = ELECTRON_BUILD ? "electron" : "web"
// Register global context for electron
registerGlobalContext({
@@ -1,3 +1,4 @@
import { ELECTRON_BUILD } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import { appSessionTraceId } from "@follow/utils/environment"
import { version } from "@pkg"
@@ -6,7 +7,6 @@ import { useEffect } from "react"
import { createRoutesFromChildren, matchRoutes, useLocation, useNavigationType } from "react-router"
import { whoami } from "~/atoms/user"
import { isElectronBuild } from "~/constants"
import { SentryConfig } from "./sentry.config"
@@ -50,5 +50,5 @@ export const initSentry = async () => {
Sentry.setTag("session_trace_id", appSessionTraceId)
Sentry.setTag("app_version", version)
Sentry.setTag("build", isElectronBuild ? "electron" : "web")
Sentry.setTag("build", ELECTRON_BUILD ? "electron" : "web")
}
@@ -1,3 +1,4 @@
import { DEV } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import type { AppType } from "@follow/shared/hono"
import PKG from "@pkg"
@@ -8,7 +9,6 @@ import { toast } from "sonner"
import { NetworkStatus, setApiStatus } from "~/atoms/network"
import { setLoginModalShow } from "~/atoms/user"
import { isDev } from "~/constants"
import { NeedActivationToast } from "~/modules/activation/NeedActivationToast"
import { DebugRegistry } from "~/modules/debug/registry"
@@ -22,7 +22,7 @@ export const apiFetch = ofetch.create({
const header = new Headers(options.headers)
header.set("x-app-version", PKG.version)
if (isDev) {
if (DEV) {
header.set("X-App-Dev", "1")
}
header.set("X-App-Name", "Folo Web")
@@ -95,7 +95,7 @@ export const apiClient = hc<AppType>(env.VITE_API_URL, {
},
})
if (isDev) {
if (DEV) {
DebugRegistry.add("Activation Toast", () => {
setTimeout(() => {
const toastId = toast.error(
@@ -1,3 +1,4 @@
import { DEV } from "@follow/shared/constants"
import { cn } from "@follow/utils/utils"
import { t } from "i18next"
import { FetchError } from "ofetch"
@@ -7,7 +8,6 @@ import { toast } from "sonner"
import { CopyButton } from "~/components/ui/button/CopyButton"
import { Markdown } from "~/components/ui/markdown/Markdown"
import { isDev } from "~/constants"
import { DebugRegistry } from "~/modules/debug/registry"
export const getFetchErrorInfo = (
@@ -120,7 +120,7 @@ export const toastFetchError = (
})
}
}
if (isDev) {
if (DEV) {
DebugRegistry.add("Simulate request error", () => {
createErrorToaster(
"Simulated request error",
@@ -1,10 +1,9 @@
import { WEB_BUILD } from "@follow/shared/constants"
import { replaceImgUrlIfNeed as replaceImgUrlIfNeedUtils } from "@follow/utils/img-proxy"
import { isWebBuild } from "~/constants"
export const replaceImgUrlIfNeed = (url?: string) => {
return replaceImgUrlIfNeedUtils({
url,
inBrowser: isWebBuild,
inBrowser: WEB_BUILD,
})
}
+3 -3
View File
@@ -2,7 +2,7 @@ import "./wdyr"
import "@follow/components/tailwind"
import "./styles/main.css"
import { IN_ELECTRON } from "@follow/shared/constants"
import { IN_ELECTRON, WEB_BUILD } from "@follow/shared/constants"
import { getOS } from "@follow/utils/utils"
import { ClickToComponent } from "click-to-react-component"
import * as React from "react"
@@ -10,14 +10,14 @@ import ReactDOM from "react-dom/client"
import { RouterProvider } from "react-router/dom"
import { setAppIsReady } from "./atoms/app"
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT, isWebBuild } from "./constants"
import { ElECTRON_CUSTOM_TITLEBAR_HEIGHT } from "./constants"
import { initializeApp } from "./initialize"
import { registerAppGlobalShortcuts } from "./initialize/global-shortcuts"
import { router } from "./router"
initializeApp().finally(() => {
import("./push-notification").then(({ registerWebPushNotifications }) => {
if (navigator.serviceWorker && isWebBuild) {
if (navigator.serviceWorker && WEB_BUILD) {
registerWebPushNotifications()
}
})
@@ -1,9 +1,8 @@
import { useMobile } from "@follow/components/hooks/useMobile.js"
import { WEB_BUILD } from "@follow/shared/constants"
import { repository } from "@pkg"
import { useTranslation } from "react-i18next"
import { isWebBuild } from "~/constants"
export const FooterInfo = () => {
const { t } = useTranslation()
@@ -16,7 +15,7 @@ export const FooterInfo = () => {
</div>
)}
{isWebBuild && !isMobile && (
{WEB_BUILD && !isMobile && (
<div className="center absolute inset-y-0 right-2">
<button
type="button"
@@ -4,7 +4,7 @@ import { PanelSplitter } from "@follow/components/ui/divider/index.js"
import { Kbd } from "@follow/components/ui/kbd/Kbd.js"
import { RootPortal } from "@follow/components/ui/portal/index.jsx"
import type { FeedViewType } from "@follow/constants"
import { IN_ELECTRON } from "@follow/shared/constants"
import { DEV, IN_ELECTRON, PROD } from "@follow/shared/constants"
import { preventDefault } from "@follow/utils/dom"
import { cn } from "@follow/utils/utils"
import { Slot } from "@radix-ui/react-slot"
@@ -31,7 +31,7 @@ import { AppErrorBoundary } from "~/components/common/AppErrorBoundary"
import { ErrorComponentType } from "~/components/errors/enum"
import { PlainModal } from "~/components/ui/modal/stacked/custom-modal"
import { DeclarativeModal } from "~/components/ui/modal/stacked/declarative-modal"
import { HotKeyScopeMap, isDev } from "~/constants"
import { HotKeyScopeMap } from "~/constants"
import { ROOT_CONTAINER_ID } from "~/constants/dom"
import { shortcuts } from "~/constants/shortcuts"
import { useDailyTask } from "~/hooks/biz/useDailyTask"
@@ -97,7 +97,7 @@ export function MainDestopLayout() {
return (
<RootContainer ref={containerRef}>
{!import.meta.env.PROD && <EnvironmentIndicator />}
{!PROD && <EnvironmentIndicator />}
<Suspense>
<AppNotificationContainer />
@@ -332,7 +332,7 @@ const FeedResponsiveResizerContainer = ({
)
}
if (isDev) {
if (DEV) {
DebugRegistry.add("New User Guide", () => {
import("~/modules/new-user-guide/guide-modal-content").then((m) => {
window.presentModal({
@@ -2,6 +2,7 @@ import { getReadonlyRoute } from "@follow/components/atoms/route.js"
import { MotionButtonBase } from "@follow/components/ui/button/index.js"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { Routes } from "@follow/constants"
import { ELECTRON_BUILD } from "@follow/shared/constants"
import { springScrollTo } from "@follow/utils/scroller"
import { cn, getOS } from "@follow/utils/utils"
import { useEffect, useRef, useState } from "react"
@@ -9,7 +10,6 @@ import { useTranslation } from "react-i18next"
import { NavigationType, Outlet, useLocation, useNavigate, useNavigationType } from "react-router"
import { FABContainer, FABPortable } from "~/components/ui/fab"
import { isElectronBuild } from "~/constants"
import { useSubViewTitleValue } from "./hooks"
@@ -51,7 +51,7 @@ export function SubviewLayout() {
const { t } = useTranslation()
// electron window has pt-[calc(var(--fo-window-padding-top)_-10px)]
const isElectronWindows = isElectronBuild && getOS() === "Windows"
const isElectronWindows = ELECTRON_BUILD && getOS() === "Windows"
return (
<div className="relative flex size-full">
@@ -5,11 +5,11 @@ import {
TooltipPortal,
TooltipTrigger,
} from "@follow/components/ui/tooltip/index.jsx"
import { DEV } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import { useUserRole } from "~/atoms/user"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
import { isDev } from "~/constants"
import { DebugRegistry } from "../debug/registry"
@@ -24,7 +24,7 @@ export const EnvironmentIndicator = () => {
aria-hidden
type="button"
onClick={() => {
if (!isDev) return
if (!DEV) return
const actionMap = DebugRegistry.getAll()
@@ -51,7 +51,7 @@ export const EnvironmentIndicator = () => {
}}
>
<div className="center bg-accent fixed bottom-0 right-0 z-[99999] flex rounded-tl px-1 py-0.5 text-xs text-white">
{role}:{isDev && <i className="i-mgc-bug-cute-re size-3" />}
{role}:{DEV && <i className="i-mgc-bug-cute-re size-3" />}
{import.meta.env.MODE}
</div>
</button>
@@ -3,6 +3,7 @@ import { ActionButton, Button, IconButton } from "@follow/components/ui/button/i
import { Kbd, KbdCombined } from "@follow/components/ui/kbd/Kbd.js"
import { RootPortal } from "@follow/components/ui/portal/index.jsx"
import { useCountdown } from "@follow/hooks"
import { ELECTRON_BUILD } from "@follow/shared/constants"
import { cn, getOS } from "@follow/utils/utils"
import { AnimatePresence, m } from "framer-motion"
import type { FC, ReactNode } from "react"
@@ -12,7 +13,7 @@ import { Trans, useTranslation } from "react-i18next"
import { toast } from "sonner"
import { useOnClickOutside } from "usehooks-ts"
import { HotKeyScopeMap, isElectronBuild } from "~/constants"
import { HotKeyScopeMap } from "~/constants"
import { shortcuts } from "~/constants/shortcuts"
import { useI18n } from "~/hooks/common"
@@ -136,7 +137,7 @@ const Popup = ({ which, containerRef, setPopoverRef, setShow, handleMarkAllAsRea
useViewport((v) => v.w)
// electron window has pt-[calc(var(--fo-window-padding-top)_-10px)]
const isElectronWindows = isElectronBuild && getOS() === "Windows"
const isElectronWindows = ELECTRON_BUILD && getOS() === "Windows"
return (
<RootPortal to={$parent}>
<m.div
@@ -5,7 +5,7 @@ import { Button, MotionButtonBase } from "@follow/components/ui/button/index.js"
import { LoadingWithIcon } from "@follow/components/ui/loading/index.jsx"
import { RootPortal } from "@follow/components/ui/portal/index.jsx"
import { useScrollViewElement } from "@follow/components/ui/scroll-area/hooks.js"
import { IN_ELECTRON } from "@follow/shared/constants"
import { IN_ELECTRON, WEB_BUILD } from "@follow/shared/constants"
import { EventBus } from "@follow/utils/event-bus"
import { springScrollTo } from "@follow/utils/scroller"
import { cn } from "@follow/utils/utils"
@@ -25,7 +25,6 @@ import { useActionLanguage } from "~/atoms/settings/general"
import { enableShowSourceContent } from "~/atoms/source-content"
import { CopyButton } from "~/components/ui/button/CopyButton"
import { Toc } from "~/components/ui/markdown/components/Toc"
import { isWebBuild } from "~/constants"
import { useEntryReadabilityToggle } from "~/hooks/biz/useEntryActions"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
import { useAuthQuery } from "~/hooks/common/useBizQuery"
@@ -138,10 +137,10 @@ export const NoContent: FC<{
return (
<div className="center">
<div className="space-y-2 text-balance text-center text-sm text-zinc-400">
{(isWebBuild || status === ReadabilityStatus.FAILURE) && (
{(WEB_BUILD || status === ReadabilityStatus.FAILURE) && (
<span>{t("entry_content.no_content")}</span>
)}
{isWebBuild && (
{WEB_BUILD && (
<div>
<span>{t("entry_content.web_app_notice")}</span>
</div>
@@ -2,6 +2,7 @@ import { Logo } from "@follow/components/icons/logo.jsx"
import { Button } from "@follow/components/ui/button/index.js"
import { styledButtonVariant } from "@follow/components/ui/button/variants.js"
import { Divider } from "@follow/components/ui/divider/index.js"
import { PROD } from "@follow/shared/constants"
import { getCurrentEnvironment } from "@follow/utils/environment"
import PKG, { repository } from "@pkg"
import { useQuery } from "@tanstack/react-query"
@@ -30,7 +31,7 @@ export const SettingAbout = () => {
<div className="flex grow flex-col">
<div className="text-lg font-bold">
{APP_NAME} {!import.meta.env.PROD ? `(${import.meta.env.MODE})` : ""}
{APP_NAME} {!PROD ? `(${import.meta.env.MODE})` : ""}
</div>
<div className="flex flex-wrap items-center gap-2">
{appVersion && (
@@ -10,7 +10,7 @@ import {
} from "@follow/components/ui/select/index.jsx"
import { ResponsiveSelect } from "@follow/components/ui/select/responsive.js"
import { useIsDark, useThemeAtomValue } from "@follow/hooks"
import { IN_ELECTRON } from "@follow/shared/constants"
import { ELECTRON_BUILD, IN_ELECTRON } from "@follow/shared/constants"
import { capitalizeFirstLetter, getOS } from "@follow/utils/utils"
import dayjs from "dayjs"
import { useForceUpdate } from "framer-motion"
@@ -28,7 +28,6 @@ import {
useUISettingValue,
} from "~/atoms/settings/ui"
import { useCurrentModal, useModalStack } from "~/components/ui/modal/stacked/hooks"
import { isElectronBuild } from "~/constants"
import { useSetTheme } from "~/hooks/common"
import { useShowCustomizeToolbarModal } from "~/modules/customize-toolbar/modal"
@@ -117,7 +116,7 @@ export const SettingAppearance = () => {
defineItem("guessCodeLanguage", {
label: t("appearance.guess_code_language.label"),
hide: !isElectronBuild,
hide: !ELECTRON_BUILD,
description: t("appearance.guess_code_language.description"),
}),
@@ -13,6 +13,7 @@ import { Input } from "@follow/components/ui/input/Input.js"
import { Label } from "@follow/components/ui/label/index.jsx"
import { Radio, RadioGroup } from "@follow/components/ui/radio-group/index.js"
import { Slider } from "@follow/components/ui/slider/index.js"
import { ELECTRON_BUILD } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import { zodResolver } from "@hookform/resolvers/zod"
import { useQuery } from "@tanstack/react-query"
@@ -22,7 +23,6 @@ import { z } from "zod"
import { setGeneralSetting, useGeneralSettingValue } from "~/atoms/settings/general"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
import { isElectronBuild } from "~/constants"
import { exportDB } from "~/database"
import { initAnalytics } from "~/initialize/analytics"
import { tipcClient } from "~/lib/client"
@@ -118,17 +118,17 @@ export const SettingDataControl = () => {
},
},
isElectronBuild && {
ELECTRON_BUILD && {
type: "title",
value: t("general.cache"),
},
isElectronBuild && AppCacheLimit,
isElectronBuild ? CleanElectronCache : CleanCacheStorage,
isElectronBuild && {
ELECTRON_BUILD && AppCacheLimit,
ELECTRON_BUILD ? CleanElectronCache : CleanCacheStorage,
ELECTRON_BUILD && {
type: "title",
value: t("general.data_file.label"),
},
isElectronBuild && {
ELECTRON_BUILD && {
label: t("general.log_file.label"),
description: t("general.log_file.description"),
buttonText: t("general.log_file.button"),
@@ -3,6 +3,7 @@ import { RootPortal } from "@follow/components/ui/portal/index.js"
import { Routes } from "@follow/constants"
import { useTypeScriptHappyCallback } from "@follow/hooks"
import { useRegisterGlobalContext } from "@follow/shared/bridge"
import { ELECTRON_BUILD } from "@follow/shared/constants"
import { clamp, cn } from "@follow/utils/utils"
import { useWheel } from "@use-gesture/react"
import { AnimatePresence, m } from "framer-motion"
@@ -14,7 +15,7 @@ import { isHotkeyPressed, useHotkeys } from "react-hotkeys-hook"
import { useRootContainerElement } from "~/atoms/dom"
import { useUISettingKey } from "~/atoms/settings/ui"
import { setTimelineColumnShow, useTimelineColumnShow } from "~/atoms/sidebar"
import { HotKeyScopeMap, isElectronBuild } from "~/constants"
import { HotKeyScopeMap } from "~/constants"
import { shortcuts } from "~/constants/shortcuts"
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
import { useReduceMotion } from "~/hooks/biz/useReduceMotion"
@@ -134,7 +135,7 @@ export function FeedColumn({ children, className }: PropsWithChildren<{ classNam
className={cn(
"relative flex h-full flex-col pt-2.5",
!feedColumnShow && isElectronBuild && "bg-zinc-200 dark:bg-neutral-800",
!feedColumnShow && ELECTRON_BUILD && "bg-zinc-200 dark:bg-neutral-800",
className,
)}
onClick={useCallback(() => navigateBackHome(), [navigateBackHome])}
@@ -1,4 +1,5 @@
import { useOnce } from "@follow/hooks"
import { DEV } from "@follow/shared/constants"
import { nextFrame } from "@follow/utils/dom"
import { getStorageNS } from "@follow/utils/ns"
import { repository } from "@pkg"
@@ -11,7 +12,6 @@ import { Markdown } from "~/components/ui/markdown/Markdown"
import { PeekModal } from "~/components/ui/modal/inspire/PeekModal"
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
import { Paper } from "~/components/ui/paper"
import { isDev } from "~/constants"
import { DebugRegistry } from "~/modules/debug/registry"
const AppNotificationContainer: FC = () => {
@@ -98,7 +98,7 @@ const AppNotificationContainer: FC = () => {
setTimeout(toaster)
}
isDev && DebugRegistry.add("simulate_app_upgraded_toast", toaster)
DEV && DebugRegistry.add("simulate_app_upgraded_toast", toaster)
})
return null
@@ -1,11 +1,10 @@
import { Logo } from "@follow/components/icons/logo.jsx"
import { IN_ELECTRON } from "@follow/shared/constants"
import { ELECTRON_BUILD, IN_ELECTRON } from "@follow/shared/constants"
import { preventDefault } from "@follow/utils/dom"
import { cn } from "@follow/utils/utils"
import { Outlet, useLocation } from "react-router"
import { WindowUnderBlur } from "~/components/ui/background"
import { isElectronBuild } from "~/constants"
import { useActivationModal } from "~/modules/activation"
import { IsInSettingIndependentWindowContext } from "~/modules/settings/context"
import {
@@ -46,7 +45,7 @@ function Layout() {
)
}
// NOTE: we disable directly nav to setting routes on the web app
export const Component = isElectronBuild ? Layout : () => null
export const Component = ELECTRON_BUILD ? Layout : () => null
const SettingItemButton = (props: { tab: string; item: SettingPageConfig; path: string }) => {
const { tab, item, path } = props
Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 KiB

-1
View File
@@ -4,7 +4,6 @@ import type { ConfigContext, ExpoConfig } from "expo/config"
import PKG from "./package.json"
// const isDev = process.env.NODE_ENV === "development"
const isCI = process.env.CI === "true"
// const roundedIconPath = resolve(__dirname, "../../resources/icon.png")
const iconPath = resolve(__dirname, "./assets/icon.png")
@@ -6,8 +6,6 @@ import { defineConfig } from "vite"
import { viteRenderBaseConfig } from "../../../desktop/configs/vite.render.config"
import { astPlugin } from "../../../desktop/plugins/vite/ast"
// const isDev = process.env.NODE_ENV === "development"
const isCI = process.env.CI === "true"
export default defineConfig({
...viteRenderBaseConfig,
-6
View File
@@ -12,12 +12,6 @@
"type": "git"
},
"scripts": {
"build:all": "turbo run Folo#build @follow/ssr#build",
"build:electron": "turbo run Folo#build",
"build:macos": "turbo run Folo#build:macos",
"build:mas": "turbo run Folo#build:mas",
"build:render": "turbo run Folo#build:render",
"build:ssr": "turbo run @follow/ssr#build",
"build:web": "turbo run Folo#build:web",
"dedupe:locales": "eslint --fix apps/desktop/locales/**/*.json",
"depcheck": "npx depcheck --quiet",
+15 -2
View File
@@ -8,8 +8,20 @@ declare const globalThis: {
electron?: ElectronAPI
}
const isDev = "process" in globalThis ? process.env.NODE_ENV === "development" : import.meta.env.DEV
export const APP_PROTOCOL = isDev ? "follow-dev" : "follow"
export enum ModeEnum {
development = "development",
staging = "staging",
production = "production",
}
export const MODE = import.meta.env.MODE as ModeEnum
export const { PROD } = import.meta.env
export const DEV =
"process" in globalThis ? process.env.NODE_ENV === "development" : import.meta.env.DEV
export const APP_PROTOCOL = DEV ? "follow-dev" : "follow"
export const DEEPLINK_SCHEME = `${APP_PROTOCOL}://` as const
export const SYSTEM_CAN_UNDER_BLUR_WINDOW = globalThis?.window?.electron
@@ -23,3 +35,4 @@ declare const ELECTRON: boolean
* Current build type for electron
*/
export const ELECTRON_BUILD = !!ELECTRON
export const WEB_BUILD = !ELECTRON
-2
View File
@@ -4,8 +4,6 @@
import { createEnv } from "@t3-oss/env-core"
import { z } from "zod"
export const isDev =
"process" in globalThis ? process.env.NODE_ENV === "development" : import.meta.env.DEV
export const env = createEnv({
clientPrefix: "VITE_",
client: {
-1
View File
@@ -25,5 +25,4 @@ export const envSchema = {
VITE_RECAPTCHA_V3_SITE_KEY: z.string().default("6LdG-asqAAAAAEXr96565MKbRvxGEv31XEykRSHV"),
}
export const isDev = false
export const env = z.object(envSchema).parse(process.env || {})
-12
View File
@@ -2,21 +2,9 @@
"$schema": "https://turbo.build/schema.json",
"envMode": "loose",
"tasks": {
"Folo#build": {
"outputs": ["dist/**", "out/**"]
},
"Folo#build:web": {
"outputs": ["out/**"]
},
"Folo#build:macos": {
"outputs": ["dist/**", "out/**"]
},
"Folo#build:mas": {
"outputs": ["dist/**", "out/**"]
},
"Folo#build:render": {
"outputs": ["out/**"]
},
"//#format:check": {},
"//#lint": {},
"test": {},