fix: lock new.gholaktala.ir as Khanegi newTheme (userTheme)

Correct prior modular/Hamkar misclassification. Protect locked newTheme domains from bulk-modular brand overrides.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-11 17:53:04 +03:30
co-authored by Cursor
parent 859530a669
commit dd4850d9fa
4 changed files with 181 additions and 23 deletions
+13 -23
View File
@@ -1,13 +1,13 @@
/**
* Apply Niazi-style modular brand colors to all Khanegi tenants
* that are NOT newTheme (Aygin stays newTheme).
* Apply Niazi-style modular brand colors to Khanegi tenants
* that are NOT locked newTheme (Aygin, new.gholaktala.ir, …).
*
* Colors (from app.niazitala.ir):
* primary #0a1b37 (هدر)
* secondary #e0be7f (اکسنت)
* background #ffffff (پس‌زمینه)
*
* Also forces uiVariant=modular for non-Aygin Khanegi rows.
* Also forces uiVariant=modular for non-protected Khanegi rows.
*
* Dry-run:
* KHANEGI_BRAND_DRY_RUN=1 npm run prisma:bulk-khanegi-modular-brand
@@ -19,6 +19,7 @@
* KHANEGI_BRAND_SOURCE_DOMAIN=app.niazitala.ir npm run prisma:bulk-khanegi-modular-brand
*/
import { KhanegiUiVariant, PrismaClient, ProductType } from '@prisma/client';
import { isForcedKhanegiNewTheme } from './khanegi-variant-locks';
const prisma = new PrismaClient();
@@ -42,20 +43,9 @@ function normalizeHost(value?: string | null) {
.split(':')[0];
}
function isAyginTenant(domain: string, domains: unknown, slug: string) {
const hosts = new Set<string>();
const primary = normalizeHost(domain);
if (primary) hosts.add(primary);
const extra = Array.isArray(domains) ? domains : [];
for (const d of extra) {
const n = normalizeHost(String(d));
if (n) hosts.add(n);
}
if (String(slug || '').toLowerCase().includes('aygin')) return true;
for (const h of hosts) {
if (h.includes('aygingold') || h === 'app.aygingold.ir') return true;
}
return false;
function isProtectedNewThemeTenant(domain: string, domains: unknown, slug: string) {
// Aygin + explicit locks (e.g. new.gholaktala.ir)
return isForcedKhanegiNewTheme(domain, domains, slug);
}
function bumpAppVersion(current?: string | null): string {
@@ -134,10 +124,10 @@ async function main() {
});
const targets = tenants.filter(
(t) => !isAyginTenant(t.domain, t.domains, t.slug),
(t) => !isProtectedNewThemeTenant(t.domain, t.domains, t.slug),
);
const skippedAygin = tenants.filter((t) =>
isAyginTenant(t.domain, t.domains, t.slug),
const skippedNewTheme = tenants.filter((t) =>
isProtectedNewThemeTenant(t.domain, t.domains, t.slug),
);
console.log(
@@ -153,7 +143,7 @@ async function main() {
},
totalKhanegi: tenants.length,
targets: targets.length,
skippedAygin: skippedAygin.map((t) => ({
skippedNewTheme: skippedNewTheme.map((t) => ({
domain: t.domain,
uiVariant: t.uiVariant,
})),
@@ -204,8 +194,8 @@ async function main() {
updated += 1;
}
// Ensure Aygin stays newTheme (do not touch colors unless variant wrong)
for (const t of skippedAygin) {
// Ensure locked newTheme tenants stay newTheme
for (const t of skippedNewTheme) {
if (t.uiVariant === KhanegiUiVariant.newTheme) continue;
console.log(
JSON.stringify({
+2
View File
@@ -30,6 +30,8 @@ const FORCE_KHANEGI: Array<{ domain?: string; name?: string; externalId?: number
{ domain: 'abaeigold.ir' },
{ domain: 'niazitala.ir' },
{ domain: 'garoosigholaktala.ir' },
// Khanegi newTheme (userTheme front) — NOT modular, NOT Hamkar.
// Keep uiVariant=newTheme in DB; see prisma/khanegi-variant-locks.ts
{ domain: 'new.gholaktala.ir' },
{ domain: 'kh.kashkolgold.ir' },
{ domain: 'goldsun.zaarbox.ir' },
+53
View File
@@ -0,0 +1,53 @@
/**
* Khanegi tenants that MUST stay on userTheme (uiVariant=newTheme).
* Never force these to modular in bulk brand scripts.
*
* Frontend: KhanegiModular/userTheme
* API: /api/get_settings (NOT Hamkar /site/settings, NOT userModular-only assumptions)
*/
export const FORCE_KHANEGI_NEW_THEME_DOMAINS = [
'new.gholaktala.ir',
'app.aygingold.ir',
] as const
export function normalizeTenantHost(value?: string | null) {
if (!value) return ''
return String(value)
.trim()
.toLowerCase()
.replace(/^https?:\/\//, '')
.split('/')[0]
.split(':')[0]
}
export function collectTenantHosts(domain: string, domains: unknown, slug = '') {
const hosts = new Set<string>()
const primary = normalizeTenantHost(domain)
if (primary) hosts.add(primary)
const extra = Array.isArray(domains) ? domains : []
for (const d of extra) {
const n = normalizeTenantHost(String(d))
if (n) hosts.add(n)
}
const s = String(slug || '').toLowerCase()
if (s) hosts.add(s)
return hosts
}
export function isForcedKhanegiNewTheme(domain: string, domains: unknown, slug = '') {
const hosts = collectTenantHosts(domain, domains, slug)
const slugLower = String(slug || '').toLowerCase()
if (slugLower.includes('aygin') || slugLower.includes('gholak_new')) return true
for (const h of hosts) {
if (h === 'new.gholaktala.ir') return true
if (h.includes('aygingold') || h === 'app.aygingold.ir') return true
}
for (const locked of FORCE_KHANEGI_NEW_THEME_DOMAINS) {
const needle = normalizeTenantHost(locked)
if (hosts.has(needle)) return true
}
return false
}