File size: 1,531 Bytes
d24381f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
#!/usr/bin/env bash
# deploy-space.sh — upload the built app (dist/) to the private static Space
#   https://huggingface.co/spaces/dshunt/anniversary-intimacy
#
# Usage (after apply-push.sh has produced a build):
#   HF_TOKEN=hf_xxx bash deploy-space.sh
#
# Get a token at https://huggingface.co/settings/tokens (scope: write).
# Keep it as an env var — never paste it into chats or issues.

set -euo pipefail

: "${HF_TOKEN:?Set HF_TOKEN env var (https://huggingface.co/settings/tokens, write scope)}"
SPACE="${SPACE:-dshunt/anniversary-intimacy}"
APP_DIR="${APP_DIR:-$HOME/next18-build/app/anniversary-intimacy}"   # workdir from apply-push.sh
DIST="${DIST:-$APP_DIR/dist}"

[ -f "$DIST/index.html" ] || { echo "No build found at $DIST — run apply-push.sh first."; exit 1; }

cd "$APP_DIR"
npm i --no-save @huggingface/hub >/dev/null 2>&1

node --input-type=module -e "
import fs from 'fs';
import path from 'path';
import { uploadFile } from '@huggingface/hub';

const dist = '${DIST}';
const files = [];
const walk = d => fs.readdirSync(d, { withFileTypes: true }).forEach(e => {
  const p = path.join(d, e.name);
  e.isDirectory() ? walk(p) : files.push(p);
});
walk(dist);
for (const f of files) {
  await uploadFile({
    repo: 'space',
    repoId: '${SPACE}',
    path: path.relative(dist, f),
    file: fs.createReadStream(f),
    credentials: { accessToken: process.env.HF_TOKEN },
  });
  console.log('uploaded:', path.relative(dist, f));
}
"

echo ""
echo "✅ Deployed to https://huggingface.co/spaces/${SPACE}"