|
|
|
@@ -11,21 +11,53 @@ import sys
|
|
|
|
|
META_ROOT = pathlib.Path(__file__).resolve().parents[2]
|
|
|
|
|
REPOS_ROOT = META_ROOT.parent
|
|
|
|
|
BASELINE_PATH = pathlib.Path(__file__).with_name("shared-webui-layout-baseline.txt")
|
|
|
|
|
WORKSPACE_BASELINE_PATH = pathlib.Path(__file__).with_name(
|
|
|
|
|
"shared-webui-workspace-baseline.txt"
|
|
|
|
|
)
|
|
|
|
|
RAW_PAGE_FRAME = 'className="content-pad workspace-data-page'
|
|
|
|
|
RAW_WORKSPACE = re.compile(r'<div\s+className="workspace(?:\s|\")')
|
|
|
|
|
LOCAL_PAGE_LAYOUT = re.compile(r"\b(?:function|class|const)\s+PageLayout\b")
|
|
|
|
|
LOCAL_WORKSPACE_LAYOUT = re.compile(
|
|
|
|
|
r"\b(?:function|class|const)\s+WorkspaceLayout\b"
|
|
|
|
|
)
|
|
|
|
|
CENTRAL_LAYOUT = pathlib.Path("govoplan-core/webui/src/components/PageLayout.tsx")
|
|
|
|
|
CENTRAL_WORKSPACE_LAYOUT = pathlib.Path(
|
|
|
|
|
"govoplan-core/webui/src/components/WorkspaceLayout.tsx"
|
|
|
|
|
)
|
|
|
|
|
REQUIRED_CONSUMERS = (
|
|
|
|
|
pathlib.Path("govoplan-core/webui/src/components/admin/AdminPageLayout.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-core/webui/src/features/dashboard/DashboardPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-dashboard/webui/src/features/dashboard/DashboardPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-ops/webui/src/features/ops/OpsPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/AttachmentsDataPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/CampaignAuditPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/CampaignFieldsPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/CampaignJsonView.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/CampaignListPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/CampaignOverviewPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/CampaignReportPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/GlobalSettingsPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/MailSettingsPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/ReviewSendPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/TemplateDataPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/components/CampaignDraftPageScaffold.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/wizard/WizardDirectoryPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/operator/OperatorQueuePage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/reports/AggregateReportsPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/templates/TemplatesPage.tsx"),
|
|
|
|
|
)
|
|
|
|
|
REQUIRED_WORKSPACE_CONSUMERS = (
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/CampaignWorkspace.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/campaigns/CampaignModulePage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-campaign/webui/src/features/templates/TemplatesPage.tsx"),
|
|
|
|
|
pathlib.Path("govoplan-approvals/webui/src/features/approvals/ApprovalsPage.tsx"),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def baseline_paths() -> set[pathlib.Path]:
|
|
|
|
|
def baseline_paths(path: pathlib.Path) -> set[pathlib.Path]:
|
|
|
|
|
return {
|
|
|
|
|
pathlib.Path(line.strip())
|
|
|
|
|
for line in BASELINE_PATH.read_text(encoding="utf-8").splitlines()
|
|
|
|
|
for line in path.read_text(encoding="utf-8").splitlines()
|
|
|
|
|
if line.strip() and not line.lstrip().startswith("#")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -47,7 +79,7 @@ def main() -> int:
|
|
|
|
|
sources = source_paths()
|
|
|
|
|
source_text = {relative(path): path.read_text(encoding="utf-8") for path in sources}
|
|
|
|
|
raw_frames = {path for path, text in source_text.items() if RAW_PAGE_FRAME in text}
|
|
|
|
|
baseline = baseline_paths()
|
|
|
|
|
baseline = baseline_paths(BASELINE_PATH)
|
|
|
|
|
available_baseline = {
|
|
|
|
|
path for path in baseline if (REPOS_ROOT / path.parts[0]).is_dir()
|
|
|
|
|
}
|
|
|
|
@@ -63,9 +95,30 @@ def main() -> int:
|
|
|
|
|
errors.append("Remove migrated page frames from the shared-layout baseline:")
|
|
|
|
|
errors.extend(f"- {path}" for path in resolved)
|
|
|
|
|
|
|
|
|
|
raw_workspaces = {
|
|
|
|
|
path for path, text in source_text.items() if RAW_WORKSPACE.search(text)
|
|
|
|
|
}
|
|
|
|
|
workspace_baseline = baseline_paths(WORKSPACE_BASELINE_PATH)
|
|
|
|
|
available_workspace_baseline = {
|
|
|
|
|
path
|
|
|
|
|
for path in workspace_baseline
|
|
|
|
|
if (REPOS_ROOT / path.parts[0]).is_dir()
|
|
|
|
|
}
|
|
|
|
|
unexpected_workspaces = sorted(raw_workspaces - available_workspace_baseline)
|
|
|
|
|
if unexpected_workspaces:
|
|
|
|
|
errors.append("New raw workspaces must use @govoplan/core-webui WorkspaceLayout:")
|
|
|
|
|
errors.extend(f"- {path}" for path in unexpected_workspaces)
|
|
|
|
|
|
|
|
|
|
resolved_workspaces = sorted(available_workspace_baseline - raw_workspaces)
|
|
|
|
|
if resolved_workspaces:
|
|
|
|
|
errors.append("Remove migrated workspaces from the shared-workspace baseline:")
|
|
|
|
|
errors.extend(f"- {path}" for path in resolved_workspaces)
|
|
|
|
|
|
|
|
|
|
for path, text in source_text.items():
|
|
|
|
|
if path != CENTRAL_LAYOUT and LOCAL_PAGE_LAYOUT.search(text):
|
|
|
|
|
errors.append(f"Module-local PageLayout definition is not allowed: {path}")
|
|
|
|
|
if path != CENTRAL_WORKSPACE_LAYOUT and LOCAL_WORKSPACE_LAYOUT.search(text):
|
|
|
|
|
errors.append(f"Module-local WorkspaceLayout definition is not allowed: {path}")
|
|
|
|
|
|
|
|
|
|
for path in REQUIRED_CONSUMERS:
|
|
|
|
|
absolute_path = REPOS_ROOT / path
|
|
|
|
@@ -77,9 +130,21 @@ def main() -> int:
|
|
|
|
|
if RAW_PAGE_FRAME in text:
|
|
|
|
|
errors.append(f"Required shared-layout consumer restored the raw page frame: {path}")
|
|
|
|
|
|
|
|
|
|
for path in REQUIRED_WORKSPACE_CONSUMERS:
|
|
|
|
|
absolute_path = REPOS_ROOT / path
|
|
|
|
|
if not absolute_path.exists():
|
|
|
|
|
continue
|
|
|
|
|
text = absolute_path.read_text(encoding="utf-8")
|
|
|
|
|
if "<WorkspaceLayout" not in text:
|
|
|
|
|
errors.append(f"Required shared-workspace consumer no longer uses WorkspaceLayout: {path}")
|
|
|
|
|
if RAW_WORKSPACE.search(text):
|
|
|
|
|
errors.append(f"Required shared-workspace consumer restored the raw workspace: {path}")
|
|
|
|
|
|
|
|
|
|
core_index = REPOS_ROOT / "govoplan-core/webui/src/index.ts"
|
|
|
|
|
if core_index.exists() and "PageLayout, PageHeader" not in core_index.read_text(encoding="utf-8"):
|
|
|
|
|
errors.append("Core must export PageLayout and PageHeader from @govoplan/core-webui.")
|
|
|
|
|
if core_index.exists() and "WorkspaceLayout" not in core_index.read_text(encoding="utf-8"):
|
|
|
|
|
errors.append("Core must export WorkspaceLayout from @govoplan/core-webui.")
|
|
|
|
|
|
|
|
|
|
if errors:
|
|
|
|
|
print("\n".join(errors), file=sys.stderr)
|
|
|
|
@@ -88,7 +153,9 @@ def main() -> int:
|
|
|
|
|
print(
|
|
|
|
|
"Shared WebUI layout contract passed: "
|
|
|
|
|
f"{len(REQUIRED_CONSUMERS)} central consumers, "
|
|
|
|
|
f"{len(raw_frames)} registered legacy page-frame files."
|
|
|
|
|
f"{len(raw_frames)} registered legacy page-frame files; "
|
|
|
|
|
f"{len(REQUIRED_WORKSPACE_CONSUMERS)} workspace consumers, "
|
|
|
|
|
f"{len(raw_workspaces)} registered legacy workspace files."
|
|
|
|
|
)
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|