import { i18n } from '../i18n' import { sdk } from '../sdk' import { dataDir, EXPLORER_DIR } from '../utils' export const resetExplorerState = sdk.Action.withoutInput( // id 'reset-explorer-state', // metadata async ({ effects }) => ({ name: i18n('Reset Explorer UI State'), description: i18n( 'Wipe /data/explorer-ui so the next start re-fetches the explorer source and rebuilds it from scratch.', ), warning: i18n( 'This deletes the cached explorer source and the built SvelteKit bundle. The next start will need internet access to re-download from GitHub and to fetch npm dependencies. PostgreSQL data is preserved.', ), allowedStatuses: 'any', group: null, visibility: 'enabled', }), // run async ({ effects }) => { const res = await sdk.SubContainer.withTemp( effects, { imageId: 'explorer-ui' }, sdk.Mounts.of().mountVolume({ volumeId: 'main', subpath: null, mountpoint: dataDir, readonly: false, }), 'spaces-reset-explorer', (subc) => subc.exec(['rm', '-rf', EXPLORER_DIR], { user: 'root' }), ) if (res.exitCode !== 0) { return { version: '1', title: i18n('Failure'), message: i18n('Could not wipe explorer state: ${error}', { error: (res.stderr ?? '').toString() || `exit ${res.exitCode}`, }), result: null, } } return { version: '1', title: i18n('Success'), message: i18n( 'Explorer cache has been wiped. Start (or restart) the service to re-fetch and rebuild from GitHub.', ), result: null, } }, )