mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-11 22:30:59 +04:30
Persist deploy_slug on domains, call the websites agent /provision endpoint, and drop the hard-coded host map so Deploy appears from the UI. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
970 B
TypeScript
27 lines
970 B
TypeScript
/** Derive storefront slug from apex host: oaktasty.com → oaktasty, ali-mohammadi.ir → ali-mohammadi */
|
|
export function deploySlugFromHost(host: string): string {
|
|
const h = host.trim().toLowerCase();
|
|
const parts = h.split('.').filter(Boolean);
|
|
const base = parts.length >= 2 ? parts.slice(0, -1).join('-') : parts[0] ?? h;
|
|
return base
|
|
.replace(/[^a-z0-9-]+/g, '-')
|
|
.replace(/-+/g, '-')
|
|
.replace(/^-|-$/g, '');
|
|
}
|
|
|
|
const GIT_SSH_RE =
|
|
/^(?:git@[\w.-]+:[\w./-]+\.git|ssh:\/\/git@[\w.-]+(?::\d+)?\/[\w./-]+\.git)$/i;
|
|
|
|
export function isValidGitRepoUrl(url: string): boolean {
|
|
return GIT_SSH_RE.test(url.trim());
|
|
}
|
|
|
|
/** Turn .../deploy into .../provision (or append /provision if bare). */
|
|
export function provisionUrlFromDeployUrl(deployUrl: string): string {
|
|
const trimmed = deployUrl.trim().replace(/\/+$/, '');
|
|
if (/\/deploy$/i.test(trimmed)) {
|
|
return trimmed.replace(/\/deploy$/i, '/provision');
|
|
}
|
|
return `${trimmed}/provision`;
|
|
}
|