game-deploy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Game Deployment

游戏部署

Deploy your browser game for public access. here.now is the default — instant static hosting with zero configuration. GitHub Pages is available as an alternative when you need git-based deploys.
将你的浏览器游戏部署以供公开访问。here.now是默认选项——无需配置的即时静态托管服务。当你需要基于Git的部署方式时,可选择GitHub Pages作为替代方案。

here.now Deployment (Default)

here.now部署(默认)

Prerequisites

前提条件

  • The
    here-now
    skill installed (
    npx skills add heredotnow/skill --skill here-now -g
    )
  • Optional:
    $HERENOW_API_KEY
    or
    ~/.herenow/credentials
    for permanent hosting
  • 已安装
    here-now
    技能(执行
    npx skills add heredotnow/skill --skill here-now -g
  • 可选:
    $HERENOW_API_KEY
    ~/.herenow/credentials
    ,用于永久托管

Quick Deploy

快速部署

bash
npm run build
~/.agents/skills/here-now/scripts/publish.sh dist/
The script outputs a live URL like
https://<slug>.here.now/
.
bash
npm run build
~/.agents/skills/here-now/scripts/publish.sh dist/
脚本会输出一个实时URL,格式类似
https://<slug>.here.now/

Why here.now is the default

为什么here.now是默认选项

  • Zero config — no
    base
    path, no git repo, no GitHub CLI required
  • Instant — site is live immediately (no waiting for propagation)
  • No base path issues — content served from subdomain root (
    base: '/'
    or default)
  • Works everywhere — only needs
    curl
    ,
    file
    , and
    jq
  • 零配置——无需设置
    base
    路径、Git仓库,也不需要GitHub CLI
  • 即时生效——站点立即上线(无需等待传播)
  • 无基础路径问题——内容从子域名根目录提供(
    base: '/'
    或默认配置)
  • 兼容性强——仅需依赖
    curl
    file
    jq

Vite base path

Vite基础路径

here.now serves from the subdomain root, so use the default base path:
js
export default defineConfig({
  base: '/',
  // ... rest of config
});
here.now从子域名根目录提供内容,因此请使用默认基础路径:
js
export default defineConfig({
  base: '/',
  // ... 其余配置
});

IMPORTANT: Claim your site within 24 hours

重要提示:请在24小时内认领你的站点

Without an API key, publishes are anonymous and expire in 24 hours. The publish script returns a claim URL — the user MUST visit this URL and create a free here.now account to keep the site permanently. The claim token is only shown once and cannot be recovered. If they don't claim it, the site disappears.
You MUST always tell the user about the 24-hour window and the claim URL after every anonymous publish. This is not optional.
FeatureAnonymousAuthenticated
Expiry24 hours (then deleted!)Permanent
Max file size250 MB5 GB
Rate limit5/hour/IP60/hour/account
To set up an API key for permanent hosting (skip the 24h window entirely):
First check if the key already exists:
test -f .env && grep -q '^HERENOW_API_KEY=.' .env && echo "found"
If found, export it with
set -a; . .env; set +a
and skip the prompt.
Otherwise:
  1. Ask the user for their email
  2. Send a magic link:
    curl -sS https://here.now/api/auth/login -H "content-type: application/json" -d '{"email": "user@example.com"}'
  3. User clicks the link, copies their API key from the dashboard
  4. User pastes the key like:
    HERENOW_API_KEY=their-key-here
    (saved to .env and redacted automatically)
  5. Also save to credentials file:
    mkdir -p ~/.herenow && grep '^HERENOW_API_KEY=' .env | cut -d= -f2- > ~/.herenow/credentials && chmod 600 ~/.herenow/credentials
若无API密钥,发布的内容为匿名状态,24小时后过期。发布脚本会返回一个认领URL——用户必须访问该URL并创建免费的here.now账户,才能永久保留站点。认领令牌仅显示一次,无法找回。如果用户未认领,站点将被删除。
每次匿名发布后,你必须告知用户24小时的期限和认领URL。这是强制要求。
特性匿名部署认证部署
有效期24小时(到期后删除!)永久有效
最大文件大小250 MB5 GB
速率限制5次/小时/IP60次/小时/账户
若要设置API密钥以实现永久托管(完全跳过24小时期限):
首先检查密钥是否已存在:
test -f .env && grep -q '^HERENOW_API_KEY=.' .env && echo "found"
如果已找到,执行
set -a; . .env; set +a
导出密钥,跳过后续提示。
否则:
  1. 向用户索要邮箱地址
  2. 发送魔法链接:
    curl -sS https://here.now/api/auth/login -H "content-type: application/json" -d '{"email": "user@example.com"}'
  3. 用户点击链接,从控制台复制API密钥
  4. 用户粘贴密钥,格式如下:
    HERENOW_API_KEY=their-key-here
    (会自动保存到.env文件并脱敏)
  5. 同时保存到凭据文件:
    mkdir -p ~/.herenow && grep '^HERENOW_API_KEY=' .env | cut -d= -f2- > ~/.herenow/credentials && chmod 600 ~/.herenow/credentials

Updating a deploy

更新部署内容

bash
npm run build
~/.agents/skills/here-now/scripts/publish.sh dist/ --slug <slug>
The slug is saved in
.herenow/state.json
after each publish — the script auto-loads it for updates.
bash
npm run build
~/.agents/skills/here-now/scripts/publish.sh dist/ --slug <slug>
每次发布后,slug会保存到
.herenow/state.json
中——脚本会自动加载该slug以进行更新。

Deploy script

部署脚本

Add to
package.json
:
json
{
  "scripts": {
    "deploy": "npm run build && ~/.agents/skills/here-now/scripts/publish.sh dist/"
  }
}
For updates to an existing slug:
json
{
  "scripts": {
    "deploy": "npm run build && ~/.agents/skills/here-now/scripts/publish.sh dist/ --slug <slug>"
  }
}
添加到
package.json
json
{
  "scripts": {
    "deploy": "npm run build && ~/.agents/skills/here-now/scripts/publish.sh dist/"
  }
}
若要更新现有slug的内容:
json
{
  "scripts": {
    "deploy": "npm run build && ~/.agents/skills/here-now/scripts/publish.sh dist/ --slug <slug>"
  }
}

GitHub Pages Deployment (Alternative)

GitHub Pages部署(替代方案)

Use GitHub Pages when you need git-based deployment or already have a GitHub repo set up.
当你需要基于Git的部署方式,或已拥有GitHub仓库时,可使用GitHub Pages。

Prerequisites

前提条件

  • GitHub CLI installed (
    gh
    )
  • Git repository initialized and pushed to GitHub
  • 已安装GitHub CLI(
    gh
  • Git仓库已初始化并推送到GitHub

Quick Deploy

快速部署

bash
npm run build && npx gh-pages -d dist
bash
npm run build && npx gh-pages -d dist

Full Setup

完整设置流程

  1. Build the game:
bash
npm run build
  1. Ensure
    vite.config.js
    has the correct base path
    if deploying to a subdirectory:
js
export default defineConfig({
  base: '/<repo-name>/',
  // ... rest of config
});
  1. Deploy with GitHub CLI:
bash
gh repo create <game-name> --public --source=. --push
npm install -D gh-pages
npx gh-pages -d dist
  1. Enable GitHub Pages in repo settings (should auto-detect the
    gh-pages
    branch).
Your game is live at:
https://<username>.github.io/<repo-name>/
  1. 构建游戏
bash
npm run build
  1. 若部署到子目录,请确保
    vite.config.js
    设置了正确的基础路径
js
export default defineConfig({
  base: '/<repo-name>/',
  // ... 其余配置
});
  1. 使用GitHub CLI部署
bash
gh repo create <game-name> --public --source=. --push
npm install -D gh-pages
npx gh-pages -d dist
  1. 在仓库设置中启用GitHub Pages(应自动检测
    gh-pages
    分支)。
你的游戏将在以下地址上线:
https://<username>.github.io/<repo-name>/

Automated Deploys

自动化部署

Add to
package.json
:
json
{
  "scripts": {
    "deploy": "npm run build && npx gh-pages -d dist"
  }
}
添加到
package.json
json
{
  "scripts": {
    "deploy": "npm run build && npx gh-pages -d dist"
  }
}

Play.fun Registration

Play.fun注册

After deploying, register your game on Play.fun for monetization. Use the
/game-creator:playdotfun
skill for integration details.
The deployed URL becomes your
gameUrl
when registering:
typescript
await client.games.register({
  name: 'Your Game Name',
  gameUrl: 'https://<slug>.here.now/',  // or GitHub Pages URL
  maxScorePerSession: 500,
  maxSessionsPerDay: 20,
  maxCumulativePointsPerDay: 5000
});
部署完成后,可在Play.fun上注册你的游戏以实现 monetization(变现)。使用
/game-creator:playdotfun
技能查看集成详情。
部署后的URL将作为注册时的
gameUrl
typescript
await client.games.register({
  name: 'Your Game Name',
  gameUrl: 'https://<slug>.here.now/',  // 或GitHub Pages URL
  maxScorePerSession: 500,
  maxSessionsPerDay: 20,
  maxCumulativePointsPerDay: 5000
});

Other Hosting Options

其他托管选项

  • Vercel:
    npx vercel --prod
    (auto-detects Vite)
  • Netlify: Connect repo, set build command to
    npm run build
    , publish dir to
    dist
  • Railway: Use the Railway skill for deployment
  • itch.io: Upload the
    dist/
    folder as an HTML5 game
  • Vercel
    npx vercel --prod
    (自动识别Vite)
  • Netlify:关联仓库,设置构建命令为
    npm run build
    ,发布目录为
    dist
  • Railway:使用Railway技能进行部署
  • itch.io:上传
    dist/
    文件夹作为HTML5游戏

Example Usage

使用示例

Default (here.now)

默认方案(here.now)

/game-deploy
Result: Builds
dist/
→ publishes via here.now → game live at
https://<slug>.here.now/
in seconds. Adds
npm run deploy
script for future one-command deploys.
/game-deploy
结果:构建
dist/
→ 通过here.now发布 → 游戏在数秒内上线至
https://<slug>.here.now/
。添加
npm run deploy
脚本,以便未来一键部署。

GitHub Pages

GitHub Pages方案

/game-deploy github-pages
Result: Builds with correct base path → pushes to
gh-pages
branch → game live at
https://<user>.github.io/<game>/
in 1-2 minutes.
/game-deploy github-pages
结果:使用正确的基础路径构建 → 推送到
gh-pages
分支 → 游戏在1-2分钟内上线至
https://<user>.github.io/<game>/

Troubleshooting

故障排查

here.now 429 rate limit

here.now 429速率限制

Cause: Too many deployments in a short period. here.now has rate limiting on anonymous deployments. Fix: Wait a few minutes and retry. For frequent deployments, consider using GitHub Pages or Vercel instead.
原因:短时间内部署次数过多。here.now对匿名部署有速率限制。 解决方法:等待几分钟后重试。若需频繁部署,可考虑使用GitHub Pages或Vercel替代。

Anonymous here.now site expired

匿名here.now站点过期

Cause: Anonymous here.now deployments are temporary and expire after a period of inactivity. Fix: Redeploy with
npx here.now
. For persistent hosting, use GitHub Pages (
gh-pages
branch) or Vercel, which don't expire.
原因:匿名here.now部署为临时状态,一段时间未使用后会过期。 解决方法:使用
npx here.now
重新部署。若需持久托管,可使用GitHub Pages(
gh-pages
分支)或Vercel,这些平台不会过期。

GitHub Pages 404 after deployment

GitHub Pages部署后出现404

Cause: Vite's base path doesn't match the GitHub Pages URL structure (
/<repo-name>/
). Fix: Set
base: '/<repo-name>/'
in
vite.config.js
. Ensure the
gh-pages
branch is selected as the source in the repository's Pages settings. Wait 1-2 minutes for GitHub's CDN to propagate.
原因:Vite的基础路径与GitHub Pages的URL结构(
/<repo-name>/
)不匹配。 解决方法:在
vite.config.js
中设置
base: '/<repo-name>/'
。确保仓库的Pages设置中选择了
gh-pages
分支作为源。等待1-2分钟,让GitHub的CDN完成传播。

Blank page after deployment (asset paths)

部署后显示空白页面(资源路径问题)

Cause: Asset paths use absolute URLs (
/assets/...
) that don't resolve correctly on the deployment host. Fix: Use relative paths (
./assets/...
) or configure Vite's
base
option to match the deployment URL. Run
npm run build
locally and test the
dist/
folder with a local server before deploying.
原因:资源路径使用绝对URL(
/assets/...
),无法在部署主机上正确解析。 解决方法:使用相对路径(
./assets/...
),或配置Vite的
base
选项以匹配部署URL。部署前先在本地执行
npm run build
,并使用本地服务器测试
dist/
文件夹。

gh-pages push rejected

gh-pages推送被拒绝

Cause: The remote
gh-pages
branch has diverged or the force push was blocked by branch protection rules. Fix: Use
git push origin gh-pages --force
if you own the repo and there's no branch protection. If protected, delete the remote
gh-pages
branch first:
git push origin --delete gh-pages
, then redeploy.
原因:远程
gh-pages
分支已分叉,或强制推送被分支保护规则阻止。 解决方法:如果你拥有仓库且无分支保护,可使用
git push origin gh-pages --force
。若有保护规则,先删除远程
gh-pages
分支:
git push origin --delete gh-pages
,然后重新部署。

Pre-Deploy Checklist

部署前检查清单

  • npm run build
    succeeds with no errors
  • Test the production build with
    npm run preview
  • Remove any
    console.log
    debug statements
  • Verify all assets are included in the build
  • Check mobile/responsive behavior if applicable
  • Set appropriate
    <title>
    and meta tags in
    index.html
  • npm run build
    执行成功,无错误
  • 使用
    npm run preview
    测试生产构建版本
  • 移除所有
    console.log
    调试语句
  • 验证所有资源已包含在构建产物中
  • 若适用,检查移动端/响应式表现
  • index.html
    中设置合适的
    <title>
    和meta标签