(
manifest: InstallManifest,
opts: {
hasEntryFile: (entryFile: string) => boolean
hasGeneratorFile: () => boolean
},
sourceLabel: string,
)
| 15 | } |
| 16 | |
| 17 | export function validateInstallManifest( |
| 18 | manifest: InstallManifest, |
| 19 | opts: { |
| 20 | hasEntryFile: (entryFile: string) => boolean |
| 21 | hasGeneratorFile: () => boolean |
| 22 | }, |
| 23 | sourceLabel: string, |
| 24 | ): ValidatedInstallManifest { |
| 25 | if (!manifest.id) throw new Error('manifest.json: required field "id" missing') |
| 26 | |
| 27 | const isProcess = manifest.type === 'process' |
| 28 | const entryFile = manifest.entry ?? 'processor.js' |
| 29 | const nodes = Array.isArray(manifest.nodes) ? manifest.nodes.filter((node) => node?.id) : [] |
| 30 | |
| 31 | if (isProcess) { |
| 32 | if (!opts.hasEntryFile(entryFile)) { |
| 33 | throw new Error(`manifest.json: entry file "${entryFile}" missing from ${sourceLabel}`) |
| 34 | } |
| 35 | } else { |
| 36 | if (!opts.hasGeneratorFile()) throw new Error(`generator.py missing from ${sourceLabel}`) |
| 37 | if (!manifest.generator_class) throw new Error('manifest.json: required field "generator_class" missing') |
| 38 | } |
| 39 | |
| 40 | return { |
| 41 | id: manifest.id, |
| 42 | isProcess, |
| 43 | isPythonProcess: isProcess && entryFile.endsWith('.py'), |
| 44 | entryFile, |
| 45 | hasNodes: nodes.length > 0, |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | export function isSetupFailureFatal(kind: { |
| 50 | isProcess: boolean |
no test coverage detected