MCPcopy
hub / github.com/deepnote/deepnote / convertSingleFileToDeepnote

Function convertSingleFileToDeepnote

packages/convert/src/cli.ts:277–313  ·  view source on GitHub ↗
(options: ConvertSingleFileOptions)

Source from the content-addressed store, hash-verified

275}
276
277async function convertSingleFileToDeepnote(options: ConvertSingleFileOptions): Promise<string> {
278 const { absolutePath, formatName, converter, resolveProjectName, resolveOutputPath, singleFile } = options
279 const spinner = ora(`Converting the ${formatName} to a Deepnote project...`).start()
280
281 try {
282 const ext = extname(absolutePath)
283 const filenameWithoutExtension = basename(absolutePath, ext)
284 const projectName = resolveProjectName(filenameWithoutExtension)
285
286 const outputFilename = `${filenameWithoutExtension}.deepnote`
287 const outputPath = await resolveOutputPath(outputFilename)
288
289 // Read and convert file to DeepnoteFile (no file I/O yet)
290 const deepnoteFile = await converter(absolutePath, { projectName })
291
292 // Write file (handles snapshot splitting in memory)
293 const { snapshotPath } = await writeDeepnoteFile({
294 file: deepnoteFile,
295 outputPath,
296 projectName,
297 singleFile,
298 })
299
300 if (snapshotPath) {
301 spinner.succeed(
302 `The Deepnote project has been saved to ${chalk.bold(outputPath)}\nSnapshot saved to ${chalk.bold(snapshotPath)}`
303 )
304 } else {
305 spinner.succeed(`The Deepnote project has been saved to ${chalk.bold(outputPath)}`)
306 }
307
308 return outputPath
309 } catch (error) {
310 spinner.fail('Conversion failed')
311 throw error
312 }
313}
314
315interface ConvertToDeepnoteOptions {
316 absolutePath: string

Callers 4

convertJupyterToDeepnoteFunction · 0.70
convertQuartoToDeepnoteFunction · 0.70
convertPercentToDeepnoteFunction · 0.70
convertMarimoToDeepnoteFunction · 0.70

Calls 4

writeDeepnoteFileFunction · 0.90
resolveProjectNameFunction · 0.85
resolveOutputPathFunction · 0.85
startMethod · 0.80

Tested by

no test coverage detected