( projectPath: string, config: WorktreeConfig, target: "cursor" | "1code" | string = "1code", )
| 110 | * Creates parent directories if needed |
| 111 | */ |
| 112 | export async function saveWorktreeConfig( |
| 113 | projectPath: string, |
| 114 | config: WorktreeConfig, |
| 115 | target: "cursor" | "1code" | string = "1code", |
| 116 | ): Promise<{ success: boolean; path: string; error?: string }> { |
| 117 | let targetPath: string |
| 118 | |
| 119 | if (target === "cursor") { |
| 120 | targetPath = join(projectPath, CURSOR_CONFIG_PATH) |
| 121 | } else if (target === "1code") { |
| 122 | targetPath = join(projectPath, ONECODE_CONFIG_PATH) |
| 123 | } else { |
| 124 | // Custom path |
| 125 | targetPath = isAbsolute(target) ? target : join(projectPath, target) |
| 126 | } |
| 127 | |
| 128 | try { |
| 129 | // Create parent directory |
| 130 | await mkdir(dirname(targetPath), { recursive: true }) |
| 131 | |
| 132 | // Write config |
| 133 | const content = JSON.stringify(config, null, 2) |
| 134 | await writeFile(targetPath, content, "utf-8") |
| 135 | |
| 136 | return { success: true, path: targetPath } |
| 137 | } catch (error) { |
| 138 | return { |
| 139 | success: false, |
| 140 | path: targetPath, |
| 141 | error: error instanceof Error ? error.message : "Unknown error", |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Get setup commands for current platform |
no test coverage detected