File size: 2,277 Bytes
5bf61fe 04c34ec 3754951 5bf61fe 3754951 04c34ec 5bf61fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | param(
[string]$Space = "nenae18/leechard" # "<user>/<spacename>"
)
# Deploy the (flat) backend app folder straight to the Hugging Face Space.
# Uses the locally CACHED HF write token (the user's fine-grained token lacks Space
# write -> 403). FAL_KEY / ACCESS_CODE / ANDROID_ASSETLINKS_JSON stay as Space secrets.
$ErrorActionPreference = "Stop"
$Backend = Split-Path -Parent $PSScriptRoot # scripts/ lives inside backend/, parent = backend
$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"
|