mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Service hostnames now follow DNS convention with a project label so
independently opened projects no longer collide on routes like
`web.localhost`. Format becomes `{script}.{project}.localhost` for
default branches and `{script}.{branch}.{project}.localhost` for other
branches. The project slug comes from the GitHub repository name when a
remote exists, otherwise from the workspace directory basename.
Server changes:
- `buildScriptHostname` takes `{ projectSlug, branchName, scriptName }`
and slugifies all labels at the boundary; `untitled` fallback only
applies at hostname-label sites, never to shared `slugify`.
- `deriveProjectSlug(cwd)` and `parseGitHubRepoNameFromRemote` derive
the slug; GitHub URL parsing now requires `host === "github.com"` to
avoid embedded-path false matches.
- `ScriptRouteEntry` carries `projectSlug`; branch-rename handler reuses
it instead of re-reading git in hot paths.
- Status projection derives slug once per call and uses route hostname
when available; only falls back to building when no route exists.
- Spawn cleanup removes routes by `{ workspaceId, scriptName }` so
cleanup after a branch rename doesn't leave a stale entry behind.
App and shared message tests updated to the new fixture shape; service
URLs continue to be opaque server-provided strings.
Landing-page service URL examples updated; allowlist docs unchanged.
28 lines
796 B
TypeScript
28 lines
796 B
TypeScript
import { slugify } from "./worktree.js";
|
|
|
|
type BuildScriptHostnameOptions = {
|
|
projectSlug: string;
|
|
branchName: string | null;
|
|
scriptName: string;
|
|
};
|
|
|
|
function toHostnameLabel(value: string): string {
|
|
return slugify(value) || "untitled";
|
|
}
|
|
|
|
export function buildScriptHostname({
|
|
projectSlug,
|
|
branchName,
|
|
scriptName,
|
|
}: BuildScriptHostnameOptions): string {
|
|
const serviceHostnameLabel = toHostnameLabel(scriptName);
|
|
const projectHostnameLabel = toHostnameLabel(projectSlug);
|
|
const isDefaultBranch = branchName === null || branchName === "main" || branchName === "master";
|
|
|
|
if (isDefaultBranch) {
|
|
return `${serviceHostnameLabel}.${projectHostnameLabel}.localhost`;
|
|
}
|
|
|
|
return `${serviceHostnameLabel}.${toHostnameLabel(branchName)}.${projectHostnameLabel}.localhost`;
|
|
}
|