(pluginInstance)
| 5 | import { ServerlessError } from '@serverless/util' |
| 6 | |
| 7 | async function getUvVersion(pluginInstance) { |
| 8 | try { |
| 9 | const res = await spawn('uv', ['--version'], { |
| 10 | cwd: pluginInstance.servicePath, |
| 11 | }) |
| 12 | const stdoutBuffer = |
| 13 | (res.stdoutBuffer && res.stdoutBuffer.toString().trim()) || '' |
| 14 | const version = stdoutBuffer.split(' ')[1] |
| 15 | if (semver.valid(version)) return version |
| 16 | throw new ServerlessError( |
| 17 | `Unable to parse uv version!`, |
| 18 | 'PYTHON_REQUIREMENTS_UV_VERSION_ERROR', |
| 19 | ) |
| 20 | } catch (e) { |
| 21 | const stderr = (e.stderrBuffer && e.stderrBuffer.toString()) || '' |
| 22 | const stdout = (e.stdoutBuffer && e.stdoutBuffer.toString()) || '' |
| 23 | const code = e && e.code |
| 24 | const message = (e && e.message) || '' |
| 25 | // Detect missing executable (ENOENT) across platforms |
| 26 | if ( |
| 27 | code === 'ENOENT' || |
| 28 | message.includes('ENOENT') || |
| 29 | stderr.includes('command not found') || |
| 30 | stdout.includes('command not found') || |
| 31 | // Windows-style message if a shell were involved |
| 32 | stderr.includes('is not recognized as an internal or external command') || |
| 33 | stdout.includes('is not recognized as an internal or external command') |
| 34 | ) { |
| 35 | throw new ServerlessError( |
| 36 | `uv not found! Install it according to the uv docs.`, |
| 37 | 'PYTHON_REQUIREMENTS_UV_NOT_FOUND', |
| 38 | { stack: false }, |
| 39 | ) |
| 40 | } |
| 41 | throw e |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | async function uvToRequirements(pluginInstance) { |
| 46 | const { servicePath, options, serverless, log, progress } = pluginInstance |
no outgoing calls
no test coverage detected
searching dependent graphs…