MCPcopy
hub / github.com/lightningpixel/modly / validateInstallManifest

Function validateInstallManifest

electron/main/extension-install-utils.ts:17–47  ·  view source on GitHub ↗
(
  manifest: InstallManifest,
  opts: {
    hasEntryFile: (entryFile: string) => boolean
    hasGeneratorFile: () => boolean
  },
  sourceLabel: string,
)

Source from the content-addressed store, hash-verified

15}
16
17export 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
49export function isSetupFailureFatal(kind: {
50 isProcess: boolean

Callers 1

setupIpcHandlersFunction · 0.90

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected