Reorganize repo structure and standards references

This commit is contained in:
david committed 2026-06-29 05:03:42 +02:00
1 parent 3cb93a81be
commit be2054274d
5885 files changed
+2588 -195

No files matched your search

@@ -0,0 +1,72 @@
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
const repoRoot = resolve(__dirname, "../../..");
function readRepoFile(path: string) {
return readFileSync(resolve(repoRoot, path), "utf8");
}
const migratedWrappers = [
"apps/web/app/utils/db/subscriptionProducts.db.server.ts",
"apps/web/app/utils/db/tenantSubscriptions.db.server.ts",
"apps/web/app/utils/db/subscriptions/tenantSubscriptionProducts.db.server.ts",
"apps/web/app/utils/db/stripe/checkoutSessions.db.server.ts",
];
const directBillingPrismaModels = [
"subscriptionProduct",
"subscriptionPrice",
"subscriptionFeature",
"subscriptionUsageBasedPrice",
"subscriptionUsageBasedTier",
"tenantSubscription",
"tenantSubscriptionProduct",
"tenantSubscriptionProductPrice",
"tenantSubscriptionUsageRecord",
"checkoutSessionStatus",
];
describe("subscription app boundary", () => {
it.each(migratedWrappers)("keeps %s behind @toolctrl/db/subscriptions.server", (path) => {
const source = readRepoFile(path);
expect(source).toContain("@toolctrl/db/subscriptions.server");
expect(source).not.toContain("~/utils/db.server");
expect(source).not.toContain("../../db.server");
expect(source).not.toContain("../db.server");
expect(source).not.toMatch(/\bdb\.[a-zA-Z]/);
});
it("keeps subscriptionService subscription billing persistence behind the package boundary", () => {
const source = readRepoFile("apps/web/app/utils/services/.server/subscriptionService.ts");
expect(source).toContain("@toolctrl/db/subscriptions.server");
expect(source).toContain("../../db.server");
expect(source).toContain("clearCacheKey");
expect(source).toContain("cancelStripeSubscription");
expect(source).toContain("EventsService.create");
for (const model of directBillingPrismaModels) {
expect(source).not.toMatch(new RegExp(`\\bdb\\.${model}\\b`));
}
});
it("keeps tenant subscription route writes behind cache-clearing web wrappers", () => {
const routePaths = [
"apps/web/app/routes/subscribe.$tenant.tsx",
"apps/web/app/routes/app.$tenant/settings/subscription.tsx",
];
for (const path of routePaths) {
const source = readRepoFile(path);
const directPackageImport = source.match(/import\s+\{([^}]+)\}\s+from\s+["']@toolctrl\/db\/subscriptions\.server["']/s);
const importedNames = directPackageImport?.[1] ?? "";
expect(importedNames).not.toMatch(/\bcreateTenantSubscription\b/);
expect(importedNames).not.toMatch(/\bupdateTenantSubscriptionCustomerId\b/);
expect(source).toContain("~/utils/db/tenantSubscriptions.db.server");
}
});
});