|
4 | 4 | isInstallableDesktopModule, |
5 | 5 | isDesktopKitPackage, |
6 | 6 | shortName, |
7 | | - getPackagesRequiredByTheme |
| 7 | + getPackagesRequiredByTheme, |
| 8 | + findMissingWorkspaceDependencies, |
8 | 9 | } from './workspace.js' |
9 | 10 | import { |
10 | 11 | readDesktopConfig, |
@@ -275,6 +276,42 @@ export async function executeInstallPlan(ctx) { |
275 | 276 | } |
276 | 277 | } |
277 | 278 |
|
| 279 | + // Detect and clone any missing workspace:* dependencies recursively |
| 280 | + let missingWorkspaceDeps = findMissingWorkspaceDependencies(workspaceRoot) |
| 281 | + const autoClonedDeps = new Set() |
| 282 | + |
| 283 | + while (missingWorkspaceDeps.length > 0) { |
| 284 | + const dep = missingWorkspaceDeps.shift() |
| 285 | + if (autoClonedDeps.has(dep)) continue |
| 286 | + autoClonedDeps.add(dep) |
| 287 | + |
| 288 | + bump(`Cloning dependency ${shortName(dep)}…`) |
| 289 | + ctx.clearLogs() |
| 290 | + |
| 291 | + try { |
| 292 | + const plan = await resolveInstallPlan(dep, settings, workspaceRoot) |
| 293 | + if (plan.error) { |
| 294 | + throw new Error(plan.error) |
| 295 | + } |
| 296 | + if (plan.targetDir && plan.source?.gitUrl) { |
| 297 | + await cloneRepo(plan.targetDir, plan.source.gitUrl, undefined, workspaceRoot, { quiet: true }) |
| 298 | + didClone = true |
| 299 | + clonedPackages.push(dep) |
| 300 | + const newMissing = findMissingWorkspaceDependencies(workspaceRoot) |
| 301 | + for (const m of newMissing) { |
| 302 | + if (!autoClonedDeps.has(m) && !missingWorkspaceDeps.includes(m)) { |
| 303 | + missingWorkspaceDeps.push(m) |
| 304 | + } |
| 305 | + } |
| 306 | + } else { |
| 307 | + throw new Error('Unknown git clone URL') |
| 308 | + } |
| 309 | + } catch (err) { |
| 310 | + const msg = err.message?.split('\n').find(l => l.trim()) ?? String(err) |
| 311 | + failures.push({ pkg: dep, error: `Failed to resolve workspace dependency ${shortName(dep)}: ${msg}` }) |
| 312 | + } |
| 313 | + } |
| 314 | + |
278 | 315 | if (didClone) { |
279 | 316 | bump('Installing dependencies…') |
280 | 317 | ctx.clearLogs() |
@@ -597,6 +634,43 @@ export async function runStartupInstallFlow(ctx, { isStartup = false } = {}) { |
597 | 634 | } |
598 | 635 | } |
599 | 636 |
|
| 637 | + // Detect and clone any missing workspace:* dependencies recursively |
| 638 | + let missingWorkspaceDeps = findMissingWorkspaceDependencies(workspaceRoot) |
| 639 | + const autoClonedDeps = new Set() |
| 640 | + |
| 641 | + while (missingWorkspaceDeps.length > 0) { |
| 642 | + const dep = missingWorkspaceDeps.shift() |
| 643 | + if (autoClonedDeps.has(dep)) continue |
| 644 | + autoClonedDeps.add(dep) |
| 645 | + |
| 646 | + bump(`Cloning dependency ${shortName(dep)}…`) |
| 647 | + ctx.clearLogs() |
| 648 | + |
| 649 | + try { |
| 650 | + const plan = await resolveInstallPlan(dep, settings, workspaceRoot) |
| 651 | + if (plan.error) { |
| 652 | + throw new Error(plan.error) |
| 653 | + } |
| 654 | + if (plan.targetDir && plan.source?.gitUrl) { |
| 655 | + await cloneRepo(plan.targetDir, plan.source.gitUrl, undefined, workspaceRoot, { quiet: true }) |
| 656 | + didClone = true |
| 657 | + allCloned.push(dep) |
| 658 | + const newMissing = findMissingWorkspaceDependencies(workspaceRoot) |
| 659 | + for (const m of newMissing) { |
| 660 | + if (!autoClonedDeps.has(m) && !missingWorkspaceDeps.includes(m)) { |
| 661 | + missingWorkspaceDeps.push(m) |
| 662 | + } |
| 663 | + } |
| 664 | + } else { |
| 665 | + throw new Error('Unknown git clone URL') |
| 666 | + } |
| 667 | + } catch (err) { |
| 668 | + const msg = err.message?.split('\n').find(l => l.trim()) ?? String(err) |
| 669 | + ctx.setStatus(`Failed to resolve workspace dependency ${shortName(dep)}: ${msg}`, 'error') |
| 670 | + ctx.screen.render() |
| 671 | + } |
| 672 | + } |
| 673 | + |
600 | 674 | if (didClone) { |
601 | 675 | if (!ctx.isInstalling()) { |
602 | 676 | dynTotal += 1 + allCloned.length + 1 |
|
0 commit comments