Compare commits
10 Commits
d3d73c255e
...
v0.1.17
| Author | SHA1 | Date | |
|---|---|---|---|
| c915d5f2ad | |||
| fee283b5d6 | |||
| 67c132d88b | |||
| f1a4b58234 | |||
| dca76ea394 | |||
| af8ec98bb4 | |||
| c43b913dde | |||
| 256b338ae3 | |||
| ec95406305 | |||
| 6bd1dc8358 |
@@ -89,6 +89,17 @@ jobs:
|
||||
[ -n "$KEYSTORE_STORE_PASSWORD" ] && echo "KEYSTORE_STORE_PASSWORD: set" || echo "KEYSTORE_STORE_PASSWORD: EMPTY"
|
||||
[ -n "$KEYSTORE_KEY_PASSWORD" ] && echo "KEYSTORE_KEY_PASSWORD: set" || echo "KEYSTORE_KEY_PASSWORD: EMPTY"
|
||||
|
||||
- name: Patch native modules for Android 15 16KB page size
|
||||
run: |
|
||||
WORKLETS="node_modules/react-native-worklets/android/CMakeLists.txt"
|
||||
REANIMATED="node_modules/react-native-reanimated/android/CMakeLists.txt"
|
||||
if [ -f "$WORKLETS" ] && ! grep -q "max-page-size" "$WORKLETS"; then
|
||||
printf '\ntarget_link_options(worklets PRIVATE "-Wl,-z,max-page-size=16384")\n' >> "$WORKLETS"
|
||||
fi
|
||||
if [ -f "$REANIMATED" ] && ! grep -q "max-page-size" "$REANIMATED"; then
|
||||
printf '\ntarget_link_options(reanimated PRIVATE "-Wl,-z,max-page-size=16384")\n' >> "$REANIMATED"
|
||||
fi
|
||||
|
||||
- name: Build signed APK
|
||||
run: ./build-apk.sh
|
||||
|
||||
|
||||
@@ -5,15 +5,13 @@
|
||||
"version": "0.1.0",
|
||||
"orientation": "portrait",
|
||||
"userInterfaceStyle": "dark",
|
||||
"backgroundColor": "#0f1117",
|
||||
"splash": {
|
||||
"backgroundColor": "#0f1117"
|
||||
},
|
||||
"icon": "./assets/icon.png",
|
||||
"backgroundColor": "#1B2433",
|
||||
"scheme": "sheethappens",
|
||||
"android": {
|
||||
"adaptiveIcon": {
|
||||
"foregroundImage": "./assets/adaptive-icon.png",
|
||||
"backgroundColor": "#0f1117"
|
||||
"backgroundColor": "#1B2433"
|
||||
},
|
||||
"package": "fr.gyozamancave.sheethappens",
|
||||
"permissions": [
|
||||
|
||||
+16
-7
@@ -1,5 +1,6 @@
|
||||
import { useEffect } from "react";
|
||||
import { Stack, router, SplashScreen } from "expo-router";
|
||||
import { Pressable, Text } from "react-native";
|
||||
import { Stack, router } from "expo-router";
|
||||
import { StatusBar } from "expo-status-bar";
|
||||
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
||||
import "../global.css";
|
||||
@@ -9,11 +10,6 @@ import { useSettings } from "@/hooks/useSettings";
|
||||
export default function RootLayout() {
|
||||
const { settings, ready } = useSettings();
|
||||
|
||||
useEffect(() => {
|
||||
if (!ready) return;
|
||||
SplashScreen.hideAsync();
|
||||
}, [ready]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ready) return;
|
||||
if (!settings.onboardingDone) {
|
||||
@@ -33,7 +29,20 @@ export default function RootLayout() {
|
||||
animation: "slide_from_right",
|
||||
}}
|
||||
>
|
||||
<Stack.Screen name="index" options={{ title: "SheetHappens" }} />
|
||||
<Stack.Screen
|
||||
name="index"
|
||||
options={{
|
||||
title: "SheetHappens",
|
||||
headerRight: () => (
|
||||
<Pressable
|
||||
onPress={() => router.push("/settings")}
|
||||
style={{ paddingLeft: 12, paddingRight: 4, paddingVertical: 6 }}
|
||||
>
|
||||
<Text style={{ color: Colors.primary, fontSize: 22, lineHeight: 26 }}>⚙</Text>
|
||||
</Pressable>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen name="new" options={{ title: "New Incident", presentation: "modal" }} />
|
||||
<Stack.Screen name="incident/[id]" options={{ title: "Incident" }} />
|
||||
<Stack.Screen name="settings" options={{ title: "Settings" }} />
|
||||
|
||||
+86
-14
@@ -10,9 +10,10 @@ import {
|
||||
import { useLocalSearchParams, router, useNavigation } from "expo-router";
|
||||
import * as Clipboard from "expo-clipboard";
|
||||
import * as SecureStore from "expo-secure-store";
|
||||
import { getIncidentById, updateIncident } from "@/lib/db";
|
||||
import { getIncidentById, updateIncident, deleteIncident } from "@/lib/db";
|
||||
import { renderMarkdown } from "@/lib/markdown";
|
||||
import { pushIncidentToGitea } from "@/lib/gitea";
|
||||
import { pushIncidentToGit } from "@/lib/git";
|
||||
import type { GitProvider } from "@/lib/git";
|
||||
import type { Incident } from "@/types/incident";
|
||||
import { Colors } from "@/constants/theme";
|
||||
|
||||
@@ -53,34 +54,88 @@ export default function IncidentDetailScreen() {
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
async function handleDelete() {
|
||||
if (!incident) return;
|
||||
Alert.alert(
|
||||
"Delete incident?",
|
||||
"This action cannot be undone.",
|
||||
[
|
||||
{ text: "Cancel", style: "cancel" },
|
||||
{
|
||||
text: "Delete",
|
||||
style: "destructive",
|
||||
onPress: async () => {
|
||||
await deleteIncident(incident.id);
|
||||
router.replace("/");
|
||||
},
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
async function handleResolve() {
|
||||
if (!incident) return;
|
||||
await updateIncident(incident.id, { status: "resolved" });
|
||||
setIncident({ ...incident, status: "resolved" });
|
||||
}
|
||||
|
||||
async function handleGiteaPush() {
|
||||
async function handleGitPush() {
|
||||
if (!incident) return;
|
||||
const [url, token, owner, repo, template] = await Promise.all([
|
||||
const [provider, template, giteaUrl, giteaToken, giteaOwner, giteaRepo, githubToken, githubOwner, githubRepo, gitlabUrl, gitlabToken, gitlabOwner, gitlabRepo] =
|
||||
await Promise.all([
|
||||
SecureStore.getItemAsync("git_provider"),
|
||||
SecureStore.getItemAsync("md_template"),
|
||||
SecureStore.getItemAsync("gitea_url"),
|
||||
SecureStore.getItemAsync("gitea_token"),
|
||||
SecureStore.getItemAsync("gitea_owner"),
|
||||
SecureStore.getItemAsync("gitea_repo"),
|
||||
SecureStore.getItemAsync("md_template"),
|
||||
SecureStore.getItemAsync("github_token"),
|
||||
SecureStore.getItemAsync("github_owner"),
|
||||
SecureStore.getItemAsync("github_repo"),
|
||||
SecureStore.getItemAsync("gitlab_url"),
|
||||
SecureStore.getItemAsync("gitlab_token"),
|
||||
SecureStore.getItemAsync("gitlab_owner"),
|
||||
SecureStore.getItemAsync("gitlab_repo"),
|
||||
]);
|
||||
if (!url || !token || !owner || !repo) {
|
||||
Alert.alert("Gitea not configured", "Set up Gitea in Settings first.");
|
||||
|
||||
const p = (provider ?? "gitea") as GitProvider;
|
||||
|
||||
let url: string | undefined;
|
||||
let token: string | null;
|
||||
let owner: string | null;
|
||||
let repo: string | null;
|
||||
|
||||
if (p === "gitea") {
|
||||
url = giteaUrl ?? undefined;
|
||||
token = giteaToken;
|
||||
owner = giteaOwner;
|
||||
repo = giteaRepo;
|
||||
} else if (p === "github") {
|
||||
token = githubToken;
|
||||
owner = githubOwner;
|
||||
repo = githubRepo;
|
||||
} else {
|
||||
url = gitlabUrl ?? undefined;
|
||||
token = gitlabToken;
|
||||
owner = gitlabOwner;
|
||||
repo = gitlabRepo;
|
||||
}
|
||||
|
||||
const needsUrl = p === "gitea" || p === "gitlab";
|
||||
if (!token || !owner || !repo || (needsUrl && !url)) {
|
||||
Alert.alert("Git not configured", `Set up ${p.charAt(0).toUpperCase() + p.slice(1)} in Settings first.`);
|
||||
return;
|
||||
}
|
||||
|
||||
setPushing(true);
|
||||
const result = await pushIncidentToGitea(
|
||||
const result = await pushIncidentToGit(
|
||||
incident,
|
||||
{ url, token, owner, repo },
|
||||
{ provider: p, url, token, owner, repo },
|
||||
template ?? undefined
|
||||
);
|
||||
setPushing(false);
|
||||
if (result.success) {
|
||||
Alert.alert("Pushed", result.url ? `${result.url}` : "Push successful.");
|
||||
Alert.alert("Pushed", result.url ?? "Push successful.");
|
||||
} else {
|
||||
Alert.alert("Push failed", result.error ?? "Unknown error");
|
||||
}
|
||||
@@ -117,7 +172,7 @@ export default function IncidentDetailScreen() {
|
||||
<View
|
||||
style={{
|
||||
backgroundColor:
|
||||
incident.status === "open" ? "#f59e0b20" : "#22c55e20",
|
||||
incident.status === "open" ? "#f59e0b20" : "#88D65620",
|
||||
borderRadius: 6,
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 4,
|
||||
@@ -188,7 +243,7 @@ export default function IncidentDetailScreen() {
|
||||
<Pressable
|
||||
onPress={handleResolve}
|
||||
style={{
|
||||
backgroundColor: "#22c55e20",
|
||||
backgroundColor: "#88D65620",
|
||||
borderWidth: 1,
|
||||
borderColor: Colors.success,
|
||||
borderRadius: 10,
|
||||
@@ -219,7 +274,7 @@ export default function IncidentDetailScreen() {
|
||||
</Pressable>
|
||||
|
||||
<Pressable
|
||||
onPress={handleGiteaPush}
|
||||
onPress={handleGitPush}
|
||||
disabled={pushing}
|
||||
style={{
|
||||
backgroundColor: pushing ? Colors.surface2 : Colors.surface,
|
||||
@@ -237,7 +292,7 @@ export default function IncidentDetailScreen() {
|
||||
fontSize: 15,
|
||||
}}
|
||||
>
|
||||
{pushing ? "Pushing…" : "Push to Gitea"}
|
||||
{pushing ? "Pushing…" : "Push to Git"}
|
||||
</Text>
|
||||
</Pressable>
|
||||
|
||||
@@ -256,6 +311,23 @@ export default function IncidentDetailScreen() {
|
||||
Edit
|
||||
</Text>
|
||||
</Pressable>
|
||||
|
||||
<Pressable
|
||||
onPress={handleDelete}
|
||||
style={{
|
||||
backgroundColor: "#ef444410",
|
||||
borderWidth: 1,
|
||||
borderColor: "#ef4444",
|
||||
borderRadius: 10,
|
||||
padding: 14,
|
||||
alignItems: "center",
|
||||
marginTop: 8,
|
||||
}}
|
||||
>
|
||||
<Text style={{ color: "#ef4444", fontWeight: "600", fontSize: 15 }}>
|
||||
Delete Incident
|
||||
</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
+7
-5
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
Pressable,
|
||||
ActivityIndicator,
|
||||
} from "react-native";
|
||||
import { router } from "expo-router";
|
||||
import { router, useFocusEffect } from "expo-router";
|
||||
import { getIncidents } from "@/lib/db";
|
||||
import { useSettings } from "@/hooks/useSettings";
|
||||
import type { Incident } from "@/types/incident";
|
||||
@@ -26,9 +26,11 @@ export default function HomeScreen() {
|
||||
}
|
||||
}, [ready, settings.homeView]);
|
||||
|
||||
useEffect(() => {
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
loadIncidents();
|
||||
}, []);
|
||||
}, [])
|
||||
);
|
||||
|
||||
async function loadIncidents() {
|
||||
setLoading(true);
|
||||
@@ -98,7 +100,7 @@ export default function HomeScreen() {
|
||||
backgroundColor:
|
||||
item.status === "open"
|
||||
? "#f59e0b20"
|
||||
: "#22c55e20",
|
||||
: "#88D65620",
|
||||
borderRadius: 4,
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 2,
|
||||
|
||||
+22
-2
@@ -10,6 +10,7 @@ import {
|
||||
Alert,
|
||||
} from "react-native";
|
||||
import { router, useLocalSearchParams, useNavigation } from "expo-router";
|
||||
import * as SecureStore from "expo-secure-store";
|
||||
import {
|
||||
createIncident,
|
||||
updateIncident,
|
||||
@@ -46,7 +47,15 @@ const LABEL_STYLE = {
|
||||
letterSpacing: 0.5,
|
||||
} as const;
|
||||
|
||||
type VoiceField = "title" | "symptom" | "rootCause" | "fix";
|
||||
type VoiceField = "title" | "service" | "symptom" | "rootCause" | "fix";
|
||||
|
||||
function incrementTemplate(template: string): string {
|
||||
const match = template.match(/^([\s\S]*?)(\d+)$/);
|
||||
if (!match) return template;
|
||||
const [, prefix, numStr] = match;
|
||||
const next = (parseInt(numStr, 10) + 1).toString().padStart(numStr.length, "0");
|
||||
return prefix + next;
|
||||
}
|
||||
|
||||
export default function NewIncidentScreen() {
|
||||
const { editId } = useLocalSearchParams<{ editId?: string }>();
|
||||
@@ -74,6 +83,13 @@ export default function NewIncidentScreen() {
|
||||
getDistinctServices().then(setKnownServices);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (editId) return;
|
||||
SecureStore.getItemAsync("pref_title_template").then((tpl) => {
|
||||
if (tpl) setForm((f) => ({ ...f, title: tpl }));
|
||||
});
|
||||
}, [editId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!editId) return;
|
||||
navigation.setOptions({ title: "Edit Incident" });
|
||||
@@ -144,6 +160,10 @@ export default function NewIncidentScreen() {
|
||||
await updateIncident(editId, form);
|
||||
} else {
|
||||
await createIncident(form);
|
||||
const tpl = await SecureStore.getItemAsync("pref_title_template");
|
||||
if (tpl) {
|
||||
await SecureStore.setItemAsync("pref_title_template", incrementTemplate(tpl));
|
||||
}
|
||||
}
|
||||
router.back();
|
||||
} catch {
|
||||
@@ -224,7 +244,7 @@ export default function NewIncidentScreen() {
|
||||
returnKeyType="next"
|
||||
/>
|
||||
|
||||
<Text style={[LABEL_STYLE, { marginBottom: 6 }]}>Service</Text>
|
||||
{labelRow("Service", "service")}
|
||||
<TextInput
|
||||
style={FIELD_STYLE}
|
||||
value={form.service}
|
||||
|
||||
+326
-100
@@ -6,22 +6,33 @@ import {
|
||||
ScrollView,
|
||||
Switch,
|
||||
Pressable,
|
||||
Alert,
|
||||
} from "react-native";
|
||||
import * as SecureStore from "expo-secure-store";
|
||||
import { Colors } from "@/constants/theme";
|
||||
import { DEFAULT_TEMPLATE } from "@/lib/markdown";
|
||||
import type { GitProvider } from "@/lib/git";
|
||||
|
||||
const KEYS = {
|
||||
INPUT_MODE: "pref_input_mode",
|
||||
HOME_VIEW: "pref_home_view",
|
||||
AI_ENABLED: "pref_ai_enabled",
|
||||
AI_KEY: "pref_ai_key",
|
||||
AI_BASE_URL: "pref_ai_base_url",
|
||||
AI_MODEL: "pref_ai_model",
|
||||
TITLE_TEMPLATE: "pref_title_template",
|
||||
MD_TEMPLATE: "md_template",
|
||||
GIT_PROVIDER: "git_provider",
|
||||
GITEA_URL: "gitea_url",
|
||||
GITEA_TOKEN: "gitea_token",
|
||||
GITEA_OWNER: "gitea_owner",
|
||||
GITEA_REPO: "gitea_repo",
|
||||
MD_TEMPLATE: "md_template",
|
||||
GITHUB_TOKEN: "github_token",
|
||||
GITHUB_OWNER: "github_owner",
|
||||
GITHUB_REPO: "github_repo",
|
||||
GITLAB_URL: "gitlab_url",
|
||||
GITLAB_TOKEN: "gitlab_token",
|
||||
GITLAB_OWNER: "gitlab_owner",
|
||||
GITLAB_REPO: "gitlab_repo",
|
||||
} as const;
|
||||
|
||||
const LABEL = {
|
||||
@@ -53,68 +64,24 @@ const INPUT = {
|
||||
fontFamily: "monospace",
|
||||
} as const;
|
||||
|
||||
export default function SettingsScreen() {
|
||||
const [inputMode, setInputMode] = useState<"voice" | "form">("form");
|
||||
const [homeView, setHomeView] = useState<"dashboard" | "capture">("dashboard");
|
||||
const [aiEnabled, setAiEnabled] = useState(false);
|
||||
const [aiKey, setAiKey] = useState("");
|
||||
const [giteaUrl, setGiteaUrl] = useState("");
|
||||
const [giteaToken, setGiteaToken] = useState("");
|
||||
const [giteaOwner, setGiteaOwner] = useState("");
|
||||
const [giteaRepo, setGiteaRepo] = useState("");
|
||||
const [mdTemplate, setMdTemplate] = useState(DEFAULT_TEMPLATE);
|
||||
const [saved, setSaved] = useState(false);
|
||||
const PROVIDER_LABELS: Record<GitProvider, string> = {
|
||||
gitea: "Gitea",
|
||||
github: "GitHub",
|
||||
gitlab: "GitLab",
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const [im, hv, ai, key, gu, gt, go, gr, tpl] = await Promise.all([
|
||||
SecureStore.getItemAsync(KEYS.INPUT_MODE),
|
||||
SecureStore.getItemAsync(KEYS.HOME_VIEW),
|
||||
SecureStore.getItemAsync(KEYS.AI_ENABLED),
|
||||
SecureStore.getItemAsync(KEYS.AI_KEY),
|
||||
SecureStore.getItemAsync(KEYS.GITEA_URL),
|
||||
SecureStore.getItemAsync(KEYS.GITEA_TOKEN),
|
||||
SecureStore.getItemAsync(KEYS.GITEA_OWNER),
|
||||
SecureStore.getItemAsync(KEYS.GITEA_REPO),
|
||||
SecureStore.getItemAsync(KEYS.MD_TEMPLATE),
|
||||
]);
|
||||
if (im) setInputMode(im as "voice" | "form");
|
||||
if (hv) setHomeView(hv as "dashboard" | "capture");
|
||||
if (ai) setAiEnabled(ai === "true");
|
||||
if (key) setAiKey(key);
|
||||
if (gu) setGiteaUrl(gu);
|
||||
if (gt) setGiteaToken(gt);
|
||||
if (go) setGiteaOwner(go);
|
||||
if (gr) setGiteaRepo(gr);
|
||||
if (tpl) setMdTemplate(tpl);
|
||||
})();
|
||||
}, []);
|
||||
// Defined outside SettingsScreen — prevents remount on every rerender, which
|
||||
// would cause TextInput to lose focus after each keystroke.
|
||||
|
||||
async function handleSave() {
|
||||
await Promise.all([
|
||||
SecureStore.setItemAsync(KEYS.INPUT_MODE, inputMode),
|
||||
SecureStore.setItemAsync(KEYS.HOME_VIEW, homeView),
|
||||
SecureStore.setItemAsync(KEYS.AI_ENABLED, String(aiEnabled)),
|
||||
SecureStore.setItemAsync(KEYS.AI_KEY, aiKey),
|
||||
SecureStore.setItemAsync(KEYS.GITEA_URL, giteaUrl),
|
||||
SecureStore.setItemAsync(KEYS.GITEA_TOKEN, giteaToken),
|
||||
SecureStore.setItemAsync(KEYS.GITEA_OWNER, giteaOwner),
|
||||
SecureStore.setItemAsync(KEYS.GITEA_REPO, giteaRepo),
|
||||
SecureStore.setItemAsync(KEYS.MD_TEMPLATE, mdTemplate),
|
||||
]);
|
||||
setSaved(true);
|
||||
setTimeout(() => setSaved(false), 2000);
|
||||
}
|
||||
|
||||
function ToggleRow({
|
||||
function ToggleRow({
|
||||
label,
|
||||
value,
|
||||
onValueChange,
|
||||
}: {
|
||||
}: {
|
||||
label: string;
|
||||
value: boolean;
|
||||
onValueChange: (v: boolean) => void;
|
||||
}) {
|
||||
}) {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@@ -136,19 +103,19 @@ export default function SettingsScreen() {
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function SegmentRow({
|
||||
function SegmentRow({
|
||||
label,
|
||||
options,
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
}: {
|
||||
label: string;
|
||||
options: { key: string; label: string }[];
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
}) {
|
||||
}) {
|
||||
return (
|
||||
<View style={{ marginBottom: 16 }}>
|
||||
<Text style={LABEL}>{label}</Text>
|
||||
@@ -171,8 +138,8 @@ export default function SettingsScreen() {
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: value === opt.key ? "#fff" : Colors.text2,
|
||||
fontWeight: "600",
|
||||
color: value === opt.key ? Colors.bg : Colors.text2,
|
||||
fontWeight: "700",
|
||||
fontSize: 13,
|
||||
}}
|
||||
>
|
||||
@@ -183,6 +150,142 @@ export default function SettingsScreen() {
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function Field({
|
||||
label,
|
||||
value,
|
||||
onChange,
|
||||
placeholder,
|
||||
secure,
|
||||
url,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
placeholder?: string;
|
||||
secure?: boolean;
|
||||
url?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Text style={LABEL}>{label}</Text>
|
||||
<TextInput
|
||||
style={INPUT}
|
||||
value={value}
|
||||
onChangeText={onChange}
|
||||
placeholder={placeholder}
|
||||
placeholderTextColor={Colors.textDim}
|
||||
secureTextEntry={secure}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
keyboardType={url ? "url" : "default"}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default function SettingsScreen() {
|
||||
const [inputMode, setInputMode] = useState<"voice" | "form">("form");
|
||||
const [homeView, setHomeView] = useState<"dashboard" | "capture">("dashboard");
|
||||
const [aiEnabled, setAiEnabled] = useState(false);
|
||||
const [aiKey, setAiKey] = useState("");
|
||||
const [aiBaseUrl, setAiBaseUrl] = useState("");
|
||||
const [aiModel, setAiModel] = useState("");
|
||||
const [titleTemplate, setTitleTemplate] = useState("");
|
||||
const [mdTemplate, setMdTemplate] = useState(DEFAULT_TEMPLATE);
|
||||
const [saved, setSaved] = useState(false);
|
||||
|
||||
const [gitProvider, setGitProvider] = useState<GitProvider>("gitea");
|
||||
const [giteaUrl, setGiteaUrl] = useState("");
|
||||
const [giteaToken, setGiteaToken] = useState("");
|
||||
const [giteaOwner, setGiteaOwner] = useState("");
|
||||
const [giteaRepo, setGiteaRepo] = useState("");
|
||||
const [githubToken, setGithubToken] = useState("");
|
||||
const [githubOwner, setGithubOwner] = useState("");
|
||||
const [githubRepo, setGithubRepo] = useState("");
|
||||
const [gitlabUrl, setGitlabUrl] = useState("");
|
||||
const [gitlabToken, setGitlabToken] = useState("");
|
||||
const [gitlabOwner, setGitlabOwner] = useState("");
|
||||
const [gitlabRepo, setGitlabRepo] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const [
|
||||
im, hv, ai, key, aiUrl, aiMdl, titleTpl, tpl,
|
||||
gp, gu, gt, go, gr,
|
||||
ghu, ghown, ghrepo,
|
||||
glu, glt, glo, glr,
|
||||
] = await Promise.all([
|
||||
SecureStore.getItemAsync(KEYS.INPUT_MODE),
|
||||
SecureStore.getItemAsync(KEYS.HOME_VIEW),
|
||||
SecureStore.getItemAsync(KEYS.AI_ENABLED),
|
||||
SecureStore.getItemAsync(KEYS.AI_KEY),
|
||||
SecureStore.getItemAsync(KEYS.AI_BASE_URL),
|
||||
SecureStore.getItemAsync(KEYS.AI_MODEL),
|
||||
SecureStore.getItemAsync(KEYS.TITLE_TEMPLATE),
|
||||
SecureStore.getItemAsync(KEYS.MD_TEMPLATE),
|
||||
SecureStore.getItemAsync(KEYS.GIT_PROVIDER),
|
||||
SecureStore.getItemAsync(KEYS.GITEA_URL),
|
||||
SecureStore.getItemAsync(KEYS.GITEA_TOKEN),
|
||||
SecureStore.getItemAsync(KEYS.GITEA_OWNER),
|
||||
SecureStore.getItemAsync(KEYS.GITEA_REPO),
|
||||
SecureStore.getItemAsync(KEYS.GITHUB_TOKEN),
|
||||
SecureStore.getItemAsync(KEYS.GITHUB_OWNER),
|
||||
SecureStore.getItemAsync(KEYS.GITHUB_REPO),
|
||||
SecureStore.getItemAsync(KEYS.GITLAB_URL),
|
||||
SecureStore.getItemAsync(KEYS.GITLAB_TOKEN),
|
||||
SecureStore.getItemAsync(KEYS.GITLAB_OWNER),
|
||||
SecureStore.getItemAsync(KEYS.GITLAB_REPO),
|
||||
]);
|
||||
if (im) setInputMode(im as "voice" | "form");
|
||||
if (hv) setHomeView(hv as "dashboard" | "capture");
|
||||
if (ai) setAiEnabled(ai === "true");
|
||||
if (key) setAiKey(key);
|
||||
if (aiUrl) setAiBaseUrl(aiUrl);
|
||||
if (aiMdl) setAiModel(aiMdl);
|
||||
if (titleTpl) setTitleTemplate(titleTpl);
|
||||
if (tpl) setMdTemplate(tpl);
|
||||
if (gp) setGitProvider(gp as GitProvider);
|
||||
if (gu) setGiteaUrl(gu);
|
||||
if (gt) setGiteaToken(gt);
|
||||
if (go) setGiteaOwner(go);
|
||||
if (gr) setGiteaRepo(gr);
|
||||
if (ghu) setGithubToken(ghu);
|
||||
if (ghown) setGithubOwner(ghown);
|
||||
if (ghrepo) setGithubRepo(ghrepo);
|
||||
if (glu) setGitlabUrl(glu);
|
||||
if (glt) setGitlabToken(glt);
|
||||
if (glo) setGitlabOwner(glo);
|
||||
if (glr) setGitlabRepo(glr);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
async function handleSave() {
|
||||
await Promise.all([
|
||||
SecureStore.setItemAsync(KEYS.INPUT_MODE, inputMode),
|
||||
SecureStore.setItemAsync(KEYS.HOME_VIEW, homeView),
|
||||
SecureStore.setItemAsync(KEYS.AI_ENABLED, String(aiEnabled)),
|
||||
SecureStore.setItemAsync(KEYS.AI_KEY, aiKey),
|
||||
SecureStore.setItemAsync(KEYS.AI_BASE_URL, aiBaseUrl),
|
||||
SecureStore.setItemAsync(KEYS.AI_MODEL, aiModel),
|
||||
SecureStore.setItemAsync(KEYS.TITLE_TEMPLATE, titleTemplate),
|
||||
SecureStore.setItemAsync(KEYS.MD_TEMPLATE, mdTemplate),
|
||||
SecureStore.setItemAsync(KEYS.GIT_PROVIDER, gitProvider),
|
||||
SecureStore.setItemAsync(KEYS.GITEA_URL, giteaUrl),
|
||||
SecureStore.setItemAsync(KEYS.GITEA_TOKEN, giteaToken),
|
||||
SecureStore.setItemAsync(KEYS.GITEA_OWNER, giteaOwner),
|
||||
SecureStore.setItemAsync(KEYS.GITEA_REPO, giteaRepo),
|
||||
SecureStore.setItemAsync(KEYS.GITHUB_TOKEN, githubToken),
|
||||
SecureStore.setItemAsync(KEYS.GITHUB_OWNER, githubOwner),
|
||||
SecureStore.setItemAsync(KEYS.GITHUB_REPO, githubRepo),
|
||||
SecureStore.setItemAsync(KEYS.GITLAB_URL, gitlabUrl),
|
||||
SecureStore.setItemAsync(KEYS.GITLAB_TOKEN, gitlabToken),
|
||||
SecureStore.setItemAsync(KEYS.GITLAB_OWNER, gitlabOwner),
|
||||
SecureStore.setItemAsync(KEYS.GITLAB_REPO, gitlabRepo),
|
||||
]);
|
||||
setSaved(true);
|
||||
setTimeout(() => setSaved(false), 2000);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -213,7 +316,48 @@ export default function SettingsScreen() {
|
||||
]}
|
||||
/>
|
||||
|
||||
<Text style={SECTION_TITLE}>AI (optional)</Text>
|
||||
<Field
|
||||
label="Title Template"
|
||||
value={titleTemplate}
|
||||
onChange={setTitleTemplate}
|
||||
placeholder="INC-001 (leave empty to disable)"
|
||||
/>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: Colors.surface,
|
||||
borderRadius: 8,
|
||||
padding: 10,
|
||||
marginTop: -8,
|
||||
marginBottom: 14,
|
||||
borderLeftWidth: 3,
|
||||
borderLeftColor: Colors.text2,
|
||||
}}
|
||||
>
|
||||
<Text style={{ color: Colors.text2, fontSize: 12, lineHeight: 18 }}>
|
||||
Pre-fills the Title field on new incidents. If the value ends with
|
||||
digits, the number is auto-incremented after each save.{"\n"}
|
||||
e.g. INC-001 → INC-002 → INC-003
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<Text style={SECTION_TITLE}>AI — Root Cause Assistant</Text>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: Colors.surface,
|
||||
borderRadius: 8,
|
||||
padding: 12,
|
||||
marginBottom: 14,
|
||||
borderLeftWidth: 3,
|
||||
borderLeftColor: Colors.text2,
|
||||
}}
|
||||
>
|
||||
<Text style={{ color: Colors.text2, fontSize: 13, lineHeight: 20 }}>
|
||||
When enabled, a button appears on the capture form to suggest a root
|
||||
cause and fix based on the incident title and symptom. Uses any
|
||||
OpenAI-compatible API — set the base URL below to point at a local
|
||||
Ollama instance, or leave empty for OpenAI (api.openai.com).
|
||||
</Text>
|
||||
</View>
|
||||
<ToggleRow
|
||||
label="Enable AI assistance"
|
||||
value={aiEnabled}
|
||||
@@ -221,58 +365,140 @@ export default function SettingsScreen() {
|
||||
/>
|
||||
{aiEnabled && (
|
||||
<>
|
||||
<Text style={LABEL}>API Key</Text>
|
||||
<TextInput
|
||||
style={INPUT}
|
||||
<Field
|
||||
label="API Base URL"
|
||||
value={aiBaseUrl}
|
||||
onChange={setAiBaseUrl}
|
||||
placeholder="http://192.168.x.x:11434/v1 (empty = OpenAI)"
|
||||
url
|
||||
/>
|
||||
<Field
|
||||
label="Model"
|
||||
value={aiModel}
|
||||
onChange={setAiModel}
|
||||
placeholder="gpt-4o-mini or llama3.2"
|
||||
/>
|
||||
<Field
|
||||
label="API Key"
|
||||
value={aiKey}
|
||||
onChangeText={setAiKey}
|
||||
placeholder="sk-..."
|
||||
placeholderTextColor={Colors.textDim}
|
||||
secureTextEntry
|
||||
autoCapitalize="none"
|
||||
onChange={setAiKey}
|
||||
placeholder="sk-... (leave empty for Ollama)"
|
||||
secure
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Text style={SECTION_TITLE}>Gitea</Text>
|
||||
<Text style={LABEL}>Instance URL</Text>
|
||||
<TextInput
|
||||
style={INPUT}
|
||||
<Text style={SECTION_TITLE}>Git Repository</Text>
|
||||
|
||||
<SegmentRow
|
||||
label="Provider"
|
||||
value={gitProvider}
|
||||
onChange={(v) => setGitProvider(v as GitProvider)}
|
||||
options={(["gitea", "github", "gitlab"] as GitProvider[]).map((p) => ({
|
||||
key: p,
|
||||
label: PROVIDER_LABELS[p],
|
||||
}))}
|
||||
/>
|
||||
|
||||
{gitProvider === "gitea" && (
|
||||
<>
|
||||
<Field
|
||||
label="Instance URL"
|
||||
value={giteaUrl}
|
||||
onChangeText={setGiteaUrl}
|
||||
placeholder="https://homegit.gyozamancave.fr"
|
||||
placeholderTextColor={Colors.textDim}
|
||||
autoCapitalize="none"
|
||||
keyboardType="url"
|
||||
onChange={setGiteaUrl}
|
||||
placeholder="https://homegit.example.com"
|
||||
url
|
||||
/>
|
||||
<Text style={LABEL}>Token</Text>
|
||||
<TextInput
|
||||
style={INPUT}
|
||||
<Field
|
||||
label="Token"
|
||||
value={giteaToken}
|
||||
onChangeText={setGiteaToken}
|
||||
onChange={setGiteaToken}
|
||||
placeholder="Bearer token"
|
||||
placeholderTextColor={Colors.textDim}
|
||||
secureTextEntry
|
||||
autoCapitalize="none"
|
||||
secure
|
||||
/>
|
||||
<Text style={LABEL}>Owner</Text>
|
||||
<TextInput
|
||||
style={INPUT}
|
||||
<Field
|
||||
label="Owner"
|
||||
value={giteaOwner}
|
||||
onChangeText={setGiteaOwner}
|
||||
onChange={setGiteaOwner}
|
||||
placeholder="username or org"
|
||||
placeholderTextColor={Colors.textDim}
|
||||
autoCapitalize="none"
|
||||
/>
|
||||
<Text style={LABEL}>Repository</Text>
|
||||
<TextInput
|
||||
style={INPUT}
|
||||
<Field
|
||||
label="Repository"
|
||||
value={giteaRepo}
|
||||
onChangeText={setGiteaRepo}
|
||||
onChange={setGiteaRepo}
|
||||
placeholder="incidents"
|
||||
placeholderTextColor={Colors.textDim}
|
||||
autoCapitalize="none"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{gitProvider === "github" && (
|
||||
<>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: Colors.surface,
|
||||
borderRadius: 8,
|
||||
padding: 12,
|
||||
marginBottom: 14,
|
||||
borderLeftWidth: 3,
|
||||
borderLeftColor: Colors.primary,
|
||||
}}
|
||||
>
|
||||
<Text style={{ color: Colors.text2, fontSize: 13 }}>
|
||||
Uses api.github.com — no instance URL required.
|
||||
</Text>
|
||||
</View>
|
||||
<Field
|
||||
label="Personal Access Token"
|
||||
value={githubToken}
|
||||
onChange={setGithubToken}
|
||||
placeholder="ghp_..."
|
||||
secure
|
||||
/>
|
||||
<Field
|
||||
label="Owner (username or org)"
|
||||
value={githubOwner}
|
||||
onChange={setGithubOwner}
|
||||
placeholder="your-username"
|
||||
/>
|
||||
<Field
|
||||
label="Repository"
|
||||
value={githubRepo}
|
||||
onChange={setGithubRepo}
|
||||
placeholder="incidents"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{gitProvider === "gitlab" && (
|
||||
<>
|
||||
<Field
|
||||
label="Instance URL"
|
||||
value={gitlabUrl}
|
||||
onChange={setGitlabUrl}
|
||||
placeholder="https://gitlab.com"
|
||||
url
|
||||
/>
|
||||
<Field
|
||||
label="Personal Access Token"
|
||||
value={gitlabToken}
|
||||
onChange={setGitlabToken}
|
||||
placeholder="glpat-..."
|
||||
secure
|
||||
/>
|
||||
<Field
|
||||
label="Namespace (user or group)"
|
||||
value={gitlabOwner}
|
||||
onChange={setGitlabOwner}
|
||||
placeholder="your-username"
|
||||
/>
|
||||
<Field
|
||||
label="Repository"
|
||||
value={gitlabRepo}
|
||||
onChange={setGitlabRepo}
|
||||
placeholder="incidents"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Text style={SECTION_TITLE}>Markdown Template</Text>
|
||||
<TextInput
|
||||
@@ -294,7 +520,7 @@ export default function SettingsScreen() {
|
||||
marginTop: 8,
|
||||
}}
|
||||
>
|
||||
<Text style={{ color: "#fff", fontSize: 16, fontWeight: "700" }}>
|
||||
<Text style={{ color: Colors.bg, fontSize: 16, fontWeight: "700" }}>
|
||||
{saved ? "Saved ✓" : "Save Settings"}
|
||||
</Text>
|
||||
</Pressable>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
@@ -77,6 +77,32 @@ info "Running expo prebuild (Android)…"
|
||||
cd "$SCRIPT_DIR"
|
||||
npx expo prebuild --platform android --clean --no-install
|
||||
|
||||
# ─── 4.5. Patch native modules — 16KB page size (Android 15) ──────────────
|
||||
info "Patching native modules for 16KB page size support (Android 15)…"
|
||||
|
||||
WORKLETS_CMAKE="$SCRIPT_DIR/node_modules/react-native-worklets/android/CMakeLists.txt"
|
||||
REANIMATED_CMAKE="$SCRIPT_DIR/node_modules/react-native-reanimated/android/CMakeLists.txt"
|
||||
|
||||
if [ -f "$WORKLETS_CMAKE" ] && ! grep -q "max-page-size" "$WORKLETS_CMAKE"; then
|
||||
printf '\ntarget_link_options(worklets PRIVATE "-Wl,-z,max-page-size=16384")\n' >> "$WORKLETS_CMAKE"
|
||||
info "Patched react-native-worklets for 16KB pages"
|
||||
fi
|
||||
|
||||
if [ -f "$REANIMATED_CMAKE" ] && ! grep -q "max-page-size" "$REANIMATED_CMAKE"; then
|
||||
printf '\ntarget_link_options(reanimated PRIVATE "-Wl,-z,max-page-size=16384")\n' >> "$REANIMATED_CMAKE"
|
||||
info "Patched react-native-reanimated for 16KB pages"
|
||||
fi
|
||||
|
||||
# ─── 4.6. Disable New Architecture (Android 15 compat) ────────────────────
|
||||
GRADLE_PROPS_NEWARCH="$SCRIPT_DIR/android/gradle.properties"
|
||||
if [ -f "$GRADLE_PROPS_NEWARCH" ]; then
|
||||
sed -i 's/^newArchEnabled=true/newArchEnabled=false/' "$GRADLE_PROPS_NEWARCH"
|
||||
if ! grep -q "^newArchEnabled=" "$GRADLE_PROPS_NEWARCH"; then
|
||||
echo "newArchEnabled=false" >> "$GRADLE_PROPS_NEWARCH"
|
||||
fi
|
||||
info "New Architecture disabled in gradle.properties"
|
||||
fi
|
||||
|
||||
# ─── 5. Patch build.gradle — inject release signingConfig ──────────────────
|
||||
info "Patching android/app/build.gradle for release signing…"
|
||||
|
||||
|
||||
+12
-12
@@ -1,16 +1,16 @@
|
||||
export const Colors = {
|
||||
bg: "#0f1117",
|
||||
surface: "#1a1d27",
|
||||
surface2: "#252836",
|
||||
primary: "#6366f1",
|
||||
primaryDim: "#4338ca",
|
||||
success: "#22c55e",
|
||||
warning: "#f59e0b",
|
||||
danger: "#ef4444",
|
||||
text1: "#f1f5f9",
|
||||
text2: "#94a3b8",
|
||||
textDim: "#64748b",
|
||||
border: "#2d3147",
|
||||
bg: "#1B2433",
|
||||
surface: "#222D3D",
|
||||
surface2: "#293648",
|
||||
primary: "#88D656",
|
||||
primaryDim: "#5FA33A",
|
||||
success: "#88D656",
|
||||
warning: "#F5A623",
|
||||
danger: "#EF4444",
|
||||
text1: "#EEF2F5",
|
||||
text2: "#8FA5BF",
|
||||
textDim: "#4E6480",
|
||||
border: "#2E3F55",
|
||||
} as const;
|
||||
|
||||
export const FontFamily = {
|
||||
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
import { incidentToFilename, renderMarkdown } from "./markdown";
|
||||
import type { Incident } from "@/types/incident";
|
||||
|
||||
export type GitProvider = "gitea" | "github" | "gitlab";
|
||||
|
||||
export interface GitConfig {
|
||||
provider: GitProvider;
|
||||
url?: string; // required for gitea and self-hosted gitlab
|
||||
token: string;
|
||||
owner: string;
|
||||
repo: string;
|
||||
}
|
||||
|
||||
export interface PushResult {
|
||||
success: boolean;
|
||||
url?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
const TIMEOUT_MS = 15_000;
|
||||
|
||||
function fetchWithTimeout(url: string, init: RequestInit): Promise<Response> {
|
||||
const controller = new AbortController();
|
||||
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
||||
return fetch(url, { ...init, signal: controller.signal }).finally(() =>
|
||||
clearTimeout(timer)
|
||||
);
|
||||
}
|
||||
|
||||
export async function pushIncidentToGit(
|
||||
incident: Incident,
|
||||
config: GitConfig,
|
||||
markdownTemplate?: string
|
||||
): Promise<PushResult> {
|
||||
switch (config.provider) {
|
||||
case "gitea":
|
||||
return pushGitea(incident, config, markdownTemplate);
|
||||
case "github":
|
||||
return pushGitHub(incident, config, markdownTemplate);
|
||||
case "gitlab":
|
||||
return pushGitLab(incident, config, markdownTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
async function pushGitea(
|
||||
incident: Incident,
|
||||
config: GitConfig,
|
||||
markdownTemplate?: string
|
||||
): Promise<PushResult> {
|
||||
if (!config.url) {
|
||||
return { success: false, error: "Gitea instance URL is not set. Check Settings → Git Repository." };
|
||||
}
|
||||
if (!config.token) {
|
||||
return { success: false, error: "Gitea token is not set. Check Settings → Git Repository." };
|
||||
}
|
||||
if (!config.owner || !config.repo) {
|
||||
return { success: false, error: "Gitea owner or repository is not set. Check Settings → Git Repository." };
|
||||
}
|
||||
|
||||
const filepath = incidentToFilename(incident);
|
||||
const content = renderMarkdown(incident, markdownTemplate);
|
||||
const base64Content = btoa(unescape(encodeURIComponent(content)));
|
||||
const apiBase = config.url.replace(/\/$/, "");
|
||||
const endpoint = `${apiBase}/api/v1/repos/${config.owner}/${config.repo}/contents/${filepath}`;
|
||||
|
||||
try {
|
||||
const existing = await fetchWithTimeout(endpoint, {
|
||||
headers: { Authorization: `token ${config.token}` },
|
||||
});
|
||||
let sha: string | undefined;
|
||||
if (existing.ok) {
|
||||
const data = await existing.json() as { sha?: string };
|
||||
sha = data.sha;
|
||||
} else if (existing.status !== 404) {
|
||||
const body = await existing.text();
|
||||
return { success: false, error: `GET ${existing.status}: ${body.slice(0, 200)}` };
|
||||
}
|
||||
|
||||
const payload: Record<string, string> = {
|
||||
message: `incident: ${incident.title}`,
|
||||
content: base64Content,
|
||||
};
|
||||
if (sha) payload.sha = sha;
|
||||
|
||||
// POST creates, PUT updates — Gitea requires the correct verb
|
||||
const res = await fetchWithTimeout(endpoint, {
|
||||
method: sha ? "PUT" : "POST",
|
||||
headers: {
|
||||
Authorization: `token ${config.token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const body = await res.text();
|
||||
return { success: false, error: `HTTP ${res.status}: ${body.slice(0, 300)}` };
|
||||
}
|
||||
const data = await res.json() as { content?: { html_url?: string } };
|
||||
return { success: true, url: data.content?.html_url };
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.name === "AbortError") {
|
||||
return { success: false, error: `Request timed out after ${TIMEOUT_MS / 1000}s. Check that the Gitea URL is reachable.` };
|
||||
}
|
||||
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
||||
}
|
||||
}
|
||||
|
||||
async function pushGitHub(
|
||||
incident: Incident,
|
||||
config: GitConfig,
|
||||
markdownTemplate?: string
|
||||
): Promise<PushResult> {
|
||||
if (!config.token) {
|
||||
return { success: false, error: "GitHub token is not set. Check Settings → Git Repository." };
|
||||
}
|
||||
if (!config.owner || !config.repo) {
|
||||
return { success: false, error: "GitHub owner or repository is not set. Check Settings → Git Repository." };
|
||||
}
|
||||
|
||||
const filepath = incidentToFilename(incident);
|
||||
const content = renderMarkdown(incident, markdownTemplate);
|
||||
const base64Content = btoa(unescape(encodeURIComponent(content)));
|
||||
const endpoint = `https://api.github.com/repos/${config.owner}/${config.repo}/contents/${filepath}`;
|
||||
|
||||
try {
|
||||
const existing = await fetchWithTimeout(endpoint, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${config.token}`,
|
||||
Accept: "application/vnd.github+json",
|
||||
},
|
||||
});
|
||||
let sha: string | undefined;
|
||||
if (existing.ok) {
|
||||
const data = await existing.json() as { sha?: string };
|
||||
sha = data.sha;
|
||||
} else if (existing.status !== 404) {
|
||||
const body = await existing.text();
|
||||
return { success: false, error: `GET ${existing.status}: ${body.slice(0, 200)}` };
|
||||
}
|
||||
|
||||
const payload: Record<string, string> = {
|
||||
message: `incident: ${incident.title}`,
|
||||
content: base64Content,
|
||||
};
|
||||
if (sha) payload.sha = sha;
|
||||
|
||||
const res = await fetchWithTimeout(endpoint, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
Authorization: `Bearer ${config.token}`,
|
||||
Accept: "application/vnd.github+json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const body = await res.text();
|
||||
return { success: false, error: `HTTP ${res.status}: ${body.slice(0, 300)}` };
|
||||
}
|
||||
const data = await res.json() as { content?: { html_url?: string } };
|
||||
return { success: true, url: data.content?.html_url };
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.name === "AbortError") {
|
||||
return { success: false, error: `Request timed out after ${TIMEOUT_MS / 1000}s.` };
|
||||
}
|
||||
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
||||
}
|
||||
}
|
||||
|
||||
async function pushGitLab(
|
||||
incident: Incident,
|
||||
config: GitConfig,
|
||||
markdownTemplate?: string
|
||||
): Promise<PushResult> {
|
||||
if (!config.token) {
|
||||
return { success: false, error: "GitLab token is not set. Check Settings → Git Repository." };
|
||||
}
|
||||
if (!config.owner || !config.repo) {
|
||||
return { success: false, error: "GitLab namespace or repository is not set. Check Settings → Git Repository." };
|
||||
}
|
||||
|
||||
const filepath = incidentToFilename(incident);
|
||||
const content = renderMarkdown(incident, markdownTemplate);
|
||||
const base64Content = btoa(unescape(encodeURIComponent(content)));
|
||||
const apiBase = (config.url ?? "https://gitlab.com").replace(/\/$/, "");
|
||||
const projectId = encodeURIComponent(`${config.owner}/${config.repo}`);
|
||||
const encodedPath = encodeURIComponent(filepath);
|
||||
const endpoint = `${apiBase}/api/v4/projects/${projectId}/repository/files/${encodedPath}`;
|
||||
|
||||
try {
|
||||
const existing = await fetchWithTimeout(`${endpoint}?ref=HEAD`, {
|
||||
headers: { "PRIVATE-TOKEN": config.token },
|
||||
});
|
||||
const method = existing.ok ? "PUT" : "POST";
|
||||
|
||||
const res = await fetchWithTimeout(endpoint, {
|
||||
method,
|
||||
headers: {
|
||||
"PRIVATE-TOKEN": config.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
branch: "main",
|
||||
content: base64Content,
|
||||
encoding: "base64",
|
||||
commit_message: `incident: ${incident.title}`,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const body = await res.text();
|
||||
return { success: false, error: `HTTP ${res.status}: ${body.slice(0, 300)}` };
|
||||
}
|
||||
const data = await res.json() as { file_path?: string };
|
||||
const webUrl = data.file_path
|
||||
? `${apiBase}/${config.owner}/${config.repo}/-/blob/main/${data.file_path}`
|
||||
: undefined;
|
||||
return { success: true, url: webUrl };
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.name === "AbortError") {
|
||||
return { success: false, error: `Request timed out after ${TIMEOUT_MS / 1000}s.` };
|
||||
}
|
||||
return { success: false, error: e instanceof Error ? e.message : String(e) };
|
||||
}
|
||||
}
|
||||
Generated
+129
-143
@@ -19,7 +19,7 @@
|
||||
"expo-sqlite": "~56.0.5",
|
||||
"expo-status-bar": "~56.0.4",
|
||||
"nativewind": "~4.2.5",
|
||||
"react": "19.2.7",
|
||||
"react": "19.2.3",
|
||||
"react-native": "0.85.3",
|
||||
"react-native-gesture-handler": "~3.0.2",
|
||||
"react-native-reanimated": "~4.4.1",
|
||||
@@ -1154,99 +1154,6 @@
|
||||
"integrity": "sha512-IJkBtN1o8u9BW5fvSii1MyHPQ7Q0HxbWcVBvOrOzgMLpVtZw7R2w94wBTVR7kZwv3w1JNTESMmLA5Sqn1+Z36A==",
|
||||
"license": "MIT AND Apache-2.0"
|
||||
},
|
||||
"node_modules/@expo/cli": {
|
||||
"version": "56.1.16",
|
||||
"resolved": "https://registry.npmjs.org/@expo/cli/-/cli-56.1.16.tgz",
|
||||
"integrity": "sha512-VBQn0mqAwc67b9Cn0RVXyeodghomAx5xGRhA/bXaQzuxDjMQk0zIOb6pXMZX7yiIwJW66UZt/zQiJNSv6aWJYw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@expo/code-signing-certificates": "^0.0.6",
|
||||
"@expo/config": "~56.0.9",
|
||||
"@expo/config-plugins": "~56.0.9",
|
||||
"@expo/devcert": "^1.2.1",
|
||||
"@expo/env": "~2.3.0",
|
||||
"@expo/image-utils": "^0.10.1",
|
||||
"@expo/inline-modules": "^0.0.12",
|
||||
"@expo/json-file": "^10.2.0",
|
||||
"@expo/log-box": "^56.0.13",
|
||||
"@expo/metro": "~56.0.0",
|
||||
"@expo/metro-config": "~56.0.14",
|
||||
"@expo/metro-file-map": "^56.0.3",
|
||||
"@expo/osascript": "^2.6.0",
|
||||
"@expo/package-manager": "^1.12.1",
|
||||
"@expo/plist": "^0.7.0",
|
||||
"@expo/prebuild-config": "^56.0.16",
|
||||
"@expo/require-utils": "^56.1.3",
|
||||
"@expo/router-server": "^56.0.14",
|
||||
"@expo/schema-utils": "^56.0.0",
|
||||
"@expo/spawn-async": "^1.8.0",
|
||||
"@expo/ws-tunnel": "^2.0.0",
|
||||
"@expo/xcpretty": "^4.4.4",
|
||||
"@react-native/dev-middleware": "0.85.3",
|
||||
"accepts": "^1.3.8",
|
||||
"arg": "^5.0.2",
|
||||
"bplist-creator": "0.1.0",
|
||||
"bplist-parser": "^0.3.1",
|
||||
"chalk": "^4.0.0",
|
||||
"ci-info": "^3.3.0",
|
||||
"compression": "^1.7.4",
|
||||
"connect": "^3.7.0",
|
||||
"debug": "^4.3.4",
|
||||
"dnssd-advertise": "^1.1.4",
|
||||
"expo-server": "^56.0.5",
|
||||
"fetch-nodeshim": "^0.4.10",
|
||||
"getenv": "^2.0.0",
|
||||
"glob": "^13.0.0",
|
||||
"lan-network": "^0.2.1",
|
||||
"multitars": "^1.0.0",
|
||||
"node-forge": "^1.3.3",
|
||||
"npm-package-arg": "^11.0.0",
|
||||
"ora": "^3.4.0",
|
||||
"picomatch": "^4.0.4",
|
||||
"pretty-format": "^29.7.0",
|
||||
"progress": "^2.0.3",
|
||||
"prompts": "^2.3.2",
|
||||
"resolve-from": "^5.0.0",
|
||||
"semver": "^7.6.0",
|
||||
"send": "^0.19.0",
|
||||
"slugify": "^1.3.4",
|
||||
"stacktrace-parser": "^0.1.10",
|
||||
"structured-headers": "^0.4.1",
|
||||
"terminal-link": "^2.1.1",
|
||||
"toqr": "^0.1.1",
|
||||
"wrap-ansi": "^7.0.0",
|
||||
"ws": "^8.12.1",
|
||||
"zod": "^3.25.76"
|
||||
},
|
||||
"bin": {
|
||||
"expo-internal": "main.js"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"expo": "*",
|
||||
"expo-router": "*",
|
||||
"react-native": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"expo-router": {
|
||||
"optional": true
|
||||
},
|
||||
"react-native": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@expo/cli/node_modules/semver": {
|
||||
"version": "7.8.4",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz",
|
||||
"integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@expo/code-signing-certificates": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@expo/code-signing-certificates/-/code-signing-certificates-0.0.6.tgz",
|
||||
@@ -1659,9 +1566,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@expo/prebuild-config/node_modules/semver": {
|
||||
"version": "7.8.4",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz",
|
||||
"integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==",
|
||||
"version": "7.8.5",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
@@ -1689,40 +1596,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@expo/router-server": {
|
||||
"version": "56.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@expo/router-server/-/router-server-56.0.14.tgz",
|
||||
"integrity": "sha512-2UCTtZfcq1ZPgp3wk8/+sq9DvFI9UxrPr1jcEKMAF2DGAJLosnpc8GWNNg2hkjt6SHUOdFHIPxujWPYyho2y3A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@expo/metro-runtime": "^56.0.15",
|
||||
"expo": "*",
|
||||
"expo-constants": "^56.0.18",
|
||||
"expo-font": "^56.0.6",
|
||||
"expo-router": "*",
|
||||
"expo-server": "^56.0.5",
|
||||
"react": "*",
|
||||
"react-dom": "*",
|
||||
"react-server-dom-webpack": "~19.0.1 || ~19.1.2 || ~19.2.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@expo/metro-runtime": {
|
||||
"optional": true
|
||||
},
|
||||
"expo-router": {
|
||||
"optional": true
|
||||
},
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"react-server-dom-webpack": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@expo/schema-utils": {
|
||||
"version": "56.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@expo/schema-utils/-/schema-utils-56.0.1.tgz",
|
||||
@@ -4306,6 +4179,121 @@
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo/node_modules/@expo/cli": {
|
||||
"version": "56.1.16",
|
||||
"resolved": "https://registry.npmjs.org/@expo/cli/-/cli-56.1.16.tgz",
|
||||
"integrity": "sha512-VBQn0mqAwc67b9Cn0RVXyeodghomAx5xGRhA/bXaQzuxDjMQk0zIOb6pXMZX7yiIwJW66UZt/zQiJNSv6aWJYw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@expo/code-signing-certificates": "^0.0.6",
|
||||
"@expo/config": "~56.0.9",
|
||||
"@expo/config-plugins": "~56.0.9",
|
||||
"@expo/devcert": "^1.2.1",
|
||||
"@expo/env": "~2.3.0",
|
||||
"@expo/image-utils": "^0.10.1",
|
||||
"@expo/inline-modules": "^0.0.12",
|
||||
"@expo/json-file": "^10.2.0",
|
||||
"@expo/log-box": "^56.0.13",
|
||||
"@expo/metro": "~56.0.0",
|
||||
"@expo/metro-config": "~56.0.14",
|
||||
"@expo/metro-file-map": "^56.0.3",
|
||||
"@expo/osascript": "^2.6.0",
|
||||
"@expo/package-manager": "^1.12.1",
|
||||
"@expo/plist": "^0.7.0",
|
||||
"@expo/prebuild-config": "^56.0.16",
|
||||
"@expo/require-utils": "^56.1.3",
|
||||
"@expo/router-server": "^56.0.14",
|
||||
"@expo/schema-utils": "^56.0.0",
|
||||
"@expo/spawn-async": "^1.8.0",
|
||||
"@expo/ws-tunnel": "^2.0.0",
|
||||
"@expo/xcpretty": "^4.4.4",
|
||||
"@react-native/dev-middleware": "0.85.3",
|
||||
"accepts": "^1.3.8",
|
||||
"arg": "^5.0.2",
|
||||
"bplist-creator": "0.1.0",
|
||||
"bplist-parser": "^0.3.1",
|
||||
"chalk": "^4.0.0",
|
||||
"ci-info": "^3.3.0",
|
||||
"compression": "^1.7.4",
|
||||
"connect": "^3.7.0",
|
||||
"debug": "^4.3.4",
|
||||
"dnssd-advertise": "^1.1.4",
|
||||
"expo-server": "^56.0.5",
|
||||
"fetch-nodeshim": "^0.4.10",
|
||||
"getenv": "^2.0.0",
|
||||
"glob": "^13.0.0",
|
||||
"lan-network": "^0.2.1",
|
||||
"multitars": "^1.0.0",
|
||||
"node-forge": "^1.3.3",
|
||||
"npm-package-arg": "^11.0.0",
|
||||
"ora": "^3.4.0",
|
||||
"picomatch": "^4.0.4",
|
||||
"pretty-format": "^29.7.0",
|
||||
"progress": "^2.0.3",
|
||||
"prompts": "^2.3.2",
|
||||
"resolve-from": "^5.0.0",
|
||||
"semver": "^7.6.0",
|
||||
"send": "^0.19.0",
|
||||
"slugify": "^1.3.4",
|
||||
"stacktrace-parser": "^0.1.10",
|
||||
"structured-headers": "^0.4.1",
|
||||
"terminal-link": "^2.1.1",
|
||||
"toqr": "^0.1.1",
|
||||
"wrap-ansi": "^7.0.0",
|
||||
"ws": "^8.12.1",
|
||||
"zod": "^3.25.76"
|
||||
},
|
||||
"bin": {
|
||||
"expo-internal": "main.js"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"expo": "*",
|
||||
"expo-router": "*",
|
||||
"react-native": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"expo-router": {
|
||||
"optional": true
|
||||
},
|
||||
"react-native": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/expo/node_modules/@expo/cli/node_modules/@expo/router-server": {
|
||||
"version": "56.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@expo/router-server/-/router-server-56.0.14.tgz",
|
||||
"integrity": "sha512-2UCTtZfcq1ZPgp3wk8/+sq9DvFI9UxrPr1jcEKMAF2DGAJLosnpc8GWNNg2hkjt6SHUOdFHIPxujWPYyho2y3A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@expo/metro-runtime": "^56.0.15",
|
||||
"expo": "*",
|
||||
"expo-constants": "^56.0.18",
|
||||
"expo-font": "^56.0.6",
|
||||
"expo-router": "*",
|
||||
"expo-server": "^56.0.5",
|
||||
"react": "*",
|
||||
"react-dom": "*",
|
||||
"react-server-dom-webpack": "~19.0.1 || ~19.1.2 || ~19.2.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@expo/metro-runtime": {
|
||||
"optional": true
|
||||
},
|
||||
"expo-router": {
|
||||
"optional": true
|
||||
},
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"react-server-dom-webpack": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/expo/node_modules/expo-modules-core": {
|
||||
"version": "56.0.17",
|
||||
"resolved": "https://registry.npmjs.org/expo-modules-core/-/expo-modules-core-56.0.17.tgz",
|
||||
@@ -4359,8 +4347,6 @@
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz",
|
||||
"integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==",
|
||||
"license": "ISC",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
@@ -6124,9 +6110,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/npm-package-arg/node_modules/semver": {
|
||||
"version": "7.8.4",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz",
|
||||
"integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==",
|
||||
"version": "7.8.5",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
@@ -6722,9 +6708,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react": {
|
||||
"version": "19.2.7",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz",
|
||||
"integrity": "sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==",
|
||||
"version": "19.2.3",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz",
|
||||
"integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
@@ -6762,16 +6748,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-dom": {
|
||||
"version": "19.2.7",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.7.tgz",
|
||||
"integrity": "sha512-t0BRVXvbiE/o20Hfw669rLbMCDWtYZLvmJigy2f0MxsXF+71pxhR3xOkspmsO8h3ZlNzyibAmtCa3l4lYKk6gQ==",
|
||||
"version": "19.2.3",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz",
|
||||
"integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"scheduler": "^0.27.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^19.2.7"
|
||||
"react": "^19.2.3"
|
||||
}
|
||||
},
|
||||
"node_modules/react-fast-compare": {
|
||||
|
||||
+5
-1
@@ -19,7 +19,7 @@
|
||||
"expo-sqlite": "~56.0.5",
|
||||
"expo-status-bar": "~56.0.4",
|
||||
"nativewind": "~4.2.5",
|
||||
"react": "19.2.7",
|
||||
"react": "19.2.3",
|
||||
"react-native": "0.85.3",
|
||||
"react-native-gesture-handler": "~3.0.2",
|
||||
"react-native-reanimated": "~4.4.1",
|
||||
@@ -27,6 +27,10 @@
|
||||
"react-native-screens": "~4.25.2",
|
||||
"tailwindcss": "~3.4.19"
|
||||
},
|
||||
"overrides": {
|
||||
"react": "19.2.3",
|
||||
"react-dom": "19.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.0",
|
||||
"@expo/metro-config": "~56.0.14",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Exclude native build for packages not used in this project.
|
||||
// react-native-gesture-handler detects their absence and falls back to its
|
||||
// noreanimated codepath, so GestureHandlerRootView continues to work.
|
||||
module.exports = {
|
||||
dependencies: {
|
||||
'react-native-reanimated': {
|
||||
platforms: { android: null },
|
||||
},
|
||||
'react-native-worklets': {
|
||||
platforms: { android: null },
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user