( projectPath: string, scope: InstallScope, platformIds: string[], shouldInstall = true, )
| 136 | } |
| 137 | |
| 138 | async function installSuperpowersForPlatforms( |
| 139 | projectPath: string, |
| 140 | scope: InstallScope, |
| 141 | platformIds: string[], |
| 142 | shouldInstall = true, |
| 143 | ): Promise<'installed' | 'failed' | 'skipped'> { |
| 144 | if (!shouldInstall) { |
| 145 | return 'skipped'; |
| 146 | } |
| 147 | |
| 148 | const unknownIds = platformIds.filter((id) => !VALID_PLATFORM_IDS.has(id)); |
| 149 | if (unknownIds.length > 0) { |
| 150 | throw new Error(`Unknown platform IDs: ${unknownIds.join(', ')}`); |
| 151 | } |
| 152 | |
| 153 | const skillsCliPlatformIds = platformIds.filter((id) => SKILLS_AGENT_MAP[id]); |
| 154 | const shouldInstallLingma = platformIds.includes(LINGMA_PLATFORM_ID); |
| 155 | let failed = false; |
| 156 | |
| 157 | if (skillsCliPlatformIds.length > 0) { |
| 158 | const command = buildSuperpowersInstallCommand(projectPath, scope, skillsCliPlatformIds); |
| 159 | |
| 160 | try { |
| 161 | execFileSync(command.command, command.args, { |
| 162 | cwd: projectPath, |
| 163 | stdio: 'inherit', |
| 164 | timeout: SUPERPOWERS_INSTALL_TIMEOUT_MS, |
| 165 | shell: process.platform === 'win32', |
| 166 | }); |
| 167 | } catch (error) { |
| 168 | console.error(` Superpowers install failed: ${(error as Error).message}`); |
| 169 | printCommandErrorDetails(error); |
| 170 | failed = true; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | if (shouldInstallLingma) { |
| 175 | const lingmaStatus = await installSuperpowersForLingma(projectPath, scope); |
| 176 | if (lingmaStatus === 'failed') failed = true; |
| 177 | } |
| 178 | |
| 179 | return failed ? 'failed' : 'installed'; |
| 180 | } |
| 181 | |
| 182 | export { |
| 183 | installSuperpowersForPlatforms, |
no test coverage detected