Team Ai
Apppublic

delqhi/sin-github-issues

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
state.ts34 linesDownload Raw Back to src
1import { mkdir, readFile, writeFile } from 'node:fs/promises';2import { dirname, join } from 'node:path';3import { homedir } from 'node:os';4 5export const DEFAULT_STATE_PATH = join(homedir(), '.config', 'sin', 'sin-github-issues', 'onboarding-state.json');6 7export type OnboardingState = {8  ownerEmail?: string;9  notes?: string;10  defaultRepo?: string;11  browserProfileEmail?: string;12  browserProfileDirectory?: string;13  updatedAt?: string;14};15 16export async function readState(): Promise<OnboardingState | null> {17  try {18    return JSON.parse(await readFile(DEFAULT_STATE_PATH, 'utf8')) as OnboardingState;19  } catch {20    return null;21  }22}23 24export async function writeState(state: OnboardingState) {25  await mkdir(dirname(DEFAULT_STATE_PATH), { recursive: true });26  await writeFile(DEFAULT_STATE_PATH, `${JSON.stringify(state, null, 2)}\n`, 'utf8');27  return state;28}29 30export function clean(value: string | undefined) {31  const normalized = String(value || '').trim();32  return normalized || undefined;33}34