| param( |
| [string]$Space = "nenae18/leechard" |
| ) |
| |
| |
| |
| $ErrorActionPreference = "Stop" |
| $Backend = Split-Path -Parent $PSScriptRoot |
|
|
| $env:HF_TOKEN = (python -c "from huggingface_hub import get_token; print(get_token() or '')").Trim() |
| if (-not $env:HF_TOKEN -or $env:HF_TOKEN.Length -lt 10) { |
| Write-Host "FAIL: no cached HF token. Run: python -c `"from huggingface_hub import login; login()`"" |
| exit 1 |
| } |
| $bf = $Backend.Replace('\', '/') |
| $py = @" |
| import os |
| from huggingface_hub import HfApi |
| api = HfApi(token=os.environ['HF_TOKEN']) |
| me = api.whoami() |
| role = ((me.get('auth') or {}).get('accessToken') or {}).get('role') |
| print('TOKEN_OK user=' + str(me.get('name')) + ' role=' + str(role)) |
| # The Space already exists; skip create_repo (free Docker Spaces now 402 on create). |
| # Only create as a best-effort fallback when the repo is genuinely missing. |
| if not api.repo_exists('$Space', repo_type='space'): |
| api.create_repo(repo_id='$Space', repo_type='space', space_sdk='docker', exist_ok=True) |
| api.upload_folder( |
| folder_path=r'$bf', repo_id='$Space', repo_type='space', |
| commit_message='Deploy SalonView AI (brand single-source)', |
| # upload_folder ๋ .gitignore ๋ฅผ ๋ณด์ง ์๋๋ค โ ์ฌ๊ธฐ ์๋ ํ์ผ์ ์ ๋ถ Space ๋ก ์ฌ๋ผ๊ฐ๋ค. |
| # docs/ = ์์
์๋ฃ(๊ฐ๊ฒฉํยท์ ์ฒญ์), CLAUDE.md/.claude = ๋ด๋ถ ๋ฉ๋ชจยท๊ฐ๋ฐ์ค์ . |
| # Space ๋ ๊ณต๊ฐ๋ผ ์ ๋ ์ฌ๋ฆฌ๋ฉด ์ ๋๋ค. |
| ignore_patterns=['tests/*', '.git/*', '**/__pycache__/*', '*.pyc', |
| '.pytest_cache/*', '*.db', '*.db-wal', '*.db-shm', |
| 'preview_ui*', 'dev_local*', '.env', 'docs/*', 'CLAUDE.md', '.claude/*', |
| 'static/_shots/*', 'static/_brand_preview.html'], |
| ) |
| print('UPLOAD_OK') |
| "@ |
| $py | python - |
| $env:HF_TOKEN = "" |
| if ($LASTEXITCODE -ne 0) { Write-Host "FAIL: upload failed."; exit 1 } |
| $liveHost = $Space.Replace("/", "-") |
| Write-Host "Uploaded. Live URL after build: https://$liveHost.hf.space" |
|
|