MCPcopy Index your code
hub / github.com/deepnote/deepnote / catDeepnoteFile

Function catDeepnoteFile

packages/cli/src/commands/cat.ts:66–90  ·  view source on GitHub ↗
(path: string, options: CatOptions)

Source from the content-addressed store, hash-verified

64}
65
66async function catDeepnoteFile(path: string, options: CatOptions): Promise<void> {
67 const { absolutePath } = await resolvePathToDeepnoteFile(path)
68
69 debug('Reading file contents...')
70 const rawBytes = await fs.readFile(absolutePath)
71 const yamlContent = decodeUtf8NoBom(rawBytes)
72
73 debug('Parsing .deepnote file...')
74 const deepnoteFile = deserializeDeepnoteFile(yamlContent)
75
76 // Filter notebooks if --notebook option is provided
77 let notebooks = deepnoteFile.project.notebooks
78 if (options.notebook) {
79 notebooks = notebooks.filter(nb => nb.name === options.notebook)
80 if (notebooks.length === 0) {
81 throw new NotFoundInProjectError(`Notebook "${options.notebook}" not found in project`)
82 }
83 }
84
85 if (options.output === 'json') {
86 outputCatJson(absolutePath, deepnoteFile, notebooks, options)
87 } else {
88 await printBlocks(absolutePath, notebooks, options)
89 }
90}
91
92type BlockSummary = Pick<DeepnoteBlock, 'id' | 'type'> & { label: string; content?: string }
93type NotebookSummary = Pick<DeepnoteFile['project']['notebooks'][number], 'name' | 'id'> & { blocks: BlockSummary[] }

Callers 1

createCatActionFunction · 0.85

Calls 6

debugFunction · 0.90
decodeUtf8NoBomFunction · 0.90
deserializeDeepnoteFileFunction · 0.90
outputCatJsonFunction · 0.85
printBlocksFunction · 0.85

Tested by

no test coverage detected