The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | // @effect-diagnostics nodeBuiltinImport:off - Vite configuration also loads before dependency installation. |
| 2 | import * as NodeFS from "node:fs"; |
| 3 | import * as NodeOS from "node:os"; |
| 4 | import * as NodePath from "node:path"; |
| 5 | |
| 6 | export function remoteCacheUrl(root: string, env = process.env, home = NodeOS.homedir()) { |
| 7 | if (env.VP_REMOTE_CACHE_URL) return env.VP_REMOTE_CACHE_URL; |
| 8 | try { |
| 9 | const { endpoint } = JSON.parse( |
| 10 | NodeFS.readFileSync(NodePath.join(root, ".task-cache.json"), "utf8"), |
| 11 | ); |
| 12 | const credentials = JSON.parse( |
| 13 | NodeFS.readFileSync(NodePath.join(home, ".config/t3-task-cache/credentials.json"), "utf8"), |
| 14 | ); |
| 15 | const credential = credentials[endpoint]; |
| 16 | if ( |
| 17 | typeof endpoint !== "string" || |
| 18 | typeof credential?.name !== "string" || |
| 19 | typeof credential.token !== "string" |
| 20 | ) |
| 21 | return; |
| 22 | const url = new URL(endpoint); |
| 23 | url.username = credential.name; |
| 24 | url.password = credential.token; |
| 25 | return url.href; |
| 26 | } catch { |
| 27 | // Missing or damaged optional setup must not prevent ordinary project commands. |
| 28 | return; |
| 29 | } |
| 30 | } |