Implement ProgCode identity and real shared reading UI kit
Build and deploy / deploy (push) Successful in 2m39s
Build and deploy / deploy (push) Successful in 2m39s
This commit is contained in:
1 parent
99c848189e
commit
12562baeb5
2040 files changed
+184656
-181
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import re,json,argparse,hashlib
|
||||
from pathlib import Path
|
||||
r=Path('/Users/gavrilovdev/tmp/progcode.ru/web');f=r/'fsd';rank={'pages':0,'widgets':1,'features':2,'entities':3,'shared':4};violations=[];imports=[]
|
||||
def resolve(path):
|
||||
for q in [path,*[Path(str(path)+x) for x in ['.jsx','.js','.mjs','.json','.css']],path/'index.js',path/'index.jsx']:
|
||||
if q.is_file():return q.resolve()
|
||||
for p in f.rglob('*'):
|
||||
if p.suffix not in ['.js','.jsx','.mjs']:continue
|
||||
src=p.relative_to(f).parts;layer=src[0];slice=src[:2]
|
||||
for name in re.findall(r"(?:from\s*|import\s*)['\"]([^'\"]+)['\"]",p.read_text()):
|
||||
if not name.startswith('.'):continue
|
||||
target=resolve(p.parent/name);assert target is not None,(p,name)
|
||||
if target.is_relative_to(f):
|
||||
dst=target.relative_to(f).parts;bad=rank[dst[0]]<rank[layer] or (dst[0]==layer and dst[:2]!=slice)
|
||||
deep=dst[:2]!=slice and target.stem!='index' and dst[0] not in ['shared']
|
||||
if bad or deep:violations.append({'from':str(p.relative_to(r)),'to':str(target.relative_to(r)),'direction':bad,'publicAPI':deep})
|
||||
imports.append({'from':str(p.relative_to(r)),'import':name,'resolved':str(target.relative_to(r))})
|
||||
assert not violations,violations
|
||||
parser=argparse.ArgumentParser();parser.add_argument('--expected-source',default='f5d92794816398171b68a1d374b24bd0cd9ea0f85d005c7be92369b40d314900');args=parser.parse_args();names=[]
|
||||
for directory in ['app','lib','scripts','data','fsd','public']:names.extend(p.relative_to(r).as_posix() for p in (r/directory).rglob('*') if p.is_file() and p.relative_to(r).as_posix()!='public/build-identity.json')
|
||||
names+=['package.json','package-lock.json','next.config.mjs'];h=hashlib.sha256()
|
||||
for name in sorted(names):h.update(name.encode());h.update((r/name).read_bytes())
|
||||
assert h.hexdigest()==args.expected_source,'Working source differs from requested evidence scope'
|
||||
out=r.parent/'docs/design-system/candidates'/args.expected_source[:12]/'fsd-boundaries.json';out.write_text(json.dumps({'namespace':'web/fsd','importsChecked':len(imports),'violations':violations,'imports':imports},indent=2)+'\n');print('FSD imports',len(imports),'violations',len(violations))
|
||||
Reference in new issue
Block a user