Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ function execCommand(command, description) {
}
}

function execCommandWithOutput(command, description) {
console.log(`\n🔄 ${description}...`)
try {
const output = execSync(command, { encoding: 'utf-8' })
console.log(output)
console.log(`✅ ${description} completed`)
return output
} catch (error) {
console.error(`❌ ${description} failed:`, error.message)
Comment on lines +30 to +38

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve interactive stdio when deploying

The new execCommandWithOutput wraps wrangler deploy but calls execSync with only { encoding: 'utf-8' }, which falls back to stdio: 'pipe'. Previously the deploy command inherited stdio, allowing Wrangler to prompt for login or other interactive confirmations. With the default pipes, Wrangler cannot read from the terminal and will hang or fail whenever it needs user input (common on first run or when credentials expire). The change therefore breaks deployments for any environment that requires an interactive Wrangler prompt. Consider inheriting stdin while still capturing stdout for URL parsing.

Useful? React with 👍 / 👎.

process.exit(1)
}
}

function getAvailableSites() {
const tomlDir = 'toml'
if (!existsSync(tomlDir)) {
Expand Down Expand Up @@ -114,10 +127,13 @@ async function deploy() {
execCommand('npm run build', 'Building project')

// Deploy Cloudflare Worker
execCommand(`wrangler deploy`, `Deploying Cloudflare Worker (${projectName})`)
const deployOutput = execCommandWithOutput(`wrangler deploy`, `Deploying Cloudflare Worker (${projectName})`)

const urlMatch = deployOutput.match(/https?:\/\/[^\s]+/)
const liveUrl = urlMatch ? urlMatch[0] : `https://${projectName}.workers.dev`

console.log('\n🎉 Deployment completed successfully!')
console.log(`\n💡 Your changes are now live at: https://${projectName}.workers.dev`)
console.log(`\n💡 Your changes are now live at: ${liveUrl}`)
process.exit(0)
}

Expand Down