From a5eb2cdd9a0171ecbc442aef09a8cf8db469a214 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 16 Apr 2025 10:15:40 +0800 Subject: [PATCH] feat: improve white label scripts on Windows (#7755) * feat: improve white label scripts on Windows * feat: add font white label script * chore: integrate font white label script --- .../assets/fonts/FlowyIconData.ttf | Bin 1904 -> 0 bytes .../ai_chat/presentation/chat_avatar.dart | 2 +- .../presentation/chat_welcome_page.dart | 2 +- .../sign_in_screen/widgets/logo/logo.dart | 2 +- .../presentation/screens/splash_screen.dart | 2 +- .../mobile_workspace_start_screen.dart | 2 +- .../notification/notification_service.dart | 14 +- .../appearance/desktop_appearance.dart | 2 + .../menu/sidebar/header/sidebar_top_menu.dart | 4 +- frontend/appflowy_flutter/pubspec.yaml | 7 +- ...lowy_ai_chat_logo.svg => ai_chat_logo.svg} | 0 .../16x/{flowy_logo.svg => app_logo.svg} | 0 .../40x/{flowy_logo.svg => app_logo.svg} | 0 ...k_mode.svg => app_logo_with_text_dark.svg} | 0 ..._text.svg => app_logo_with_text_light.svg} | 0 .../scripts/white_label/code_white_label.sh | 72 +++++++ .../scripts/white_label/font_white_label.sh | 198 ++++++++++++++++++ .../scripts/white_label/icon_white_label.sh | 49 +++-- frontend/scripts/white_label/white_label.sh | 30 ++- 19 files changed, 352 insertions(+), 34 deletions(-) delete mode 100644 frontend/appflowy_flutter/assets/fonts/FlowyIconData.ttf rename frontend/resources/flowy_icons/16x/{flowy_ai_chat_logo.svg => ai_chat_logo.svg} (100%) rename frontend/resources/flowy_icons/16x/{flowy_logo.svg => app_logo.svg} (100%) rename frontend/resources/flowy_icons/40x/{flowy_logo.svg => app_logo.svg} (100%) rename frontend/resources/flowy_icons/40x/{flowy_logo_dark_mode.svg => app_logo_with_text_dark.svg} (100%) rename frontend/resources/flowy_icons/40x/{flowy_logo_text.svg => app_logo_with_text_light.svg} (100%) create mode 100644 frontend/scripts/white_label/code_white_label.sh create mode 100644 frontend/scripts/white_label/font_white_label.sh diff --git a/frontend/appflowy_flutter/assets/fonts/FlowyIconData.ttf b/frontend/appflowy_flutter/assets/fonts/FlowyIconData.ttf deleted file mode 100644 index 8f03a5c8f932e4e65caac7823e05f2c1a0eb7e8d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1904 zcmd^9L2D#M6#i;@GBeI>Cg4VqMM5Lln8h$NnS(5A48de41O%649b_+|ccy20LQi+o zUD;&zu*pG0FoGxX;#s^3q6dF~_y;_QvMe6v;6V|O8oyWF(aDnhf~}^yzW06aRlWD9 zZYTg19K%9mbLZW+?2oQL1k_Ekci-8mH&^YgL)s^_+nu2keYpPHm$ZN9eAM?xz0OaK z9|4O#h& zifhzgqHPDx(0%{C9f$gub0rEB{l(SWe*ndK>RVv$*7oUMs++e|GdV2rkvW}sE4wo* zf1x6K0Y886cW-jF#!7N5Atx+{#964C6^1RNOzu=f4$;eKU=_KI*4uYc^&K5B_qmo5&RAyg38r}5!<=MulCJ78mKF2LVag(V!MM}A-No7%V`chr z&)UYPbdwx8O!uUNrgGVzl>tkf%t5s?zdK|lVu>p&C7;K<@yQE6R;R3e40+Q|vu9RH zvVYdc71MyltPSjnwA!@WbWXZQ;_Pn8ofjLqk9q5+*~4OCPQ9U;tE#RRUQthuN~&7< zr&3j=qv8wd>*M0=%*<@@xX6&RxX&f-`l}185;v!2RN?8kKaWZh#x3M1;CcL#MiaL< z%}#tz(@Jp;MeJnQB7ZN#dE$PCr}($f87`1N%5WL4;UvQqT*WtXoAS@`oD=+zVTEhF zRVklCRYe)L$Un+(p7^s2PvJ%NRfY@Xzt36)fa#u7}Ym9`rqJFRtIPn~mnO zeSc(!qy~ZG+s?lB!Z@+l?4G}`wHpsQVNmOY!zH^H2HN%gP^^|89*njqZ8+N5cKiFj z6QASG8ErRC24P??*Ba;eO*e33N4s4~A$ibmYTdJYaX7SF*;#fJhkI^E*F3GGTlM;6 z4p>Ks2qVN8u;(6oZDWz_4X#c8Z<<&px=#b9PBf~GfF~xjk8BZSPj?s zcc=!aLDnI^cJUBKbe~W7pVl(g0ngep-T^jvg67<&Z=bvR#4+!WL|x=}xzaY-B&<@- zwpmq;)m`qtN&mpaNCqytj7htY-~n@KlGUt4s)@Phkf>$${=Y7pofU15@f~{COn)`m qTd4E7tPf}3t^EHl8kWi_OXX4R#$mME4G)4{Z_sro%)|>1Oys}7A{Fld diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_avatar.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_avatar.dart index d5ecd09c38..59b7fbd39b 100644 --- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_avatar.dart +++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_avatar.dart @@ -27,7 +27,7 @@ class ChatAIAvatar extends StatelessWidget { child: const CircleAvatar( backgroundColor: Colors.transparent, child: FlowySvg( - FlowySvgs.flowy_logo_s, + FlowySvgs.app_logo_s, size: Size.square(16), blendMode: null, ), diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart index d7a90bd18a..30dc918f70 100644 --- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart +++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart @@ -46,7 +46,7 @@ class ChatWelcomePage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ const FlowySvg( - FlowySvgs.flowy_logo_xl, + FlowySvgs.app_logo_xl, size: Size.square(32), blendMode: null, ), diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/logo/logo.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/logo/logo.dart index eb29807b5b..8e126db7ad 100644 --- a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/logo/logo.dart +++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/logo/logo.dart @@ -12,7 +12,7 @@ class AFLogo extends StatelessWidget { @override Widget build(BuildContext context) { return FlowySvg( - FlowySvgs.flowy_logo_xl, + FlowySvgs.app_logo_xl, blendMode: null, size: size, ); diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/splash_screen.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/splash_screen.dart index 146bf06df1..71345aa8dd 100644 --- a/frontend/appflowy_flutter/lib/user/presentation/screens/splash_screen.dart +++ b/frontend/appflowy_flutter/lib/user/presentation/screens/splash_screen.dart @@ -115,7 +115,7 @@ class Body extends StatelessWidget { return Container( alignment: Alignment.center, child: UniversalPlatform.isMobile - ? const FlowySvg(FlowySvgs.flowy_logo_xl, blendMode: null) + ? const FlowySvg(FlowySvgs.app_logo_xl, blendMode: null) : const _DesktopSplashBody(), ); } diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/workspace_start_screen/mobile_workspace_start_screen.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/workspace_start_screen/mobile_workspace_start_screen.dart index 59b61aa54b..a6124da60b 100644 --- a/frontend/appflowy_flutter/lib/user/presentation/screens/workspace_start_screen/mobile_workspace_start_screen.dart +++ b/frontend/appflowy_flutter/lib/user/presentation/screens/workspace_start_screen/mobile_workspace_start_screen.dart @@ -57,7 +57,7 @@ class _MobileWorkspaceStartScreenState children: [ const Spacer(), const FlowySvg( - FlowySvgs.flowy_logo_xl, + FlowySvgs.app_logo_xl, size: Size.square(64), blendMode: null, ), diff --git a/frontend/appflowy_flutter/lib/workspace/application/notification/notification_service.dart b/frontend/appflowy_flutter/lib/workspace/application/notification/notification_service.dart index 7a19e2a822..3f9657c5cf 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/notification/notification_service.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/notification/notification_service.dart @@ -1,8 +1,12 @@ -import 'package:appflowy/generated/locale_keys.g.dart'; -import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/foundation.dart'; import 'package:local_notifier/local_notifier.dart'; +/// The app name used in the local notification. +/// +/// DO NOT Use i18n here, because the i18n plugin is not ready +/// before the local notification is initialized. +const _localNotifierAppName = 'AppFlowy'; + /// Manages Local Notifications /// /// Currently supports: @@ -12,7 +16,11 @@ import 'package:local_notifier/local_notifier.dart'; /// class NotificationService { static Future initialize() async { - await localNotifier.setup(appName: LocaleKeys.appName.tr()); + await localNotifier.setup( + appName: _localNotifierAppName, + // Don't create a shortcut on Windows, because the setup.exe will create a shortcut + shortcutPolicy: ShortcutPolicy.requireNoCreate, + ); } } diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/desktop_appearance.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/desktop_appearance.dart index 2a707b6b2d..c1e539cf58 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/desktop_appearance.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/desktop_appearance.dart @@ -14,6 +14,8 @@ class DesktopAppearance extends BaseAppearance { ) { assert(codeFontFamily.isNotEmpty); + fontFamily = fontFamily.isEmpty ? defaultFontFamily : fontFamily; + final isLight = brightness == Brightness.light; final theme = isLight ? appTheme.lightTheme : appTheme.darkTheme; diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/header/sidebar_top_menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/header/sidebar_top_menu.dart index 559c189925..67930c336a 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/header/sidebar_top_menu.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/header/sidebar_top_menu.dart @@ -50,8 +50,8 @@ class SidebarTopMenu extends StatelessWidget { } final svgData = Theme.of(context).brightness == Brightness.dark - ? FlowySvgs.flowy_logo_dark_mode_xl - : FlowySvgs.flowy_logo_text_xl; + ? FlowySvgs.app_logo_with_text_dark_xl + : FlowySvgs.app_logo_with_text_light_xl; return Padding( padding: const EdgeInsets.only(top: 12.0, left: 8), diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml index e9dfbf48d0..8fe956a194 100644 --- a/frontend/appflowy_flutter/pubspec.yaml +++ b/frontend/appflowy_flutter/pubspec.yaml @@ -254,9 +254,6 @@ flutter: uses-material-design: true fonts: - - family: FlowyIconData - fonts: - - asset: assets/fonts/FlowyIconData.ttf - family: Poppins fonts: - asset: assets/google_fonts/Poppins/Poppins-ExtraLight.ttf @@ -282,6 +279,9 @@ flutter: - asset: assets/google_fonts/Roboto_Mono/RobotoMono-Regular.ttf - asset: assets/google_fonts/Roboto_Mono/RobotoMono-Italic.ttf style: italic + # White-label font configuration will be added here + # BEGIN: WHITE_LABEL_FONT + # END: WHITE_LABEL_FONT # To add assets to your application, add an assets section, like this: assets: @@ -298,6 +298,7 @@ flutter: - assets/images/login/ - assets/translations/ - assets/icons/icons.json + - assets/fonts/ # The following assets will be excluded in release. # BEGIN: EXCLUDE_IN_RELEASE diff --git a/frontend/resources/flowy_icons/16x/flowy_ai_chat_logo.svg b/frontend/resources/flowy_icons/16x/ai_chat_logo.svg similarity index 100% rename from frontend/resources/flowy_icons/16x/flowy_ai_chat_logo.svg rename to frontend/resources/flowy_icons/16x/ai_chat_logo.svg diff --git a/frontend/resources/flowy_icons/16x/flowy_logo.svg b/frontend/resources/flowy_icons/16x/app_logo.svg similarity index 100% rename from frontend/resources/flowy_icons/16x/flowy_logo.svg rename to frontend/resources/flowy_icons/16x/app_logo.svg diff --git a/frontend/resources/flowy_icons/40x/flowy_logo.svg b/frontend/resources/flowy_icons/40x/app_logo.svg similarity index 100% rename from frontend/resources/flowy_icons/40x/flowy_logo.svg rename to frontend/resources/flowy_icons/40x/app_logo.svg diff --git a/frontend/resources/flowy_icons/40x/flowy_logo_dark_mode.svg b/frontend/resources/flowy_icons/40x/app_logo_with_text_dark.svg similarity index 100% rename from frontend/resources/flowy_icons/40x/flowy_logo_dark_mode.svg rename to frontend/resources/flowy_icons/40x/app_logo_with_text_dark.svg diff --git a/frontend/resources/flowy_icons/40x/flowy_logo_text.svg b/frontend/resources/flowy_icons/40x/app_logo_with_text_light.svg similarity index 100% rename from frontend/resources/flowy_icons/40x/flowy_logo_text.svg rename to frontend/resources/flowy_icons/40x/app_logo_with_text_light.svg diff --git a/frontend/scripts/white_label/code_white_label.sh b/frontend/scripts/white_label/code_white_label.sh new file mode 100644 index 0000000000..1123a394ee --- /dev/null +++ b/frontend/scripts/white_label/code_white_label.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +show_usage() { + echo "Usage: $0 [options]" + echo "Options:" + echo " --company-name Set the custom company name" + echo " --help Show this help message" + echo "" + echo "Example:" + echo " $0 --company-name \"MyCompany Ltd.\"" +} + +CUSTOM_COMPANY_NAME="" +CODE_FILE="appflowy_flutter/lib/workspace/application/notification/notification_service.dart" + +while [[ $# -gt 0 ]]; do + case $1 in + --company-name) + CUSTOM_COMPANY_NAME="$2" + shift 2 + ;; + --help) + show_usage + exit 0 + ;; + *) + echo "Unknown option: $1" + show_usage + exit 1 + ;; + esac +done + +if [ -z "$CUSTOM_COMPANY_NAME" ]; then + echo "Error: Company name is required" + show_usage + exit 1 +fi + +if [ ! -f "$CODE_FILE" ]; then + echo "Error: Code file not found at $CODE_FILE" + exit 1 +fi + +echo "Replacing '_localNotifierAppName' value with '$CUSTOM_COMPANY_NAME' in code file..." + +if sed --version >/dev/null 2>&1; then + SED_INPLACE="-i" +else + SED_INPLACE="-i ''" +fi + +echo "Processing code file..." +if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then + # First, escape any special characters in the company name + ESCAPED_COMPANY_NAME=$(echo "$CUSTOM_COMPANY_NAME" | sed 's/[\/&]/\\&/g') + # Replace the _localNotifierAppName value with the custom company name + sed $SED_INPLACE "s/const _localNotifierAppName = 'AppFlowy'/const _localNotifierAppName = '$ESCAPED_COMPANY_NAME'/" "$CODE_FILE" + if [ $? -ne 0 ]; then + echo "Error: Failed to process $CODE_FILE with sed" + exit 1 + fi +else + # For Unix-like systems + sed $SED_INPLACE "s/const _localNotifierAppName = 'AppFlowy'/const _localNotifierAppName = '$CUSTOM_COMPANY_NAME'/" "$CODE_FILE" + if [ $? -ne 0 ]; then + echo "Error: Failed to process $CODE_FILE with sed" + exit 1 + fi +fi + +echo "Replacement complete!" diff --git a/frontend/scripts/white_label/font_white_label.sh b/frontend/scripts/white_label/font_white_label.sh new file mode 100644 index 0000000000..412ee6b062 --- /dev/null +++ b/frontend/scripts/white_label/font_white_label.sh @@ -0,0 +1,198 @@ +#!/bin/bash + +show_usage() { + echo "Usage: $0 [options]" + echo "Options:" + echo " --font-path Set the path to the folder containing font files (.ttf or .otf files)" + echo " --font-family Set the name of the font family" + echo " --help Show this help message" + echo "" + echo "Example:" + echo " $0 --font-path \"/path/to/fonts\" --font-family \"CustomFont\"" +} + +FONT_PATH="" +FONT_FAMILY="" +TARGET_FONT_DIR="appflowy_flutter/assets/fonts/" +PUBSPEC_FILE="appflowy_flutter/pubspec.yaml" +BASE_APPEARANCE_FILE="appflowy_flutter/lib/workspace/application/settings/appearance/base_appearance.dart" + +while [[ $# -gt 0 ]]; do + case $1 in + --font-path) + FONT_PATH="$2" + shift 2 + ;; + --font-family) + FONT_FAMILY="$2" + shift 2 + ;; + --help) + show_usage + exit 0 + ;; + *) + echo "Unknown option: $1" + show_usage + exit 1 + ;; + esac +done + +# Validate required arguments +if [ -z "$FONT_PATH" ]; then + echo "Error: Font path is required" + show_usage + exit 1 +fi + +if [ -z "$FONT_FAMILY" ]; then + echo "Error: Font family name is required" + show_usage + exit 1 +fi + +# Check if source directory exists +if [ ! -d "$FONT_PATH" ]; then + echo "Error: Font directory not found at $FONT_PATH" + exit 1 +fi + +# Create target directory if it doesn't exist +mkdir -p "$TARGET_FONT_DIR" + +# Clean existing fonts in target directory +echo "Cleaning existing fonts in $TARGET_FONT_DIR..." +rm -rf "$TARGET_FONT_DIR"/* + +# Copy font files to target directory +echo "Copying font files from $FONT_PATH to $TARGET_FONT_DIR..." +found_fonts=false +for ext in ttf otf; do + if ls "$FONT_PATH"/*."$ext" >/dev/null 2>&1; then + cp "$FONT_PATH"/*."$ext" "$TARGET_FONT_DIR"/ 2>/dev/null && found_fonts=true + fi +done + +if [ "$found_fonts" = false ]; then + echo "Error: No font files (.ttf or .otf) found in source directory" + exit 1 +fi + +# Generate font configuration for pubspec.yaml +echo "Generating font configuration..." + +# Create temporary file for font configuration +TEMP_FILE=$(mktemp) + +{ + echo " # BEGIN: WHITE_LABEL_FONT" + echo " - family: $FONT_FAMILY" + echo " fonts:" + + # Generate entries for each font file + for font_file in "$TARGET_FONT_DIR"/*; do + filename=$(basename "$font_file") + echo " - asset: assets/fonts/$filename" + + # Try to detect font weight from filename + if [[ $filename =~ (Thin|ExtraLight|Light|Regular|Medium|SemiBold|Bold|ExtraBold|Black) ]]; then + case ${BASH_REMATCH[1]} in + "Thin") echo " weight: 100";; + "ExtraLight") echo " weight: 200";; + "Light") echo " weight: 300";; + "Regular") echo " weight: 400";; + "Medium") echo " weight: 500";; + "SemiBold") echo " weight: 600";; + "Bold") echo " weight: 700";; + "ExtraBold") echo " weight: 800";; + "Black") echo " weight: 900";; + esac + fi + + # Try to detect italic style from filename + if [[ $filename =~ Italic ]]; then + echo " style: italic" + fi + done + echo " # END: WHITE_LABEL_FONT" +} > "$TEMP_FILE" + +# Update pubspec.yaml +echo "Updating pubspec.yaml..." +if [ -f "$PUBSPEC_FILE" ]; then + # Create a backup of the original file + cp "$PUBSPEC_FILE" "${PUBSPEC_FILE}.bak" + + if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then + # Windows-specific handling + # First, remove existing white label font configuration + awk '/# BEGIN: WHITE_LABEL_FONT/,/# END: WHITE_LABEL_FONT/{ next } /# White-label font configuration will be added here/{ print; system("cat '"$TEMP_FILE"'"); next } 1' "$PUBSPEC_FILE" > "${PUBSPEC_FILE}.tmp" + + if [ $? -eq 0 ]; then + mv "${PUBSPEC_FILE}.tmp" "$PUBSPEC_FILE" + rm -f "${PUBSPEC_FILE}.bak" + else + echo "Error: Failed to update pubspec.yaml" + mv "${PUBSPEC_FILE}.bak" "$PUBSPEC_FILE" + rm -f "${PUBSPEC_FILE}.tmp" + rm -f "$TEMP_FILE" + exit 1 + fi + else + # Unix-like systems handling + if sed --version >/dev/null 2>&1; then + SED_INPLACE="-i" + else + SED_INPLACE="-i ''" + fi + + # Remove existing white label font configuration + sed $SED_INPLACE '/# BEGIN: WHITE_LABEL_FONT/,/# END: WHITE_LABEL_FONT/d' "$PUBSPEC_FILE" + + # Add new font configuration + sed $SED_INPLACE "/# White-label font configuration will be added here/r $TEMP_FILE" "$PUBSPEC_FILE" + + if [ $? -ne 0 ]; then + echo "Error: Failed to update pubspec.yaml" + mv "${PUBSPEC_FILE}.bak" "$PUBSPEC_FILE" + rm -f "$TEMP_FILE" + exit 1 + fi + rm -f "${PUBSPEC_FILE}.bak" + fi +else + echo "Error: pubspec.yaml not found at $PUBSPEC_FILE" + rm -f "$TEMP_FILE" + exit 1 +fi + +# Update base_appearance.dart +echo "Updating base_appearance.dart..." +if [ -f "$BASE_APPEARANCE_FILE" ]; then + # Create a backup of the original file + cp "$BASE_APPEARANCE_FILE" "${BASE_APPEARANCE_FILE}.bak" + + if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then + # Windows-specific handling + sed -i "s/const defaultFontFamily = '.*'/const defaultFontFamily = '$FONT_FAMILY'/" "$BASE_APPEARANCE_FILE" + else + # Unix-like systems handling + sed -i '' "s/const defaultFontFamily = '.*'/const defaultFontFamily = '$FONT_FAMILY'/" "$BASE_APPEARANCE_FILE" + fi + + if [ $? -ne 0 ]; then + echo "Error: Failed to update base_appearance.dart" + mv "${BASE_APPEARANCE_FILE}.bak" "$BASE_APPEARANCE_FILE" + exit 1 + fi + rm -f "${BASE_APPEARANCE_FILE}.bak" +else + echo "Error: base_appearance.dart not found at $BASE_APPEARANCE_FILE" + exit 1 +fi + +# Cleanup +rm -f "$TEMP_FILE" + +echo "Font white labeling completed successfully!" diff --git a/frontend/scripts/white_label/icon_white_label.sh b/frontend/scripts/white_label/icon_white_label.sh index eb45d0f02f..ca70bc1661 100644 --- a/frontend/scripts/white_label/icon_white_label.sh +++ b/frontend/scripts/white_label/icon_white_label.sh @@ -3,16 +3,16 @@ show_usage() { echo "Usage: $0 [options]" echo "Options:" - echo " --icon-path Set the path to the application icon (.svg file)" + echo " --icon-path Set the path to the folder containing application icons (.svg files)" echo " --help Show this help message" echo "" echo "Example:" - echo " $0 --icon-path \"/path/to/new/icon.svg\"" + echo " $0 --icon-path \"/path/to/icons_folder\"" } NEW_ICON_PATH="" ICON_DIR="resources/flowy_icons" -ICON_NAME_NEED_REPLACE=("flowy_logo.svg" "flowy_ai_chat_logo.svg" "flowy_logo_dark_mode.svg" "flowy_logo_text.svg") +ICON_NAME_NEED_REPLACE=("app_logo.svg" "ai_chat_logo.svg" "app_logo_with_text_light.svg" "app_logo_with_text_dark.svg") while [[ $# -gt 0 ]]; do case $1 in @@ -38,12 +38,17 @@ if [ -z "$NEW_ICON_PATH" ]; then exit 1 fi +if [ ! -d "$NEW_ICON_PATH" ]; then + echo "Error: New icon directory not found at $NEW_ICON_PATH" + exit 1 +fi + if [ ! -d "$ICON_DIR" ]; then echo "Error: Icon directory not found at $ICON_DIR" exit 1 fi -echo "Replacing icon..." +echo "Replacing icons..." echo "Processing icon files..." if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then @@ -52,13 +57,18 @@ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then echo "Checking subdirectory: $(basename "$subdir")" for file in "${subdir}"*.svg; do if [ -f "$file" ] && [[ " ${ICON_NAME_NEED_REPLACE[@]} " =~ " $(basename "$file") " ]]; then - echo "Updating: $(basename "$subdir")/$(basename "$file")" - cp "$NEW_ICON_PATH" "$file" - if [ $? -eq 0 ]; then - echo "Successfully replaced $(basename "$file") in $(basename "$subdir") with new icon" + new_icon="${NEW_ICON_PATH}/$(basename "$file")" + if [ -f "$new_icon" ]; then + echo "Updating: $(basename "$subdir")/$(basename "$file")" + cp "$new_icon" "$file" + if [ $? -eq 0 ]; then + echo "Successfully replaced $(basename "$file") in $(basename "$subdir") with new icon" + else + echo "Error: Failed to replace $(basename "$file") in $(basename "$subdir")" + exit 1 + fi else - echo "Error: Failed to replace $(basename "$file") in $(basename "$subdir")" - exit 1 + echo "Warning: New icon file $(basename "$file") not found in $NEW_ICON_PATH" fi fi done @@ -67,15 +77,18 @@ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then else for file in $(find "$ICON_DIR" -name "*.svg" -type f); do if [[ " ${ICON_NAME_NEED_REPLACE[@]} " =~ " $(basename "$file") " ]]; then - echo "Updating: $(basename "$file")" - - cp "$NEW_ICON_PATH" "$file" - - if [ $? -eq 0 ]; then - echo "Successfully replaced $(basename "$file") with new icon" + new_icon="${NEW_ICON_PATH}/$(basename "$file")" + if [ -f "$new_icon" ]; then + echo "Updating: $(basename "$file")" + cp "$new_icon" "$file" + if [ $? -eq 0 ]; then + echo "Successfully replaced $(basename "$file") with new icon" + else + echo "Error: Failed to replace $(basename "$file")" + exit 1 + fi else - echo "Error: Failed to replace $(basename "$file")" - exit 1 + echo "Warning: New icon file $(basename "$file") not found in $NEW_ICON_PATH" fi fi done diff --git a/frontend/scripts/white_label/white_label.sh b/frontend/scripts/white_label/white_label.sh index 2d6004cf9d..8ecd187210 100644 --- a/frontend/scripts/white_label/white_label.sh +++ b/frontend/scripts/white_label/white_label.sh @@ -7,6 +7,8 @@ COMPANY_NAME="AppFlowy Inc." COPYRIGHT="Copyright © 2025 AppFlowy Inc." ICON_PATH="" WINDOWS_ICON_PATH="" +FONT_PATH="" +FONT_FAMILY="" PLATFORMS=("windows" "linux" "macos" "ios" "android") show_usage() { @@ -18,6 +20,8 @@ show_usage() { echo " --copyright Set the copyright information" echo " --icon-path Set the path to the application icon (.svg)" echo " --windows-icon-path Set the path to the windows application icon (.ico)" + echo " --font-path Set the path to the folder containing font files (.ttf or .otf files)" + echo " --font-family Set the name of the font family" echo " --platforms Comma-separated list of platforms to white label (windows,linux,macos,ios,android)" echo " --help Show this help message" echo "" @@ -26,7 +30,8 @@ show_usage() { echo " --company-name \"MyCompany Ltd.\" --copyright \"Copyright © 2025 MyCompany Ltd.\" \\" echo " --platforms \"windows,linux,macos\" \\" echo " --windows-icon-path \"./assets/icons/mycompany.ico\" \\" - echo " --icon-path \"./assets/icons/mycompany.svg\"" + echo " --icon-path \"./assets/icons/\" \\" + echo " --font-path \"./assets/fonts/\" --font-family \"CustomFont\"" } while [[ $# -gt 0 ]]; do @@ -55,6 +60,14 @@ while [[ $# -gt 0 ]]; do WINDOWS_ICON_PATH="$2" shift 2 ;; + --font-path) + FONT_PATH="$2" + shift 2 + ;; + --font-family) + FONT_FAMILY="$2" + shift 2 + ;; --platforms) IFS=',' read -ra PLATFORMS <<< "$2" shift 2 @@ -77,8 +90,8 @@ if [ -z "$APP_NAME" ] || [ -z "$APP_IDENTIFIER" ] || [ -z "$COMPANY_NAME" ] || [ exit 1 fi -if [ ! -f "$ICON_PATH" ]; then - echo "Error: Icon file not found at $ICON_PATH" +if [ ! -d "$ICON_PATH" ]; then + echo "Error: Icon directory not found at $ICON_PATH" exit 1 fi @@ -111,6 +124,17 @@ bash "scripts/white_label/i18n_white_label.sh" --company-name "$COMPANY_NAME" echo -e "\033[32mRunning icon white label script...\033[0m" bash "scripts/white_label/icon_white_label.sh" --icon-path "$ICON_PATH" +echo -e "\033[32mRunning code white label script...\033[0m" +bash "scripts/white_label/code_white_label.sh" --company-name "$COMPANY_NAME" + +# Run font white label script if font parameters are provided +if [ ! -z "$FONT_PATH" ] && [ ! -z "$FONT_FAMILY" ]; then + echo -e "\033[32mRunning font white label script...\033[0m" + bash "scripts/white_label/font_white_label.sh" \ + --font-path "$FONT_PATH" \ + --font-family "$FONT_FAMILY" +fi + for platform in "${PLATFORMS[@]}"; do run_platform_script "$platform" done