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-next-line nodeBuiltinImport:off -- Build configs resolve the tag before an Effect runtime exists. |
| 2 | import * as NodeChildProcess from "node:child_process"; |
| 3 | |
| 4 | export const releasePackageFiles = [ |
| 5 | "apps/server/package.json", |
| 6 | "apps/desktop/package.json", |
| 7 | "apps/web/package.json", |
| 8 | "packages/contracts/package.json", |
| 9 | ] as const; |
| 10 | |
| 11 | /** |
| 12 | * A release is tagged on the commit it was built from, and the manifest bump lands on main |
| 13 | * afterwards, so source at `vX.Y.Z` still carries the previous version. Server, web and desktop |
| 14 | * builds must all resolve through here, or the client reports a different version than its server. |
| 15 | */ |
| 16 | export function resolveTaggedSourceVersion(repoRoot: string, manifestVersion: string): string { |
| 17 | const git = (...args: ReadonlyArray<string>) => |
| 18 | NodeChildProcess.execFileSync("git", args, { cwd: repoRoot, encoding: "utf8", stdio: "pipe" }); |
| 19 | |
| 20 | try { |
| 21 | // Release jobs and the desktop packager write the version they build into the manifests. |
| 22 | git("diff", "--quiet", "HEAD", "--", ...releasePackageFiles); |
| 23 | const stableTags = git("tag", "--points-at", "HEAD") |
| 24 | .split("\n") |
| 25 | .filter((tag) => /^v\d+\.\d+\.\d+$/.test(tag)); |
| 26 | if (stableTags.length === 1) return stableTags[0]!.slice(1); |
| 27 | } catch { |
| 28 | // No Git, a source archive, or edited manifests: the manifest is the version. |
| 29 | } |
| 30 | return manifestVersion; |
| 31 | } |