(
ideWorkspacePath: string | undefined,
currentIdeDisplayName: string | undefined,
cwd: string,
)
| 255 | } |
| 256 | |
| 257 | static validateWorkspacePath( |
| 258 | ideWorkspacePath: string | undefined, |
| 259 | currentIdeDisplayName: string | undefined, |
| 260 | cwd: string, |
| 261 | ): { isValid: boolean; error?: string } { |
| 262 | if (ideWorkspacePath === undefined) { |
| 263 | return { |
| 264 | isValid: false, |
| 265 | error: `Failed to connect to IDE companion extension for ${currentIdeDisplayName}. Please ensure the extension is running. To install the extension, run /ide install.`, |
| 266 | }; |
| 267 | } |
| 268 | |
| 269 | if (ideWorkspacePath === '') { |
| 270 | return { |
| 271 | isValid: false, |
| 272 | error: `To use this feature, please open a workspace folder in ${currentIdeDisplayName} and try again.`, |
| 273 | }; |
| 274 | } |
| 275 | |
| 276 | const ideWorkspacePaths = ideWorkspacePath.split(path.delimiter); |
| 277 | const realCwd = getRealPath(cwd); |
| 278 | const isWithinWorkspace = ideWorkspacePaths.some((workspacePath) => { |
| 279 | const idePath = getRealPath(workspacePath); |
| 280 | return isSubpath(idePath, realCwd); |
| 281 | }); |
| 282 | |
| 283 | if (!isWithinWorkspace) { |
| 284 | return { |
| 285 | isValid: false, |
| 286 | error: `Directory mismatch. ANUS is running in a different location than the open workspace in ${currentIdeDisplayName}. Please run the CLI from one of the following directories: ${ideWorkspacePaths.join( |
| 287 | ', ', |
| 288 | )}`, |
| 289 | }; |
| 290 | } |
| 291 | return { isValid: true }; |
| 292 | } |
| 293 | |
| 294 | private getPortFromEnv(): string | undefined { |
| 295 | const port = process.env['ANUS_CLI_IDE_SERVER_PORT']; |
no test coverage detected