- Updated ESLint configuration to enforce stricter import rules for the @customer-portal/domain package, promoting better import hygiene and preventing deep imports. - Refactored various files across the BFF and portal applications to comply with the new import rules, ensuring that only the appropriate modules are imported from the domain. - Cleaned up unused imports and optimized code structure for improved maintainability and clarity. - Updated documentation to reflect changes in import practices and domain structure.
27 lines
790 B
JavaScript
27 lines
790 B
JavaScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
const ROOT = process.cwd();
|
|
const pkgPath = path.join(ROOT, "packages", "domain", "package.json");
|
|
|
|
const pkg = JSON.parse(await fs.readFile(pkgPath, "utf8"));
|
|
|
|
const exportsField = pkg.exports;
|
|
if (!exportsField || typeof exportsField !== "object") {
|
|
console.error("[domain] ERROR: package.json exports field is missing or invalid.");
|
|
process.exit(1);
|
|
}
|
|
|
|
const keys = Object.keys(exportsField);
|
|
const wildcardKeys = keys.filter(k => k.includes("*"));
|
|
|
|
if (wildcardKeys.length > 0) {
|
|
console.error("[domain] ERROR: wildcard subpath exports are not allowed:");
|
|
for (const k of wildcardKeys) console.error(`- ${k}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log("[domain] OK: package.json exports contains no wildcard keys.");
|
|
|
|
|