Files
shumai/scripts/extract-runtime-deps.ts
T
yiling 97af81d157 feat(workflow): migrate workflow engine from temporal to dbos
Replace Temporal and LocalExecutor with DBOS Transact (@dbos-inc/dbos-sdk) as the unified workflow engine. Background tasks, media transcoding, and AI agent workflows now execute with durable steps and task queues directly against PostgreSQL, eliminating the need for an external Temporal cluster and separate polling executors.
2026-10-17 15:50:17 +08:00

67 lines
2.1 KiB
TypeScript

import { execSync } from 'node:child_process'
import { writeFileSync } from 'node:fs'
/**
* This script extracts the exact versions of specific runtime dependencies
* from the current workspace using `bun pm ls --all`.
* It generates a `runner-package.json` that is used in the final stage of the Docker build
* to ensure that production dependencies match development/build versions exactly.
*/
const depsToExtract = ['@dbos-inc/dbos-sdk', 'pg', 'exiftool-vendored', 'pdfkit', 'prisma', 'sharp']
function run(cmd: string) {
try {
return execSync(cmd, { encoding: 'utf-8', stdio: 'pipe' })
} catch {
console.error(`Command failed: ${cmd}`)
return null
}
}
console.log('Extracting runtime dependency versions using `bun pm ls --all`...')
const output = run('bun pm ls --all')
if (!output) {
console.error('Failed to get dependency list from bun.')
process.exit(1)
}
const deps: Record<string, string> = {}
for (const dep of depsToExtract) {
// regex to find the version after the package name in `bun pm ls` output
// e.g., ├── @dbos-inc/dbos-sdk@5.2.11
const escapedDep = dep.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const regex = new RegExp(`(?:^|\\s)${escapedDep}@(\\d+\\.\\d+\\.\\d+[^\\s]*)`, 'g')
const match = regex.exec(output)
if (match && match[1]) {
// If there are multiple matches (different versions in workspace), we take the first one found.
// In our pinned workspace, they should all be the same.
deps[dep] = match[1]
console.log(` Found ${dep}@${match[1]}`)
} else {
console.warn(` Warning: Could not find version for ${dep} in \`bun pm ls --all\` output.`)
}
}
if (Object.keys(deps).length === 0) {
console.error('Error: No dependencies were extracted. Check if `bun install` was run correctly.')
process.exit(1)
}
const runnerPkg = {
name: 'shumai-runner',
version: '1.0.0',
private: true,
dependencies: deps,
}
const outputPath = 'runner-package.json'
writeFileSync(outputPath, JSON.stringify(runnerPkg, null, 2) + '\n', 'utf-8')
console.log(
`\nGenerated ${outputPath} with ${Object.keys(deps).length} dependencies for Docker runner stage.`,
)