// rnx storage profile — manage isolated app storage profiles. import { clearProfileStorage, createProfile, deleteProfile, ensureProfile, listProfiles, } from '../../src/profiles' interface ProfileOptions { port?: number verbose?: boolean } function printHelp() { console.log(` rnx storage profile — manage isolated storage profiles usage: rnx storage profile list rnx storage profile create rnx storage profile clear rnx storage profile delete profiles isolate cookies, localStorage, IndexedDB, cache, permissions, and service workers in Electron and Playwright launches. Plain browser-tab launches cannot honor profiles and will fail clearly if a profile is requested. examples: rnx storage profile list rnx storage profile create qa rnx open 8081 --profile qa rnx open 8081 --profile qa --driver playwright rnx storage profile clear qa rnx storage profile delete qa `) } export async function runProfile(args: string[], _opts: ProfileOptions): Promise { if (args.includes('--help') || args.includes('-h')) { printHelp() return 0 } const subcommand = args[0] ?? 'list' try { switch (subcommand) { case 'list': { const profiles = listProfiles() for (const profile of profiles) { console.log(` ${profile.id}`) } return 0 } case 'create': { const id = args[1] if (!id) { console.error(' profile create expects ') return 1 } const profile = createProfile(id) console.log(` created profile: ${profile.id}`) return 0 } case 'ensure': { const id = args[1] if (!id) { console.error(' profile ensure expects ') return 1 } const profile = ensureProfile(id) console.log(` profile: ${profile.id}`) return 0 } case 'clear': { const id = args[1] if (!id) { console.error(' profile clear expects ') return 1 } ensureProfile(id) clearProfileStorage(id) console.log(` cleared profile: ${id}`) return 0 } case 'delete': { const id = args[1] if (!id) { console.error(' profile delete expects ') return 1 } const profile = deleteProfile(id) console.log(` deleted profile: ${profile.id}`) return 0 } default: console.error(` unknown profile command: ${subcommand}`) printHelp() return 1 } } catch (err) { console.error(` profile failed: ${err instanceof Error ? err.message : String(err)}`) return 1 } }