(
id: string,
options: { healthyRoot?: boolean; metadataId?: string | null } = {}
)
| 53 | } |
| 54 | |
| 55 | async function registerStore( |
| 56 | id: string, |
| 57 | options: { healthyRoot?: boolean; metadataId?: string | null } = {} |
| 58 | ): Promise<string> { |
| 59 | const storeRoot = mkdir(`stores/${id}`); |
| 60 | if (options.healthyRoot !== false) { |
| 61 | createOpenSpecRoot(storeRoot); |
| 62 | } |
| 63 | if (options.metadataId !== null) { |
| 64 | await writeStoreMetadataState(storeRoot, { |
| 65 | version: 1, |
| 66 | id: options.metadataId ?? id, |
| 67 | }); |
| 68 | } |
| 69 | |
| 70 | const existing = fs.existsSync(path.join(globalDataDir, 'stores', 'registry.yaml')); |
| 71 | const registryStores = existing |
| 72 | ? (await import('../../src/core/store/foundation.js').then((m) => |
| 73 | m.readStoreRegistryState({ globalDataDir }) |
| 74 | ))?.stores ?? {} |
| 75 | : {}; |
| 76 | |
| 77 | await writeStoreRegistryState( |
| 78 | { |
| 79 | version: 1, |
| 80 | stores: { |
| 81 | ...registryStores, |
| 82 | [id]: { backend: { type: 'git', local_path: storeRoot } }, |
| 83 | }, |
| 84 | }, |
| 85 | { globalDataDir } |
| 86 | ); |
| 87 | |
| 88 | return storeRoot; |
| 89 | } |
| 90 | |
| 91 | async function expectRootSelectionError( |
| 92 | promise: Promise<unknown>, |
no test coverage detected