Deploy implemented Videoreg interface and persistent theme cycle

This commit is contained in:
huncode committed 2026-10-27 15:49:46 +03:00
1 parent 6405a8d101
commit a12eefa1de
98 files changed
+4094 -2319

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
/** Audit the actually imported UI graph, public APIs, layers and real consumers. */
import ts from 'typescript';
import { readdir,readFile,stat,writeFile } from 'node:fs/promises';
import { resolve,relative,dirname,sep } from 'node:path';
const root=resolve('web-front/src'), fsd=resolve(root,'fsd'), app=resolve(root,'app');
async function files(dir){let all=[];for(const d of await readdir(dir,{withFileTypes:true})){const p=resolve(dir,d.name);if(d.isDirectory())all.push(...await files(p));else if(/\.(ts|tsx)$/.test(p)&&!p.endsWith('.test.ts'))all.push(p);}return all;}
async function exists(p){try{return (await stat(p)).isFile();}catch{return false;}}
async function target(owner,name){let stem;if(name.startsWith('@/'))stem=resolve(root,name.slice(2));else if(name.startsWith('.'))stem=resolve(dirname(owner),name);else return null;for(const p of [stem,...['.ts','.tsx','.json','.css'].map(x=>stem+x),...['index.ts','index.tsx'].map(x=>resolve(stem,x))])if(await exists(p))return p;return null;}
const paths=[...await files(fsd),...await files(app)],info=new Map(),errors=[],edges=[];
const levels={app:6,pages:5,widgets:4,features:3,entities:2,shared:1};
function owner(p){if(p.startsWith(app+sep))return {layer:'app',slice:'app'};const [layer,slice]=relative(fsd,p).split(sep);return {layer,slice};}
for(const path of paths){const code=await readFile(path,'utf8'),ast=ts.createSourceFile(path,code,ts.ScriptTarget.Latest,true),imports=[];
for(const node of ast.statements){if((ts.isImportDeclaration(node)||ts.isExportDeclaration(node))&&node.moduleSpecifier&&ts.isStringLiteral(node.moduleSpecifier)){const name=node.moduleSpecifier.text,to=await target(path,name);imports.push({name,to,names:ts.isImportDeclaration(node)&&node.importClause?.namedBindings&&ts.isNamedImports(node.importClause.namedBindings)?node.importClause.namedBindings.elements.map(x=>x.name.text):[]});}}
const from=owner(path);if((from.layer==='shared'||from.layer==='entities')&&ast.statements.some(n=>ts.isExpressionStatement(n)&&ts.isStringLiteral(n.expression)&&n.expression.text==='use client'))errors.push({kind:'client-boundary-in-shared/entity',file:relative(root,path)});
for(const imp of imports){if(imp.name==='@/content/library')errors.push({kind:'compatibility-cycle-risk',file:relative(root,path)});if(!imp.to)continue;if(imp.to.startsWith(fsd+sep)){const dest=owner(imp.to);if(levels[dest.layer]>levels[from.layer]||(dest.layer===from.layer&&dest.slice!==from.slice&&from.layer!=='app'))errors.push({kind:'upward/lateral-import',from:relative(root,path),to:relative(root,imp.to)});if(imp.name.startsWith('@/fsd/')&&!(dest.layer==='shared'&&imp.to.endsWith('.css'))&&!/^index\.tsx?$/.test(imp.to.split(sep).at(-1)))errors.push({kind:'slice-public-api-bypass',from:relative(root,path),import:imp.name});}edges.push({from:relative(root,path),to:relative(root,imp.to),import:imp.name});}
info.set(path,{imports,ast});
}
const active=new Set();async function visit(p){if(active.has(p))return;active.add(p);for(const imp of info.get(p)?.imports??[])if(imp.to)await visit(imp.to);}
for(const p of await files(app))await visit(p);
const consumers={};for(const [path,data] of info){if(!active.has(path)||path.includes('/pages/ui-kit/'))continue;for(const imp of data.imports)if(imp.name==='@/fsd/shared/ui')for(const name of imp.names)(consumers[name]??=[]).push(relative(root,path));}
const ui=info.get(resolve(fsd,'shared/ui/index.tsx'));const exports=ui.ast.statements.filter(n=>ts.isFunctionDeclaration(n)&&n.modifiers?.some(m=>m.kind===ts.SyntaxKind.ExportKeyword)).map(n=>n.name.text);
for(const name of exports)if(!consumers[name]?.length)errors.push({kind:'shared-ui-without-real-page-consumer',component:name});
if(await exists(resolve(root,'pages/index.tsx')))errors.push({kind:'accidental-next-pages-router'});
const report={scope:'Active technical-library FSD graph; inactive legacy catalog shared->entities debt preserved, no runtime cycle inferred',activeSourceFiles:active.size,FSDModules:info.size,edges,sharedComponentRealConsumers:consumers,errors};
await writeFile('docs/design-system/fsd-graph.json',JSON.stringify(report,null,2)+'\n');console.log(JSON.stringify({activeFiles:active.size,modules:info.size,sharedComponents:exports.length,errors}));if(errors.length)process.exitCode=1;
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""Compare original corpus, anchors and binary payload against published R3."""
from pathlib import Path
import hashlib,json,subprocess,sys
sys.path.insert(0,str(Path('scripts/rebuild-v2/vendor').resolve()))
from bs4 import BeautifulSoup
root=Path('.');out=root/'web-front/out';checks=[]
def check(kind,path,ok):
checks.append(dict(kind=kind,path=path,same=bool(ok)))
def digest(data):return hashlib.sha256(data).hexdigest()
for name in ['web-front/src/content/v2-articles.json','web-front/src/content/v2-community.json','deploy/legacy-map.conf','deploy/legacy-routes.json','deploy/legacy-matchers.json']:
check('immutable-source/legacy',name,(root/name).read_bytes()==subprocess.check_output(['git','show','6405a8d:'+name]))
public=subprocess.check_output(['git','ls-tree','-r','--name-only','6405a8d','--','web-front/public'],text=True).splitlines()
for name in public:
relative=name.removeprefix('web-front/public/');before=subprocess.check_output(['git','show','6405a8d:'+name]);check('original-public-source-bytes',relative,digest((root/name).read_bytes())==digest(before));check('original-public-export-bytes',relative,(out/relative).is_file()and digest((out/relative).read_bytes())==digest(before))
articles=json.loads((root/'web-front/src/content/v2-articles.json').read_text())+json.loads((root/'web-front/src/content/v2-community.json').read_text())
for article in articles:
path=article['path'];soup=BeautifulSoup((out/(path.lstrip('/')+'.html')).read_bytes(),'html.parser');body=soup.select_one('article.article-body');check('real-reader',path,body is not None)
if body is None:continue
for i,s in enumerate(article['sections']):
section=body.find('section',id='section-'+str(i));key=path+'#section-'+str(i);check('anchor-and-toc',key,section is not None and soup.find('a',href='#section-'+str(i))is not None)
if section is None:continue
check('exact-heading',key,section.h2.get_text()==s['heading']);check('exact-paragraphs',key,[p.get_text()for p in section.find_all('p',recursive=False)]==s['paragraphs'])
if s.get('list'):check('exact-list',key,[n.get_text()for n in section.find('ol').find_all('li')]==s['list'])
if s.get('note'):check('exact-note',key,section.select_one('.reading-note').get_text()==s['note'])
if s.get('code'):check('exact-code',key,section.find('code').get_text()==s['code'])
if s.get('table'):
t=s['table'];table=section.find('table');check('exact-table-caption',key,table.caption.get_text()==t['caption']);check('exact-table-headers',key,[c.get_text()for c in table.thead.find_all('th')]==t['head']);check('exact-table-cells',key,[[c.get_text()for c in row.find_all(['th','td'])]for row in table.tbody.find_all('tr')]==t['rows'])
if s.get('figure'):f=s['figure'];check('exact-figure/caption',key,section.find('img',src=f['src'])is not None and section.find('figcaption').get_text()==f['caption'])
for link in s.get('links',[]):a=section.find('a',href=link['href']);check('exact-resource-link',key+' '+link['href'],a is not None and a.get_text()==link['label']+' ↗')
for frame in s.get('gallery',[])[:6]:check('original-frame/name',key+' '+frame['filename'],section.find('img',src=frame['src'])is not None and frame['filename']in section.get_text())
check('exact-related-targets',path,[a['href']for a in body.select('.related-reading a')]==article['related'])
x=dict(scope='Actual rendered historical body/anchors/related and all original public bytes; brand/UI utility additions excluded from historical count',baselineCommit='6405a8d',sourceCommit=json.loads((out/'health/ready').read_text())['metadata']['commitSha'],originalArticles=len(articles),originalPublicFiles=len(public),checks=checks,failures=[x for x in checks if not x['same']],newUtilityRoutes=['/sources','/privacy','/ui-kit'],fullHistoricalRestorationAccepted=False)
(root/'docs/design-system/evidence/preservation.json').write_text(json.dumps(x,ensure_ascii=False,indent=2)+'\n');print(json.dumps(dict(checks=len(checks),failures=x['failures'],originalArticles=len(articles),originalPublicFiles=len(public)),ensure_ascii=False));raise SystemExit(1 if x['failures']else 0)