(
id: string,
options: { healthyRoot?: boolean; metadataId?: string | null } = {}
)
| 49 | } |
| 50 | |
| 51 | async function registerStore( |
| 52 | id: string, |
| 53 | options: { healthyRoot?: boolean; metadataId?: string | null } = {} |
| 54 | ): Promise<string> { |
| 55 | const storeRoot = mkdir(`stores/${id}`); |
| 56 | if (options.healthyRoot !== false) { |
| 57 | createOpenSpecRoot(storeRoot); |
| 58 | } |
| 59 | if (options.metadataId !== null) { |
| 60 | await writeStoreMetadataState(storeRoot, { |
| 61 | version: 1, |
| 62 | id: options.metadataId ?? id, |
| 63 | }); |
| 64 | } |
| 65 | |
| 66 | const existing = await readStoreRegistryState({ globalDataDir }).catch(() => null); |
| 67 | await writeStoreRegistryState( |
| 68 | { |
| 69 | version: 1, |
| 70 | stores: { |
| 71 | ...(existing?.stores ?? {}), |
| 72 | [id]: { backend: { type: 'git', local_path: storeRoot } }, |
| 73 | }, |
| 74 | }, |
| 75 | { globalDataDir } |
| 76 | ); |
| 77 | |
| 78 | return storeRoot; |
| 79 | } |
| 80 | |
| 81 | function appRoot(): ResolvedOpenSpecRoot { |
| 82 | const rootDir = mkdir('app-repo'); |
no test coverage detected