(targetPath: string, options: InitOptions = {})
| 281 | } |
| 282 | |
| 283 | export async function initCommand(targetPath: string, options: InitOptions = {}): Promise<void> { |
| 284 | const projectPath = path.resolve(targetPath); |
| 285 | const log = options.json ? () => undefined : console.log; |
| 286 | |
| 287 | log(`\n${COMET_BANNER}\n`); |
| 288 | if (!options.json) { |
| 289 | await printVersionInfo(log); |
| 290 | } |
| 291 | |
| 292 | const language = await selectLanguage(options); |
| 293 | const lang = language.id; |
| 294 | |
| 295 | log(` ${t(lang, 'settingUp')} ${projectPath}\n`); |
| 296 | |
| 297 | const detected = await detectPlatforms(projectPath); |
| 298 | const scope = await selectScope(options, lang); |
| 299 | |
| 300 | const selectedPlatformIds = await selectPlatforms(detected, options, lang); |
| 301 | if (selectedPlatformIds.length === 0) { |
| 302 | if (options.json) { |
| 303 | console.log( |
| 304 | JSON.stringify( |
| 305 | { |
| 306 | projectPath, |
| 307 | scope, |
| 308 | language: language.id, |
| 309 | selectedPlatforms: [], |
| 310 | results: [], |
| 311 | }, |
| 312 | null, |
| 313 | 2, |
| 314 | ), |
| 315 | ); |
| 316 | return; |
| 317 | } |
| 318 | log(`\n ${t(lang, 'noPlatforms')}\n`); |
| 319 | return; |
| 320 | } |
| 321 | |
| 322 | const selectedPlatforms = PLATFORMS.filter((p) => selectedPlatformIds.includes(p.id)); |
| 323 | const baseDir = getBaseDir(scope, projectPath); |
| 324 | |
| 325 | type PlatformPlan = ComponentPlan & { |
| 326 | platform: Platform; |
| 327 | hasOS: boolean; |
| 328 | hasSP: boolean; |
| 329 | hasCM: boolean; |
| 330 | }; |
| 331 | |
| 332 | const plans: PlatformPlan[] = []; |
| 333 | |
| 334 | for (const platform of selectedPlatforms) { |
| 335 | const hasOS = await hasSkills(baseDir, platform, 'openspec', selectedPlatforms, scope); |
| 336 | const hasSP = await hasSkills(baseDir, platform, 'superpowers', selectedPlatforms, scope); |
| 337 | const hasCM = await hasSkills(baseDir, platform, 'comet', selectedPlatforms, scope); |
| 338 | |
| 339 | let osAction = resolveAction(hasOS, options); |
| 340 | let spAction = resolveAction(hasSP, options); |
no test coverage detected