From 7efd27bc2c309a57c3a6cd1e60ef5c45d4fe4b54 Mon Sep 17 00:00:00 2001 From: gm852 <184552300+gm852@users.noreply.github.com> Date: Wed, 22 Oct 2025 14:46:00 +0000 Subject: [PATCH 1/2] upgrade to expo 54; added linting action --- .github/workflows/lint-check.yml | 63 ++++++++++++++++++++++++++++++++ app.json | 6 ++- app/(tabs)/_layout.tsx | 2 +- app/(tabs)/acl.tsx | 5 --- app/(tabs)/apikeys.tsx | 17 +++++---- app/(tabs)/devices.tsx | 13 ------- app/(tabs)/preauthkeys.tsx | 1 + app/(tabs)/routes.tsx | 3 -- app/api/acl.ts | 1 - app/customScreens/[id].tsx | 3 +- app/funcs/deviceDetail.ts | 6 +++ app/funcs/devices.ts | 3 +- app/funcs/routes.ts | 2 +- app/funcs/users.ts | 3 ++ app/index.tsx | 1 - app/utils/apiUtils.ts | 3 +- app/utils/deviceUtils.ts | 1 + components/SetupGuideModal.tsx | 20 +++++----- package.json | 55 ++++++++++++++-------------- 19 files changed, 132 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/lint-check.yml diff --git a/.github/workflows/lint-check.yml b/.github/workflows/lint-check.yml new file mode 100644 index 0000000..1bad4bf --- /dev/null +++ b/.github/workflows/lint-check.yml @@ -0,0 +1,63 @@ +name: Lint Auto Check + +on: + pull_request: + branches: + - main + - staging + - dev + +jobs: + lint: + name: Run Lint Auto Checks + runs-on: ubuntu-latest + + steps: + # Checkout to repo + - name: Checkout code + uses: actions/checkout@v4 + + # Install Bun + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + # Install deps + - name: Install dependencies + run: bun install + + # Run ESLint check + - name: Run ESLint + id: lint + run: bun run lint + + # Comment on PR if lint fails + - name: Comment on PR if lint fails + if: failure() + uses: marocchino/sticky-pull-request-comment@v2 + with: + message: | + ```diff + ================================================== + || ⚠️ ESLint Checks Failed! ❌ || + ================================================== + ``` + Please review the errors and fix them **before requesting a review.** + + **Tips:** + - Run `bun run lint` locally to see detailed issues. + - Commit fixes, push again, and this check will re-run automatically. + + # Comment on PR if lint passes + - name: Comment on PR if lint passes + if: success() + uses: marocchino/sticky-pull-request-comment@v2 + with: + message: | + ```ini + ================================================== + || ✅ ESLint Checks Passed! 🎉 || + ================================================== + ``` + All linting checks completed successfully. You can now request a review. diff --git a/app.json b/app.json index 71688ef..8b387fd 100644 --- a/app.json +++ b/app.json @@ -2,7 +2,7 @@ "expo": { "name": "Scale Manager", "slug": "scaleManager", - "version": "1.2.2", + "version": "1.2.3", "orientation": "portrait", "icon": "./assets/images/noBgScaleManagerLogo.png", "scheme": "myapp", @@ -39,7 +39,9 @@ "resizeMode": "contain", "backgroundColor": "#ffffff" } - ] + ], + "expo-font", + "expo-web-browser" ], "experiments": { "typedRoutes": true diff --git a/app/(tabs)/_layout.tsx b/app/(tabs)/_layout.tsx index b424905..c184fad 100644 --- a/app/(tabs)/_layout.tsx +++ b/app/(tabs)/_layout.tsx @@ -12,7 +12,7 @@ export default function TabLayout() { useEffect(() => { async function checkVersion() { const serverConf = await getServerConfig(); - if (serverConf?.version && serverConf.version == "0.26") { + if (serverConf?.version && serverConf.version === "0.26") { setHideRoutes(true); } } diff --git a/app/(tabs)/acl.tsx b/app/(tabs)/acl.tsx index 3414601..415ef1e 100644 --- a/app/(tabs)/acl.tsx +++ b/app/(tabs)/acl.tsx @@ -18,7 +18,6 @@ export default function ACLScreen() { const { // State policy, - originalPolicy, loading, saving, policyVersions, @@ -26,8 +25,6 @@ export default function ACLScreen() { editing, editText, showSetupGuide, - showErrorModal, - currentError, // Actions fetchPolicy, @@ -41,8 +38,6 @@ export default function ACLScreen() { // Modal controls setShowVersions, setShowSetupGuide, - setShowErrorModal, - setCurrentError, setEditText, } = useACL(); diff --git a/app/(tabs)/apikeys.tsx b/app/(tabs)/apikeys.tsx index 2026279..79d8bbd 100644 --- a/app/(tabs)/apikeys.tsx +++ b/app/(tabs)/apikeys.tsx @@ -8,7 +8,7 @@ import { MaterialIcons } from "@expo/vector-icons"; import Toast from "react-native-toast-message"; import { useApiKeys } from "@/app/funcs/apikeys"; -export default function apiKeysScreen() { +export default function ApiKeysScreen() { const { apiKeys, newKeyExpire, @@ -26,7 +26,7 @@ export default function apiKeysScreen() { useEffect(() => { fetchApiKeys(); - }, []); + }, [fetchApiKeys]); const handleCreateKeyWithDisplay = async () => { const result = await handleCreateKey(); @@ -69,8 +69,8 @@ export default function apiKeysScreen() { visible={showKeyModal} onRequestClose={closeKeyModal} > - - + + @@ -91,6 +91,7 @@ export default function apiKeysScreen() { copyToClipboard(newApiKey!)} className="flex-1 bg-blue-600 py-3 rounded-lg flex-row items-center justify-center" + activeOpacity={0.7} > Copy Key @@ -99,6 +100,7 @@ export default function apiKeysScreen() { Done @@ -113,7 +115,7 @@ export default function apiKeysScreen() { ); return ( - + {loading ? ( @@ -129,7 +131,7 @@ export default function apiKeysScreen() { {/* Header */} API Keys - + @@ -170,7 +172,7 @@ export default function apiKeysScreen() { @@ -265,6 +267,7 @@ export default function apiKeysScreen() { className={`p-3 rounded-lg flex-row items-center justify-center ${ expired ? "bg-zinc-600" : "bg-red-600" }`} + activeOpacity={0.7} > { - try { - return new Date(dateString).toLocaleDateString('en-US', { - month: 'short', - day: 'numeric', - hour: '2-digit', - minute: '2-digit' - }); - } catch { - return "Unknown"; - } - }; return ( diff --git a/app/(tabs)/preauthkeys.tsx b/app/(tabs)/preauthkeys.tsx index 335ded4..0cc527b 100644 --- a/app/(tabs)/preauthkeys.tsx +++ b/app/(tabs)/preauthkeys.tsx @@ -44,6 +44,7 @@ export default function PreAuthKeysScreen() { text1: "Copy Failed", text2: "Could not copy to clipboard", }); + console.error(error) } }; diff --git a/app/(tabs)/routes.tsx b/app/(tabs)/routes.tsx index 01df8d8..e6b6ee2 100644 --- a/app/(tabs)/routes.tsx +++ b/app/(tabs)/routes.tsx @@ -9,7 +9,6 @@ import { Alert, RefreshControl, } from "react-native"; -import Toast from "react-native-toast-message"; import { MaterialIcons } from "@expo/vector-icons"; import { useRoutes } from "@/app/funcs/routes"; @@ -22,9 +21,7 @@ export default function RoutesScreen() { handleDisableRoute, handleEnableRoute, routes, - setRoutes, loading, - setLoading, fetchRoutes } = useRoutes(); diff --git a/app/api/acl.ts b/app/api/acl.ts index d64d8de..7fe9025 100644 --- a/app/api/acl.ts +++ b/app/api/acl.ts @@ -1,4 +1,3 @@ -import { getServerConfig } from "../utils/getServer"; import { getApiEndpoints, makeApiRequest } from "../utils/apiUtils"; export async function getACLPolicy() { diff --git a/app/customScreens/[id].tsx b/app/customScreens/[id].tsx index 1e392fe..516bc96 100644 --- a/app/customScreens/[id].tsx +++ b/app/customScreens/[id].tsx @@ -1,11 +1,10 @@ import React, { useRef } from "react"; import { View, Text, TextInput, TouchableOpacity, SafeAreaView, - ScrollView, Animated + Animated } from "react-native"; import { MaterialIcons } from "@expo/vector-icons"; import { useRouter, useLocalSearchParams } from "expo-router"; -import { Device } from "../types"; import { useDeviceDetail } from "../funcs/deviceDetail"; import { formatDate, getTimeAgo, copyToClipboard } from "../utils/deviceUtils"; import { InfoRow } from "../components/InfoRow"; diff --git a/app/funcs/deviceDetail.ts b/app/funcs/deviceDetail.ts index 3ef8d7d..eca770a 100644 --- a/app/funcs/deviceDetail.ts +++ b/app/funcs/deviceDetail.ts @@ -89,6 +89,7 @@ export function useDeviceDetail(deviceData: string | undefined) { text1: "⚠️ Rename Error", text2: "An error occurred while renaming", }); + console.error(error) } }; @@ -137,6 +138,7 @@ export function useDeviceDetail(deviceData: string | undefined) { text1: "⚠️ Change Error", text2: "An error occurred while changing user", }); + console.error(error) } }; @@ -198,6 +200,7 @@ export function useDeviceDetail(deviceData: string | undefined) { text1: "⚠️ Add Error", text2: "An error occurred while adding tags", }); + console.error(error) } }; @@ -239,6 +242,7 @@ export function useDeviceDetail(deviceData: string | undefined) { text1: "⚠️ Update Error", text2: "An error occurred while approving routes", }); + console.error(error) } }; @@ -285,6 +289,7 @@ export function useDeviceDetail(deviceData: string | undefined) { text1: "⚠️ Update Error", text2: "An error occurred while removing route", }); + console.error(error) } }, }, @@ -337,6 +342,7 @@ export function useDeviceDetail(deviceData: string | undefined) { text1: "Delete Error", text2: "An error occurred while deleting", }); + console.error(error) } }, }, diff --git a/app/funcs/devices.ts b/app/funcs/devices.ts index e553f7f..fbd3e74 100644 --- a/app/funcs/devices.ts +++ b/app/funcs/devices.ts @@ -1,5 +1,4 @@ import { useEffect, useState } from "react"; -import { Alert } from "react-native"; import { getDevices, registerDevice } from "../api/devices"; import { getUsers } from "../api/users"; import Toast from "react-native-toast-message"; @@ -194,7 +193,7 @@ export function useDevices() { ); if (fullCommandMatch) { - const username = fullCommandMatch[1]; + //const username = fullCommandMatch[1]; const preAuthKey = fullCommandMatch[2]; if (preAuthKey) { setDeviceKey(preAuthKey); diff --git a/app/funcs/routes.ts b/app/funcs/routes.ts index 7f6c5c0..8a81b2e 100644 --- a/app/funcs/routes.ts +++ b/app/funcs/routes.ts @@ -1,5 +1,5 @@ -import { useEffect, useState } from "react"; +import { useState } from "react"; import { getServerRoutes, disableRoute, enableRoute } from "../api/routes"; import Toast from "react-native-toast-message"; diff --git a/app/funcs/users.ts b/app/funcs/users.ts index eb612de..ff3dff0 100644 --- a/app/funcs/users.ts +++ b/app/funcs/users.ts @@ -120,6 +120,7 @@ export function useUsers() { text1: "⚠️ Add Failed", text2: "An error occurred while adding the user.", }); + console.error(error) } }, }, @@ -205,6 +206,7 @@ export function useUsers() { text1: "⚠️ Rename Failed", text2: "An error occurred while renaming the user.", }); + console.error(error) } }, }, @@ -262,6 +264,7 @@ export function useUsers() { text1: "⚠️ Delete Failed", text2: "An error occurred while deleting the user.", }); + console.error(error) } }; diff --git a/app/index.tsx b/app/index.tsx index c1bb5fc..9cb75ab 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -8,7 +8,6 @@ import { Platform, ActivityIndicator, Image, - Modal, ScrollView } from "react-native"; import { MaterialIcons } from "@expo/vector-icons"; diff --git a/app/utils/apiUtils.ts b/app/utils/apiUtils.ts index aaee0d7..717f174 100644 --- a/app/utils/apiUtils.ts +++ b/app/utils/apiUtils.ts @@ -53,7 +53,8 @@ export async function makeApiRequest(url: string, options: RequestInit = {}) { try { const errorData = JSON.parse(errorText); return errorData; // Return the error data instead of null - } catch (parseError) { + } catch (error) { + console.error(error) // If parsing fails, return a generic error object return { code: response.status, diff --git a/app/utils/deviceUtils.ts b/app/utils/deviceUtils.ts index 9100190..508915e 100644 --- a/app/utils/deviceUtils.ts +++ b/app/utils/deviceUtils.ts @@ -47,6 +47,7 @@ export const copyToClipboard = async (text: string, label: string) => { text1: "Copy Failed", text2: "Could not copy to clipboard", }); + console.error(error) } }; diff --git a/components/SetupGuideModal.tsx b/components/SetupGuideModal.tsx index 7517651..428d6d7 100644 --- a/components/SetupGuideModal.tsx +++ b/components/SetupGuideModal.tsx @@ -1,10 +1,9 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useMemo } from 'react'; import { Modal, View, Text, TouchableOpacity, - SafeAreaView, ScrollView, Animated, Dimensions, @@ -20,11 +19,11 @@ const { width } = Dimensions.get('window'); export default function SetupGuideModal({ visible, onClose }: SetupGuideModalProps) { const [currentStep, setCurrentStep] = useState(0); - const [fadeAnim] = useState(new Animated.Value(0)); - const [slideAnim] = useState(new Animated.Value(50)); - const [progressAnim] = useState(new Animated.Value(0)); + const fadeAnim = useMemo(() => new Animated.Value(0), []); + const slideAnim = useMemo(() => new Animated.Value(50), []); + const progressAnim = useMemo(() => new Animated.Value(0), []); - const steps = [ + const steps = useMemo(() => [ { id: 'welcome', title: 'Welcome to ACL Setup', @@ -414,7 +413,7 @@ export default function SetupGuideModal({ visible, onClose }: SetupGuideModalPro ), }, - ]; + ], [width]); useEffect(() => { if (visible) { @@ -444,7 +443,7 @@ export default function SetupGuideModal({ visible, onClose }: SetupGuideModalPro slideAnim.setValue(50); progressAnim.setValue(0); } - }, [visible]); + }, [visible, fadeAnim, slideAnim, progressAnim]); useEffect(() => { Animated.spring(progressAnim, { @@ -453,7 +452,7 @@ export default function SetupGuideModal({ visible, onClose }: SetupGuideModalPro friction: 7, useNativeDriver: false, }).start(); - }, [currentStep]); + }, [currentStep, progressAnim, steps.length]); const nextStep = () => { if (currentStep < steps.length - 1) { @@ -483,9 +482,10 @@ export default function SetupGuideModal({ visible, onClose }: SetupGuideModalPro style={{ opacity: fadeAnim, transform: [{ translateY: slideAnim }], + maxHeight: '75%', + minHeight: '80%', }} className="bg-zinc-900 rounded-3xl w-full max-w-2xl border-2 border-zinc-700 shadow-2xl overflow-hidden" - style={{ maxHeight: '75%', minHeight: '80%' }} > {/* Header with gradient background */} Date: Wed, 22 Oct 2025 14:50:01 +0000 Subject: [PATCH 2/2] perms fix for action i hope --- .github/workflows/lint-check.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/lint-check.yml b/.github/workflows/lint-check.yml index 1bad4bf..dbcf5fc 100644 --- a/.github/workflows/lint-check.yml +++ b/.github/workflows/lint-check.yml @@ -7,6 +7,10 @@ on: - staging - dev +permissions: + contents: read + pull-requests: write + jobs: lint: name: Run Lint Auto Checks