import { spawnSync } from 'node:child_process' import { fileURLToPath } from 'node:url' import { verifyLive } from './verify-live.mjs' const message = process.argv.slice(2).join(' ').trim() if (!message) { console.error('Usage: npm run release -- "Describe the deck changes"') process.exit(1) } process.chdir(fileURLToPath(new URL('../', import.meta.url))) function run(command, args) { const result = spawnSync(command, args, { stdio: 'inherit' }) if (result.error) throw result.error if (result.status !== 0) throw new Error(`${command} ${args.join(' ')} failed (${result.status ?? result.signal}). Release stopped.`) } try { for (const script of ['typecheck', 'check', 'build']) run('npm', ['run', script]) run('git', ['diff', '--check']) // This dedicated deck repository ships sources and generated assets together. run('git', ['add', '-A', '--', '.']) const staged = spawnSync('git', ['diff', '--cached', '--quiet']) if (staged.status === 1) run('git', ['commit', '-m', message]) else if (staged.status !== 0) throw new Error('Could not inspect staged changes.') else console.log('No new changes to commit; publishing the current commit.') run('git', ['push']) run('npx', ['--yes', '@kodycodes/cli', 'package', 'publish', '@kentcdodds/kody-connect-talk']) await verifyLive() } catch (error) { console.error(error.message) process.exitCode = 1 }