|
92 | 92 | - name: Ensure CLI dependencies |
93 | 93 | run: bun install --frozen-lockfile --cwd cli |
94 | 94 |
|
| 95 | + - name: Fix OpenTUI module symlinks |
| 96 | + shell: bash |
| 97 | + run: | |
| 98 | + set -euo pipefail |
| 99 | + node <<'NODE' |
| 100 | + import fs from 'fs'; |
| 101 | + import path from 'path'; |
| 102 | +
|
| 103 | + const rootDir = process.cwd(); |
| 104 | + const rootOpenTui = path.join(rootDir, 'node_modules', '@opentui'); |
| 105 | + const cliNodeModules = path.join(rootDir, 'cli', 'node_modules'); |
| 106 | + const cliOpenTui = path.join(cliNodeModules, '@opentui'); |
| 107 | +
|
| 108 | + if (!fs.existsSync(rootOpenTui)) { |
| 109 | + console.log('Root @opentui packages missing; skipping fix'); |
| 110 | + process.exit(0); |
| 111 | + } |
| 112 | +
|
| 113 | + fs.mkdirSync(cliOpenTui, { recursive: true }); |
| 114 | +
|
| 115 | + const packages = ['core', 'react']; |
| 116 | + for (const pkg of packages) { |
| 117 | + const target = path.join(rootOpenTui, pkg); |
| 118 | + const link = path.join(cliOpenTui, pkg); |
| 119 | +
|
| 120 | + if (!fs.existsSync(target)) { |
| 121 | + console.log(`Target ${target} missing; skipping ${pkg}`); |
| 122 | + continue; |
| 123 | + } |
| 124 | +
|
| 125 | + if (fs.existsSync(link)) { |
| 126 | + try { |
| 127 | + const actual = fs.realpathSync(link); |
| 128 | + if (actual === target) { |
| 129 | + continue; |
| 130 | + } |
| 131 | + } catch (error) { |
| 132 | + // If the link is broken or realpath fails, remove it. |
| 133 | + } |
| 134 | + fs.rmSync(link, { recursive: true, force: true }); |
| 135 | + } |
| 136 | +
|
| 137 | + const type = process.platform === 'win32' ? 'junction' : 'dir'; |
| 138 | + fs.symlinkSync(target, link, type); |
| 139 | + console.log(`Linked ${link} -> ${target}`); |
| 140 | + } |
| 141 | + NODE |
| 142 | +
|
95 | 143 | - name: Configure environment variables |
96 | 144 | env: |
97 | 145 | SECRETS_CONTEXT: ${{ toJSON(secrets) }} |
|
0 commit comments