* Build inspect result data structure for machine-readable output.
(absolutePath: string, deepnoteFile: ReturnType<typeof deserializeDeepnoteFile>)
| 57 | * Build inspect result data structure for machine-readable output. |
| 58 | */ |
| 59 | function buildInspectResult(absolutePath: string, deepnoteFile: ReturnType<typeof deserializeDeepnoteFile>) { |
| 60 | const { project, metadata, version: fileVersion } = deepnoteFile |
| 61 | const notebooks = project.notebooks |
| 62 | const totalBlocks = notebooks.reduce((sum, notebook) => sum + notebook.blocks.length, 0) |
| 63 | |
| 64 | return { |
| 65 | success: true, |
| 66 | path: absolutePath, |
| 67 | project: { |
| 68 | name: project.name, |
| 69 | id: project.id, |
| 70 | }, |
| 71 | version: fileVersion, |
| 72 | metadata: { |
| 73 | createdAt: metadata.createdAt, |
| 74 | modifiedAt: metadata.modifiedAt ?? null, |
| 75 | exportedAt: metadata.exportedAt ?? null, |
| 76 | }, |
| 77 | statistics: { |
| 78 | notebookCount: notebooks.length, |
| 79 | totalBlocks, |
| 80 | }, |
| 81 | notebooks: notebooks.map(notebook => ({ |
| 82 | name: notebook.name, |
| 83 | blockCount: notebook.blocks.length, |
| 84 | isModule: notebook.isModule ?? false, |
| 85 | })), |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Output inspect results as JSON for scripting. |
no outgoing calls
no test coverage detected