Files
soroban-abacus-flashcards/apps/web/scripts/generate-build-info.js
Thomas Hallock c0680cad0f fix(arcade): add host-only game selection with clear messaging
Non-host room members were getting 403 errors when trying to select games.
Added proper UI restrictions and messaging to clarify only the host can
select games.

**Changes**:

1. **Host Detection**: Check if current user is room creator
   - Find `currentMember` in `roomData.members`
   - Check `isCreator` flag

2. **Visual Restrictions**:
   - Game buttons disabled for non-hosts (opacity: 0.4, cursor: not-allowed)
   - No hover effects when disabled
   - Clear visual feedback

3. **Messaging**:
   - **Host**: "👑 You're the room host. Select a game to start playing."
   - **Non-host**: " Waiting for [Host Name] to select a game..."
   - **Error**: "⚠️ Only the room host can select a game. Ask [Host] to choose."

4. **Error Handling**:
   - Client-side check before API call
   - Server error caught and displayed with host name
   - Auto-dismiss after 5 seconds

**UX Flow**:
- Non-hosts see disabled games with clear "waiting for host" message
- If they somehow click, they get clear error message
- Host sees active games with confirmation they can select

Prevents confusing 403 errors and clarifies room permissions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 11:59:43 -05:00

62 lines
1.9 KiB
JavaScript
Executable File

#!/usr/bin/env node
/**
* Generate build information for deployment tracking
* This script captures git commit, branch, timestamp, and other metadata
*/
const { execSync } = require('child_process')
const fs = require('fs')
const path = require('path')
function exec(command) {
try {
return execSync(command, { encoding: 'utf-8' }).trim()
} catch (_error) {
return null
}
}
function getBuildInfo() {
// Try to get git info from environment variables first (for Docker builds)
// Fall back to git commands (for local development)
const gitCommit = process.env.GIT_COMMIT || exec('git rev-parse HEAD')
const gitCommitShort = process.env.GIT_COMMIT_SHORT || exec('git rev-parse --short HEAD')
const gitBranch = process.env.GIT_BRANCH || exec('git rev-parse --abbrev-ref HEAD')
const gitTag = process.env.GIT_TAG || exec('git describe --tags --exact-match 2>/dev/null')
const gitDirty =
process.env.GIT_DIRTY === 'true' || exec('git diff --quiet || echo "dirty"') === 'dirty'
const packageJson = require('../package.json')
return {
version: packageJson.version,
buildTime: new Date().toISOString(),
buildTimestamp: Date.now(),
git: {
commit: gitCommit,
commitShort: gitCommitShort,
branch: gitBranch,
tag: gitTag,
isDirty: gitDirty,
},
environment: process.env.NODE_ENV || 'development',
buildNumber: process.env.BUILD_NUMBER || null,
nodeVersion: process.version,
}
}
const buildInfo = getBuildInfo()
const outputPath = path.join(__dirname, '..', 'src', 'generated', 'build-info.json')
// Ensure directory exists
const dir = path.dirname(outputPath)
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true })
}
fs.writeFileSync(outputPath, JSON.stringify(buildInfo, null, 2))
console.log('✅ Build info generated:', outputPath)
console.log(JSON.stringify(buildInfo, null, 2))