()
| 261 | } |
| 262 | |
| 263 | export async function installRaycastExtension(): Promise<RaycastExtensionStatus> { |
| 264 | const status = await getRaycastExtensionStatus() |
| 265 | if (!status.available) { |
| 266 | throw new Error(status.reason ?? 'Raycast extension installation is unavailable.') |
| 267 | } |
| 268 | if (!status.sourcePath || !status.nodePath || !status.npmPath) { |
| 269 | throw new Error('Raycast extension installation is missing its source or toolchain.') |
| 270 | } |
| 271 | |
| 272 | const env = buildCommandEnv({ nodePath: status.nodePath, npmPath: status.npmPath }) |
| 273 | await copyRaycastExtensionSource(status.sourcePath, status.extensionPath) |
| 274 | await runCommand( |
| 275 | status.npmPath, |
| 276 | ['ci', '--include=dev'], |
| 277 | status.extensionPath, |
| 278 | env, |
| 279 | 'Installing Raycast extension dependencies' |
| 280 | ) |
| 281 | await runCommand( |
| 282 | status.npmPath, |
| 283 | ['run', 'build', '--', '--non-interactive'], |
| 284 | status.extensionPath, |
| 285 | env, |
| 286 | 'Building the Raycast extension' |
| 287 | ) |
| 288 | await runRaycastDevelopmentImport(status.npmPath, status.extensionPath, env) |
| 289 | await writeInstallMarker(status.extensionPath, status.bundledVersion) |
| 290 | await shell.openExternal('raycast://extensions').catch(() => undefined) |
| 291 | |
| 292 | return await getRaycastExtensionStatus() |
| 293 | } |
| 294 | |
| 295 | async function copyRaycastExtensionSource(sourcePath: string, extensionPath: string): Promise<void> { |
| 296 | await fsp.rm(extensionPath, { recursive: true, force: true }) |
no test coverage detected