git 저장소가 없어 히스토리·협업 기반이 아예 없던 상태를 연다.
함께 문서를 재편했다. 그동안 문서가 있어도 "이 제품이 뭘 푸는가"와
"어떻게 도는가"를 담은 문서가 없어서, 목표 문장이 backend/frontend
README 두 곳에 복붙돼 있었다 — 상위 문서가 없어 아래로 샌 것이다.
신설
README.md 레포 진입점 + 문서 지도 + 문서 규칙 4가지
AGENTS.md 에이전트·신규 합류자용 함정 목록과 규약
(CLAUDE.md 는 여기로 걸린 심볼릭 링크)
docs/PRODUCT.md 제품 정의 — 문제·사용자·원칙·**non-goals**·성공 기준
docs/ARCHITECTURE.md payload 경계·발행 파이프라인·서빙 결정·앱 분리 설계
이동
backend/docs/DECISIONS.md → docs/DECISIONS.md
백엔드만의 결정이 아니다. 게다가 코드 주석 ~25곳이 이미
`docs/DECISIONS.md` 로 적고 있어 레포 루트 기준으로는 그게 맞다.
갱신
docs/DEPLOY.md 서빙 결정 반영 — nginx 정적 서빙이 지금 경로(3절),
Azure 는 나중에 켤 때(4절)로 분리
docs/ARCHITECTURE.md 사이트 = 한 장(2026-08-31) 구조 반영
docs/COLLECTION_SEO_AEO_FLOW.md
robots.txt·sitemap.xml 은 오리진 루트에만 굽는다는 점 명시
frontend/site/scripts/prerender.ts
헤더 주석의 렌더 보고서 경로가 실제(422줄)와 달라 수정
.gitignore
★ CLAUDE.md 를 더 이상 무시하지 않는다. 에이전트 지침은 팀과 모든
에이전트가 공유하는 규약이라 커밋해야 한다 — 무시하면 클론한 사람이
"배포 후 republish_all.py 필수" 같은 함정을 전달받지 못한다.
개인용 오버라이드는 ~/.claude/CLAUDE.md 에 둔다.
87 lines
3.6 KiB
Python
87 lines
3.6 KiB
Python
from pathlib import Path
|
|
from types import SimpleNamespace
|
|
|
|
from services import azure_static
|
|
|
|
|
|
class FakeContainer:
|
|
def __init__(self):
|
|
self.uploads = {}
|
|
self.existing = []
|
|
self.deleted = []
|
|
|
|
def upload_blob(self, name, data, **options):
|
|
self.uploads[name] = {"body": data.read(), **options}
|
|
|
|
def list_blobs(self, name_starts_with):
|
|
return [SimpleNamespace(name=name) for name in self.existing if name.startswith(name_starts_with)]
|
|
|
|
def delete_blob(self, name):
|
|
self.deleted.append(name)
|
|
|
|
|
|
def test_설정없으면_로컬발행만_유지(monkeypatch):
|
|
monkeypatch.delenv("AZURE_STORAGE_CONNECTION_STRING", raising=False)
|
|
assert azure_static.is_configured() is False
|
|
|
|
|
|
def test_ai_for_web_아래에_사이트와_공용산출물을_업로드(tmp_path, monkeypatch):
|
|
(tmp_path / "assets").mkdir()
|
|
(tmp_path / "assets" / "index-abc.js").write_text("console.log(1)")
|
|
(tmp_path / "fonts").mkdir()
|
|
(tmp_path / "fonts" / "Pretendard.woff2").write_bytes(b"font")
|
|
# ★ 오리진 루트 파일 — 크롤러가 robots.txt 를 읽는 유일한 자리다(RFC 9309).
|
|
(tmp_path / "robots.txt").write_text("User-agent: *\nAllow: /\n")
|
|
(tmp_path / "sitemap.xml").write_text("<sitemapindex/>")
|
|
site_dir = tmp_path / "s" / "butter"
|
|
(site_dir / "about").mkdir(parents=True)
|
|
(site_dir / "index.html").write_text("<h1>Butter</h1>")
|
|
(site_dir / "about" / "index.html").write_text("<h1>About</h1>")
|
|
# 다른 사업장의 발행본. 이번 발행 대상이 아니므로 올라가면 안 된다.
|
|
(tmp_path / "s" / "joy").mkdir(parents=True)
|
|
(tmp_path / "s" / "joy" / "index.html").write_text("<h1>Joy</h1>")
|
|
|
|
container = FakeContainer()
|
|
container.existing = [
|
|
"ai-for-web/s/butter/index.html",
|
|
"ai-for-web/s/butter/old/index.html",
|
|
]
|
|
service = SimpleNamespace(get_container_client=lambda name: container)
|
|
monkeypatch.setattr(
|
|
azure_static.BlobServiceClient,
|
|
"from_connection_string",
|
|
lambda value: service,
|
|
)
|
|
monkeypatch.setattr(azure_static, "output_dir", lambda: Path(tmp_path))
|
|
monkeypatch.setenv("AZURE_STORAGE_CONNECTION_STRING", "UseDevelopmentStorage=true")
|
|
monkeypatch.delenv("AZURE_STORAGE_PREFIX", raising=False)
|
|
|
|
result = azure_static._publish_sync("butter")
|
|
|
|
assert set(container.uploads) == {
|
|
"ai-for-web/assets/index-abc.js",
|
|
"ai-for-web/fonts/Pretendard.woff2",
|
|
"ai-for-web/robots.txt",
|
|
"ai-for-web/sitemap.xml",
|
|
"ai-for-web/s/butter/index.html",
|
|
"ai-for-web/s/butter/about/index.html",
|
|
}
|
|
assert container.deleted == ["ai-for-web/s/butter/old/index.html"]
|
|
assert result == {
|
|
"container": "$web",
|
|
"prefix": "ai-for-web",
|
|
"shared_files": 4,
|
|
"site_files": 2,
|
|
"removed_stale": 1,
|
|
}
|
|
|
|
|
|
def test_루트_robots_와_사이트맵은_짧게_캐시된다():
|
|
# 해시가 박힌 번들만 영구 캐시다. robots·사이트맵이 길게 캐시되면
|
|
# 새 사업장이 사이트맵 인덱스에 들어가도 크롤러가 옛 파일을 계속 본다.
|
|
assert "immutable" in azure_static._cache_control(Path("assets/index-abc.js"))
|
|
assert azure_static._cache_control(Path("robots.txt")) == "public, max-age=60, must-revalidate"
|
|
assert azure_static._cache_control(Path("sitemap.xml")) == "public, max-age=60, must-revalidate"
|
|
assert azure_static._cache_control(Path("s/butter/index.html")) == "public, max-age=60, must-revalidate"
|
|
assert azure_static._cache_control(Path("fonts/Pretendard.woff2")) == "public, max-age=604800"
|