mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 03:23:12 +00:00
32 lines
748 B
TypeScript
32 lines
748 B
TypeScript
export const SENTRY_SERVICE_NAME = "shoc-frontend";
|
|
export const LOCAL_DEVELOPMENT_RELEASE = "local-development";
|
|
|
|
const COMMIT_SHA = /^[0-9a-f]{40}$/i;
|
|
|
|
export function resolveSentryRelease(
|
|
candidate: string | undefined,
|
|
ci: boolean,
|
|
): {
|
|
commitSha: string;
|
|
release: string;
|
|
} {
|
|
const commitSha = candidate?.trim();
|
|
|
|
if (commitSha && COMMIT_SHA.test(commitSha)) {
|
|
return {
|
|
commitSha: commitSha.toLowerCase(),
|
|
release: `${SENTRY_SERVICE_NAME}@${commitSha.toLowerCase()}`,
|
|
};
|
|
}
|
|
|
|
if (ci) {
|
|
throw new Error(
|
|
"CI builds require VITE_APP_COMMIT_SHA or GITHUB_SHA as a 40-character commit SHA",
|
|
);
|
|
}
|
|
|
|
return {
|
|
commitSha: LOCAL_DEVELOPMENT_RELEASE,
|
|
release: LOCAL_DEVELOPMENT_RELEASE,
|
|
};
|
|
}
|