From 42d179db472774956ada630d42a731a15e0faf1a Mon Sep 17 00:00:00 2001
From: PoolOfDeath20 <53143214+GervinFung@users.noreply.github.com>
Date: Sun, 14 Apr 2024 10:51:50 +0800
Subject: [PATCH] Fix build device type (#23)
* fix(apps/web): inject `DEVICE` dynamically when building for different
platform
* fix(actions/desktop-release): downgrade ubuntu to from latest to 20
---
.github/workflows/desktop.yaml | 2 +-
apps/mobile/Makefile | 4 ++--
apps/web/next/desktop.mjs | 3 +++
apps/web/next/mobile.mjs | 3 +++
apps/web/src/web/components/pages/index/native.tsx | 10 +++++++++-
5 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/desktop.yaml b/.github/workflows/desktop.yaml
index 675084a..dfb7633 100644
--- a/.github/workflows/desktop.yaml
+++ b/.github/workflows/desktop.yaml
@@ -18,7 +18,7 @@ jobs:
threads: [4]
config:
- - os: ubuntu-latest
+ - os: ubuntu-20.04
arch: x86_64
- os: macos-latest
diff --git a/apps/mobile/Makefile b/apps/mobile/Makefile
index 964eebf..dc5db47 100644
--- a/apps/mobile/Makefile
+++ b/apps/mobile/Makefile
@@ -23,10 +23,10 @@ sync-android:
clean-android:
cd android && ./gradlew clean
-build-production-android: build-executable-production build
+build-production-android: build-executable-production sync-android build
cd android && ./gradlew assembleRelease
-build-development-android: build-executable-development build
+build-development-android: build-executable-development sync-android build
cd android && ./gradlew assembleDebug
# format
diff --git a/apps/web/next/desktop.mjs b/apps/web/next/desktop.mjs
index 6e86f1c..2b37c12 100644
--- a/apps/web/next/desktop.mjs
+++ b/apps/web/next/desktop.mjs
@@ -6,6 +6,9 @@ const config = {
images: {
unoptimized: true,
},
+ env: {
+ DEVICE: 'desktop',
+ },
};
export default config;
diff --git a/apps/web/next/mobile.mjs b/apps/web/next/mobile.mjs
index 3281805..4c8ea8c 100644
--- a/apps/web/next/mobile.mjs
+++ b/apps/web/next/mobile.mjs
@@ -6,6 +6,9 @@ const config = {
images: {
unoptimized: true,
},
+ env: {
+ DEVICE: 'mobile',
+ },
};
export default config;
diff --git a/apps/web/src/web/components/pages/index/native.tsx b/apps/web/src/web/components/pages/index/native.tsx
index 31539b9..cfbdf4c 100644
--- a/apps/web/src/web/components/pages/index/native.tsx
+++ b/apps/web/src/web/components/pages/index/native.tsx
@@ -6,7 +6,15 @@ import type { ClassificationProps } from '../../../../../pages/classifications/[
import type { SubshellProps } from '../../../../../pages/subshells/[subshell]';
const NativeIndex = (props: ClassificationProps & SubshellProps) => {
- return ;
+ const device = process.env.DEVICE;
+
+ if (device === 'mobile') {
+ return ;
+ } else if (device === 'desktop') {
+ return ;
+ }
+
+ throw new Error(`Unknown device: ${device}`);
};
export default NativeIndex;